The earlier code only used the counts from the last slice. The two FATE tests using slices show compression improvements due to this.
Showing the changes to libavcodec (1 of 3 files). Show all
Unified · Split
| @@ -395,20 +395,20 @@ static int encode_table(AVCodecContext *avctx, · 394 unmodified lines | ||
| 395 | 395 | PutBitContext *pb, HuffEntry *he, int plane) |
| 396 | 396 | { |
| 397 | 397 | MagicYUVContext *s = avctx->priv_data; |
| 398 | − PTable counts[256] = { {0} }; | |
| 398 | + PTable counts[256]; | |
| 399 | 399 | uint16_t codes_counts[33] = { 0 }; |
| 400 | 400 | |
| 401 | + for (size_t i = 0; i < FF_ARRAY_ELEMS(counts); i++) { | |
| 402 | + counts[i].prob = 1; | |
| 403 | + counts[i].value = i; | |
| 404 | + } | |
| 405 | + | |
| 401 | 406 | for (int n = 0; n < s->nb_slices; n++) { |
| 402 | 407 | Slice *sl = &s->slices[n * s->planes + plane]; |
| 403 | 408 | PTable *slice_counts = sl->counts; |
| 404 | 409 | |
| 405 | 410 | 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; | |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | magy_huffman_compute_bits(counts, he, codes_counts, 256, 12); |