diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2016-03-24 16:02:59 +0300 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2016-03-24 16:04:59 +0300 |
commit | 72e13600079ea480ed8b8ae1ac44469590024596 (patch) | |
tree | 32d8071db1299a526783f45f4937fb9f7350f1e5 /libavcodec/vc2enc.c | |
parent | 26811fd9468dc484402faca3ca33cacb2e58c53e (diff) |
vc2enc: optimize and simplify quantization
Everything except ORing the sign is now done in the LUT.
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/vc2enc.c')
-rw-r--r-- | libavcodec/vc2enc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 12cdd84887..577d49dd07 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -583,11 +583,7 @@ static void encode_subband(VC2EncContext *s, PutBitContext *pb, int sx, int sy, const int neg = coeff[x] < 0; uint32_t c_abs = FFABS(coeff[x]); if (c_abs < COEF_LUT_TAB) { - const uint8_t len = len_lut[c_abs]; - if (len == 1) - put_bits(pb, 1, 1); - else - put_bits(pb, len + 1, (val_lut[c_abs] << 1) | neg); + put_bits(pb, len_lut[c_abs], val_lut[c_abs] | neg); } else { c_abs = QUANT(c_abs, qfactor); put_vc2_ue_uint(pb, c_abs); @@ -639,8 +635,7 @@ static int count_hq_slice(SliceArgs *slice, int quant_idx) for (x = left; x < right; x++) { uint32_t c_abs = FFABS(buf[x]); if (c_abs < COEF_LUT_TAB) { - const int len = len_lut[c_abs]; - bits += len + (len != 1); + bits += len_lut[c_abs]; } else { c_abs = QUANT(c_abs, qfactor); bits += count_vc2_ue_uint(c_abs); @@ -1219,6 +1214,12 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx) for (j = 0; j < COEF_LUT_TAB; j++) { get_vc2_ue_uint(QUANT(j, ff_dirac_qscale_tab[i]), &len_lut[j], &val_lut[j]); + if (len_lut[j] != 1) { + len_lut[j] += 1; + val_lut[j] <<= 1; + } else { + val_lut[j] = 1; + } } } |