[FFmpeg-devel] [RFC] stream parsing

Michael Niedermayer michaelni
Mon Sep 27 12:39:31 CEST 2010


On Mon, Sep 27, 2010 at 10:10:04AM +0200, Benjamin Larsson wrote:
> On 09/27/2010 02:35 AM, Michael Niedermayer wrote:
> > On Mon, Sep 27, 2010 at 01:17:40AM +0200, Benjamin Larsson wrote:
> >   
> >>     
> >>>> -static int has_codec_parameters(AVCodecContext *enc)
> >>>> +static int has_codec_parameters(AVCodecContext *enc, AVCodec *codec)
> >>>>  {
> >>>>      int val;
> >>>>      switch(enc->codec_type) {
> >>>>      case AVMEDIA_TYPE_AUDIO:
> >>>>          val = enc->sample_rate && enc->channels && enc->sample_fmt != SAMPLE_FMT_NONE;
> >>>> +        /* Some containers report wrong information about channel configuration
> >>>> +         * let the codecs handle it in those cases (dca for example)).
> >>>> +         */
> >>>> +        if (codec && codec->capabilities & CODEC_CAP_CHANNEL_CONF) {
> >>>> +            enc->sample_rate    = 0;
> >>>> +            enc->channel_layout = 0;
> >>>> +            enc->frame_size     = 0;
> >>>> +            enc->channels       = 0;
> >>>> +            return 0;
> >>>> +        }
> >>>>         
> >>> av_find_stream_info() will return once all streams has_codec_parameters()
> >>> return non zero
> >>> this explicitly returns 0 unconditional on any parameters being available or
> >>> not thus has_codec_parameters() will never return non zero for an affected
> >>> stream, leading to exit only by bug and time/pos limits
> >>>       
> >> codec is always NULL in the for(;;) block. Thus this code will only be
> >> triggered once.
> >>     
> > i have to maintain this code, and this patch is a huge convoluted hack
> > passing NULL instead of the correct AVCodec to make the code not end in a
> > near infinite loop is just crazy
> >
> > Please tell me if this works:
> > @@ -2000,6 +2000,8 @@
> >      int val;
> >      switch(enc->codec_type) {
> >      case AVMEDIA_TYPE_AUDIO:
> > +        if(!enc->channel_layout && (!enc->codec || (enc->codec->capabilities & CODEC_CAP_CHANNEL_CONF)))
> > +            return 0;
> >          val = enc->sample_rate && enc->channels && enc->sample_fmt != SAMPLE_FMT_NONE;
> >          if(!enc->frame_size &&
> >             (enc->codec_id == CODEC_ID_VORBIS ||
> >
> > if not, please tell me why it fails, ill fix it
> >   
> 
> Well it works if the container does not populate the channel_layout
> (riff based ones do that if the field is there). So in that case the

and is it wrong in the riff case?
(if its wrong this could be argued to be a bug in the riff demuxer)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100927/4b69c3a6/attachment.pgp>



More information about the ffmpeg-devel mailing list