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