Skip to content

Commit e4788ae

Browse files
da8eatdwbuiten
authored andcommitted
avcodec/prores_ks: Fix luma quantization if q >= MAX_STORED_Q
The problem occurs in slice quant estimation and slice encoding: If the slice quant is larger than MAX_STORED_Q we don't use pre-calculated quant matrices, but generate a new one, but both qmat and qmat_chroma both point to the same table, so the luma table ends up having chroma table values. Add custom_chroma_q the same way as custom_q. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
1 parent a53a9f1 commit e4788ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libavcodec/proresenc_kostya.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ typedef struct ProresThreadData {
222222
DECLARE_ALIGNED(16, int16_t, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
223223
DECLARE_ALIGNED(16, uint16_t, emu_buf)[16 * 16];
224224
int16_t custom_q[64];
225+
int16_t custom_chroma_q[64];
225226
struct TrellisNode *nodes;
226227
} ProresThreadData;
227228

@@ -232,6 +233,7 @@ typedef struct ProresContext {
232233
int16_t quants[MAX_STORED_Q][64];
233234
int16_t quants_chroma[MAX_STORED_Q][64];
234235
int16_t custom_q[64];
236+
int16_t custom_chroma_q[64];
235237
const uint8_t *quant_mat;
236238
const uint8_t *quant_chroma_mat;
237239
const uint8_t *scantable;
@@ -574,7 +576,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
574576
qmat_chroma = ctx->quants_chroma[quant];
575577
} else {
576578
qmat = ctx->custom_q;
577-
qmat_chroma = ctx->custom_q;
579+
qmat_chroma = ctx->custom_chroma_q;
578580
for (i = 0; i < 64; i++) {
579581
qmat[i] = ctx->quant_mat[i] * quant;
580582
qmat_chroma[i] = ctx->quant_chroma_mat[i] * quant;
@@ -902,7 +904,7 @@ static int find_slice_quant(AVCodecContext *avctx,
902904
qmat_chroma = ctx->quants_chroma[q];
903905
} else {
904906
qmat = td->custom_q;
905-
qmat_chroma = td->custom_q;
907+
qmat_chroma = td->custom_chroma_q;
906908
for (i = 0; i < 64; i++) {
907909
qmat[i] = ctx->quant_mat[i] * q;
908910
qmat_chroma[i] = ctx->quant_chroma_mat[i] * q;

0 commit comments

Comments
 (0)