[FFmpeg-devel] [PATCH] vc2enc: replace quantization LUT with a smaller division LUT

Michael Niedermayer michael at niedermayer.cc
Thu Mar 1 01:38:57 EET 2018

On Tue, Feb 27, 2018 at 11:12:33PM +0000, Rostislav Pehlivanov wrote:
> This commit replaces the huge and impractical LUT which converted coeffs
> and a quantizer to bits to encode and instead uses a standard multiplication
> and a shift to replace the division and then codes the values using the
> regular golomb coding functions.
> I was unable to see a performance difference on my machine but perhaps
> someone else here can test. In any case, its better than the old one if
> only because its smaller and less intrusive.
> Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
> ---
>  libavcodec/vc2enc.c | 118 ++++++++++++++--------------------------------------
>  1 file changed, 31 insertions(+), 87 deletions(-)

> @@ -557,7 +521,7 @@ static void encode_picture_start(VC2EncContext *s)
>      encode_wavelet_transform(s);
>  }
> -#define QUANT(c, qf) (((c) << 2)/(qf))
> +#define QUANT(c, mul, add, shift) ((mul * c + add) >> shift)

This needs more () otherwise this will misbehave with many
expressions, for example a+b in mul would be a+b*c not (a+b)*c

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180301/55d1e4da/attachment.sig>

More information about the ffmpeg-devel mailing list