Commit 185a2c08 authored by Mans Rullgard's avatar Mans Rullgard

dnxhddec: store 2*level+1 in ac_level tables

This is the value actually used by the decoder in speed-critical code.
The encoder uses these tables only in init code.
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent b297c881
This diff is collapsed.
......@@ -33,6 +33,7 @@ typedef struct {
unsigned int coding_unit_size;
int index_bits;
int bit_depth;
int eob_index;
const uint8_t *luma_weight, *chroma_weight;
const uint8_t *dc_codes, *dc_bits;
const uint16_t *ac_codes;
......
......@@ -182,6 +182,8 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
int i, j, index1, index2, len;
int level, component, sign;
const uint8_t *weight_matrix;
const uint8_t *ac_level = ctx->cid_table->ac_level;
const int eob_index = ctx->cid_table->eob_index;
OPEN_READER(bs, &ctx->gb);
if (n&2) {
......@@ -209,14 +211,15 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
UPDATE_CACHE(bs, &ctx->gb);
GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table,
DNXHD_VLC_BITS, 2);
level = ctx->cid_table->ac_level[index1];
while (level) {
while (index1 != eob_index) {
level = ac_level[index1];
sign = SHOW_SBITS(bs, &ctx->gb, 1);
SKIP_BITS(bs, &ctx->gb, 1);
if (ctx->cid_table->ac_index_flag[index1]) {
level += SHOW_UBITS(bs, &ctx->gb, index_bits) << 6;
level += SHOW_UBITS(bs, &ctx->gb, index_bits) << 7;
SKIP_BITS(bs, &ctx->gb, index_bits);
}
......@@ -235,7 +238,7 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
j = ctx->scantable.permutated[i];
//av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j);
//av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weight %d\n", level, weight_matrix[i]);
level = (2*level+1) * qscale * weight_matrix[i];
level *= qscale * weight_matrix[i];
if (level_bias < 32 || weight_matrix[i] != level_bias)
level += level_bias;
level >>= level_shift;
......@@ -246,7 +249,6 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
UPDATE_CACHE(bs, &ctx->gb);
GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table,
DNXHD_VLC_BITS, 2);
level = ctx->cid_table->ac_level[index1];
}
CLOSE_READER(bs, &ctx->gb);
......
......@@ -121,7 +121,7 @@ static int dnxhd_init_vlc(DNXHDEncContext *ctx)
alevel -= offset<<6;
}
for (j = 0; j < 257; j++) {
if (ctx->cid_table->ac_level[j] == alevel &&
if (ctx->cid_table->ac_level[j] >> 1 == alevel &&
(!offset || (ctx->cid_table->ac_index_flag[j] && offset)) &&
(!run || (ctx->cid_table->ac_run_flag [j] && run))) {
assert(!ctx->vlc_codes[index]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment