This also makes encoder take DCT permutation into account as well.
---
libavcodec/proresdec.c | 10 +++++-----
libavcodec/proresdsp.c | 11 +++++++++++
libavcodec/proresdsp.h | 1 +
libavcodec/proresenc.c | 14 +++++++-------
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index 207fd97..9663caa 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -460,7 +460,7 @@ static int decode_slice(AVCodecContext *avctx, void *tdata)
const uint8_t *buf;
uint8_t *y_data, *u_data, *v_data;
AVFrame *pic = avctx->coded_frame;
- int i, sf, slice_width_factor;
+ int sf, slice_width_factor;
int slice_data_size, hdr_size, y_data_size, u_data_size, v_data_size;
int y_linesize, u_linesize, v_linesize;
@@ -512,10 +512,10 @@ static int decode_slice(AVCodecContext *avctx, void
*tdata)
/* TODO: this can be SIMD-optimized a lot */
if (ctx->qmat_changed || sf != td->prev_slice_sf) {
td->prev_slice_sf = sf;
- for (i = 0; i < 64; i++) {
- td->qmat_luma_scaled[ctx->dsp.idct_permutation[i]] =
ctx->qmat_luma[i] * sf;
- td->qmat_chroma_scaled[ctx->dsp.idct_permutation[i]] =
ctx->qmat_chroma[i] * sf;
- }
+ ctx->dsp.gen_quant(td->qmat_luma_scaled, ctx->dsp.idct_permutation,
+ ctx->qmat_luma, sf);
+ ctx->dsp.gen_quant(td->qmat_chroma_scaled, ctx->dsp.idct_permutation,
+ ctx->qmat_chroma, sf);
}
/* decode luma plane */
diff --git a/libavcodec/proresdsp.c b/libavcodec/proresdsp.c
index 99adf64..b5b5a1b 100644
--- a/libavcodec/proresdsp.c
+++ b/libavcodec/proresdsp.c
@@ -68,6 +68,15 @@ static void prores_fdct_c(const uint16_t *src, int linesize,
DCTELEM *block)
}
#endif
+static void gen_quant_c(int16_t *out, const uint8_t *scan, const uint8_t *ref,
+ int quant)
+{
+ int i;
+
+ for (i = 0; i < 64; i++)
+ out[scan[i]] = ref[i] * quant;
+}
+
void ff_proresdsp_init(ProresDSPContext *dsp)
{
#if CONFIG_PRORES_DECODER
@@ -85,4 +94,6 @@ void ff_proresdsp_init(ProresDSPContext *dsp)
ff_init_scantable_permutation(dsp->dct_permutation,
dsp->dct_permutation_type);
#endif
+
+ dsp->gen_quant = gen_quant_c;
}
diff --git a/libavcodec/proresdsp.h b/libavcodec/proresdsp.h
index f657825..7aa568e 100644
--- a/libavcodec/proresdsp.h
+++ b/libavcodec/proresdsp.h
@@ -34,6 +34,7 @@ typedef struct {
uint8_t dct_permutation[64];
void (* idct_put) (uint16_t *out, int linesize, DCTELEM *block, const
int16_t *qmat);
void (* fdct) (const uint16_t *src, int linesize, DCTELEM *block);
+ void (* gen_quant) (int16_t *out, const uint8_t *scan, const uint8_t *ref,
int quant);
} ProresDSPContext;
void ff_proresdsp_init(ProresDSPContext *dsp);
diff --git a/libavcodec/proresenc.c b/libavcodec/proresenc.c
index 7e3e066..d68e1ff 100644
--- a/libavcodec/proresenc.c
+++ b/libavcodec/proresenc.c
@@ -359,8 +359,8 @@ static int encode_slice(AVCodecContext *avctx, const
AVFrame *pic,
qmat = ctx->quants[quant];
} else {
qmat = ctx->custom_q;
- for (i = 0; i < 64; i++)
- qmat[i] = ctx->profile_info->quant[i] * quant;
+ ctx->dsp.gen_quant(qmat, ctx->dsp.dct_permutation,
+ ctx->profile_info->quant, quant);
}
for (i = 0; i < ctx->num_planes; i++) {
@@ -577,8 +577,8 @@ static int find_slice_quant(AVCodecContext *avctx, const
AVFrame *pic,
qmat = ctx->quants[q];
} else {
qmat = ctx->custom_q;
- for (i = 0; i < 64; i++)
- qmat[i] = ctx->profile_info->quant[i] * q;
+ ctx->dsp.gen_quant(qmat, ctx->dsp.dct_permutation,
+ ctx->profile_info->quant, q);
}
for (i = 0; i < ctx->num_planes; i++) {
bits += estimate_slice_plane(ctx, &error, i,
@@ -772,7 +772,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
{
ProresContext *ctx = avctx->priv_data;
int mps;
- int i, j;
+ int i;
int min_quant, max_quant;
avctx->bits_per_raw_sample = 10;
@@ -815,8 +815,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
min_quant = ctx->profile_info->min_quant;
max_quant = ctx->profile_info->max_quant;
for (i = min_quant; i < MAX_STORED_Q; i++) {
- for (j = 0; j < 64; j++)
- ctx->quants[i][j] = ctx->profile_info->quant[j] * i;
+ ctx->dsp.gen_quant(ctx->quants[i], ctx->dsp.dct_permutation,
+ ctx->profile_info->quant, i);
}
avctx->codec_tag = ctx->profile_info->tag;
--
1.7.0.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel