aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2023-12-11 01:19:56 +0100
committerClément Bœsch <u@pkh.me>2024-01-10 14:08:00 +0100
commit631fa19ee0d6fbbe8e82516345090f433cea6532 (patch)
treebdf617b43f0712a3d7cd0bb33ab00ece390bbd34
parentf06f2cf16a47d7fad60dd0fa30db6e99445ad89f (diff)
downloadffmpeg-631fa19ee0d6fbbe8e82516345090f433cea6532.tar.gz
avcodec/proresenc_kostya: save a few operations in DC encoding
This matches the logic from proresenc_anatoliy.
-rw-r--r--libavcodec/proresenc_kostya.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index cc53d142bc..cf49614c84 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -135,13 +135,6 @@ static const uint8_t prores_quant_matrices[][64] = {
},
};
-static const uint8_t prores_dc_codebook[4] = {
- 0x04, // rice_order = 0, exp_golomb_order = 1, switch_bits = 0
- 0x28, // rice_order = 1, exp_golomb_order = 2, switch_bits = 0
- 0x4D, // rice_order = 2, exp_golomb_order = 3, switch_bits = 1
- 0x70 // rice_order = 3, exp_golomb_order = 4, switch_bits = 0
-};
-
#define NUM_MB_LIMITS 4
static const int prores_mb_limits[NUM_MB_LIMITS] = {
1620, // up to 720x576
@@ -416,7 +409,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
int blocks_per_slice, int scale)
{
int i;
- int codebook = 3, code, dc, prev_dc, delta, sign, new_sign;
+ int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
prev_dc = (blocks[0] - 0x4000) / scale;
encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
@@ -429,9 +422,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
new_sign = GET_SIGN(delta);
delta = (delta ^ sign) - sign;
code = MAKE_CODE(delta);
- encode_vlc_codeword(pb, prores_dc_codebook[codebook], code);
- codebook = (code + (code & 1)) >> 1;
- codebook = FFMIN(codebook, 3);
+ encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
+ codebook = FFMIN(code, 6);
sign = new_sign;
prev_dc = dc;
}
@@ -649,7 +641,7 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
int scale)
{
int i;
- int codebook = 3, code, dc, prev_dc, delta, sign, new_sign;
+ int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
int bits;
prev_dc = (blocks[0] - 0x4000) / scale;
@@ -665,9 +657,8 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
new_sign = GET_SIGN(delta);
delta = (delta ^ sign) - sign;
code = MAKE_CODE(delta);
- bits += estimate_vlc(prores_dc_codebook[codebook], code);
- codebook = (code + (code & 1)) >> 1;
- codebook = FFMIN(codebook, 3);
+ bits += estimate_vlc(ff_prores_dc_codebook[codebook], code);
+ codebook = FFMIN(code, 6);
sign = new_sign;
prev_dc = dc;
}