[Ffmpeg-devel] [PATCH] Re: AMR bitrate

Michael Niedermayer michaelni
Mon Nov 20 17:50:02 CET 2006


Hi

On Mon, Nov 20, 2006 at 03:35:55PM +0100, Martin wrote:
> Hi,
> 
> Martin wrote:
> > Hi,
> > 
> > Benjamin Larsson wrote:
> > 
> >>Martin skrev:
> >>
> >>
> >>>Hi,
> >>>
> >>>gravsten at yahoo.com wrote:
> >>>
> >>>
> >>>>>>I have a question regarding encoding and decoding of AMR using
> >>>>>>ffmpeg. To me it seems that the bitrate mode is fixed after
> >>>>>>avcodec_open(). Is that correct (the bitrate mode cannot be changed
> >>>>>>on the fly)?
> >>>>>
> >>>>>No the bitrate can't be changed on the fly and user questions
> >>>>>to the user list.
> >>>>
> >>>>
> >>>>Actually, the standard let one negotiation a set of AMR bit rates
> >>>>beforehand,
> >>>>and the transmitter may arbitrarily change bitrate within the agreed
> >>>>set on an
> >>>>AMR frame boundary (20ms).
> >>>>
> >>>>I am unsure whether ffmpeg let you change the bitrate on-the-fly
> >>>>(i.e. without
> >>>>close/open codec), but if not, you should be able to fix this by
> >>>>merely making
> >>>>the AMR codec access a bitrate value in the avctx structure directly
> >>>>(ffmpeg
> >>>>only serves as a proxy to an external AMR library originally from the
> >>>>ITU).
> >>>
> >>>
> >>>thanks for clarifying that!
> >>>I tested it and it worked. Would you accept a patch for that? There
> >>>shouldn't be a downside in directly accessing the avctx structure, right?
> >>>
> >>>Martin
> >>
> >>
> >>Send the patch for review.
> > 
> 
> I attached a patch for amr bitrate mode which can now be changed "on the
> fly" through avctx->bitrate. Is the attached patch ok? I have sent it a
> week ago but I have no reply whether it is ok and will be applied.
> 
> Martin

> --- amr.c_bak	2006-11-13 10:44:29.954294020 +0100
> +++ amr.c	2006-11-13 10:44:34.345708296 +0100
> @@ -482,6 +482,8 @@ static int amr_nb_encode_frame(AVCodecCo
>      AMRContext *s = (AMRContext*)avctx->priv_data;
>      int written;
>  
> +    s->enc_bitrate=getBitrateMode(avctx->bit_rate);
> +
>      written = Encoder_Interface_Encode(s->enstate,
>          s->enc_bitrate,
>          data,
> @@ -624,6 +626,7 @@ static int amr_wb_encode_frame(AVCodecCo
>                              unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
>  {
>      AMRWBContext *s = (AMRWBContext*) avctx->priv_data;
> +    s->mode=getWBBitrateMode(avctx->bit_rate);
>      int size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);

mixes declaration and code -> breaks ISO C90

besides this iam fine with the patch

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list