ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | Fri Apr 11 23:23:56 2025 +0200| [a6c2c463c76be03c8fd4e1986b85734eab87b9da] | committer: Andreas Rheinhardt
avcodec/magicyuvenc: Fix Huffman element probabilities The earlier code only used the counts from the last slice. The two FATE tests using slices show compression improvements due to this. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a6c2c463c76be03c8fd4e1986b85734eab87b9da --- libavcodec/magicyuvenc.c | 14 +++++++------- tests/ref/vsynth/vsynth1-magicyuv | 4 ++-- tests/ref/vsynth/vsynth_lena-magicyuv | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index ba39bbb89f..9e9c3ecd46 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -395,20 +395,20 @@ static int encode_table(AVCodecContext *avctx, PutBitContext *pb, HuffEntry *he, int plane) { MagicYUVContext *s = avctx->priv_data; - PTable counts[256] = { {0} }; + PTable counts[256]; uint16_t codes_counts[33] = { 0 }; + for (size_t i = 0; i < FF_ARRAY_ELEMS(counts); i++) { + counts[i].prob = 1; + counts[i].value = i; + } + for (int n = 0; n < s->nb_slices; n++) { Slice *sl = &s->slices[n * s->planes + plane]; PTable *slice_counts = sl->counts; for (int i = 0; i < 256; i++) - counts[i].prob = slice_counts[i].prob; - } - - for (int i = 0; i < 256; i++) { - counts[i].prob++; - counts[i].value = i; + counts[i].prob += slice_counts[i].prob; } magy_huffman_compute_bits(counts, he, codes_counts, 256, 12); diff --git a/tests/ref/vsynth/vsynth1-magicyuv b/tests/ref/vsynth/vsynth1-magicyuv index 2e883bf1a0..c67066088e 100644 --- a/tests/ref/vsynth/vsynth1-magicyuv +++ b/tests/ref/vsynth/vsynth1-magicyuv @@ -1,4 +1,4 @@ -dc919cb0b3415d31fd51dfc6d7c22a6b *tests/data/fate/vsynth1-magicyuv.avi -3013600 tests/data/fate/vsynth1-magicyuv.avi +c52dd1622adefa1d863ed3fea03b304e *tests/data/fate/vsynth1-magicyuv.avi +2972044 tests/data/fate/vsynth1-magicyuv.avi c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-magicyuv.out.rawvideo stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth_lena-magicyuv b/tests/ref/vsynth/vsynth_lena-magicyuv index 4a9aae3989..52f515bf62 100644 --- a/tests/ref/vsynth/vsynth_lena-magicyuv +++ b/tests/ref/vsynth/vsynth_lena-magicyuv @@ -1,4 +1,4 @@ -3f74bf17bb8d9ba2022004f95de4b666 *tests/data/fate/vsynth_lena-magicyuv.avi -3477676 tests/data/fate/vsynth_lena-magicyuv.avi +b7cd87cec898d66cfce82e649376bb0d *tests/data/fate/vsynth_lena-magicyuv.avi +3471504 tests/data/fate/vsynth_lena-magicyuv.avi d7bfbe259af9ae323bb94b09c33570a5 *tests/data/fate/vsynth_lena-magicyuv.out.rawvideo stddev: 18.65 PSNR: 22.72 MAXDIFF: 72 bytes: 7603200/ 7603200 _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".