[FFmpeg-devel] [PATCH] G.722 decoder
Martin Storsjö
martin
Wed Sep 8 17:06:42 CEST 2010
On Wed, 8 Sep 2010, Michael Niedermayer wrote:
> On Wed, Sep 08, 2010 at 04:38:36PM +0300, Martin Storsj? wrote:
> > On Wed, 8 Sep 2010, Michael Niedermayer wrote:
> >
> > > also the <<2 can be removed, scale_factor be scaled down by 4 thus and a
> > > few shifts readjusted in uses of it
> >
> > Hmm, I'm not sure I'm following you here. Do you mean that I should
> > premultiply inv_log2_table by 4 and skip the final right shift? Or just
> > add/subtract 2 from the 'shift' variable? I tried that (the former, but
> > the latter would have the same effect), but it doesn't give bitexact
> > output, since the codec relies on truncating the values when doing the
> > right shift.
>
> ive meant making scale_factor= scale_factor/4 and simplifying all code that
> reads or writes it. This seems possible, am i missing something?
Ah, yes, now I see. Yes, that's possible - changed it that way.
> > > > +static av_cold int g722_init(AVCodecContext * avctx)
> > > > +{
> > > > + G722Context *c = avctx->priv_data;
> > > > +
> > > > + if (avctx->channels != 1) {
> > > > + av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
> > > > + return AVERROR_INVALIDDATA;
> > > > + }
> > > > + avctx->sample_fmt = SAMPLE_FMT_S16;
> > > > +
> > > > + switch (avctx->bit_rate) {
> > > > + case 64000:
> > > > + case 56000:
> > > > + case 48000:
> > > > + c->bits_per_sample = avctx->bit_rate/8000;
> > > > + break;
> > >
> > > theres a problem here
> > > bitrate is the bitrate of the bitstream in libavcodec
> > > thus a lower bitrate stream + trash bits has 64000 too you cant distinguish
> > > them like this
> >
> > Yes, this is a problem. Do you have any other suggestion for how to signal
> > the lower bitrate variants? Would AVCodecContext->bits_per_coded_sample
> > perhaps be suitable for this?
>
> maybe
Ok, changed to use that instead, that sure does look much better.
Updated patch attached.
// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Initial-G.722-decoder-patch.patch
Type: text/x-diff
Size: 14093 bytes
Desc:
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100908/bb499678/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-G.722-muxer-demuxer.patch
Type: text/x-diff
Size: 2874 bytes
Desc:
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100908/bb499678/attachment-0001.patch>
More information about the ffmpeg-devel
mailing list