History

avcodec/ffv1enc: Remove 65536 pixel per slice limit for remap

About 1% better compression with large slices

Michael Niedermayer committed 1 year ago

Commit 1b04fb31 parent feceed92 files · +2 −8Browse files

Unified · Split

2 files
  1. libavcodec/ffv1.h +2 −2
  2. libavcodec/ffv1enc.c +0 −6
libavcodec/ffv1.h+2−2
@@ -108,14 +108,14 @@ typedef struct FFV1SliceContext { · 107 unmodified lines
108 };108 };
109 int remap_count[4];109 int remap_count[4];
110 110
111 uint16_t *bitmap [4]; //float encode111 uint32_t *bitmap [4]; //float encode
112 uint16_t *fltmap [4]; //halffloat encode & decode112 uint16_t *fltmap [4]; //halffloat encode & decode
113 uint32_t *fltmap32[4]; //float decode113 uint32_t *fltmap32[4]; //float decode
114 unsigned int fltmap_size[4];114 unsigned int fltmap_size[4];
115 unsigned int fltmap32_size[4];115 unsigned int fltmap32_size[4];
116 struct Unit {116 struct Unit {
117 uint32_t val; //this is unneeded if you accept a dereference on each access117 uint32_t val; //this is unneeded if you accept a dereference on each access
118 uint16_t ndx;118 uint32_t ndx;
119 } *unit[4];119 } *unit[4];
120} FFV1SliceContext;120} FFV1SliceContext;
121 121
libavcodec/ffv1enc.c+0−6
@@ -577,9 +577,6 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx) · 576 unmodified lines
577 continue;577 continue;
578 if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24)578 if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24)
579 continue;579 continue;
580 if (s->bits_per_raw_sample == 32)
581 if (maxw * maxh > 65536)
582 continue;
583 if (s->version < 4)580 if (s->version < 4)
584 if ( ff_need_new_slices(avctx->width , s->num_h_slices, s->chroma_h_shift)581 if ( ff_need_new_slices(avctx->width , s->num_h_slices, s->chroma_h_shift)
585 ||ff_need_new_slices(avctx->height, s->num_v_slices, s->chroma_v_shift))582 ||ff_need_new_slices(avctx->height, s->num_v_slices, s->chroma_v_shift))
@@ -1382,7 +1379,6 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc, · 796 unmodified lines
1382 1379
1383 if (update) {1380 if (update) {
1384 sc->c = rc;1381 sc->c = rc;
1385 av_assert0(compact_index <= 65535);
1386 sc->remap_count[p] = compact_index + 1;1382 sc->remap_count[p] = compact_index + 1;
1387 }1383 }
1388 return get_rac_count(&rc);1384 return get_rac_count(&rc);
@@ -1400,8 +1396,6 @@ static void encode_float32_remap(FFV1Context *f, FFV1SliceContext *sc, · 11 unmodified lines
1400 const int stair_mode = ((int[]){ 0, 0, 0, 1, 0, 0})[f->remap_optimizer];1396 const int stair_mode = ((int[]){ 0, 0, 0, 1, 0, 0})[f->remap_optimizer];
1401 const int magic_log2 = ((int[]){ 1, 1, 1, 1, 0, 0})[f->remap_optimizer];1397 const int magic_log2 = ((int[]){ 1, 1, 1, 1, 0, 0})[f->remap_optimizer];
1402 1398
1403 av_assert0 (pixel_num <= 65536);
1404
1405 for (int p= 0; p < 1 + 2*f->chroma_planes + f->transparency; p++) {1399 for (int p= 0; p < 1 + 2*f->chroma_planes + f->transparency; p++) {
1406 int best_log2_mul_count = 0;1400 int best_log2_mul_count = 0;
1407 float score_sum[11] = {0};1401 float score_sum[11] = {0};

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