[FFmpeg-devel] [PATCH] make av_get_bit_rate part of public API

Robert Krüger krueger
Sun Nov 29 13:18:28 CET 2009


On 27.11.2009, at 19:39, Michael Niedermayer wrote:

> On Fri, Nov 27, 2009 at 01:32:19PM +0100, Robert Kr?ger wrote:
>>
>> On 25.11.2009, at 01:28, Michael Niedermayer wrote:
>>
>>> On Sat, Nov 21, 2009 at 03:10:38PM +0100, Robert Kr?ger wrote:
>>>> Hi,
>>>>
>>>> this patch adds a prototype for av_get_bit_rate (implemented in
>>>> libavcodec/utils.c) to avcodec.h.
>>>
>>> why is AVCodecContext.bit_rate not set?
>>>
>>
>> you mean instead of returning it or do both, return the value and  
>> set it in
>> AVCodecContext (in the audio case because in all others it is taken  
>> as the
>> source of this information)?
>>
>> The primary reason I didn't set it was that I attempted a  
>> refactoring, i.e.
>> didn't want to change behaviour. if you say it makes sense to set  
>> it there,
>> the next question would be, where it is called because it seems a bit
>> strange to have the field set as a side effect of calling something  
>> like
>> avcodec_string. I don't know enough about ffmpeg or libav yet to  
>> decide
>> where that would make sense.
>
>> However, if it would happen in some
>> initialization code which is typically called before someone  
>> obtains an
>> AVCodecContext pointer, there would be no reason to have this  
>> function in
>> the API (which I personally would also be OK with as my main  
>> motivation for
>> the changes is to have libav expose the same bit rate information  
>> via API
>> that ffmpeg shows as output on the command line).
>
> yes, id like to have bit_rate set correctly instead of not and then  
> have
> a function that provides the correct value.
>

Would av_find_stream_info (around line 2276) be the proper place to  
set the bit rate, i.e. see, if the audio decoder has set the bit rate  
to a non-zero value and if not calculate it as sample_rate * channels  
* bits_per_sample?

If that were in place, would one still need a separate function or  
would if be OK to remove it entirely and rely on  
AVCodecContext.bit_rate being set correctly?

Regards,

Robert









More information about the ffmpeg-devel mailing list