From b297c881d6b968bbb2bb7a3a0979429ee03b594c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 22 Jul 2011 22:38:14 +0100 Subject: [PATCH] dnxhddec: rearrange decode_dct_block loop This makes decoding a bit faster. Signed-off-by: Mans Rullgard --- libavcodec/dnxhddec.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 63ccd08b48..79e4bb36a2 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -204,17 +204,14 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, block[0] = ctx->last_dc[component]; //av_log(ctx->avctx, AV_LOG_DEBUG, "dc %d\n", block[0]); - for (i = 1; ; i++) { - UPDATE_CACHE(bs, &ctx->gb); - GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table, - DNXHD_VLC_BITS, 2); - //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index1); - level = ctx->cid_table->ac_level[index1]; - if (!level) { /* EOB */ - //av_log(ctx->avctx, AV_LOG_DEBUG, "EOB\n"); - break; - } + i = 0; + 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) { sign = SHOW_SBITS(bs, &ctx->gb, 1); SKIP_BITS(bs, &ctx->gb, 1); @@ -230,7 +227,7 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, i += ctx->cid_table->run[index2]; } - if (i > 63) { + if (++i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); break; } @@ -245,6 +242,11 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level); block[j] = (level^sign) - sign; + + 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);