ffmpeg | branch: master | Rostislav Pehlivanov <atomnu...@gmail.com> | Thu Mar 24 13:02:59 2016 +0000| [72e13600079ea480ed8b8ae1ac44469590024596] | committer: Rostislav Pehlivanov
vc2enc: optimize and simplify quantization Everything except ORing the sign is now done in the LUT. Signed-off-by: Rostislav Pehlivanov <atomnu...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72e13600079ea480ed8b8ae1ac44469590024596 --- libavcodec/vc2enc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 12cdd84..577d49d 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; + } } } _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog