[FFmpeg-devel] [PATCH] extract bit rate calculation into separate function

Robert Krüger krueger
Wed Nov 11 15:48:26 CET 2009


Hi,

On 11.11.2009, at 15:23, Michael Niedermayer wrote:

> On Wed, Nov 11, 2009 at 12:41:33PM +0100, Robert Kr?ger wrote:
>> Hi,
>>
>> On 11.11.2009, at 11:23, Carl Eugen Hoyos wrote:
>>
>>> Hi!
>>>
>>> Robert Kr?ger <krueger <at> signal7.de> writes:
>>>
>>
>> Index: libavcodec/avcodec.h
>> ===================================================================
>> --- libavcodec/avcodec.h	(revision 20511)
>> +++ libavcodec/avcodec.h	(working copy)
>> @@ -3444,6 +3444,14 @@
>>  */
>> int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
>>
>> +/**
>> + * Calculates the bit rate of a stream
>> + *
>> + * @ctx AVCodecContext of the stream
>> + * @return Bit rate in bits per second or 0 if it could not be  
>> determined
>> + */
>> +int av_get_bitrate(AVCodecContext *ctx);
>> +
>> /* frame parsing */
>> typedef struct AVCodecParserContext {
>>     void *priv_data;
>> Index: libavcodec/utils.c
>> ===================================================================
>> --- libavcodec/utils.c	(revision 20511)
>> +++ libavcodec/utils.c	(working copy)
>> @@ -741,6 +741,34 @@
>>     return NULL;
>> }
>>
>> +int av_get_bitrate(AVCodecContext *ctx)
>> +{
>> +    int bitrate;
>> +    int bits_per_sample;
>> +
>> +    switch(ctx->codec_type) {
>> +    case CODEC_TYPE_VIDEO:
>> +  	    bitrate = ctx->bit_rate;
>> +        break;
>> +    case CODEC_TYPE_AUDIO:
>> +    	bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
>
> tabs
>
fixed, sorry (wrong editor settings)

>
>> +    	bitrate = bits_per_sample ? ctx->sample_rate * ctx->channels *
>> bits_per_sample : ctx->bit_rate;
>> +        break;
>
> line break in the middle of a patch
>
there is no line break in the code. probably mail client, I attached  
it as a text file now. hope that's OK now.

>
>> +    case CODEC_TYPE_DATA:
>> +        bitrate = ctx->bit_rate;
>> +        break;
>> +    case CODEC_TYPE_SUBTITLE:
>> +        bitrate = ctx->bit_rate;
>> +        break;
>> +    case CODEC_TYPE_ATTACHMENT:
>> +        bitrate = ctx->bit_rate;
>> +        break;
>> +    default:
>> +        break;
>> +    }
>> +    return bitrate;
>
> returning an uninitalized value
>
fixed

>

Regards,

Robert






More information about the ffmpeg-devel mailing list