[FFmpeg-devel] [RFC] stream parsing

Benjamin Larsson banan
Mon Sep 27 01:17:40 CEST 2010


>> -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.

> 
> like i said the code should test if channel_layout has been set and
> return 0 if not it should not set any variable to 0 because this is unneeded
> that is unless it is actually needed but then id like to know why

It is needed as it has to make sure that val = enc->sample_rate &&
enc->channels is of values that makes has_codec_parameters() return 0 up
until it tries to decode the stream. But you are right with regard to
enc->frame_size and enc->channel_layout. But I think that this code
doesn't belong in has_codec_parameters() maybe better to put it in a new
function or like the original code.


MvH
Benjamin Larsson



More information about the ffmpeg-devel mailing list