1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

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

About 1% better compression with large slices

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2025-04-03 11:20:50 +02:00
parent feceed9222
commit 1b04fb385c
2 changed files with 2 additions and 8 deletions

View File

@ -108,14 +108,14 @@ typedef struct FFV1SliceContext {
}; };
int remap_count[4]; int remap_count[4];
uint16_t *bitmap [4]; //float encode uint32_t *bitmap [4]; //float encode
uint16_t *fltmap [4]; //halffloat encode & decode uint16_t *fltmap [4]; //halffloat encode & decode
uint32_t *fltmap32[4]; //float decode uint32_t *fltmap32[4]; //float decode
unsigned int fltmap_size[4]; unsigned int fltmap_size[4];
unsigned int fltmap32_size[4]; unsigned int fltmap32_size[4];
struct Unit { struct Unit {
uint32_t val; //this is unneeded if you accept a dereference on each access uint32_t val; //this is unneeded if you accept a dereference on each access
uint16_t ndx; uint32_t ndx;
} *unit[4]; } *unit[4];
} FFV1SliceContext; } FFV1SliceContext;

View File

@ -577,9 +577,6 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
continue; continue;
if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24) if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24)
continue; continue;
if (s->bits_per_raw_sample == 32)
if (maxw * maxh > 65536)
continue;
if (s->version < 4) if (s->version < 4)
if ( ff_need_new_slices(avctx->width , s->num_h_slices, s->chroma_h_shift) if ( ff_need_new_slices(avctx->width , s->num_h_slices, s->chroma_h_shift)
||ff_need_new_slices(avctx->height, s->num_v_slices, s->chroma_v_shift)) ||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,
if (update) { if (update) {
sc->c = rc; sc->c = rc;
av_assert0(compact_index <= 65535);
sc->remap_count[p] = compact_index + 1; sc->remap_count[p] = compact_index + 1;
} }
return get_rac_count(&rc); return get_rac_count(&rc);
@ -1400,8 +1396,6 @@ static void encode_float32_remap(FFV1Context *f, FFV1SliceContext *sc,
const int stair_mode = ((int[]){ 0, 0, 0, 1, 0, 0})[f->remap_optimizer]; const int stair_mode = ((int[]){ 0, 0, 0, 1, 0, 0})[f->remap_optimizer];
const int magic_log2 = ((int[]){ 1, 1, 1, 1, 0, 0})[f->remap_optimizer]; const int magic_log2 = ((int[]){ 1, 1, 1, 1, 0, 0})[f->remap_optimizer];
av_assert0 (pixel_num <= 65536);
for (int p= 0; p < 1 + 2*f->chroma_planes + f->transparency; p++) { for (int p= 0; p < 1 + 2*f->chroma_planes + f->transparency; p++) {
int best_log2_mul_count = 0; int best_log2_mul_count = 0;
float score_sum[11] = {0}; float score_sum[11] = {0};