[FFmpeg-devel] [PATCH] G722 decoder

Kenan Gillet kenan.gillet
Wed Mar 25 23:20:18 CET 2009


On Mar 25, 2009, at 2:39 PM, Michael Niedermayer 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
>

ok will investigate


> [...]
>>>
>>>
>>> [...]
>>>> +static int inline scale(const int log_factor, int shift) {
>>>> +    const int wd1 = ilb[(log_factor >> 6) & 31];
>>>> +    shift -= log_factor >> 11;
>>>> +    return shift < 0 ? wd1 << (2-shift) : (wd1 >> shift) << 2;
>>>
>>> wd1 << (2-shift) : wd1 >> (shift-2)
>>
>> shift - 2 can be negative
>
> but can shift - 2  and 2-shift be both negative?
>
> (excluding INT_MIN)

yes but i need the 2 lower bits cleared so for instance in the case  
where shift =1
only 1 lower bit would be cleared.
or am i missing something?

maybe
return (shift < 0 ? wd1 << -shift : wd1 >> shift) << 2;
might be clearer

Kenan




More information about the ffmpeg-devel mailing list