[FFmpeg-devel] [PATCH] Add a G.722 encoder
Michael Niedermayer
michaelni
Thu Sep 16 16:35:58 CEST 2010
On Thu, Sep 16, 2010 at 10:50:18AM +0300, Martin Storsj? wrote:
> On Wed, 15 Sep 2010, Michael Niedermayer wrote:
>
> > On Wed, Sep 15, 2010 at 05:42:39PM +0300, Martin Storsj? wrote:
> > >
> > > I managed to do this, so I've got the following two versions:
> > >
> > > limit = limit + 1 << 10;
> > > while (limit > low_quant[i] * state->scale_factor)
> > >
> > > 885 dezicycles in encode_low, 1047991 runs, 585 skips
> > >
> > > and
> > >
> > > limit = limit + 1 << 10;
> > > limit = (limit + state->scale_factor - 1) / state->scale_factor;
> > > while (limit > low_quant[i])
> > >
> > > 988 dezicycles in encode_low, 1047886 runs, 690 skips
> > >
> > > So the former version is a bit faster, even if it does more
> > > multiplications.
> > >
> > > Removing the i < 29 check with a sentinel works fine for normal samples,
> > > but the reference test vectors fail on this if using the former version,
> > > since the numeric range of 32 bit numbers isn't enough.
> > >
> > > I.e., low_quant[i] * scale_factor mustn't overflow, so the the sentinel
> > > must be INT_MAX/max_scale_factor, which is (2^31-1)/4096, and limit << 10
> > > can be larger than this.
> >
> > multiple sentinels should then work
>
> Good idea, I was able to get this to work, too, in this form:
>
> limit = limit + 1 << 10;
> while (limit > low_quant[i] * state->scale_factor)
> i++;
> i = av_clip(i, 0, 29);
>
> When the initial version took 919 dezicycles today, it went up to 948 when
> I changed the low_quant table to be int instead of int16_t (which is
> needed for the sentinels to fit), dropped to 914 when I removed the i < 29
> check from the loop, and increased to 922 when I added the av_clip at the
> end.
>
> If I instead of the av_clip use an if (i > 29) i = 29; I got it down to
> 918, one dezicycle less than where I started.
that doesnt feel right
can you show us some statistic on how often each of the 0..29 occurs on
your test file / normal audio?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100916/61d28549/attachment.pgp>
More information about the ffmpeg-devel
mailing list