dnxhddec: cache luma/chroma_weight*qscale tables for last qscale
This commit is contained in:
parent
9dfd89b831
commit
5bcdc099f3
@ -49,6 +49,9 @@ typedef struct DNXHDContext {
|
|||||||
int bit_depth; // 8, 10 or 0 if not initialized at all.
|
int bit_depth; // 8, 10 or 0 if not initialized at all.
|
||||||
void (*decode_dct_block)(struct DNXHDContext *ctx, DCTELEM *block,
|
void (*decode_dct_block)(struct DNXHDContext *ctx, DCTELEM *block,
|
||||||
int n, int qscale);
|
int n, int qscale);
|
||||||
|
int last_qscale;
|
||||||
|
int luma_scale[64];
|
||||||
|
int chroma_scale[64];
|
||||||
} DNXHDContext;
|
} DNXHDContext;
|
||||||
|
|
||||||
#define DNXHD_VLC_BITS 9
|
#define DNXHD_VLC_BITS 9
|
||||||
@ -181,6 +184,7 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
|
|||||||
{
|
{
|
||||||
int i, j, index1, index2, len, flags;
|
int i, j, index1, index2, len, flags;
|
||||||
int level, component, sign;
|
int level, component, sign;
|
||||||
|
const int *scale;
|
||||||
const uint8_t *weight_matrix;
|
const uint8_t *weight_matrix;
|
||||||
const uint8_t *ac_level = ctx->cid_table->ac_level;
|
const uint8_t *ac_level = ctx->cid_table->ac_level;
|
||||||
const uint8_t *ac_flags = ctx->cid_table->ac_flags;
|
const uint8_t *ac_flags = ctx->cid_table->ac_flags;
|
||||||
@ -189,9 +193,11 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
|
|||||||
|
|
||||||
if (n&2) {
|
if (n&2) {
|
||||||
component = 1 + (n&1);
|
component = 1 + (n&1);
|
||||||
|
scale = ctx->chroma_scale;
|
||||||
weight_matrix = ctx->cid_table->chroma_weight;
|
weight_matrix = ctx->cid_table->chroma_weight;
|
||||||
} else {
|
} else {
|
||||||
component = 0;
|
component = 0;
|
||||||
|
scale = ctx->luma_scale;
|
||||||
weight_matrix = ctx->cid_table->luma_weight;
|
weight_matrix = ctx->cid_table->luma_weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +246,7 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
|
|||||||
j = ctx->scantable.permutated[i];
|
j = ctx->scantable.permutated[i];
|
||||||
//av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j);
|
//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]);
|
//av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weight %d\n", level, weight_matrix[i]);
|
||||||
level *= qscale * weight_matrix[i];
|
level *= scale[i];
|
||||||
if (level_bias < 32 || weight_matrix[i] != level_bias)
|
if (level_bias < 32 || weight_matrix[i] != level_bias)
|
||||||
level += level_bias;
|
level += level_bias;
|
||||||
level >>= level_shift;
|
level >>= level_shift;
|
||||||
@ -281,6 +287,14 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y)
|
|||||||
skip_bits1(&ctx->gb);
|
skip_bits1(&ctx->gb);
|
||||||
//av_log(ctx->avctx, AV_LOG_DEBUG, "qscale %d\n", qscale);
|
//av_log(ctx->avctx, AV_LOG_DEBUG, "qscale %d\n", qscale);
|
||||||
|
|
||||||
|
if (qscale != ctx->last_qscale) {
|
||||||
|
for (i = 0; i < 64; i++) {
|
||||||
|
ctx->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i];
|
||||||
|
ctx->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i];
|
||||||
|
}
|
||||||
|
ctx->last_qscale = qscale;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
ctx->dsp.clear_block(ctx->blocks[i]);
|
ctx->dsp.clear_block(ctx->blocks[i]);
|
||||||
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
|
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user