Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] Initial tickering at unifying ProRes encoder
@ 2023-12-11  1:35 Clément Bœsch
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro Clément Bœsch
                   ` (36 more replies)
  0 siblings, 37 replies; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel

Hello there,

I'm currently investigating an issue¹ affecting Kostya ProRes encoder
which is not reproducible with Anatoliy encoder (but it's too early to
say if the bug is not present there as well given the differences in
quantization, and it's also unclear if the issue is even actually
there in the first place and not in M2/M3 firmwares).

Since these encoders share more than similiarities, I've been looking
into their differences, and unifying their common codepaths was helpful
to my investigation.

Attached is an initial patchset working out their differences by either
sharing data or making code identical where relevant.

I will continue that work as the investigation progresses. The
quantization work might require more involved changes though.

Regards,

¹ https://trac.ffmpeg.org/ticket/10255


_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-12  6:53   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 02/35] avcodec/proresenc_kostya: remove unused plane factor variables Clément Bœsch
                   ` (35 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_kostya.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 52fe5639b1..58fc340879 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -429,7 +429,7 @@ static inline void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int
 }
 
 #define GET_SIGN(x)  ((x) >> 31)
-#define MAKE_CODE(x) ((((x)) * 2) ^ GET_SIGN(x))
+#define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
 
 static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int scale)
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 02/35] avcodec/proresenc_kostya: remove unused plane factor variables
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-12  6:56   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments Clément Bœsch
                   ` (34 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_kostya.c | 36 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 58fc340879..7aed3974c3 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -459,7 +459,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
 
 static void encode_acs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice,
-                       int plane_size_factor,
                        const uint8_t *scan, const int16_t *qmat)
 {
     int idx, i;
@@ -494,14 +493,13 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
 static void encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
                               const uint16_t *src, ptrdiff_t linesize,
                               int mbs_per_slice, int16_t *blocks,
-                              int blocks_per_mb, int plane_size_factor,
+                              int blocks_per_mb,
                               const int16_t *qmat)
 {
     int blocks_per_slice = mbs_per_slice * blocks_per_mb;
 
     encode_dcs(pb, blocks, blocks_per_slice, qmat[0]);
-    encode_acs(pb, blocks, blocks_per_slice, plane_size_factor,
-               ctx->scantable, qmat);
+    encode_acs(pb, blocks, blocks_per_slice, ctx->scantable, qmat);
 }
 
 static void put_alpha_diff(PutBitContext *pb, int cur, int prev, int abits)
@@ -575,10 +573,9 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
     int i, xp, yp;
     int total_size = 0;
     const uint16_t *src;
-    int slice_width_factor = av_log2(mbs_per_slice);
     int num_cblocks, pwidth, line_add;
     ptrdiff_t linesize;
-    int plane_factor, is_chroma;
+    int is_chroma;
     uint16_t *qmat;
     uint16_t *qmat_chroma;
 
@@ -604,9 +601,6 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
 
     for (i = 0; i < ctx->num_planes; i++) {
         is_chroma    = (i == 1 || i == 2);
-        plane_factor = slice_width_factor + 2;
-        if (is_chroma)
-            plane_factor += ctx->chroma_factor - 3;
         if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) {
             xp          = x << 4;
             yp          = y << 4;
@@ -631,11 +625,11 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
             if (!is_chroma) {/* luma quant */
                 encode_slice_plane(ctx, pb, src, linesize,
                                    mbs_per_slice, ctx->blocks[0],
-                                   num_cblocks, plane_factor, qmat);
+                                   num_cblocks, qmat);
             } else { /* chroma plane */
                 encode_slice_plane(ctx, pb, src, linesize,
                                    mbs_per_slice, ctx->blocks[0],
-                                   num_cblocks, plane_factor, qmat_chroma);
+                                   num_cblocks, qmat_chroma);
             }
         } else {
             get_alpha_data(ctx, src, linesize, xp, yp,
@@ -704,7 +698,6 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
 }
 
 static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
-                        int plane_size_factor,
                         const uint8_t *scan, const int16_t *qmat)
 {
     int idx, i;
@@ -742,7 +735,7 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
 static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
                                 const uint16_t *src, ptrdiff_t linesize,
                                 int mbs_per_slice,
-                                int blocks_per_mb, int plane_size_factor,
+                                int blocks_per_mb,
                                 const int16_t *qmat, ProresThreadData *td)
 {
     int blocks_per_slice;
@@ -751,8 +744,7 @@ static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
     blocks_per_slice = mbs_per_slice * blocks_per_mb;
 
     bits  = estimate_dcs(error, td->blocks[plane], blocks_per_slice, qmat[0]);
-    bits += estimate_acs(error, td->blocks[plane], blocks_per_slice,
-                         plane_size_factor, ctx->scantable, qmat);
+    bits += estimate_acs(error, td->blocks[plane], blocks_per_slice, ctx->scantable, qmat);
 
     return FFALIGN(bits, 8);
 }
@@ -821,9 +813,8 @@ static int find_slice_quant(AVCodecContext *avctx,
     ProresContext *ctx = avctx->priv_data;
     int i, q, pq, xp, yp;
     const uint16_t *src;
-    int slice_width_factor = av_log2(mbs_per_slice);
     int num_cblocks[MAX_PLANES], pwidth;
-    int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];
+    int is_chroma[MAX_PLANES];
     const int min_quant = ctx->profile_info->min_quant;
     const int max_quant = ctx->profile_info->max_quant;
     int error, bits, bits_limit;
@@ -843,9 +834,6 @@ static int find_slice_quant(AVCodecContext *avctx,
 
     for (i = 0; i < ctx->num_planes; i++) {
         is_chroma[i]    = (i == 1 || i == 2);
-        plane_factor[i] = slice_width_factor + 2;
-        if (is_chroma[i])
-            plane_factor[i] += ctx->chroma_factor - 3;
         if (!is_chroma[i] || ctx->chroma_factor == CFACTOR_Y444) {
             xp             = x << 4;
             yp             = y << 4;
@@ -889,13 +877,13 @@ static int find_slice_quant(AVCodecContext *avctx,
         bits += estimate_slice_plane(ctx, &error, 0,
                                      src, linesize[0],
                                      mbs_per_slice,
-                                     num_cblocks[0], plane_factor[0],
+                                     num_cblocks[0],
                                      ctx->quants[q], td); /* estimate luma plane */
         for (i = 1; i < ctx->num_planes - !!ctx->alpha_bits; i++) { /* estimate chroma plane */
             bits += estimate_slice_plane(ctx, &error, i,
                                          src, linesize[i],
                                          mbs_per_slice,
-                                         num_cblocks[i], plane_factor[i],
+                                         num_cblocks[i],
                                          ctx->quants_chroma[q], td);
         }
         if (bits > 65000 * 8)
@@ -926,13 +914,13 @@ static int find_slice_quant(AVCodecContext *avctx,
             bits += estimate_slice_plane(ctx, &error, 0,
                                          src, linesize[0],
                                          mbs_per_slice,
-                                         num_cblocks[0], plane_factor[0],
+                                         num_cblocks[0],
                                          qmat, td);/* estimate luma plane */
             for (i = 1; i < ctx->num_planes - !!ctx->alpha_bits; i++) { /* estimate chroma plane */
                 bits += estimate_slice_plane(ctx, &error, i,
                                              src, linesize[i],
                                              mbs_per_slice,
-                                             num_cblocks[i], plane_factor[i],
+                                             num_cblocks[i],
                                              qmat_chroma, td);
             }
             if (bits <= ctx->bits_per_mb * mbs_per_slice)
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro Clément Bœsch
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 02/35] avcodec/proresenc_kostya: remove unused plane factor variables Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-12  7:00   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata Clément Bœsch
                   ` (33 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This is already assigned at declaration.
---
 libavcodec/proresenc_kostya.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 7aed3974c3..6e1d5a0cef 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -440,7 +440,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
     prev_dc = (blocks[0] - 0x4000) / scale;
     encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
     sign     = 0;
-    codebook = 3;
     blocks  += 64;
 
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
@@ -676,7 +675,6 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
     prev_dc  = (blocks[0] - 0x4000) / scale;
     bits     = estimate_vlc(FIRST_DC_CB, MAKE_CODE(prev_dc));
     sign     = 0;
-    codebook = 3;
     blocks  += 64;
     *error  += FFABS(blocks[0] - 0x4000) % scale;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (2 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-12  7:02   ` Stefano Sabatini
  2023-12-12  8:02   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping Clément Bœsch
                   ` (32 subsequent siblings)
  36 siblings, 2 replies; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This is going to be shared with proresenc_kostya in the upcoming commit.
---
 libavcodec/proresdata.c         | 6 ++++++
 libavcodec/proresdata.h         | 2 ++
 libavcodec/proresenc_anatoliy.c | 9 ++-------
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
index 4787907c71..12ee43bddd 100644
--- a/libavcodec/proresdata.c
+++ b/libavcodec/proresdata.c
@@ -43,3 +43,9 @@ const uint8_t ff_prores_interlaced_scan[64] = {
     30, 23, 31, 38, 45, 52, 60, 53,
     46, 39, 47, 54, 61, 62, 55, 63
 };
+
+const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
+        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
+
+const uint8_t ff_prores_lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
+        0x28, 0x28, 0x28, 0x4C };
diff --git a/libavcodec/proresdata.h b/libavcodec/proresdata.h
index d8c8786689..4d16992892 100644
--- a/libavcodec/proresdata.h
+++ b/libavcodec/proresdata.h
@@ -29,6 +29,8 @@
 
 extern const uint8_t ff_prores_progressive_scan[64];
 extern const uint8_t ff_prores_interlaced_scan[64];
+extern const uint8_t ff_prores_run_to_cb[16];
+extern const uint8_t ff_prores_lev_to_cb[10];
 
 #define FIRST_DC_CB 0xB8 // rice_order = 5, exp_golomb_order = 6, switch_bits = 0
 
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index e7114f1646..6b2e513bed 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -296,11 +296,6 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
     }
 }
 
-static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
-        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
-static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
-        0x28, 0x28, 0x28, 0x4C };
-
 static void encode_ac_coeffs(PutBitContext *pb,
         int16_t *in, int blocks_per_slice, int *qmat, const uint8_t ff_prores_scan[64])
 {
@@ -313,14 +308,14 @@ static void encode_ac_coeffs(PutBitContext *pb,
         for (j = 0; j < blocks_per_slice; j++) {
             int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
             if (val) {
-                encode_codeword(pb, run, run_to_cb[FFMIN(prev_run, 15)]);
+                encode_codeword(pb, run, ff_prores_run_to_cb[FFMIN(prev_run, 15)]);
 
                 prev_run   = run;
                 run        = 0;
                 level      = get_level(val);
                 code       = level - 1;
 
-                encode_codeword(pb, code, lev_to_cb[FFMIN(prev_level, 9)]);
+                encode_codeword(pb, code, ff_prores_lev_to_cb[FFMIN(prev_level, 9)]);
 
                 prev_level = level;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (3 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-12  8:16   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 06/35] avcodec/proresenc_anatoliy: remove duplicated define Clément Bœsch
                   ` (31 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This is following the same logic as proresenc_anatoliy.
---
 libavcodec/proresenc_kostya.c | 47 +++++++++++------------------------
 1 file changed, 14 insertions(+), 33 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 6e1d5a0cef..f883ab550b 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -142,25 +142,6 @@ static const uint8_t prores_dc_codebook[4] = {
     0x70  // rice_order = 3, exp_golomb_order = 4, switch_bits = 0
 };
 
-static const uint8_t prores_ac_codebook[7] = {
-    0x04, // rice_order = 0, exp_golomb_order = 1, switch_bits = 0
-    0x28, // rice_order = 1, exp_golomb_order = 2, switch_bits = 0
-    0x4C, // rice_order = 2, exp_golomb_order = 3, switch_bits = 0
-    0x05, // rice_order = 0, exp_golomb_order = 1, switch_bits = 1
-    0x29, // rice_order = 1, exp_golomb_order = 2, switch_bits = 1
-    0x06, // rice_order = 0, exp_golomb_order = 1, switch_bits = 2
-    0x0A, // rice_order = 0, exp_golomb_order = 2, switch_bits = 2
-};
-
-/**
- * Lookup tables for adaptive switching between codebooks
- * according with previous run/level value.
- */
-static const uint8_t prores_run_to_cb_index[16] =
-    { 5, 5, 3, 3, 0, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 2 };
-
-static const uint8_t prores_lev_to_cb_index[10] = { 0, 6, 3, 5, 0, 1, 1, 1, 1, 2 };
-
 #define NUM_MB_LIMITS 4
 static const int prores_mb_limits[NUM_MB_LIMITS] = {
     1620, // up to 720x576
@@ -461,12 +442,12 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
                        const uint8_t *scan, const int16_t *qmat)
 {
     int idx, i;
-    int run, level, run_cb, lev_cb;
+    int prev_run = 4;
+    int prev_level = 2;
+    int run, level;
     int max_coeffs, abs_level;
 
     max_coeffs = blocks_per_slice << 6;
-    run_cb     = prores_run_to_cb_index[4];
-    lev_cb     = prores_lev_to_cb_index[2];
     run        = 0;
 
     for (i = 1; i < 64; i++) {
@@ -474,13 +455,13 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
             level = blocks[idx] / qmat[scan[i]];
             if (level) {
                 abs_level = FFABS(level);
-                encode_vlc_codeword(pb, prores_ac_codebook[run_cb], run);
-                encode_vlc_codeword(pb, prores_ac_codebook[lev_cb],
+                encode_vlc_codeword(pb, ff_prores_run_to_cb[prev_run], run);
+                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level],
                                     abs_level - 1);
                 put_sbits(pb, 1, GET_SIGN(level));
 
-                run_cb = prores_run_to_cb_index[FFMIN(run, 15)];
-                lev_cb = prores_lev_to_cb_index[FFMIN(abs_level, 9)];
+                prev_run   = FFMIN(run, 15);
+                prev_level = FFMIN(abs_level, 9);
                 run    = 0;
             } else {
                 run++;
@@ -699,13 +680,13 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
                         const uint8_t *scan, const int16_t *qmat)
 {
     int idx, i;
-    int run, level, run_cb, lev_cb;
+    int prev_run = 4;
+    int prev_level = 2;
+    int run, level;
     int max_coeffs, abs_level;
     int bits = 0;
 
     max_coeffs = blocks_per_slice << 6;
-    run_cb     = prores_run_to_cb_index[4];
-    lev_cb     = prores_lev_to_cb_index[2];
     run        = 0;
 
     for (i = 1; i < 64; i++) {
@@ -714,12 +695,12 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
             *error += FFABS(blocks[idx]) % qmat[scan[i]];
             if (level) {
                 abs_level = FFABS(level);
-                bits += estimate_vlc(prores_ac_codebook[run_cb], run);
-                bits += estimate_vlc(prores_ac_codebook[lev_cb],
+                bits += estimate_vlc(ff_prores_run_to_cb[prev_run], run);
+                bits += estimate_vlc(ff_prores_lev_to_cb[prev_level],
                                      abs_level - 1) + 1;
 
-                run_cb = prores_run_to_cb_index[FFMIN(run, 15)];
-                lev_cb = prores_lev_to_cb_index[FFMIN(abs_level, 9)];
+                prev_run   = FFMIN(run, 15);
+                prev_level = FFMIN(abs_level, 9);
                 run    = 0;
             } else {
                 run++;
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 06/35] avcodec/proresenc_anatoliy: remove duplicated define
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (4 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-16 16:32   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 07/35] avcodec/proresenc_anatoliy: move DC codebook LUT to shared proresdata Clément Bœsch
                   ` (30 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This is already defined in proresdata.h
---
 libavcodec/proresenc_anatoliy.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 6b2e513bed..c6f49be9b8 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -266,8 +266,6 @@ static av_always_inline int get_level(int val)
     return (val ^ sign) - sign;
 }
 
-#define FIRST_DC_CB 0xB8
-
 static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70};
 
 static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 07/35] avcodec/proresenc_anatoliy: move DC codebook LUT to shared proresdata
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (5 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 06/35] avcodec/proresenc_anatoliy: remove duplicated define Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-16 16:33   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding Clément Bœsch
                   ` (29 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This is going to be shared with proresenc_kostya in the upcoming commit.
---
 libavcodec/proresdata.c         | 2 ++
 libavcodec/proresdata.h         | 1 +
 libavcodec/proresenc_anatoliy.c | 3 +--
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
index 12ee43bddd..866839c8d1 100644
--- a/libavcodec/proresdata.c
+++ b/libavcodec/proresdata.c
@@ -44,6 +44,8 @@ const uint8_t ff_prores_interlaced_scan[64] = {
     46, 39, 47, 54, 61, 62, 55, 63
 };
 
+const uint8_t ff_prores_dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70 };
+
 const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
         0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
 
diff --git a/libavcodec/proresdata.h b/libavcodec/proresdata.h
index 4d16992892..e24472d844 100644
--- a/libavcodec/proresdata.h
+++ b/libavcodec/proresdata.h
@@ -29,6 +29,7 @@
 
 extern const uint8_t ff_prores_progressive_scan[64];
 extern const uint8_t ff_prores_interlaced_scan[64];
+extern const uint8_t ff_prores_dc_codebook[7];
 extern const uint8_t ff_prores_run_to_cb[16];
 extern const uint8_t ff_prores_lev_to_cb[10];
 
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index c6f49be9b8..d6f5cefc16 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -266,7 +266,6 @@ static av_always_inline int get_level(int val)
     return (val ^ sign) - sign;
 }
 
-static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70};
 
 static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
         int blocks_per_slice, int *qmat)
@@ -286,7 +285,7 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
         diff_sign = DIFF_SIGN(delta, sign);
         new_code  = TO_GOLOMB2(get_level(delta), diff_sign);
 
-        encode_codeword(pb, new_code, dc_codebook[FFMIN(code, 6)]);
+        encode_codeword(pb, new_code, ff_prores_dc_codebook[FFMIN(code, 6)]);
 
         code      = new_code;
         sign      = delta >> 31;
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (6 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 07/35] avcodec/proresenc_anatoliy: move DC codebook LUT to shared proresdata Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-16 16:54   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header Clément Bœsch
                   ` (28 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches the logic from proresenc_anatoliy.
---
 libavcodec/proresenc_kostya.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index f883ab550b..2d45f9a685 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;
     }
@@ -650,7 +642,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;
@@ -666,9 +658,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;
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (7 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-16 17:12   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 10/35] avcodec/proresenc_kostya: simplify quantization matrix bytestream writing Clément Bœsch
                   ` (27 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_kostya.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 2d45f9a685..103051830a 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1019,7 +1019,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             bytestream_put_byte(&buf, ctx->quant_mat[i]);
         // chroma quantisation matrix
         for (i = 0; i < 64; i++)
-            bytestream_put_byte(&buf, ctx->quant_mat[i]);
+            bytestream_put_byte(&buf, ctx->quant_chroma_mat[i]);
     } else {
         bytestream_put_byte  (&buf, 0x00);      // matrix flags - default matrices are used
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 10/35] avcodec/proresenc_kostya: simplify quantization matrix bytestream writing
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (8 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-17 18:18   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 11/35] avcodec/proresenc_anatoliy: use FRAME_ID defined in proresdata.h Clément Bœsch
                   ` (26 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_kostya.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 103051830a..e0aa7cf47a 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1014,12 +1014,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     bytestream_put_byte  (&buf, 0);             // reserved
     if (ctx->quant_sel != QUANT_MAT_DEFAULT) {
         bytestream_put_byte  (&buf, 0x03);      // matrix flags - both matrices are present
-        // luma quantisation matrix
-        for (i = 0; i < 64; i++)
-            bytestream_put_byte(&buf, ctx->quant_mat[i]);
-        // chroma quantisation matrix
-        for (i = 0; i < 64; i++)
-            bytestream_put_byte(&buf, ctx->quant_chroma_mat[i]);
+        bytestream_put_buffer(&buf, ctx->quant_mat, 64);        // luma quantisation matrix
+        bytestream_put_buffer(&buf, ctx->quant_chroma_mat, 64); // chroma quantisation matrix
     } else {
         bytestream_put_byte  (&buf, 0x00);      // matrix flags - default matrices are used
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 11/35] avcodec/proresenc_anatoliy: use FRAME_ID defined in proresdata.h
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (9 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 10/35] avcodec/proresenc_kostya: simplify quantization matrix bytestream writing Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-17 18:19   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder Clément Bœsch
                   ` (25 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_anatoliy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index d6f5cefc16..804ff6ddf7 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -755,7 +755,7 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     compress_frame_size = 8 + header_size;
 
     bytestream_put_be32(&buf, compress_frame_size);/* frame size will be update after picture(s) encoding */
-    bytestream_put_buffer(&buf, "icpf", 4);
+    bytestream_put_be32(&buf, FRAME_ID);
 
     bytestream_put_be16(&buf, header_size);
     bytestream_put_be16(&buf, 0); /* version */
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (10 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 11/35] avcodec/proresenc_anatoliy: use FRAME_ID defined in proresdata.h Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:07   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 13/35] avcodec/proresenc_anatoliy: rework encode_codeword() prototype Clément Bœsch
                   ` (24 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

Code is functionally identical, it's just rename of variables, cosmetics
and branch logic shuffling.
---
 libavcodec/proresenc_anatoliy.c | 45 +++++++++++++++++----------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 804ff6ddf7..c7e43fc88c 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -226,31 +226,32 @@ static int int_from_list_or_default(void *ctx, const char *val_name, int val,
     return default_value;
 }
 
-static void encode_codeword(PutBitContext *pb, int val, int codebook)
+static void encode_codeword(PutBitContext *pb, int val, unsigned codebook)
 {
-    unsigned int rice_order, exp_order, switch_bits, first_exp, exp, zeros;
-
-    /* number of bits to switch between rice and exp golomb */
-    switch_bits = codebook & 3;
-    rice_order  = codebook >> 5;
-    exp_order   = (codebook >> 2) & 7;
-
-    first_exp = ((switch_bits + 1) << rice_order);
-
-    if (val >= first_exp) { /* exp golomb */
-        val -= first_exp;
-        val += (1 << exp_order);
-        exp = av_log2(val);
-        zeros = exp - exp_order + switch_bits + 1;
-        put_bits(pb, zeros, 0);
-        put_bits(pb, exp + 1, val);
-    } else if (rice_order) {
-        put_bits(pb, (val >> rice_order), 0);
-        put_bits(pb, 1, 1);
-        put_sbits(pb, rice_order, val);
+    unsigned int rice_order, exp_order, switch_bits, switch_val;
+    int exponent;
+
+    /* number of prefix bits to switch between Rice and expGolomb */
+    switch_bits = (codebook & 3) + 1;
+    rice_order  =  codebook >> 5;       /* rice code order */
+    exp_order   = (codebook >> 2) & 7;  /* exp golomb code order */
+
+    switch_val  = switch_bits << rice_order;
+
+    if (val >= switch_val) {
+        val -= switch_val - (1 << exp_order);
+        exponent = av_log2(val);
+
+        put_bits(pb, exponent - exp_order + switch_bits, 0);
+        put_bits(pb, exponent + 1, val);
     } else {
-        put_bits(pb, val, 0);
+        exponent = val >> rice_order;
+
+        if (exponent)
+            put_bits(pb, exponent, 0);
         put_bits(pb, 1, 1);
+        if (rice_order)
+            put_sbits(pb, rice_order, val);
     }
 }
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 13/35] avcodec/proresenc_anatoliy: rework encode_codeword() prototype
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (11 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:09   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 14/35] avcodec/proresenc_anatoliy: inline QSCALE() Clément Bœsch
                   ` (23 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches the function of the same name in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index c7e43fc88c..86e436615c 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -226,7 +226,7 @@ static int int_from_list_or_default(void *ctx, const char *val_name, int val,
     return default_value;
 }
 
-static void encode_codeword(PutBitContext *pb, int val, unsigned codebook)
+static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 {
     unsigned int rice_order, exp_order, switch_bits, switch_val;
     int exponent;
@@ -277,7 +277,7 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
 
     prev_dc = QSCALE(qmat, 0, in[0] - 16384);
     code = TO_GOLOMB(prev_dc);
-    encode_codeword(pb, code, FIRST_DC_CB);
+    encode_vlc_codeword(pb, FIRST_DC_CB, code);
 
     code = 5; sign = 0; idx = 64;
     for (i = 1; i < blocks_per_slice; i++, idx += 64) {
@@ -286,7 +286,7 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
         diff_sign = DIFF_SIGN(delta, sign);
         new_code  = TO_GOLOMB2(get_level(delta), diff_sign);
 
-        encode_codeword(pb, new_code, ff_prores_dc_codebook[FFMIN(code, 6)]);
+        encode_vlc_codeword(pb, ff_prores_dc_codebook[FFMIN(code, 6)], new_code);
 
         code      = new_code;
         sign      = delta >> 31;
@@ -306,14 +306,14 @@ static void encode_ac_coeffs(PutBitContext *pb,
         for (j = 0; j < blocks_per_slice; j++) {
             int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
             if (val) {
-                encode_codeword(pb, run, ff_prores_run_to_cb[FFMIN(prev_run, 15)]);
+                encode_vlc_codeword(pb, ff_prores_run_to_cb[FFMIN(prev_run, 15)], run);
 
                 prev_run   = run;
                 run        = 0;
                 level      = get_level(val);
                 code       = level - 1;
 
-                encode_codeword(pb, code, ff_prores_lev_to_cb[FFMIN(prev_level, 9)]);
+                encode_vlc_codeword(pb, ff_prores_lev_to_cb[FFMIN(prev_level, 9)], code);
 
                 prev_level = level;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 14/35] avcodec/proresenc_anatoliy: inline QSCALE()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (12 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 13/35] avcodec/proresenc_anatoliy: rework encode_codeword() prototype Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:13   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 15/35] avcodec/proresenc_anatoliy: rename new_code/code to code/codebook Clément Bœsch
                   ` (22 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

Also replaces 16384 with 0x4000.

This makes the function slightly closer to same function in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 86e436615c..b8433ee872 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -255,7 +255,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
     }
 }
 
-#define QSCALE(qmat,ind,val) ((val) / ((qmat)[ind]))
 #define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31))
 #define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign))
 #define IS_NEGATIVE(val) ((((val) >> 31) ^ -1) + 1)
@@ -275,13 +274,13 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
     int i, sign, idx;
     int new_dc, delta, diff_sign, new_code;
 
-    prev_dc = QSCALE(qmat, 0, in[0] - 16384);
+    prev_dc = (in[0] - 0x4000) / qmat[0];
     code = TO_GOLOMB(prev_dc);
     encode_vlc_codeword(pb, FIRST_DC_CB, code);
 
     code = 5; sign = 0; idx = 64;
     for (i = 1; i < blocks_per_slice; i++, idx += 64) {
-        new_dc    = QSCALE(qmat, 0, in[idx] - 16384);
+        new_dc    = (in[idx] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
         diff_sign = DIFF_SIGN(delta, sign);
         new_code  = TO_GOLOMB2(get_level(delta), diff_sign);
@@ -304,7 +303,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
     for (i = 1; i < 64; i++) {
         int indp = ff_prores_scan[i];
         for (j = 0; j < blocks_per_slice; j++) {
-            int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
+            int val = (in[(j << 6) + indp]) / qmat[indp];
             if (val) {
                 encode_vlc_codeword(pb, ff_prores_run_to_cb[FFMIN(prev_run, 15)], run);
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 15/35] avcodec/proresenc_anatoliy: rename new_code/code to code/codebook
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (13 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 14/35] avcodec/proresenc_anatoliy: inline QSCALE() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:18   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 16/35] avcodec/proresenc_anatoliy: execute codebook FFMIN() at assignment Clément Bœsch
                   ` (21 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to encode_dcs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index b8433ee872..e79c465590 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -270,24 +270,24 @@ static av_always_inline int get_level(int val)
 static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
         int blocks_per_slice, int *qmat)
 {
-    int prev_dc, code;
+    int prev_dc, codebook;
     int i, sign, idx;
-    int new_dc, delta, diff_sign, new_code;
+    int new_dc, delta, diff_sign, code;
 
     prev_dc = (in[0] - 0x4000) / qmat[0];
-    code = TO_GOLOMB(prev_dc);
-    encode_vlc_codeword(pb, FIRST_DC_CB, code);
+    codebook = TO_GOLOMB(prev_dc);
+    encode_vlc_codeword(pb, FIRST_DC_CB, codebook);
 
-    code = 5; sign = 0; idx = 64;
+    codebook = 5; sign = 0; idx = 64;
     for (i = 1; i < blocks_per_slice; i++, idx += 64) {
         new_dc    = (in[idx] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
         diff_sign = DIFF_SIGN(delta, sign);
-        new_code  = TO_GOLOMB2(get_level(delta), diff_sign);
+        code      = TO_GOLOMB2(get_level(delta), diff_sign);
 
-        encode_vlc_codeword(pb, ff_prores_dc_codebook[FFMIN(code, 6)], new_code);
+        encode_vlc_codeword(pb, ff_prores_dc_codebook[FFMIN(codebook, 6)], code);
 
-        code      = new_code;
+        codebook  = code;
         sign      = delta >> 31;
         prev_dc   = new_dc;
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 16/35] avcodec/proresenc_anatoliy: execute codebook FFMIN() at assignment
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (14 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 15/35] avcodec/proresenc_anatoliy: rename new_code/code to code/codebook Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:24   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 17/35] avcodec/proresenc_anatoliy: reduce DC encoding function prototype differences with Kostya encoder Clément Bœsch
                   ` (20 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to encode_dcs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index e79c465590..f8feff850f 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -285,9 +285,9 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
         diff_sign = DIFF_SIGN(delta, sign);
         code      = TO_GOLOMB2(get_level(delta), diff_sign);
 
-        encode_vlc_codeword(pb, ff_prores_dc_codebook[FFMIN(codebook, 6)], code);
+        encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
 
-        codebook  = code;
+        codebook  = FFMIN(code, 6);
         sign      = delta >> 31;
         prev_dc   = new_dc;
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 17/35] avcodec/proresenc_anatoliy: reduce DC encoding function prototype differences with Kostya encoder
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (15 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 16/35] avcodec/proresenc_anatoliy: execute codebook FFMIN() at assignment Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:26   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 18/35] avcodec/proresenc_anatoliy: directly work with blocks in encode_dcs() Clément Bœsch
                   ` (19 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_anatoliy.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index f8feff850f..97d681467d 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -267,20 +267,20 @@ static av_always_inline int get_level(int val)
 }
 
 
-static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
-        int blocks_per_slice, int *qmat)
+static void encode_dcs(PutBitContext *pb, int16_t *blocks,
+                       int blocks_per_slice, int *qmat)
 {
     int prev_dc, codebook;
     int i, sign, idx;
     int new_dc, delta, diff_sign, code;
 
-    prev_dc = (in[0] - 0x4000) / qmat[0];
+    prev_dc = (blocks[0] - 0x4000) / qmat[0];
     codebook = TO_GOLOMB(prev_dc);
     encode_vlc_codeword(pb, FIRST_DC_CB, codebook);
 
     codebook = 5; sign = 0; idx = 64;
     for (i = 1; i < blocks_per_slice; i++, idx += 64) {
-        new_dc    = (in[idx] - 0x4000) / qmat[0];
+        new_dc    = (blocks[idx] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
         diff_sign = DIFF_SIGN(delta, sign);
         code      = TO_GOLOMB2(get_level(delta), diff_sign);
@@ -388,7 +388,7 @@ static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsig
     blocks_per_slice = mb_count << (2 - sub_sample_chroma);
     init_put_bits(&pb, buf, buf_size);
 
-    encode_dc_coeffs(&pb, blocks, blocks_per_slice, qmat);
+    encode_dcs(&pb, blocks, blocks_per_slice, qmat);
     encode_ac_coeffs(&pb, blocks, blocks_per_slice, qmat, ff_prores_scan);
 
     flush_put_bits(&pb);
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 18/35] avcodec/proresenc_anatoliy: directly work with blocks in encode_dcs()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (16 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 17/35] avcodec/proresenc_anatoliy: reduce DC encoding function prototype differences with Kostya encoder Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:30   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 19/35] avcodec/proresenc_anatoliy: import GET_SIGN() macro from Kostya encoder and use it Clément Bœsch
                   ` (18 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to encode_dcs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 97d681467d..a418a12705 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -271,16 +271,17 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int *qmat)
 {
     int prev_dc, codebook;
-    int i, sign, idx;
+    int i, sign;
     int new_dc, delta, diff_sign, code;
 
     prev_dc = (blocks[0] - 0x4000) / qmat[0];
     codebook = TO_GOLOMB(prev_dc);
     encode_vlc_codeword(pb, FIRST_DC_CB, codebook);
+    blocks  += 64;
 
-    codebook = 5; sign = 0; idx = 64;
-    for (i = 1; i < blocks_per_slice; i++, idx += 64) {
-        new_dc    = (blocks[idx] - 0x4000) / qmat[0];
+    codebook = 5; sign = 0;
+    for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
+        new_dc    = (blocks[0] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
         diff_sign = DIFF_SIGN(delta, sign);
         code      = TO_GOLOMB2(get_level(delta), diff_sign);
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 19/35] avcodec/proresenc_anatoliy: import GET_SIGN() macro from Kostya encoder and use it
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (17 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 18/35] avcodec/proresenc_anatoliy: directly work with blocks in encode_dcs() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:30   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 20/35] avcodec/proresenc_anatoliy: compute sign only once Clément Bœsch
                   ` (17 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_anatoliy.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index a418a12705..0de262c9c5 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -255,9 +255,10 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
     }
 }
 
-#define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31))
-#define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign))
-#define IS_NEGATIVE(val) ((((val) >> 31) ^ -1) + 1)
+#define GET_SIGN(x)  ((x) >> 31)
+#define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
+#define DIFF_SIGN(val, sign) (GET_SIGN(val) ^ (sign))
+#define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1)
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
 
 static av_always_inline int get_level(int val)
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 20/35] avcodec/proresenc_anatoliy: compute sign only once
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (18 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 19/35] avcodec/proresenc_anatoliy: import GET_SIGN() macro from Kostya encoder and use it Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:37   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 21/35] avcodec/proresenc_anatoliy: rename new_dc to dc Clément Bœsch
                   ` (16 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to encode_dcs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 0de262c9c5..0d8ca5515f 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 
 #define GET_SIGN(x)  ((x) >> 31)
 #define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
-#define DIFF_SIGN(val, sign) (GET_SIGN(val) ^ (sign))
 #define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1)
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
 
@@ -272,7 +271,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int *qmat)
 {
     int prev_dc, codebook;
-    int i, sign;
+    int i, sign, new_sign;
     int new_dc, delta, diff_sign, code;
 
     prev_dc = (blocks[0] - 0x4000) / qmat[0];
@@ -284,13 +283,14 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
         new_dc    = (blocks[0] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
-        diff_sign = DIFF_SIGN(delta, sign);
+        new_sign  = GET_SIGN(delta);
+        diff_sign = new_sign ^ sign;
         code      = TO_GOLOMB2(get_level(delta), diff_sign);
 
         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
 
         codebook  = FFMIN(code, 6);
-        sign      = delta >> 31;
+        sign      = new_sign;
         prev_dc   = new_dc;
     }
 }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 21/35] avcodec/proresenc_anatoliy: rename new_dc to dc
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (19 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 20/35] avcodec/proresenc_anatoliy: compute sign only once Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18  0:38   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 22/35] avcodec/proresenc_anatoliy: remove IS_NEGATIVE() macro Clément Bœsch
                   ` (15 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to encode_dcs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 0d8ca5515f..4ea3d89126 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -272,7 +272,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
 {
     int prev_dc, codebook;
     int i, sign, new_sign;
-    int new_dc, delta, diff_sign, code;
+    int dc, delta, diff_sign, code;
 
     prev_dc = (blocks[0] - 0x4000) / qmat[0];
     codebook = TO_GOLOMB(prev_dc);
@@ -281,8 +281,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
 
     codebook = 5; sign = 0;
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
-        new_dc    = (blocks[0] - 0x4000) / qmat[0];
-        delta     = new_dc - prev_dc;
+        dc        = (blocks[0] - 0x4000) / qmat[0];
+        delta     = dc - prev_dc;
         new_sign  = GET_SIGN(delta);
         diff_sign = new_sign ^ sign;
         code      = TO_GOLOMB2(get_level(delta), diff_sign);
@@ -291,7 +291,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
 
         codebook  = FFMIN(code, 6);
         sign      = new_sign;
-        prev_dc   = new_dc;
+        prev_dc   = dc;
     }
 }
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 22/35] avcodec/proresenc_anatoliy: remove IS_NEGATIVE() macro
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (20 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 21/35] avcodec/proresenc_anatoliy: rename new_dc to dc Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18 22:29   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 23/35] avcodec/proresenc_kostya: add Anatoliy copyright Clément Bœsch
                   ` (14 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to encode_acs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 4ea3d89126..43dee7f79b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 
 #define GET_SIGN(x)  ((x) >> 31)
 #define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
-#define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1)
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
 
 static av_always_inline int get_level(int val)
@@ -318,7 +317,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
 
                 prev_level = level;
 
-                put_bits(pb, 1, IS_NEGATIVE(val));
+                put_sbits(pb, 1, GET_SIGN(val));
             } else {
                 ++run;
             }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 23/35] avcodec/proresenc_kostya: add Anatoliy copyright
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (21 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 22/35] avcodec/proresenc_anatoliy: remove IS_NEGATIVE() macro Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18 22:30   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 24/35] avcodec/proresenc_anatoliy: rename TO_GOLOMB() to MAKE_CODE() Clément Bœsch
                   ` (13 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

Both encoders share a lot of code from both authors.
---
 libavcodec/proresenc_kostya.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index e0aa7cf47a..c6c045be73 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1,6 +1,7 @@
 /*
  * Apple ProRes encoder
  *
+ * Copyright (c) 2011 Anatoliy Wasserman
  * Copyright (c) 2012 Konstantin Shishkov
  *
  * This encoder appears to be based on Anatoliy Wassermans considering
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 24/35] avcodec/proresenc_anatoliy: rename TO_GOLOMB() to MAKE_CODE()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (22 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 23/35] avcodec/proresenc_kostya: add Anatoliy copyright Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18 22:32   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 25/35] avcodec/proresenc_anatoliy: shuffle declarations around in encode_dcs() Clément Bœsch
                   ` (12 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches the name in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 43dee7f79b..4b72798689 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -256,7 +256,7 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 }
 
 #define GET_SIGN(x)  ((x) >> 31)
-#define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
+#define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
 
 static av_always_inline int get_level(int val)
@@ -274,7 +274,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
     int dc, delta, diff_sign, code;
 
     prev_dc = (blocks[0] - 0x4000) / qmat[0];
-    codebook = TO_GOLOMB(prev_dc);
+    codebook = MAKE_CODE(prev_dc);
     encode_vlc_codeword(pb, FIRST_DC_CB, codebook);
     blocks  += 64;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 25/35] avcodec/proresenc_anatoliy: shuffle declarations around in encode_dcs()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (23 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 24/35] avcodec/proresenc_anatoliy: rename TO_GOLOMB() to MAKE_CODE() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18 22:35   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 26/35] avcodec/proresenc_anatoliy: only pass down the first scale to encode_dcs() Clément Bœsch
                   ` (11 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function closer to the same function in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 4b72798689..56baeb9956 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -269,16 +269,15 @@ static av_always_inline int get_level(int val)
 static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int *qmat)
 {
-    int prev_dc, codebook;
-    int i, sign, new_sign;
-    int dc, delta, diff_sign, code;
+    int i;
+    int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
+    int diff_sign;
 
     prev_dc = (blocks[0] - 0x4000) / qmat[0];
-    codebook = MAKE_CODE(prev_dc);
-    encode_vlc_codeword(pb, FIRST_DC_CB, codebook);
+    encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
+    sign     = 0;
     blocks  += 64;
 
-    codebook = 5; sign = 0;
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
         dc        = (blocks[0] - 0x4000) / qmat[0];
         delta     = dc - prev_dc;
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 26/35] avcodec/proresenc_anatoliy: only pass down the first scale to encode_dcs()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (24 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 25/35] avcodec/proresenc_anatoliy: shuffle declarations around in encode_dcs() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-18 22:36   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2() Clément Bœsch
                   ` (10 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches encode_dcs() prototype from proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 56baeb9956..bdf7bface4 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -267,19 +267,19 @@ static av_always_inline int get_level(int val)
 
 
 static void encode_dcs(PutBitContext *pb, int16_t *blocks,
-                       int blocks_per_slice, int *qmat)
+                       int blocks_per_slice, int scale)
 {
     int i;
     int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
     int diff_sign;
 
-    prev_dc = (blocks[0] - 0x4000) / qmat[0];
+    prev_dc = (blocks[0] - 0x4000) / scale;
     encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
     sign     = 0;
     blocks  += 64;
 
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
-        dc        = (blocks[0] - 0x4000) / qmat[0];
+        dc        = (blocks[0] - 0x4000) / scale;
         delta     = dc - prev_dc;
         new_sign  = GET_SIGN(delta);
         diff_sign = new_sign ^ sign;
@@ -388,7 +388,7 @@ static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsig
     blocks_per_slice = mb_count << (2 - sub_sample_chroma);
     init_put_bits(&pb, buf, buf_size);
 
-    encode_dcs(&pb, blocks, blocks_per_slice, qmat);
+    encode_dcs(&pb, blocks, blocks_per_slice, qmat[0]);
     encode_ac_coeffs(&pb, blocks, blocks_per_slice, qmat, ff_prores_scan);
 
     flush_put_bits(&pb);
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (25 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 26/35] avcodec/proresenc_anatoliy: only pass down the first scale to encode_dcs() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-23 23:43   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 28/35] avcodec/proresenc_anatoliy: cosmetics to make encode_dcs() identical to the one in Kostya encoder Clément Bœsch
                   ` (9 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

A few cosmetics aside, this makes the function identical to the one with
the same name in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index bdf7bface4..aed5c68b1b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 
 #define GET_SIGN(x)  ((x) >> 31)
 #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
-#define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
 
 static av_always_inline int get_level(int val)
 {
@@ -271,7 +270,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
 {
     int i;
     int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
-    int diff_sign;
 
     prev_dc = (blocks[0] - 0x4000) / scale;
     encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
@@ -282,8 +280,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
         dc        = (blocks[0] - 0x4000) / scale;
         delta     = dc - prev_dc;
         new_sign  = GET_SIGN(delta);
-        diff_sign = new_sign ^ sign;
-        code      = TO_GOLOMB2(get_level(delta), diff_sign);
+        delta     = (delta ^ sign) - sign;
+        code      = MAKE_CODE(delta);
 
         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 28/35] avcodec/proresenc_anatoliy: cosmetics to make encode_dcs() identical to the one in Kostya encoder
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (26 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-23 23:46   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 29/35] avcodec/proresenc_anatoliy: replace get_level() with FFABS() Clément Bœsch
                   ` (8 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_anatoliy.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index aed5c68b1b..0318379461 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -277,17 +277,15 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
     blocks  += 64;
 
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
-        dc        = (blocks[0] - 0x4000) / scale;
-        delta     = dc - prev_dc;
-        new_sign  = GET_SIGN(delta);
-        delta     = (delta ^ sign) - sign;
-        code      = MAKE_CODE(delta);
-
+        dc       = (blocks[0] - 0x4000) / scale;
+        delta    = dc - prev_dc;
+        new_sign = GET_SIGN(delta);
+        delta    = (delta ^ sign) - sign;
+        code     = MAKE_CODE(delta);
         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
-
-        codebook  = FFMIN(code, 6);
-        sign      = new_sign;
-        prev_dc   = dc;
+        codebook = FFMIN(code, 6);
+        sign     = new_sign;
+        prev_dc  = dc;
     }
 }
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 29/35] avcodec/proresenc_anatoliy: replace get_level() with FFABS()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (27 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 28/35] avcodec/proresenc_anatoliy: cosmetics to make encode_dcs() identical to the one in Kostya encoder Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:25   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 30/35] avcodec/proresenc_anatoliy: rework encode_ac_coeffs() prototype Clément Bœsch
                   ` (7 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches the code from proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 0318379461..88c6d47ab7 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -258,13 +258,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 #define GET_SIGN(x)  ((x) >> 31)
 #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
 
-static av_always_inline int get_level(int val)
-{
-    int sign = (val >> 31);
-    return (val ^ sign) - sign;
-}
-
-
 static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int scale)
 {
@@ -305,7 +298,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
 
                 prev_run   = run;
                 run        = 0;
-                level      = get_level(val);
+                level      = FFABS(val);
                 code       = level - 1;
 
                 encode_vlc_codeword(pb, ff_prores_lev_to_cb[FFMIN(prev_level, 9)], code);
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 30/35] avcodec/proresenc_anatoliy: rework encode_ac_coeffs() prototype
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (28 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 29/35] avcodec/proresenc_anatoliy: replace get_level() with FFABS() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:26   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 31/35] avcodec/proresenc_anatoliy: avoid using ff_ prefix in function arguments Clément Bœsch
                   ` (6 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the prototype closer to the function of the same name in
proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 88c6d47ab7..57324a3b27 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -282,8 +282,9 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
     }
 }
 
-static void encode_ac_coeffs(PutBitContext *pb,
-        int16_t *in, int blocks_per_slice, int *qmat, const uint8_t ff_prores_scan[64])
+static void encode_acs(PutBitContext *pb, int16_t *blocks,
+                       int blocks_per_slice,
+                       int *qmat, const uint8_t ff_prores_scan[64])
 {
     int prev_run = 4;
     int prev_level = 2;
@@ -292,7 +293,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
     for (i = 1; i < 64; i++) {
         int indp = ff_prores_scan[i];
         for (j = 0; j < blocks_per_slice; j++) {
-            int val = (in[(j << 6) + indp]) / qmat[indp];
+            int val = (blocks[(j << 6) + indp]) / qmat[indp];
             if (val) {
                 encode_vlc_codeword(pb, ff_prores_run_to_cb[FFMIN(prev_run, 15)], run);
 
@@ -378,7 +379,7 @@ static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsig
     init_put_bits(&pb, buf, buf_size);
 
     encode_dcs(&pb, blocks, blocks_per_slice, qmat[0]);
-    encode_ac_coeffs(&pb, blocks, blocks_per_slice, qmat, ff_prores_scan);
+    encode_acs(&pb, blocks, blocks_per_slice, qmat, ff_prores_scan);
 
     flush_put_bits(&pb);
     return put_bits_ptr(&pb) - pb.buf;
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 31/35] avcodec/proresenc_anatoliy: avoid using ff_ prefix in function arguments
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (29 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 30/35] avcodec/proresenc_anatoliy: rework encode_ac_coeffs() prototype Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:27   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 32/35] avcodec/proresenc_anatoliy: rework inner loop in encode_acs() Clément Bœsch
                   ` (5 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

---
 libavcodec/proresenc_anatoliy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 57324a3b27..816c27e481 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -284,14 +284,14 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
 
 static void encode_acs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice,
-                       int *qmat, const uint8_t ff_prores_scan[64])
+                       int *qmat, const uint8_t *scan)
 {
     int prev_run = 4;
     int prev_level = 2;
 
     int run = 0, level, code, i, j;
     for (i = 1; i < 64; i++) {
-        int indp = ff_prores_scan[i];
+        int indp = scan[i];
         for (j = 0; j < blocks_per_slice; j++) {
             int val = (blocks[(j << 6) + indp]) / qmat[indp];
             if (val) {
@@ -370,7 +370,7 @@ static void calc_plane_dct(FDCTDSPContext *fdsp, const uint8_t *src, int16_t * b
 }
 
 static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsigned buf_size, int *qmat, int sub_sample_chroma,
-                              const uint8_t ff_prores_scan[64])
+                              const uint8_t *scan)
 {
     int blocks_per_slice;
     PutBitContext pb;
@@ -379,7 +379,7 @@ static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsig
     init_put_bits(&pb, buf, buf_size);
 
     encode_dcs(&pb, blocks, blocks_per_slice, qmat[0]);
-    encode_acs(&pb, blocks, blocks_per_slice, qmat, ff_prores_scan);
+    encode_acs(&pb, blocks, blocks_per_slice, qmat, scan);
 
     flush_put_bits(&pb);
     return put_bits_ptr(&pb) - pb.buf;
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 32/35] avcodec/proresenc_anatoliy: rework inner loop in encode_acs()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (30 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 31/35] avcodec/proresenc_anatoliy: avoid using ff_ prefix in function arguments Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:36   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 33/35] avcodec/proresenc_anatoliy: execute AC run/level FFMIN() at assignment Clément Bœsch
                   ` (4 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches the logic from the function of the same name in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 816c27e481..161a05a6e6 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -286,14 +286,17 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice,
                        int *qmat, const uint8_t *scan)
 {
+    int idx;
     int prev_run = 4;
     int prev_level = 2;
+    int max_coeffs;
+    int run = 0, level, code, i;
+
+    max_coeffs = blocks_per_slice << 6;
 
-    int run = 0, level, code, i, j;
     for (i = 1; i < 64; i++) {
-        int indp = scan[i];
-        for (j = 0; j < blocks_per_slice; j++) {
-            int val = (blocks[(j << 6) + indp]) / qmat[indp];
+        for (idx = scan[i]; idx < max_coeffs; idx += 64) {
+            int val = blocks[idx] / qmat[scan[i]];
             if (val) {
                 encode_vlc_codeword(pb, ff_prores_run_to_cb[FFMIN(prev_run, 15)], run);
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 33/35] avcodec/proresenc_anatoliy: execute AC run/level FFMIN() at assignment
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (31 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 32/35] avcodec/proresenc_anatoliy: rework inner loop in encode_acs() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:40   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 34/35] avcodec/proresenc_anatoliy: make a few cosmetics in encode_acs() Clément Bœsch
                   ` (3 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This matches the logic from the function of the same name in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 161a05a6e6..2515ee38f8 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -298,18 +298,18 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
         for (idx = scan[i]; idx < max_coeffs; idx += 64) {
             int val = blocks[idx] / qmat[scan[i]];
             if (val) {
-                encode_vlc_codeword(pb, ff_prores_run_to_cb[FFMIN(prev_run, 15)], run);
+                encode_vlc_codeword(pb, ff_prores_run_to_cb[prev_run], run);
 
-                prev_run   = run;
-                run        = 0;
                 level      = FFABS(val);
                 code       = level - 1;
 
-                encode_vlc_codeword(pb, ff_prores_lev_to_cb[FFMIN(prev_level, 9)], code);
-
-                prev_level = level;
+                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level], code);
 
                 put_sbits(pb, 1, GET_SIGN(val));
+
+                prev_run   = FFMIN(run, 15);
+                prev_level = FFMIN(level, 9);
+                run        = 0;
             } else {
                 ++run;
             }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 34/35] avcodec/proresenc_anatoliy: make a few cosmetics in encode_acs()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (32 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 33/35] avcodec/proresenc_anatoliy: execute AC run/level FFMIN() at assignment Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:45   ` Stefano Sabatini
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 35/35] avcodec/proresenc_kostya: " Clément Bœsch
                   ` (2 subsequent siblings)
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

This makes the function pretty much identical to the function of the
same name in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 2515ee38f8..414f52d396 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -286,32 +286,28 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice,
                        int *qmat, const uint8_t *scan)
 {
-    int idx;
+    int idx, i;
     int prev_run = 4;
     int prev_level = 2;
-    int max_coeffs;
-    int run = 0, level, code, i;
+    int run = 0, level;
+    int max_coeffs, abs_level;
 
     max_coeffs = blocks_per_slice << 6;
 
     for (i = 1; i < 64; i++) {
         for (idx = scan[i]; idx < max_coeffs; idx += 64) {
-            int val = blocks[idx] / qmat[scan[i]];
-            if (val) {
+            level = blocks[idx] / qmat[scan[i]];
+            if (level) {
+                abs_level = FFABS(level);
                 encode_vlc_codeword(pb, ff_prores_run_to_cb[prev_run], run);
-
-                level      = FFABS(val);
-                code       = level - 1;
-
-                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level], code);
-
-                put_sbits(pb, 1, GET_SIGN(val));
+                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level], abs_level - 1);
+                put_sbits(pb, 1, GET_SIGN(level));
 
                 prev_run   = FFMIN(run, 15);
-                prev_level = FFMIN(level, 9);
+                prev_level = FFMIN(abs_level, 9);
                 run        = 0;
             } else {
-                ++run;
+                run++;
             }
         }
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* [FFmpeg-devel] [PATCH 35/35] avcodec/proresenc_kostya: make a few cosmetics in encode_acs()
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (33 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 34/35] avcodec/proresenc_anatoliy: make a few cosmetics in encode_acs() Clément Bœsch
@ 2023-12-11  1:35 ` Clément Bœsch
  2023-12-24 10:46   ` Stefano Sabatini
  2023-12-11  9:15 ` [FFmpeg-devel] Initial tickering at unifying ProRes encoder Anton Khirnov
  2023-12-24 10:56 ` Stefano Sabatini
  36 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  1:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Clément Bœsch

Unify cosmetics with encode_acs() from proresenc_anatoliy.
---
 libavcodec/proresenc_kostya.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index c6c045be73..05e90bb236 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -437,11 +437,10 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
     int idx, i;
     int prev_run = 4;
     int prev_level = 2;
-    int run, level;
+    int run = 0, level;
     int max_coeffs, abs_level;
 
     max_coeffs = blocks_per_slice << 6;
-    run        = 0;
 
     for (i = 1; i < 64; i++) {
         for (idx = scan[i]; idx < max_coeffs; idx += 64) {
@@ -449,13 +448,12 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
             if (level) {
                 abs_level = FFABS(level);
                 encode_vlc_codeword(pb, ff_prores_run_to_cb[prev_run], run);
-                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level],
-                                    abs_level - 1);
+                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level], abs_level - 1);
                 put_sbits(pb, 1, GET_SIGN(level));
 
                 prev_run   = FFMIN(run, 15);
                 prev_level = FFMIN(abs_level, 9);
-                run    = 0;
+                run        = 0;
             } else {
                 run++;
             }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] Initial tickering at unifying ProRes encoder
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (34 preceding siblings ...)
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 35/35] avcodec/proresenc_kostya: " Clément Bœsch
@ 2023-12-11  9:15 ` Anton Khirnov
  2023-12-11  9:36   ` Clément Bœsch
  2023-12-24 10:56 ` Stefano Sabatini
  36 siblings, 1 reply; 80+ messages in thread
From: Anton Khirnov @ 2023-12-11  9:15 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Clément Bœsch (2023-12-11 02:35:01)
> Hello there,
> 
> I'm currently investigating an issue¹ affecting Kostya ProRes encoder
> which is not reproducible with Anatoliy encoder (but it's too early to
> say if the bug is not present there as well given the differences in
> quantization, and it's also unclear if the issue is even actually
> there in the first place and not in M2/M3 firmwares).
> 
> Since these encoders share more than similiarities, I've been looking
> into their differences, and unifying their common codepaths was helpful
> to my investigation.
> 
> Attached is an initial patchset working out their differences by either
> sharing data or making code identical where relevant.

Do you have any comments on their respective strengths and weaknesses -
when would one want to prefer one over the other?

And how feasible would it be to reduce that to a single encoder?

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] Initial tickering at unifying ProRes encoder
  2023-12-11  9:15 ` [FFmpeg-devel] Initial tickering at unifying ProRes encoder Anton Khirnov
@ 2023-12-11  9:36   ` Clément Bœsch
  0 siblings, 0 replies; 80+ messages in thread
From: Clément Bœsch @ 2023-12-11  9:36 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Mon, Dec 11, 2023 at 10:15:09AM +0100, Anton Khirnov wrote:
> Quoting Clément Bœsch (2023-12-11 02:35:01)
> > Hello there,
> > 
> > I'm currently investigating an issue¹ affecting Kostya ProRes encoder
> > which is not reproducible with Anatoliy encoder (but it's too early to
> > say if the bug is not present there as well given the differences in
> > quantization, and it's also unclear if the issue is even actually
> > there in the first place and not in M2/M3 firmwares).
> > 
> > Since these encoders share more than similiarities, I've been looking
> > into their differences, and unifying their common codepaths was helpful
> > to my investigation.
> > 
> > Attached is an initial patchset working out their differences by either
> > sharing data or making code identical where relevant.
> 
> Do you have any comments on their respective strengths and weaknesses -
> when would one want to prefer one over the other?

Right now their strength is that having both is helping me debugging a
pretty obscure issue, but I agree that's not a good argument for users.

Kostya encoder has more parameters, and seems to have a more advanced
quantization model. Internally it implies a bunch of duplication of
code for predicting the frame sizes (thinking of the estimate vs encode
AC/DC functions), but that's just internal stuff that can be reworked and
that doesn't concern users.

Anatoliy has more checks to avoid writing out invalid data (referring to
the sanity checks around color management right now), and doesn't seem to
trigger the bug I'm investigating (but again, still unclear if it is
unaffected by it).

> And how feasible would it be to reduce that to a single encoder?

That's pretty much the direction I'm taking, making as much in common as
possible in the hope that they will converge to the same identical code,
and in the process points out the eventual issue I'm looking for.

-- 
Clément B.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro Clément Bœsch
@ 2023-12-12  6:53   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-12  6:53 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:02 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_kostya.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 52fe5639b1..58fc340879 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -429,7 +429,7 @@ static inline void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int
>  }
>  
>  #define GET_SIGN(x)  ((x) >> 31)
> -#define MAKE_CODE(x) ((((x)) * 2) ^ GET_SIGN(x))
> +#define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 02/35] avcodec/proresenc_kostya: remove unused plane factor variables
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 02/35] avcodec/proresenc_kostya: remove unused plane factor variables Clément Bœsch
@ 2023-12-12  6:56   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-12  6:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:03 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_kostya.c | 36 ++++++++++++-----------------------
>  1 file changed, 12 insertions(+), 24 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 58fc340879..7aed3974c3 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -459,7 +459,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>  
>  static void encode_acs(PutBitContext *pb, int16_t *blocks,
>                         int blocks_per_slice,
> -                       int plane_size_factor,
>                         const uint8_t *scan, const int16_t *qmat)
>  {
>      int idx, i;
> @@ -494,14 +493,13 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
>  static void encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
>                                const uint16_t *src, ptrdiff_t linesize,
>                                int mbs_per_slice, int16_t *blocks,
> -                              int blocks_per_mb, int plane_size_factor,
> +                              int blocks_per_mb,
>                                const int16_t *qmat)
>  {
>      int blocks_per_slice = mbs_per_slice * blocks_per_mb;
>  
>      encode_dcs(pb, blocks, blocks_per_slice, qmat[0]);
> -    encode_acs(pb, blocks, blocks_per_slice, plane_size_factor,
> -               ctx->scantable, qmat);
> +    encode_acs(pb, blocks, blocks_per_slice, ctx->scantable, qmat);
>  }
>  
>  static void put_alpha_diff(PutBitContext *pb, int cur, int prev, int abits)
> @@ -575,10 +573,9 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
>      int i, xp, yp;
>      int total_size = 0;
>      const uint16_t *src;
> -    int slice_width_factor = av_log2(mbs_per_slice);
>      int num_cblocks, pwidth, line_add;
>      ptrdiff_t linesize;
> -    int plane_factor, is_chroma;
> +    int is_chroma;
>      uint16_t *qmat;
>      uint16_t *qmat_chroma;
>  
> @@ -604,9 +601,6 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
>  
>      for (i = 0; i < ctx->num_planes; i++) {
>          is_chroma    = (i == 1 || i == 2);
> -        plane_factor = slice_width_factor + 2;
> -        if (is_chroma)
> -            plane_factor += ctx->chroma_factor - 3;
>          if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) {
>              xp          = x << 4;
>              yp          = y << 4;
> @@ -631,11 +625,11 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
>              if (!is_chroma) {/* luma quant */
>                  encode_slice_plane(ctx, pb, src, linesize,
>                                     mbs_per_slice, ctx->blocks[0],
> -                                   num_cblocks, plane_factor, qmat);
> +                                   num_cblocks, qmat);
>              } else { /* chroma plane */
>                  encode_slice_plane(ctx, pb, src, linesize,
>                                     mbs_per_slice, ctx->blocks[0],
> -                                   num_cblocks, plane_factor, qmat_chroma);
> +                                   num_cblocks, qmat_chroma);
>              }
>          } else {
>              get_alpha_data(ctx, src, linesize, xp, yp,
> @@ -704,7 +698,6 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
>  }
>  
>  static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
> -                        int plane_size_factor,
>                          const uint8_t *scan, const int16_t *qmat)
>  {
>      int idx, i;
> @@ -742,7 +735,7 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
>  static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
>                                  const uint16_t *src, ptrdiff_t linesize,
>                                  int mbs_per_slice,
> -                                int blocks_per_mb, int plane_size_factor,
> +                                int blocks_per_mb,
>                                  const int16_t *qmat, ProresThreadData *td)
>  {
>      int blocks_per_slice;
> @@ -751,8 +744,7 @@ static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
>      blocks_per_slice = mbs_per_slice * blocks_per_mb;
>  
>      bits  = estimate_dcs(error, td->blocks[plane], blocks_per_slice, qmat[0]);
> -    bits += estimate_acs(error, td->blocks[plane], blocks_per_slice,
> -                         plane_size_factor, ctx->scantable, qmat);
> +    bits += estimate_acs(error, td->blocks[plane], blocks_per_slice, ctx->scantable, qmat);
>  
>      return FFALIGN(bits, 8);
>  }
> @@ -821,9 +813,8 @@ static int find_slice_quant(AVCodecContext *avctx,
>      ProresContext *ctx = avctx->priv_data;
>      int i, q, pq, xp, yp;
>      const uint16_t *src;
> -    int slice_width_factor = av_log2(mbs_per_slice);
>      int num_cblocks[MAX_PLANES], pwidth;
> -    int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];
> +    int is_chroma[MAX_PLANES];
>      const int min_quant = ctx->profile_info->min_quant;
>      const int max_quant = ctx->profile_info->max_quant;
>      int error, bits, bits_limit;
> @@ -843,9 +834,6 @@ static int find_slice_quant(AVCodecContext *avctx,
>  
>      for (i = 0; i < ctx->num_planes; i++) {
>          is_chroma[i]    = (i == 1 || i == 2);
> -        plane_factor[i] = slice_width_factor + 2;
> -        if (is_chroma[i])
> -            plane_factor[i] += ctx->chroma_factor - 3;
>          if (!is_chroma[i] || ctx->chroma_factor == CFACTOR_Y444) {
>              xp             = x << 4;
>              yp             = y << 4;
> @@ -889,13 +877,13 @@ static int find_slice_quant(AVCodecContext *avctx,
>          bits += estimate_slice_plane(ctx, &error, 0,
>                                       src, linesize[0],
>                                       mbs_per_slice,
> -                                     num_cblocks[0], plane_factor[0],
> +                                     num_cblocks[0],
>                                       ctx->quants[q], td); /* estimate luma plane */
>          for (i = 1; i < ctx->num_planes - !!ctx->alpha_bits; i++) { /* estimate chroma plane */
>              bits += estimate_slice_plane(ctx, &error, i,
>                                           src, linesize[i],
>                                           mbs_per_slice,
> -                                         num_cblocks[i], plane_factor[i],
> +                                         num_cblocks[i],
>                                           ctx->quants_chroma[q], td);
>          }
>          if (bits > 65000 * 8)
> @@ -926,13 +914,13 @@ static int find_slice_quant(AVCodecContext *avctx,
>              bits += estimate_slice_plane(ctx, &error, 0,
>                                           src, linesize[0],
>                                           mbs_per_slice,
> -                                         num_cblocks[0], plane_factor[0],
> +                                         num_cblocks[0],
>                                           qmat, td);/* estimate luma plane */
>              for (i = 1; i < ctx->num_planes - !!ctx->alpha_bits; i++) { /* estimate chroma plane */
>                  bits += estimate_slice_plane(ctx, &error, i,
>                                               src, linesize[i],
>                                               mbs_per_slice,
> -                                             num_cblocks[i], plane_factor[i],
> +                                             num_cblocks[i],
>                                               qmat_chroma, td);

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments Clément Bœsch
@ 2023-12-12  7:00   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-12  7:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:04 +0100, Clément Bœsch wrote:
> This is already assigned at declaration.
> ---
>  libavcodec/proresenc_kostya.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 7aed3974c3..6e1d5a0cef 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -440,7 +440,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>      prev_dc = (blocks[0] - 0x4000) / scale;
>      encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
>      sign     = 0;
> -    codebook = 3;
>      blocks  += 64;
>  
>      for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
> @@ -676,7 +675,6 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
>      prev_dc  = (blocks[0] - 0x4000) / scale;
>      bits     = estimate_vlc(FIRST_DC_CB, MAKE_CODE(prev_dc));
>      sign     = 0;
> -    codebook = 3;
>      blocks  += 64;
>      *error  += FFABS(blocks[0] - 0x4000) % scale;

Since this is the only value assigned with declaration, maybe it's
better to drop the codebook = 3 in the assignment, but LGTM anyway.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata Clément Bœsch
@ 2023-12-12  7:02   ` Stefano Sabatini
  2023-12-12  8:02   ` Stefano Sabatini
  1 sibling, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-12  7:02 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> This is going to be shared with proresenc_kostya in the upcoming commit.
> ---
>  libavcodec/proresdata.c         | 6 ++++++
>  libavcodec/proresdata.h         | 2 ++
>  libavcodec/proresenc_anatoliy.c | 9 ++-------
>  3 files changed, 10 insertions(+), 7 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata Clément Bœsch
  2023-12-12  7:02   ` Stefano Sabatini
@ 2023-12-12  8:02   ` Stefano Sabatini
  2024-01-08 17:06     ` Clément Bœsch
  1 sibling, 1 reply; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-12  8:02 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> This is going to be shared with proresenc_kostya in the upcoming commit.
> ---
>  libavcodec/proresdata.c         | 6 ++++++
>  libavcodec/proresdata.h         | 2 ++
>  libavcodec/proresenc_anatoliy.c | 9 ++-------
>  3 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
> index 4787907c71..12ee43bddd 100644
> --- a/libavcodec/proresdata.c
> +++ b/libavcodec/proresdata.c
> @@ -43,3 +43,9 @@ const uint8_t ff_prores_interlaced_scan[64] = {
>      30, 23, 31, 38, 45, 52, 60, 53,
>      46, 39, 47, 54, 61, 62, 55, 63
>  };
> +
> +const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> +        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> +

> +const uint8_t ff_prores_lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> +        0x28, 0x28, 0x28, 0x4C };

while at it this could employ "lev" => "level" to clarify code and
maybe enable some pattern matching trick

> diff --git a/libavcodec/proresdata.h b/libavcodec/proresdata.h
> index d8c8786689..4d16992892 100644
> --- a/libavcodec/proresdata.h
> +++ b/libavcodec/proresdata.h
> @@ -29,6 +29,8 @@
>  
>  extern const uint8_t ff_prores_progressive_scan[64];
>  extern const uint8_t ff_prores_interlaced_scan[64];
> +extern const uint8_t ff_prores_run_to_cb[16];
> +extern const uint8_t ff_prores_lev_to_cb[10];
>  
>  #define FIRST_DC_CB 0xB8 // rice_order = 5, exp_golomb_order = 6, switch_bits = 0
>  
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index e7114f1646..6b2e513bed 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -296,11 +296,6 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
>      }
>  }
>  
> -static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> -        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> -static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> -        0x28, 0x28, 0x28, 0x4C };
> -
>  static void encode_ac_coeffs(PutBitContext *pb,
>          int16_t *in, int blocks_per_slice, int *qmat, const uint8_t ff_prores_scan[64])
>  {
> @@ -313,14 +308,14 @@ static void encode_ac_coeffs(PutBitContext *pb,
>          for (j = 0; j < blocks_per_slice; j++) {
>              int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
>              if (val) {
> -                encode_codeword(pb, run, run_to_cb[FFMIN(prev_run, 15)]);
> +                encode_codeword(pb, run, ff_prores_run_to_cb[FFMIN(prev_run, 15)]);
>  
>                  prev_run   = run;
>                  run        = 0;
>                  level      = get_level(val);
>                  code       = level - 1;
>  
> -                encode_codeword(pb, code, lev_to_cb[FFMIN(prev_level, 9)]);
> +                encode_codeword(pb, code, ff_prores_lev_to_cb[FFMIN(prev_level, 9)]);
>  
>                  prev_level = level;
>  
> -- 
> 2.43.0
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping Clément Bœsch
@ 2023-12-12  8:16   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-12  8:16 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:06 +0100, Clément Bœsch wrote:
> This is following the same logic as proresenc_anatoliy.
> ---
>  libavcodec/proresenc_kostya.c | 47 +++++++++++------------------------
>  1 file changed, 14 insertions(+), 33 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 6e1d5a0cef..f883ab550b 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -142,25 +142,6 @@ static const uint8_t prores_dc_codebook[4] = {
>      0x70  // rice_order = 3, exp_golomb_order = 4, switch_bits = 0
>  };
>  
> -static const uint8_t prores_ac_codebook[7] = {
> -    0x04, // rice_order = 0, exp_golomb_order = 1, switch_bits = 0
> -    0x28, // rice_order = 1, exp_golomb_order = 2, switch_bits = 0
> -    0x4C, // rice_order = 2, exp_golomb_order = 3, switch_bits = 0
> -    0x05, // rice_order = 0, exp_golomb_order = 1, switch_bits = 1
> -    0x29, // rice_order = 1, exp_golomb_order = 2, switch_bits = 1
> -    0x06, // rice_order = 0, exp_golomb_order = 1, switch_bits = 2
> -    0x0A, // rice_order = 0, exp_golomb_order = 2, switch_bits = 2
> -};
> -
> -/**
> - * Lookup tables for adaptive switching between codebooks
> - * according with previous run/level value.
> - */
> -static const uint8_t prores_run_to_cb_index[16] =
> -    { 5, 5, 3, 3, 0, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 2 };
> -
> -static const uint8_t prores_lev_to_cb_index[10] = { 0, 6, 3, 5, 0, 1, 1, 1, 1, 2 };
> -
>  #define NUM_MB_LIMITS 4
>  static const int prores_mb_limits[NUM_MB_LIMITS] = {
>      1620, // up to 720x576
> @@ -461,12 +442,12 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
>                         const uint8_t *scan, const int16_t *qmat)
>  {
>      int idx, i;
> -    int run, level, run_cb, lev_cb;
> +    int prev_run = 4;
> +    int prev_level = 2;
> +    int run, level;
>      int max_coeffs, abs_level;
>  
>      max_coeffs = blocks_per_slice << 6;
> -    run_cb     = prores_run_to_cb_index[4];
> -    lev_cb     = prores_lev_to_cb_index[2];
>      run        = 0;
>  
>      for (i = 1; i < 64; i++) {
> @@ -474,13 +455,13 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
>              level = blocks[idx] / qmat[scan[i]];
>              if (level) {
>                  abs_level = FFABS(level);
> -                encode_vlc_codeword(pb, prores_ac_codebook[run_cb], run);
> -                encode_vlc_codeword(pb, prores_ac_codebook[lev_cb],
> +                encode_vlc_codeword(pb, ff_prores_run_to_cb[prev_run], run);
> +                encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level],
>                                      abs_level - 1);
>                  put_sbits(pb, 1, GET_SIGN(level));
>  
> -                run_cb = prores_run_to_cb_index[FFMIN(run, 15)];
> -                lev_cb = prores_lev_to_cb_index[FFMIN(abs_level, 9)];
> +                prev_run   = FFMIN(run, 15);
> +                prev_level = FFMIN(abs_level, 9);
>                  run    = 0;
>              } else {
>                  run++;
> @@ -699,13 +680,13 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
>                          const uint8_t *scan, const int16_t *qmat)
>  {
>      int idx, i;
> -    int run, level, run_cb, lev_cb;
> +    int prev_run = 4;
> +    int prev_level = 2;
> +    int run, level;
>      int max_coeffs, abs_level;
>      int bits = 0;
>  
>      max_coeffs = blocks_per_slice << 6;
> -    run_cb     = prores_run_to_cb_index[4];
> -    lev_cb     = prores_lev_to_cb_index[2];
>      run        = 0;
>  
>      for (i = 1; i < 64; i++) {
> @@ -714,12 +695,12 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
>              *error += FFABS(blocks[idx]) % qmat[scan[i]];
>              if (level) {
>                  abs_level = FFABS(level);
> -                bits += estimate_vlc(prores_ac_codebook[run_cb], run);
> -                bits += estimate_vlc(prores_ac_codebook[lev_cb],
> +                bits += estimate_vlc(ff_prores_run_to_cb[prev_run], run);
> +                bits += estimate_vlc(ff_prores_lev_to_cb[prev_level],
>                                       abs_level - 1) + 1;
>  
> -                run_cb = prores_run_to_cb_index[FFMIN(run, 15)];
> -                lev_cb = prores_lev_to_cb_index[FFMIN(abs_level, 9)];
> +                prev_run   = FFMIN(run, 15);
> +                prev_level = FFMIN(abs_level, 9);
>                  run    = 0;
>              } else {
>                  run++;

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 06/35] avcodec/proresenc_anatoliy: remove duplicated define
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 06/35] avcodec/proresenc_anatoliy: remove duplicated define Clément Bœsch
@ 2023-12-16 16:32   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-16 16:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:07 +0100, Clément Bœsch wrote:
> This is already defined in proresdata.h
> ---
>  libavcodec/proresenc_anatoliy.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 6b2e513bed..c6f49be9b8 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -266,8 +266,6 @@ static av_always_inline int get_level(int val)
>      return (val ^ sign) - sign;
>  }
>  
> -#define FIRST_DC_CB 0xB8
> -
>  static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70};

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 07/35] avcodec/proresenc_anatoliy: move DC codebook LUT to shared proresdata
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 07/35] avcodec/proresenc_anatoliy: move DC codebook LUT to shared proresdata Clément Bœsch
@ 2023-12-16 16:33   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-16 16:33 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:08 +0100, Clément Bœsch wrote:
> This is going to be shared with proresenc_kostya in the upcoming commit.
> ---
>  libavcodec/proresdata.c         | 2 ++
>  libavcodec/proresdata.h         | 1 +
>  libavcodec/proresenc_anatoliy.c | 3 +--
>  3 files changed, 4 insertions(+), 2 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding Clément Bœsch
@ 2023-12-16 16:54   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-16 16:54 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:09 +0100, Clément Bœsch wrote:
> This matches the logic from proresenc_anatoliy.
> ---
>  libavcodec/proresenc_kostya.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header Clément Bœsch
@ 2023-12-16 17:12   ` Stefano Sabatini
  2024-01-06 17:12     ` Clément Bœsch
  0 siblings, 1 reply; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-16 17:12 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:10 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_kostya.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 2d45f9a685..103051830a 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -1019,7 +1019,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>              bytestream_put_byte(&buf, ctx->quant_mat[i]);
>          // chroma quantisation matrix
>          for (i = 0; i < 64; i++)
> -            bytestream_put_byte(&buf, ctx->quant_mat[i]);
> +            bytestream_put_byte(&buf, ctx->quant_chroma_mat[i]);

Looks good, but I wonder, is this covered by tests and a results in a
reference change?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 10/35] avcodec/proresenc_kostya: simplify quantization matrix bytestream writing
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 10/35] avcodec/proresenc_kostya: simplify quantization matrix bytestream writing Clément Bœsch
@ 2023-12-17 18:18   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-17 18:18 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:11 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_kostya.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 103051830a..e0aa7cf47a 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -1014,12 +1014,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>      bytestream_put_byte  (&buf, 0);             // reserved
>      if (ctx->quant_sel != QUANT_MAT_DEFAULT) {
>          bytestream_put_byte  (&buf, 0x03);      // matrix flags - both matrices are present
> -        // luma quantisation matrix
> -        for (i = 0; i < 64; i++)
> -            bytestream_put_byte(&buf, ctx->quant_mat[i]);
> -        // chroma quantisation matrix
> -        for (i = 0; i < 64; i++)
> -            bytestream_put_byte(&buf, ctx->quant_chroma_mat[i]);
> +        bytestream_put_buffer(&buf, ctx->quant_mat, 64);        // luma quantisation matrix
> +        bytestream_put_buffer(&buf, ctx->quant_chroma_mat, 64); // chroma quantisation matrix
>      } else {
>          bytestream_put_byte  (&buf, 0x00);      // matrix flags - default matrices are used
>      }

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 11/35] avcodec/proresenc_anatoliy: use FRAME_ID defined in proresdata.h
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 11/35] avcodec/proresenc_anatoliy: use FRAME_ID defined in proresdata.h Clément Bœsch
@ 2023-12-17 18:19   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-17 18:19 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:12 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_anatoliy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index d6f5cefc16..804ff6ddf7 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -755,7 +755,7 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>      compress_frame_size = 8 + header_size;
>  
>      bytestream_put_be32(&buf, compress_frame_size);/* frame size will be update after picture(s) encoding */
> -    bytestream_put_buffer(&buf, "icpf", 4);
> +    bytestream_put_be32(&buf, FRAME_ID);

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder Clément Bœsch
@ 2023-12-18  0:07   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:13 +0100, Clément Bœsch wrote:
> Code is functionally identical, it's just rename of variables, cosmetics
> and branch logic shuffling.
> ---
>  libavcodec/proresenc_anatoliy.c | 45 +++++++++++++++++----------------
>  1 file changed, 23 insertions(+), 22 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 804ff6ddf7..c7e43fc88c 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -226,31 +226,32 @@ static int int_from_list_or_default(void *ctx, const char *val_name, int val,
>      return default_value;
>  }
>  
> -static void encode_codeword(PutBitContext *pb, int val, int codebook)
> +static void encode_codeword(PutBitContext *pb, int val, unsigned codebook)
>  {
> -    unsigned int rice_order, exp_order, switch_bits, first_exp, exp, zeros;
> -
> -    /* number of bits to switch between rice and exp golomb */
> -    switch_bits = codebook & 3;
> -    rice_order  = codebook >> 5;
> -    exp_order   = (codebook >> 2) & 7;
> -
> -    first_exp = ((switch_bits + 1) << rice_order);
> -
> -    if (val >= first_exp) { /* exp golomb */
> -        val -= first_exp;
> -        val += (1 << exp_order);
> -        exp = av_log2(val);
> -        zeros = exp - exp_order + switch_bits + 1;
> -        put_bits(pb, zeros, 0);
> -        put_bits(pb, exp + 1, val);
> -    } else if (rice_order) {
> -        put_bits(pb, (val >> rice_order), 0);
> -        put_bits(pb, 1, 1);
> -        put_sbits(pb, rice_order, val);
> +    unsigned int rice_order, exp_order, switch_bits, switch_val;
> +    int exponent;
> +
> +    /* number of prefix bits to switch between Rice and expGolomb */
> +    switch_bits = (codebook & 3) + 1;
> +    rice_order  =  codebook >> 5;       /* rice code order */
> +    exp_order   = (codebook >> 2) & 7;  /* exp golomb code order */
> +
> +    switch_val  = switch_bits << rice_order;
> +
> +    if (val >= switch_val) {
> +        val -= switch_val - (1 << exp_order);
> +        exponent = av_log2(val);
> +
> +        put_bits(pb, exponent - exp_order + switch_bits, 0);
> +        put_bits(pb, exponent + 1, val);
>      } else {
> -        put_bits(pb, val, 0);
> +        exponent = val >> rice_order;
> +
> +        if (exponent)
> +            put_bits(pb, exponent, 0);
>          put_bits(pb, 1, 1);
> +        if (rice_order)
> +            put_sbits(pb, rice_order, val);
>      }
>  }
>  
> -- 
> 2.43.0

Should be equivalent to the original code (and with some small
optimizations), so it should be fine.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 13/35] avcodec/proresenc_anatoliy: rework encode_codeword() prototype
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 13/35] avcodec/proresenc_anatoliy: rework encode_codeword() prototype Clément Bœsch
@ 2023-12-18  0:09   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:14 +0100, Clément Bœsch wrote:
> This matches the function of the same name in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 14/35] avcodec/proresenc_anatoliy: inline QSCALE()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 14/35] avcodec/proresenc_anatoliy: inline QSCALE() Clément Bœsch
@ 2023-12-18  0:13   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:13 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:15 +0100, Clément Bœsch wrote:
> Also replaces 16384 with 0x4000.
> 
> This makes the function slightly closer to same function in proresenc_kostya.

LGTM (and possibly improves readability by removing an unnecessary indirection).
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 15/35] avcodec/proresenc_anatoliy: rename new_code/code to code/codebook
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 15/35] avcodec/proresenc_anatoliy: rename new_code/code to code/codebook Clément Bœsch
@ 2023-12-18  0:18   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:18 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:16 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_dcs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index b8433ee872..e79c465590 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -270,24 +270,24 @@ static av_always_inline int get_level(int val)
>  static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
>          int blocks_per_slice, int *qmat)
>  {
> -    int prev_dc, code;
> +    int prev_dc, codebook;
>      int i, sign, idx;
> -    int new_dc, delta, diff_sign, new_code;
> +    int new_dc, delta, diff_sign, code;

better to use the same term to make the relationship evident,
code and new_code
or
codebook and new_codebook

rather than using two similar but different terms (code and codebook)
for the same thing
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 16/35] avcodec/proresenc_anatoliy: execute codebook FFMIN() at assignment
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 16/35] avcodec/proresenc_anatoliy: execute codebook FFMIN() at assignment Clément Bœsch
@ 2023-12-18  0:24   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:24 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:17 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_dcs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index e79c465590..f8feff850f 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -285,9 +285,9 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
>          diff_sign = DIFF_SIGN(delta, sign);
>          code      = TO_GOLOMB2(get_level(delta), diff_sign);
>  
> -        encode_vlc_codeword(pb, ff_prores_dc_codebook[FFMIN(codebook, 6)], code);
> +        encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
>  
> -        codebook  = code;
> +        codebook  = FFMIN(code, 6);
>          sign      = delta >> 31;
>          prev_dc   = new_dc;

should be good, assuming that codebook in the first run is 5
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 17/35] avcodec/proresenc_anatoliy: reduce DC encoding function prototype differences with Kostya encoder
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 17/35] avcodec/proresenc_anatoliy: reduce DC encoding function prototype differences with Kostya encoder Clément Bœsch
@ 2023-12-18  0:26   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:18 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_anatoliy.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index f8feff850f..97d681467d 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -267,20 +267,20 @@ static av_always_inline int get_level(int val)
>  }

should be good
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 18/35] avcodec/proresenc_anatoliy: directly work with blocks in encode_dcs()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 18/35] avcodec/proresenc_anatoliy: directly work with blocks in encode_dcs() Clément Bœsch
@ 2023-12-18  0:30   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:19 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_dcs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

should be good
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 19/35] avcodec/proresenc_anatoliy: import GET_SIGN() macro from Kostya encoder and use it
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 19/35] avcodec/proresenc_anatoliy: import GET_SIGN() macro from Kostya encoder and use it Clément Bœsch
@ 2023-12-18  0:30   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:20 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_anatoliy.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

LGTM
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 20/35] avcodec/proresenc_anatoliy: compute sign only once
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 20/35] avcodec/proresenc_anatoliy: compute sign only once Clément Bœsch
@ 2023-12-18  0:37   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:37 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:21 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_dcs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Should be good.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 21/35] avcodec/proresenc_anatoliy: rename new_dc to dc
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 21/35] avcodec/proresenc_anatoliy: rename new_dc to dc Clément Bœsch
@ 2023-12-18  0:38   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18  0:38 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:22 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_dcs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Should be good.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 22/35] avcodec/proresenc_anatoliy: remove IS_NEGATIVE() macro
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 22/35] avcodec/proresenc_anatoliy: remove IS_NEGATIVE() macro Clément Bœsch
@ 2023-12-18 22:29   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18 22:29 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:23 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_acs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 4ea3d89126..43dee7f79b 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
>  
>  #define GET_SIGN(x)  ((x) >> 31)
>  #define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
> -#define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1)
>  #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
>  
>  static av_always_inline int get_level(int val)
> @@ -318,7 +317,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
>  
>                  prev_level = level;
>  
> -                put_bits(pb, 1, IS_NEGATIVE(val));
> +                put_sbits(pb, 1, GET_SIGN(val));

Should be good.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 23/35] avcodec/proresenc_kostya: add Anatoliy copyright
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 23/35] avcodec/proresenc_kostya: add Anatoliy copyright Clément Bœsch
@ 2023-12-18 22:30   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18 22:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:24 +0100, Clément Bœsch wrote:
> Both encoders share a lot of code from both authors.
> ---
>  libavcodec/proresenc_kostya.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index e0aa7cf47a..c6c045be73 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -1,6 +1,7 @@
>  /*
>   * Apple ProRes encoder
>   *
> + * Copyright (c) 2011 Anatoliy Wasserman
>   * Copyright (c) 2012 Konstantin Shishkov
>   *
>   * This encoder appears to be based on Anatoliy Wassermans considering
> -- 
> 2.43.0

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 24/35] avcodec/proresenc_anatoliy: rename TO_GOLOMB() to MAKE_CODE()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 24/35] avcodec/proresenc_anatoliy: rename TO_GOLOMB() to MAKE_CODE() Clément Bœsch
@ 2023-12-18 22:32   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18 22:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:25 +0100, Clément Bœsch wrote:
> This matches the name in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 43dee7f79b..4b72798689 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -256,7 +256,7 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
>  }
>  
>  #define GET_SIGN(x)  ((x) >> 31)
> -#define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
> +#define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
>  #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 25/35] avcodec/proresenc_anatoliy: shuffle declarations around in encode_dcs()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 25/35] avcodec/proresenc_anatoliy: shuffle declarations around in encode_dcs() Clément Bœsch
@ 2023-12-18 22:35   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18 22:35 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:26 +0100, Clément Bœsch wrote:
> This makes the function closer to the same function in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 26/35] avcodec/proresenc_anatoliy: only pass down the first scale to encode_dcs()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 26/35] avcodec/proresenc_anatoliy: only pass down the first scale to encode_dcs() Clément Bœsch
@ 2023-12-18 22:36   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-18 22:36 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:27 +0100, Clément Bœsch wrote:
> This matches encode_dcs() prototype from proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2() Clément Bœsch
@ 2023-12-23 23:43   ` Stefano Sabatini
  2024-01-07 23:00     ` Clément Bœsch
  0 siblings, 1 reply; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-23 23:43 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:28 +0100, Clément Bœsch wrote:
> A few cosmetics aside, this makes the function identical to the one with
> the same name in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index bdf7bface4..aed5c68b1b 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
>  
>  #define GET_SIGN(x)  ((x) >> 31)
>  #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
> -#define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
>  
>  static av_always_inline int get_level(int val)
>  {
> @@ -271,7 +270,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>  {
>      int i;
>      int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
> -    int diff_sign;
>  
>      prev_dc = (blocks[0] - 0x4000) / scale;
>      encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
> @@ -282,8 +280,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>          dc        = (blocks[0] - 0x4000) / scale;
>          delta     = dc - prev_dc;
>          new_sign  = GET_SIGN(delta);

> -        diff_sign = new_sign ^ sign;
> -        code      = TO_GOLOMB2(get_level(delta), diff_sign);
> +        delta     = (delta ^ sign) - sign;
> +        code      = MAKE_CODE(delta);

These don't look equivalent,

MAKE_CODE((delta ^ sign) - sign) is equivalent to
TO_GOLOMB2(get_level(delta), sign)

not to
TO_GOLOMB2(get_level(delta), diff_sign)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 28/35] avcodec/proresenc_anatoliy: cosmetics to make encode_dcs() identical to the one in Kostya encoder
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 28/35] avcodec/proresenc_anatoliy: cosmetics to make encode_dcs() identical to the one in Kostya encoder Clément Bœsch
@ 2023-12-23 23:46   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-23 23:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:29 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_anatoliy.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index aed5c68b1b..0318379461 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -277,17 +277,15 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>      blocks  += 64;
>  
>      for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
> -        dc        = (blocks[0] - 0x4000) / scale;
> -        delta     = dc - prev_dc;
> -        new_sign  = GET_SIGN(delta);
> -        delta     = (delta ^ sign) - sign;
> -        code      = MAKE_CODE(delta);
> -
> +        dc       = (blocks[0] - 0x4000) / scale;
> +        delta    = dc - prev_dc;
> +        new_sign = GET_SIGN(delta);
> +        delta    = (delta ^ sign) - sign;
> +        code     = MAKE_CODE(delta);
>          encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
> -
> -        codebook  = FFMIN(code, 6);
> -        sign      = new_sign;
> -        prev_dc   = dc;
> +        codebook = FFMIN(code, 6);
> +        sign     = new_sign;
> +        prev_dc  = dc;

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 29/35] avcodec/proresenc_anatoliy: replace get_level() with FFABS()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 29/35] avcodec/proresenc_anatoliy: replace get_level() with FFABS() Clément Bœsch
@ 2023-12-24 10:25   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:25 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:30 +0100, Clément Bœsch wrote:
> This matches the code from proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 0318379461..88c6d47ab7 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -258,13 +258,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
>  #define GET_SIGN(x)  ((x) >> 31)
>  #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
>  
> -static av_always_inline int get_level(int val)
> -{
> -    int sign = (val >> 31);
> -    return (val ^ sign) - sign;
> -}
> -
> -
>  static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>                         int blocks_per_slice, int scale)
>  {
> @@ -305,7 +298,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
>  
>                  prev_run   = run;
>                  run        = 0;
> -                level      = get_level(val);
> +                level      = FFABS(val);
>                  code       = level - 1;

LGTM, given that (for sign = 1):
val ^ sign = val + 1
val + 1 - 1 = val + 1 + 2**N -1 = val + 2**N = ABS(val) 
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 30/35] avcodec/proresenc_anatoliy: rework encode_ac_coeffs() prototype
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 30/35] avcodec/proresenc_anatoliy: rework encode_ac_coeffs() prototype Clément Bœsch
@ 2023-12-24 10:26   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:31 +0100, Clément Bœsch wrote:
> This makes the prototype closer to the function of the same name in
> proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 31/35] avcodec/proresenc_anatoliy: avoid using ff_ prefix in function arguments
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 31/35] avcodec/proresenc_anatoliy: avoid using ff_ prefix in function arguments Clément Bœsch
@ 2023-12-24 10:27   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:27 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:32 +0100, Clément Bœsch wrote:
> ---
>  libavcodec/proresenc_anatoliy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 32/35] avcodec/proresenc_anatoliy: rework inner loop in encode_acs()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 32/35] avcodec/proresenc_anatoliy: rework inner loop in encode_acs() Clément Bœsch
@ 2023-12-24 10:36   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:36 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:33 +0100, Clément Bœsch wrote:
> This matches the logic from the function of the same name in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 816c27e481..161a05a6e6 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -286,14 +286,17 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
>                         int blocks_per_slice,
>                         int *qmat, const uint8_t *scan)
>  {
> +    int idx;
>      int prev_run = 4;
>      int prev_level = 2;
> +    int max_coeffs;
> +    int run = 0, level, code, i;
> +
> +    max_coeffs = blocks_per_slice << 6;
>  
> -    int run = 0, level, code, i, j;
>      for (i = 1; i < 64; i++) {
> -        int indp = scan[i];
> -        for (j = 0; j < blocks_per_slice; j++) {
> -            int val = (blocks[(j << 6) + indp]) / qmat[indp];
> +        for (idx = scan[i]; idx < max_coeffs; idx += 64) {
> +            int val = blocks[idx] / qmat[scan[i]];

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 33/35] avcodec/proresenc_anatoliy: execute AC run/level FFMIN() at assignment
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 33/35] avcodec/proresenc_anatoliy: execute AC run/level FFMIN() at assignment Clément Bœsch
@ 2023-12-24 10:40   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:40 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:34 +0100, Clément Bœsch wrote:
> This matches the logic from the function of the same name in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/35] avcodec/proresenc_anatoliy: make a few cosmetics in encode_acs()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 34/35] avcodec/proresenc_anatoliy: make a few cosmetics in encode_acs() Clément Bœsch
@ 2023-12-24 10:45   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:45 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:35 +0100, Clément Bœsch wrote:
> This makes the function pretty much identical to the function of the
> same name in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 2515ee38f8..414f52d396 100644

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 35/35] avcodec/proresenc_kostya: make a few cosmetics in encode_acs()
  2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 35/35] avcodec/proresenc_kostya: " Clément Bœsch
@ 2023-12-24 10:46   ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Clément Bœsch

On date Monday 2023-12-11 02:35:36 +0100, Clément Bœsch wrote:
> Unify cosmetics with encode_acs() from proresenc_anatoliy.
> ---
>  libavcodec/proresenc_kostya.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] Initial tickering at unifying ProRes encoder
  2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
                   ` (35 preceding siblings ...)
  2023-12-11  9:15 ` [FFmpeg-devel] Initial tickering at unifying ProRes encoder Anton Khirnov
@ 2023-12-24 10:56 ` Stefano Sabatini
  2024-01-10 13:22   ` Clément Bœsch
  36 siblings, 1 reply; 80+ messages in thread
From: Stefano Sabatini @ 2023-12-24 10:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On date Monday 2023-12-11 02:35:01 +0100, Clément Bœsch wrote:
> Hello there,
> 
> I'm currently investigating an issue¹ affecting Kostya ProRes encoder
> which is not reproducible with Anatoliy encoder (but it's too early to
> say if the bug is not present there as well given the differences in
> quantization, and it's also unclear if the issue is even actually
> there in the first place and not in M2/M3 firmwares).
> 
> Since these encoders share more than similiarities, I've been looking
> into their differences, and unifying their common codepaths was helpful
> to my investigation.
> 
> Attached is an initial patchset working out their differences by either
> sharing data or making code identical where relevant.
> 
> I will continue that work as the investigation progresses. The
> quantization work might require more involved changes though.
> 
> Regards,
> 
> ¹ https://trac.ffmpeg.org/ticket/10255

Hi Clement.

Most patches look good to me. You can skip style comments in patches
3, 4, 15 if they complicate the rebase.

About functional changes in 9 and 27, I assume the one in 27 is an
overlook, while 9 could be a lecit change but in this case I assume
the output changes should be spotted by a test - not sure we have such
a test in place to compare kostya/anatoliy encoders output.

Or maybe I'm wrong and I misread the changes, but having the test
would be good anyway.

Thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header
  2023-12-16 17:12   ` Stefano Sabatini
@ 2024-01-06 17:12     ` Clément Bœsch
  0 siblings, 0 replies; 80+ messages in thread
From: Clément Bœsch @ 2024-01-06 17:12 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Dec 16, 2023 at 06:12:19PM +0100, Stefano Sabatini wrote:
> On date Monday 2023-12-11 02:35:10 +0100, Clément Bœsch wrote:
> > ---
> >  libavcodec/proresenc_kostya.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> > index 2d45f9a685..103051830a 100644
> > --- a/libavcodec/proresenc_kostya.c
> > +++ b/libavcodec/proresenc_kostya.c
> > @@ -1019,7 +1019,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> >              bytestream_put_byte(&buf, ctx->quant_mat[i]);
> >          // chroma quantisation matrix
> >          for (i = 0; i < 64; i++)
> > -            bytestream_put_byte(&buf, ctx->quant_mat[i]);
> > +            bytestream_put_byte(&buf, ctx->quant_chroma_mat[i]);
> 
> Looks good, but I wonder, is this covered by tests and a results in a
> reference change?

Most of the time the quantisation matrices are tehe same, it only matters
with the "proxy" profile. I've added that last sentence to the commit
description to explain why it didn't cause any test ref change.

-- 
Clément B.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2()
  2023-12-23 23:43   ` Stefano Sabatini
@ 2024-01-07 23:00     ` Clément Bœsch
  2024-01-09 23:08       ` Stefano Sabatini
  0 siblings, 1 reply; 80+ messages in thread
From: Clément Bœsch @ 2024-01-07 23:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sun, Dec 24, 2023 at 12:43:32AM +0100, Stefano Sabatini wrote:
> On date Monday 2023-12-11 02:35:28 +0100, Clément Bœsch wrote:
> > A few cosmetics aside, this makes the function identical to the one with
> > the same name in proresenc_kostya.
> > ---
> >  libavcodec/proresenc_anatoliy.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> > index bdf7bface4..aed5c68b1b 100644
> > --- a/libavcodec/proresenc_anatoliy.c
> > +++ b/libavcodec/proresenc_anatoliy.c
> > @@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
> >  
> >  #define GET_SIGN(x)  ((x) >> 31)
> >  #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
> > -#define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
> >  
> >  static av_always_inline int get_level(int val)
> >  {
> > @@ -271,7 +270,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
> >  {
> >      int i;
> >      int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
> > -    int diff_sign;
> >  
> >      prev_dc = (blocks[0] - 0x4000) / scale;
> >      encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
> > @@ -282,8 +280,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
> >          dc        = (blocks[0] - 0x4000) / scale;
> >          delta     = dc - prev_dc;
> >          new_sign  = GET_SIGN(delta);
> 
> > -        diff_sign = new_sign ^ sign;
> > -        code      = TO_GOLOMB2(get_level(delta), diff_sign);
> > +        delta     = (delta ^ sign) - sign;
> > +        code      = MAKE_CODE(delta);
> 
> These don't look equivalent,
> 
> MAKE_CODE((delta ^ sign) - sign) is equivalent to
> TO_GOLOMB2(get_level(delta), sign)
> 
> not to
> TO_GOLOMB2(get_level(delta), diff_sign)

OK so this one is a bit tricky.

Let's start from the specs, which states that the signed integer to symbol
(code) mapping should be:

    2|n|    if n>=0
    2|n|-1  if n<0

We also know that n>>31 is -1 if n < 0, and 0 if n>=0, which means the
above condition can be simplified to:

    2|n| + (n>>31)

With prores_aw we have:

    s = -1 if different sign, 0 otherwise
    2|n| + s
 
Because:
- get_level() is an absolute function¹
- the val==0 case doesn't matter because in this case s will also be 0

In prores_ks we have:

    n'=-n if different sign, n otherwise
    (2n')^sign(n') <=> 2|n'|-(n'>>31)

So basically, aw does use the comparison with the previous delta and
encodes it accordingly, while ks decides to swap the sign of n according
to that previous delta, then encode it using its new sign.

I wouldn't mind a third pair of eyes on the matter, but these look
equivalent to me.

Note that in practice I also tried to encode a bunch of frames from
testsrc2 with and without the patch, and they are bit identical.

¹ I mis-replied earlier directly to Stefano in the get_level() patch, so
the explanation for why get_leve() is equivalent to the absolute value:
sign can only be -1 (if val < 0) or 0 (if val >= 0). Which means val^sign
will either swap all bits or do nothing. And then it's pretty much what
can be found here:
https://graphics.stanford.edu/~seander/bithacks.html#IntegerAbs

-- 
Clément B.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata
  2023-12-12  8:02   ` Stefano Sabatini
@ 2024-01-08 17:06     ` Clément Bœsch
  0 siblings, 0 replies; 80+ messages in thread
From: Clément Bœsch @ 2024-01-08 17:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Tue, Dec 12, 2023 at 09:02:23AM +0100, Stefano Sabatini wrote:
> On date Monday 2023-12-11 02:35:05 +0100, Clément Bœsch wrote:
> > This is going to be shared with proresenc_kostya in the upcoming commit.
> > ---
> >  libavcodec/proresdata.c         | 6 ++++++
> >  libavcodec/proresdata.h         | 2 ++
> >  libavcodec/proresenc_anatoliy.c | 9 ++-------
> >  3 files changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/libavcodec/proresdata.c b/libavcodec/proresdata.c
> > index 4787907c71..12ee43bddd 100644
> > --- a/libavcodec/proresdata.c
> > +++ b/libavcodec/proresdata.c
> > @@ -43,3 +43,9 @@ const uint8_t ff_prores_interlaced_scan[64] = {
> >      30, 23, 31, 38, 45, 52, 60, 53,
> >      46, 39, 47, 54, 61, 62, 55, 63
> >  };
> > +
> > +const uint8_t ff_prores_run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> > +        0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> > +
> 
> > +const uint8_t ff_prores_lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> > +        0x28, 0x28, 0x28, 0x4C };
> 
> while at it this could employ "lev" => "level" to clarify code and
> maybe enable some pattern matching trick

Renamed locally

-- 
Clément B.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2()
  2024-01-07 23:00     ` Clément Bœsch
@ 2024-01-09 23:08       ` Stefano Sabatini
  0 siblings, 0 replies; 80+ messages in thread
From: Stefano Sabatini @ 2024-01-09 23:08 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On date Monday 2024-01-08 00:00:37 +0100, Clément Bœsch wrote:
> On Sun, Dec 24, 2023 at 12:43:32AM +0100, Stefano Sabatini wrote:
> > On date Monday 2023-12-11 02:35:28 +0100, Clément Bœsch wrote:
> > > A few cosmetics aside, this makes the function identical to the one with
> > > the same name in proresenc_kostya.
> > > ---
> > >  libavcodec/proresenc_anatoliy.c | 6 ++----
> > >  1 file changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> > > index bdf7bface4..aed5c68b1b 100644
> > > --- a/libavcodec/proresenc_anatoliy.c
> > > +++ b/libavcodec/proresenc_anatoliy.c
> > > @@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
> > >  
> > >  #define GET_SIGN(x)  ((x) >> 31)
> > >  #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
> > > -#define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
> > >  
> > >  static av_always_inline int get_level(int val)
> > >  {
> > > @@ -271,7 +270,6 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
> > >  {
> > >      int i;
> > >      int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
> > > -    int diff_sign;
> > >  
> > >      prev_dc = (blocks[0] - 0x4000) / scale;
> > >      encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
> > > @@ -282,8 +280,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
> > >          dc        = (blocks[0] - 0x4000) / scale;
> > >          delta     = dc - prev_dc;
> > >          new_sign  = GET_SIGN(delta);
> > 
> > > -        diff_sign = new_sign ^ sign;
> > > -        code      = TO_GOLOMB2(get_level(delta), diff_sign);
> > > +        delta     = (delta ^ sign) - sign;
> > > +        code      = MAKE_CODE(delta);
> > 
> > These don't look equivalent,
> > 
> > MAKE_CODE((delta ^ sign) - sign) is equivalent to
> > TO_GOLOMB2(get_level(delta), sign)
> > 
> > not to
> > TO_GOLOMB2(get_level(delta), diff_sign)
> 
> OK so this one is a bit tricky.
> 
> Let's start from the specs, which states that the signed integer to symbol
> (code) mapping should be:
> 
>     2|n|    if n>=0
>     2|n|-1  if n<0
> 
> We also know that n>>31 is -1 if n < 0, and 0 if n>=0, which means the
> above condition can be simplified to:
> 
>     2|n| + (n>>31)
> 
> With prores_aw we have:
> 
>     s = -1 if different sign, 0 otherwise
>     2|n| + s
>  
> Because:
> - get_level() is an absolute function¹
> - the val==0 case doesn't matter because in this case s will also be 0
> 
> In prores_ks we have:
> 
>     n'=-n if different sign, n otherwise
>     (2n')^sign(n') <=> 2|n'|-(n'>>31)
> 
> So basically, aw does use the comparison with the previous delta and
> encodes it accordingly, while ks decides to swap the sign of n according
> to that previous delta, then encode it using its new sign.
> 
> I wouldn't mind a third pair of eyes on the matter, but these look
> equivalent to me.
> 
> Note that in practice I also tried to encode a bunch of frames from
> testsrc2 with and without the patch, and they are bit identical.

Thanks for the detailed explanation, I think it's safe to push
especially considering that there are no output changes.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

* Re: [FFmpeg-devel] Initial tickering at unifying ProRes encoder
  2023-12-24 10:56 ` Stefano Sabatini
@ 2024-01-10 13:22   ` Clément Bœsch
  0 siblings, 0 replies; 80+ messages in thread
From: Clément Bœsch @ 2024-01-10 13:22 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sun, Dec 24, 2023 at 11:56:56AM +0100, Stefano Sabatini wrote:
> On date Monday 2023-12-11 02:35:01 +0100, Clément Bœsch wrote:
> > Hello there,
> > 
> > I'm currently investigating an issue¹ affecting Kostya ProRes encoder
> > which is not reproducible with Anatoliy encoder (but it's too early to
> > say if the bug is not present there as well given the differences in
> > quantization, and it's also unclear if the issue is even actually
> > there in the first place and not in M2/M3 firmwares).
> > 
> > Since these encoders share more than similiarities, I've been looking
> > into their differences, and unifying their common codepaths was helpful
> > to my investigation.
> > 
> > Attached is an initial patchset working out their differences by either
> > sharing data or making code identical where relevant.
> > 
> > I will continue that work as the investigation progresses. The
> > quantization work might require more involved changes though.
> > 
> > Regards,
> > 
> > ¹ https://trac.ffmpeg.org/ticket/10255
> 
> Hi Clement.
> 
> Most patches look good to me. You can skip style comments in patches
> 3, 4, 15 if they complicate the rebase.

Patchset applied; I skipped the 2 out of the 3 cosmetics

Thank you for the review

-- 
Clément B.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 80+ messages in thread

end of thread, other threads:[~2024-01-10 13:22 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11  1:35 [FFmpeg-devel] Initial tickering at unifying ProRes encoder Clément Bœsch
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro Clément Bœsch
2023-12-12  6:53   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 02/35] avcodec/proresenc_kostya: remove unused plane factor variables Clément Bœsch
2023-12-12  6:56   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 03/35] avcodec/proresenc_kostya: remove redundant codebook assignments Clément Bœsch
2023-12-12  7:00   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 04/35] avcodec/proresenc_anatoliy: move run/lev to codebook LUT to shared proresdata Clément Bœsch
2023-12-12  7:02   ` Stefano Sabatini
2023-12-12  8:02   ` Stefano Sabatini
2024-01-08 17:06     ` Clément Bœsch
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping Clément Bœsch
2023-12-12  8:16   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 06/35] avcodec/proresenc_anatoliy: remove duplicated define Clément Bœsch
2023-12-16 16:32   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 07/35] avcodec/proresenc_anatoliy: move DC codebook LUT to shared proresdata Clément Bœsch
2023-12-16 16:33   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding Clément Bœsch
2023-12-16 16:54   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 09/35] avcodec/proresenc_kostya: fix chroma quantisation matrix in frame header Clément Bœsch
2023-12-16 17:12   ` Stefano Sabatini
2024-01-06 17:12     ` Clément Bœsch
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 10/35] avcodec/proresenc_kostya: simplify quantization matrix bytestream writing Clément Bœsch
2023-12-17 18:18   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 11/35] avcodec/proresenc_anatoliy: use FRAME_ID defined in proresdata.h Clément Bœsch
2023-12-17 18:19   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder Clément Bœsch
2023-12-18  0:07   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 13/35] avcodec/proresenc_anatoliy: rework encode_codeword() prototype Clément Bœsch
2023-12-18  0:09   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 14/35] avcodec/proresenc_anatoliy: inline QSCALE() Clément Bœsch
2023-12-18  0:13   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 15/35] avcodec/proresenc_anatoliy: rename new_code/code to code/codebook Clément Bœsch
2023-12-18  0:18   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 16/35] avcodec/proresenc_anatoliy: execute codebook FFMIN() at assignment Clément Bœsch
2023-12-18  0:24   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 17/35] avcodec/proresenc_anatoliy: reduce DC encoding function prototype differences with Kostya encoder Clément Bœsch
2023-12-18  0:26   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 18/35] avcodec/proresenc_anatoliy: directly work with blocks in encode_dcs() Clément Bœsch
2023-12-18  0:30   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 19/35] avcodec/proresenc_anatoliy: import GET_SIGN() macro from Kostya encoder and use it Clément Bœsch
2023-12-18  0:30   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 20/35] avcodec/proresenc_anatoliy: compute sign only once Clément Bœsch
2023-12-18  0:37   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 21/35] avcodec/proresenc_anatoliy: rename new_dc to dc Clément Bœsch
2023-12-18  0:38   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 22/35] avcodec/proresenc_anatoliy: remove IS_NEGATIVE() macro Clément Bœsch
2023-12-18 22:29   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 23/35] avcodec/proresenc_kostya: add Anatoliy copyright Clément Bœsch
2023-12-18 22:30   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 24/35] avcodec/proresenc_anatoliy: rename TO_GOLOMB() to MAKE_CODE() Clément Bœsch
2023-12-18 22:32   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 25/35] avcodec/proresenc_anatoliy: shuffle declarations around in encode_dcs() Clément Bœsch
2023-12-18 22:35   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 26/35] avcodec/proresenc_anatoliy: only pass down the first scale to encode_dcs() Clément Bœsch
2023-12-18 22:36   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 27/35] avcodec/proresenc_anatoliy: remove TO_GOLOMB2() Clément Bœsch
2023-12-23 23:43   ` Stefano Sabatini
2024-01-07 23:00     ` Clément Bœsch
2024-01-09 23:08       ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 28/35] avcodec/proresenc_anatoliy: cosmetics to make encode_dcs() identical to the one in Kostya encoder Clément Bœsch
2023-12-23 23:46   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 29/35] avcodec/proresenc_anatoliy: replace get_level() with FFABS() Clément Bœsch
2023-12-24 10:25   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 30/35] avcodec/proresenc_anatoliy: rework encode_ac_coeffs() prototype Clément Bœsch
2023-12-24 10:26   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 31/35] avcodec/proresenc_anatoliy: avoid using ff_ prefix in function arguments Clément Bœsch
2023-12-24 10:27   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 32/35] avcodec/proresenc_anatoliy: rework inner loop in encode_acs() Clément Bœsch
2023-12-24 10:36   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 33/35] avcodec/proresenc_anatoliy: execute AC run/level FFMIN() at assignment Clément Bœsch
2023-12-24 10:40   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 34/35] avcodec/proresenc_anatoliy: make a few cosmetics in encode_acs() Clément Bœsch
2023-12-24 10:45   ` Stefano Sabatini
2023-12-11  1:35 ` [FFmpeg-devel] [PATCH 35/35] avcodec/proresenc_kostya: " Clément Bœsch
2023-12-24 10:46   ` Stefano Sabatini
2023-12-11  9:15 ` [FFmpeg-devel] Initial tickering at unifying ProRes encoder Anton Khirnov
2023-12-11  9:36   ` Clément Bœsch
2023-12-24 10:56 ` Stefano Sabatini
2024-01-10 13:22   ` Clément Bœsch

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git