[FFmpeg-devel] [PATCH 04/11] avcodec/ffv1enc: remap table size is 1<<bits_per_raw_sample not fixed 65536

Michael Niedermayer michael at niedermayer.cc
Mon Mar 24 19:39:38 EET 2025


not a bugfix as this path was only used for float16 but it makes sense
to allow using this for integers too

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/ffv1enc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 05b43c12abf..78a9a903039 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1168,6 +1168,7 @@ static void choose_rct_params(const FFV1Context *f, FFV1SliceContext *sc,
 
 static void encode_histogram_remap(FFV1Context *f, FFV1SliceContext *sc)
 {
+    int len = 1 << f->bits_per_raw_sample;
     int flip = sc->remap == 2 ? 0x7FFF : 0;
 
     for (int p= 0; p < 1 + 2*f->chroma_planes + f->transparency; p++) {
@@ -1179,7 +1180,7 @@ static void encode_histogram_remap(FFV1Context *f, FFV1SliceContext *sc)
         memset(state, 128, sizeof(state));
         put_symbol(&sc->c, state[0], 0, 0);
         memset(state, 128, sizeof(state));
-        for (int i= 0; i<65536; i++) {
+        for (int i= 0; i<len; i++) {
             int ri = i ^ ((i&0x8000) ? 0 : flip);
             int u = sc->fltmap[p][ri];
             sc->fltmap[p][ri] = j;
-- 
2.48.1



More information about the ffmpeg-devel mailing list