[FFmpeg-devel] [PATCH] g722 decoder, no licensing fame

Kenan Gillet kenan.gillet
Thu Mar 26 05:37:58 CET 2009


On Wed, Mar 25, 2009 at 2:39 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Wed, Mar 25, 2009 at 09:57:51AM -0700, Kenan Gillet wrote:
>> Hi,
>>
>> On Mar 21, 2009, at 1:34 PM, Michael Niedermayer wrote:
>>
>>> On Sat, Mar 21, 2009 at 12:43:35AM -0700, Kenan Gillet wrote:
> [...]
>>>
>>>
>>>> @@ -2819,6 +2822,7 @@
>>>>     memset(ap, 0, sizeof(*ap));
>>>>     ap->prealloced_context = 1;
>>>>     ap->sample_rate = audio_sample_rate;
>>>> +    ap->bit_rate = audio_bit_rate;
>>>>     ap->channels = audio_channels;
>>>>     ap->time_base.den = frame_rate.num;
>>>>     ap->time_base.num = frame_rate.den;
>>>> @@ -2892,6 +2896,7 @@
>>>>             channel_layout = enc->channel_layout;
>>>>             audio_channels = enc->channels;
>>>>             audio_sample_rate = enc->sample_rate;
>>>> +            audio_bit_rate = enc->bit_rate;
>>>>             audio_sample_fmt = enc->sample_fmt;
>>>>             input_codecs[nb_icodecs++] =
>>>> avcodec_find_decoder_by_name(audio_codec_name);
>>>>             if(audio_disable)
>>>> @@ -3211,6 +3216,7 @@
>>>>     }
>>>>     nb_ocodecs++;
>>>>     audio_enc->sample_rate = audio_sample_rate;
>>>> +    audio_enc->bit_rate = audio_bit_rate;
>>>>     audio_enc->time_base= (AVRational){1, audio_sample_rate};
>>>>     if (audio_language) {
>>>>         av_metadata_set(&st->metadata, "language", audio_language);
>>>
>>>> Index: libavformat/avformat.h
>>>> ===================================================================
>>>> --- libavformat/avformat.h  (revision 18096)
>>>> +++ libavformat/avformat.h  (working copy)
>>>> @@ -261,6 +261,7 @@
>>>>     enum CodecID video_codec_id;
>>>>     enum CodecID audio_codec_id;
>>>> #endif
>>>> +    int bit_rate;
>>>> } AVFormatParameters;
>>>>
>>>> //! Demuxer will use url_fopen, no opened file should be provided by the
>>>> caller.
>>>
>>> the whole struct is pretty much deprecated and iam not happy if people
>>> add new things to it.
>>
>> any hint on to "do it the right way" ?
>
> AVFormatContext.bit_rate maybe but i am not sure if this might cause some
> issues
>

actually a much simpler solution would be to change the -ab options to
set in the
AVCodecContext.bitrate for decoder too like in the patch attached

but it would change the behavior of ffmpeg

but that's exactly what is needed, to be able to give the g722 decoder
a bit_rate

would that be acceptable?

Kenan
-------------- next part --------------
Index: libavcodec/options.c
===================================================================
--- libavcodec/options.c	(revision 18171)
+++ libavcodec/options.c	(working copy)
@@ -50,7 +50,7 @@
 
 static const AVOption options[]={
 {"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|E},
-{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, 64*1000, INT_MIN, INT_MAX, A|E},
+{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, 64*1000, INT_MIN, INT_MAX, A|E|D},
 {"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE*20, 1, INT_MAX, V|E},
 {"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, 0, UINT_MAX, V|A|E|D, "flags"},
 {"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_4MV, INT_MIN, INT_MAX, V|E, "flags"},
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h	(revision 18171)
+++ libavcodec/avcodec.h	(working copy)
@@ -872,6 +873,7 @@
      * the average bitrate
      * - encoding: Set by user; unused for constant quantizer encoding.
      * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
+     *             May be set by user for some raw container.
      */
     int bit_rate;
 



More information about the ffmpeg-devel mailing list