History

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.

Andreas Rheinhardt committed 1 year ago

Commit a6c2c461 parent 0e4d5133 files · +11 −11Browse files

Unified · Split

3 files
  1. libavcodec/magicyuvenc.c +7 −7
  2. tests/ref/vsynth/vsynth1-magicyuv +2 −2
  3. tests/ref/vsynth/vsynth_lena-magicyuv +2 −2
libavcodec/magicyuvenc.c+7−7
@@ -395,20 +395,20 @@ static int encode_table(AVCodecContext *avctx, · 394 unmodified lines
395395 PutBitContext *pb, HuffEntry *he, int plane)
396396 {
397397 MagicYUVContext *s = avctx->priv_data;
398− PTable counts[256] = { {0} };
398+ PTable counts[256];
399399 uint16_t codes_counts[33] = { 0 };
400400
401+ for (size_t i = 0; i < FF_ARRAY_ELEMS(counts); i++) {
402+ counts[i].prob = 1;
403+ counts[i].value = i;
404+ }
405+
401406 for (int n = 0; n < s->nb_slices; n++) {
402407 Slice *sl = &s->slices[n * s->planes + plane];
403408 PTable *slice_counts = sl->counts;
404409
405410 for (int i = 0; i < 256; i++)
406− counts[i].prob = slice_counts[i].prob;
407− }
408−
409− for (int i = 0; i < 256; i++) {
410− counts[i].prob++;
411− counts[i].value = i;
411+ counts[i].prob += slice_counts[i].prob;
412412 }
413413
414414 magy_huffman_compute_bits(counts, he, codes_counts, 256, 12);
tests/ref/vsynth/vsynth1-magicyuv+2−2
@@ -1,4 +1,4 @@
1−dc919cb0b3415d31fd51dfc6d7c22a6b *tests/data/fate/vsynth1-magicyuv.avi
2−3013600 tests/data/fate/vsynth1-magicyuv.avi
1+c52dd1622adefa1d863ed3fea03b304e *tests/data/fate/vsynth1-magicyuv.avi
2+2972044 tests/data/fate/vsynth1-magicyuv.avi
33 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-magicyuv.out.rawvideo
44 stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200
tests/ref/vsynth/vsynth_lena-magicyuv+2−2
@@ -1,4 +1,4 @@
1−3f74bf17bb8d9ba2022004f95de4b666 *tests/data/fate/vsynth_lena-magicyuv.avi
2−3477676 tests/data/fate/vsynth_lena-magicyuv.avi
1+b7cd87cec898d66cfce82e649376bb0d *tests/data/fate/vsynth_lena-magicyuv.avi
2+3471504 tests/data/fate/vsynth_lena-magicyuv.avi
33 d7bfbe259af9ae323bb94b09c33570a5 *tests/data/fate/vsynth_lena-magicyuv.out.rawvideo
44 stddev: 18.65 PSNR: 22.72 MAXDIFF: 72 bytes: 7603200/ 7603200

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t