* [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number
@ 2025-04-03 10:50 Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ffv1enc: Remove 65536 pixel per slice limit for remap Michael Niedermayer
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-03 10:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
This reduces needed memory and also removes the 65536 maximum for remap
on the decoder side
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/ffv1.c | 2 ++
libavcodec/ffv1.h | 2 ++
libavcodec/ffv1dec.c | 25 ++++++++++---------------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 86fe9455c4c..885cef265f7 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -273,6 +273,8 @@ av_cold void ff_ffv1_close(FFV1Context *s)
for(int p = 0; p < 4 ; p++) {
av_freep(&sc->fltmap[p]);
av_freep(&sc->fltmap32[p]);
+ sc->fltmap_size [p] = 0;
+ sc->fltmap32_size[p] = 0;
}
av_refstruct_unref(&sc->plane);
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index c95508e2844..664a48d1f0d 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -111,6 +111,8 @@ typedef struct FFV1SliceContext {
uint16_t *bitmap [4]; //float encode
uint16_t *fltmap [4]; //halffloat encode & decode
uint32_t *fltmap32[4]; //float decode
+ unsigned int fltmap_size[4];
+ unsigned int fltmap32_size[4];
struct Unit {
uint32_t val; //this is unneeded if you accept a dereference on each access
uint16_t ndx;
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index dc4eeecc87c..8d10d2cf8b7 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -264,10 +264,6 @@ static int decode_slice_header(const FFV1Context *f,
av_log(f->avctx, AV_LOG_ERROR, "unsupported remap\n");
return AVERROR_INVALIDDATA;
}
- if (sc->slice_width * sc->slice_height > 65536) {
- av_log(f->avctx, AV_LOG_ERROR, "32bit needs remap\n");
- return AVERROR_INVALIDDATA;
- }
}
return 0;
@@ -298,6 +294,7 @@ static int decode_remap(FFV1Context *f, FFV1SliceContext *sc)
{
unsigned int end = (1LL<<f->avctx->bits_per_raw_sample) - 1;
int flip = sc->remap == 2 ? (end>>1) : 0;
+ const int pixel_num = sc->slice_width * sc->slice_height;
for (int p= 0; p < 1 + 2*f->chroma_planes + f->transparency; p++) {
int j = 0;
@@ -336,7 +333,7 @@ static int decode_remap(FFV1Context *f, FFV1SliceContext *sc)
}
if (i - 1 >= end)
break;
- if (j >= 65536 /*FF_ARRAY_ELEMS(sc->fltmap[p])*/)
+ if (j >= pixel_num)
return AVERROR_INVALIDDATA;
if (end <= 0xFFFF) {
sc->fltmap [p][j++] = i ^ ((i& 0x8000) ? 0 : flip);
@@ -398,19 +395,17 @@ static int decode_slice(AVCodecContext *c, void *arg)
y = sc->slice_y;
if (sc->remap) {
+ const int pixel_num = sc->slice_width * sc->slice_height;
+
for(int p = 0; p < 1 + 2*f->chroma_planes + f->transparency ; p++) {
if (f->avctx->bits_per_raw_sample == 32) {
- if (!sc->fltmap32[p]) {
- sc->fltmap32[p] = av_malloc_array(65536, sizeof(*sc->fltmap32[p]));
- if (!sc->fltmap32[p])
- return AVERROR(ENOMEM);
- }
+ av_fast_malloc(&sc->fltmap32[p], &sc->fltmap32_size[p], pixel_num * sizeof(*sc->fltmap32[p]));
+ if (!sc->fltmap32[p])
+ return AVERROR(ENOMEM);
} else {
- if (!sc->fltmap[p]) {
- sc->fltmap[p] = av_malloc_array(65536, sizeof(*sc->fltmap[p]));
- if (!sc->fltmap[p])
- return AVERROR(ENOMEM);
- }
+ av_fast_malloc(&sc->fltmap[p], &sc->fltmap_size[p], pixel_num * sizeof(*sc->fltmap[p]));
+ if (!sc->fltmap[p])
+ return AVERROR(ENOMEM);
}
}
--
2.49.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 2/4] avcodec/ffv1enc: Remove 65536 pixel per slice limit for remap
2025-04-03 10:50 [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
@ 2025-04-03 10:50 ` Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 3/4] avcodec/ffv1enc: Consider 2s x s slice configurations Michael Niedermayer
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-03 10:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
About 1% better compression with large slices
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/ffv1.h | 4 ++--
libavcodec/ffv1enc.c | 6 ------
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 664a48d1f0d..9472f9c9585 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -108,14 +108,14 @@ typedef struct FFV1SliceContext {
};
int remap_count[4];
- uint16_t *bitmap [4]; //float encode
+ uint32_t *bitmap [4]; //float encode
uint16_t *fltmap [4]; //halffloat encode & decode
uint32_t *fltmap32[4]; //float decode
unsigned int fltmap_size[4];
unsigned int fltmap32_size[4];
struct Unit {
uint32_t val; //this is unneeded if you accept a dereference on each access
- uint16_t ndx;
+ uint32_t ndx;
} *unit[4];
} FFV1SliceContext;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 8f61b183eb0..70821a10159 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -577,9 +577,6 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
continue;
if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24)
continue;
- if (s->bits_per_raw_sample == 32)
- if (maxw * maxh > 65536)
- continue;
if (s->version < 4)
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))
@@ -1382,7 +1379,6 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc,
if (update) {
sc->c = rc;
- av_assert0(compact_index <= 65535);
sc->remap_count[p] = compact_index + 1;
}
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 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++) {
int best_log2_mul_count = 0;
float score_sum[11] = {0};
--
2.49.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 3/4] avcodec/ffv1enc: Consider 2s x s slice configurations
2025-04-03 10:50 [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ffv1enc: Remove 65536 pixel per slice limit for remap Michael Niedermayer
@ 2025-04-03 10:50 ` Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified Michael Niedermayer
2025-04-06 18:43 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
3 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-03 10:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/ffv1enc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 70821a10159..ce3f8e023e5 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -570,7 +570,7 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
s->num_v_slices = (avctx->width > 352 || avctx->height > 288 || !avctx->slices) ? 2 : 1;
s->num_v_slices = FFMIN(s->num_v_slices, max_v_slices);
for (; s->num_v_slices < 32; s->num_v_slices++) {
- for (s->num_h_slices = s->num_v_slices; s->num_h_slices < 2*s->num_v_slices; s->num_h_slices++) {
+ for (s->num_h_slices = s->num_v_slices; s->num_h_slices <= 2*s->num_v_slices; s->num_h_slices++) {
int maxw = (avctx->width + s->num_h_slices - 1) / s->num_h_slices;
int maxh = (avctx->height + s->num_v_slices - 1) / s->num_v_slices;
if (s->num_h_slices > max_h_slices || s->num_v_slices > max_v_slices)
--
2.49.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified
2025-04-03 10:50 [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ffv1enc: Remove 65536 pixel per slice limit for remap Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 3/4] avcodec/ffv1enc: Consider 2s x s slice configurations Michael Niedermayer
@ 2025-04-03 10:50 ` Michael Niedermayer
2025-04-06 23:29 ` James Almer
2025-04-06 18:43 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
3 siblings, 1 reply; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-03 10:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
This improves speed by providing more independent things for more CPUs
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/ffv1enc.c | 6 +++++-
.../ref/fate/matroska-mastering-display-metadata | 16 ++++++++--------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index ce3f8e023e5..221344794e2 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -581,7 +581,11 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
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))
continue;
- if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES || !avctx->slices)
+ if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES)
+ return 0;
+ if (maxw*maxh > 360*288)
+ continue;
+ if (!avctx->slices)
return 0;
}
}
diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
index 91ce6a05584..6a2ff15b1b2 100644
--- a/tests/ref/fate/matroska-mastering-display-metadata
+++ b/tests/ref/fate/matroska-mastering-display-metadata
@@ -1,7 +1,7 @@
-ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-metadata.matroska
-1669589 tests/data/fate/matroska-mastering-display-metadata.matroska
+c1e5e2ecf433cf05af8556debc7d4d0b *tests/data/fate/matroska-mastering-display-metadata.matroska
+1669773 tests/data/fate/matroska-mastering-display-metadata.matroska
#extradata 0: 4, 0x040901a3
-#extradata 3: 200, 0x506463a8
+#extradata 3: 202, 0xfce96279
#tb 0: 1/1000
#media_type 0: video
#codec_id 0: prores
@@ -24,23 +24,23 @@ ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-met
#sar 3: 1/1
0, 0, 0, 16, 57008, 0x43416399
1, 0, 0, 16, 2403, 0xaa818522
-3, 0, 0, 16, 274117, 0xc439610f
+3, 0, 0, 16, 274884, 0x775840e5
0, 17, 17, 16, 57248, 0xa06cd7b5
1, 17, 17, 16, 2403, 0xe1a991e5
2, 17, 17, 16, 1602, 0x5d868171
-3, 17, 17, 16, 273691, 0x5a3b88a5, F=0x0
+3, 17, 17, 16, 273716, 0xa41fc5e3, F=0x0
0, 33, 33, 16, 57200, 0x5623da10
1, 33, 33, 16, 2400, 0x6650907f
2, 33, 33, 16, 1600, 0xa90f0044
-3, 33, 33, 16, 272987, 0x48c443e7, F=0x0
+3, 33, 33, 16, 272838, 0x3c308d03, F=0x0
0, 50, 50, 16, 57152, 0x52d89d3f
1, 50, 50, 16, 2403, 0x43398a08
2, 50, 50, 16, 1602, 0x3a350084
-3, 50, 50, 16, 271465, 0x251b9cbe, F=0x0
+3, 50, 50, 16, 271251, 0xe802cc77, F=0x0
0, 67, 67, 16, 56960, 0x431d5189
1, 67, 67, 16, 2403, 0x61cd96cb
2, 67, 67, 16, 1602, 0xd74800c6
-3, 67, 67, 16, 270800, 0x8fb2e217, F=0x0
+3, 67, 67, 16, 270553, 0x36d83705, F=0x0
[STREAM]
index=0
codec_name=prores
--
2.49.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number
2025-04-03 10:50 [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
` (2 preceding siblings ...)
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified Michael Niedermayer
@ 2025-04-06 18:43 ` Michael Niedermayer
3 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-06 18:43 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 712 bytes --]
On Thu, Apr 03, 2025 at 12:50:46PM +0200, Michael Niedermayer wrote:
> This reduces needed memory and also removes the 65536 maximum for remap
> on the decoder side
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavcodec/ffv1.c | 2 ++
> libavcodec/ffv1.h | 2 ++
> libavcodec/ffv1dec.c | 25 ++++++++++---------------
> 3 files changed, 14 insertions(+), 15 deletions(-)
will apply patchset
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified Michael Niedermayer
@ 2025-04-06 23:29 ` James Almer
2025-04-06 23:44 ` Michael Niedermayer
0 siblings, 1 reply; 9+ messages in thread
From: James Almer @ 2025-04-06 23:29 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 3915 bytes --]
On 4/3/2025 7:50 AM, Michael Niedermayer wrote:
> This improves speed by providing more independent things for more CPUs
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavcodec/ffv1enc.c | 6 +++++-
> .../ref/fate/matroska-mastering-display-metadata | 16 ++++++++--------
> 2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
> index ce3f8e023e5..221344794e2 100644
> --- a/libavcodec/ffv1enc.c
> +++ b/libavcodec/ffv1enc.c
> @@ -581,7 +581,11 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
> 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))
> continue;
> - if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES || !avctx->slices)
> + if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES)
> + return 0;
> + if (maxw*maxh > 360*288)
> + continue;
> + if (!avctx->slices)
> return 0;
> }
> }
> diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
> index 91ce6a05584..6a2ff15b1b2 100644
> --- a/tests/ref/fate/matroska-mastering-display-metadata
> +++ b/tests/ref/fate/matroska-mastering-display-metadata
> @@ -1,7 +1,7 @@
> -ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-metadata.matroska
> -1669589 tests/data/fate/matroska-mastering-display-metadata.matroska
> +c1e5e2ecf433cf05af8556debc7d4d0b *tests/data/fate/matroska-mastering-display-metadata.matroska
> +1669773 tests/data/fate/matroska-mastering-display-metadata.matroska
> #extradata 0: 4, 0x040901a3
> -#extradata 3: 200, 0x506463a8
> +#extradata 3: 202, 0xfce96279
Why did extradata change? Slice dimension value changes?
> #tb 0: 1/1000
> #media_type 0: video
> #codec_id 0: prores
> @@ -24,23 +24,23 @@ ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-met
> #sar 3: 1/1
> 0, 0, 0, 16, 57008, 0x43416399
> 1, 0, 0, 16, 2403, 0xaa818522
> -3, 0, 0, 16, 274117, 0xc439610f
> +3, 0, 0, 16, 274884, 0x775840e5
> 0, 17, 17, 16, 57248, 0xa06cd7b5
> 1, 17, 17, 16, 2403, 0xe1a991e5
> 2, 17, 17, 16, 1602, 0x5d868171
> -3, 17, 17, 16, 273691, 0x5a3b88a5, F=0x0
> +3, 17, 17, 16, 273716, 0xa41fc5e3, F=0x0
> 0, 33, 33, 16, 57200, 0x5623da10
> 1, 33, 33, 16, 2400, 0x6650907f
> 2, 33, 33, 16, 1600, 0xa90f0044
> -3, 33, 33, 16, 272987, 0x48c443e7, F=0x0
> +3, 33, 33, 16, 272838, 0x3c308d03, F=0x0
> 0, 50, 50, 16, 57152, 0x52d89d3f
> 1, 50, 50, 16, 2403, 0x43398a08
> 2, 50, 50, 16, 1602, 0x3a350084
> -3, 50, 50, 16, 271465, 0x251b9cbe, F=0x0
> +3, 50, 50, 16, 271251, 0xe802cc77, F=0x0
> 0, 67, 67, 16, 56960, 0x431d5189
> 1, 67, 67, 16, 2403, 0x61cd96cb
> 2, 67, 67, 16, 1602, 0xd74800c6
> -3, 67, 67, 16, 270800, 0x8fb2e217, F=0x0
> +3, 67, 67, 16, 270553, 0x36d83705, F=0x0
> [STREAM]
> index=0
> codec_name=prores
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified
2025-04-06 23:29 ` James Almer
@ 2025-04-06 23:44 ` Michael Niedermayer
2025-04-07 1:13 ` James Almer
0 siblings, 1 reply; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-06 23:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2493 bytes --]
On Sun, Apr 06, 2025 at 08:29:42PM -0300, James Almer wrote:
> On 4/3/2025 7:50 AM, Michael Niedermayer wrote:
> > This improves speed by providing more independent things for more CPUs
> >
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavcodec/ffv1enc.c | 6 +++++-
> > .../ref/fate/matroska-mastering-display-metadata | 16 ++++++++--------
> > 2 files changed, 13 insertions(+), 9 deletions(-)
> >
> > diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
> > index ce3f8e023e5..221344794e2 100644
> > --- a/libavcodec/ffv1enc.c
> > +++ b/libavcodec/ffv1enc.c
> > @@ -581,7 +581,11 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
> > 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))
> > continue;
> > - if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES || !avctx->slices)
> > + if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES)
> > + return 0;
> > + if (maxw*maxh > 360*288)
> > + continue;
> > + if (!avctx->slices)
> > return 0;
> > }
> > }
> > diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
> > index 91ce6a05584..6a2ff15b1b2 100644
> > --- a/tests/ref/fate/matroska-mastering-display-metadata
> > +++ b/tests/ref/fate/matroska-mastering-display-metadata
> > @@ -1,7 +1,7 @@
> > -ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-metadata.matroska
> > -1669589 tests/data/fate/matroska-mastering-display-metadata.matroska
> > +c1e5e2ecf433cf05af8556debc7d4d0b *tests/data/fate/matroska-mastering-display-metadata.matroska
> > +1669773 tests/data/fate/matroska-mastering-display-metadata.matroska
> > #extradata 0: 4, 0x040901a3
> > -#extradata 3: 200, 0x506463a8
> > +#extradata 3: 202, 0xfce96279
>
> Why did extradata change? Slice dimension value changes?
yes, any reason you belive theres an issue ?
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The educated differ from the uneducated as much as the living from the
dead. -- Aristotle
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified
2025-04-06 23:44 ` Michael Niedermayer
@ 2025-04-07 1:13 ` James Almer
2025-04-07 12:35 ` Michael Niedermayer
0 siblings, 1 reply; 9+ messages in thread
From: James Almer @ 2025-04-07 1:13 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 2431 bytes --]
On 4/6/2025 8:44 PM, Michael Niedermayer wrote:
> On Sun, Apr 06, 2025 at 08:29:42PM -0300, James Almer wrote:
>> On 4/3/2025 7:50 AM, Michael Niedermayer wrote:
>>> This improves speed by providing more independent things for more CPUs
>>>
>>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>>> ---
>>> libavcodec/ffv1enc.c | 6 +++++-
>>> .../ref/fate/matroska-mastering-display-metadata | 16 ++++++++--------
>>> 2 files changed, 13 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
>>> index ce3f8e023e5..221344794e2 100644
>>> --- a/libavcodec/ffv1enc.c
>>> +++ b/libavcodec/ffv1enc.c
>>> @@ -581,7 +581,11 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
>>> 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))
>>> continue;
>>> - if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES || !avctx->slices)
>>> + if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES)
>>> + return 0;
>>> + if (maxw*maxh > 360*288)
>>> + continue;
>>> + if (!avctx->slices)
>>> return 0;
>>> }
>>> }
>>> diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
>>> index 91ce6a05584..6a2ff15b1b2 100644
>>> --- a/tests/ref/fate/matroska-mastering-display-metadata
>>> +++ b/tests/ref/fate/matroska-mastering-display-metadata
>>> @@ -1,7 +1,7 @@
>>> -ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-metadata.matroska
>>> -1669589 tests/data/fate/matroska-mastering-display-metadata.matroska
>>> +c1e5e2ecf433cf05af8556debc7d4d0b *tests/data/fate/matroska-mastering-display-metadata.matroska
>>> +1669773 tests/data/fate/matroska-mastering-display-metadata.matroska
>>> #extradata 0: 4, 0x040901a3
>>> -#extradata 3: 200, 0x506463a8
>>> +#extradata 3: 202, 0xfce96279
>>
>> Why did extradata change? Slice dimension value changes?
>
> yes, any reason you belive theres an issue ?
No, just wanted to know why the size of extradata changed.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified
2025-04-07 1:13 ` James Almer
@ 2025-04-07 12:35 ` Michael Niedermayer
0 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2025-04-07 12:35 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 3227 bytes --]
On Sun, Apr 06, 2025 at 10:13:23PM -0300, James Almer wrote:
> On 4/6/2025 8:44 PM, Michael Niedermayer wrote:
> > On Sun, Apr 06, 2025 at 08:29:42PM -0300, James Almer wrote:
> > > On 4/3/2025 7:50 AM, Michael Niedermayer wrote:
> > > > This improves speed by providing more independent things for more CPUs
> > > >
> > > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > > > ---
> > > > libavcodec/ffv1enc.c | 6 +++++-
> > > > .../ref/fate/matroska-mastering-display-metadata | 16 ++++++++--------
> > > > 2 files changed, 13 insertions(+), 9 deletions(-)
> > > >
> > > > diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
> > > > index ce3f8e023e5..221344794e2 100644
> > > > --- a/libavcodec/ffv1enc.c
> > > > +++ b/libavcodec/ffv1enc.c
> > > > @@ -581,7 +581,11 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
> > > > 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))
> > > > continue;
> > > > - if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES || !avctx->slices)
> > > > + if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES)
> > > > + return 0;
> > > > + if (maxw*maxh > 360*288)
> > > > + continue;
> > > > + if (!avctx->slices)
> > > > return 0;
> > > > }
> > > > }
> > > > diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
> > > > index 91ce6a05584..6a2ff15b1b2 100644
> > > > --- a/tests/ref/fate/matroska-mastering-display-metadata
> > > > +++ b/tests/ref/fate/matroska-mastering-display-metadata
> > > > @@ -1,7 +1,7 @@
> > > > -ad5e3c4e338599c81ef7d0f9ae25f871 *tests/data/fate/matroska-mastering-display-metadata.matroska
> > > > -1669589 tests/data/fate/matroska-mastering-display-metadata.matroska
> > > > +c1e5e2ecf433cf05af8556debc7d4d0b *tests/data/fate/matroska-mastering-display-metadata.matroska
> > > > +1669773 tests/data/fate/matroska-mastering-display-metadata.matroska
> > > > #extradata 0: 4, 0x040901a3
> > > > -#extradata 3: 200, 0x506463a8
> > > > +#extradata 3: 202, 0xfce96279
> > >
> > > Why did extradata change? Slice dimension value changes?
> >
> > yes, any reason you belive theres an issue ?
>
> No, just wanted to know why the size of extradata changed.
yes, 1280x720 used 2x2 slice configuration before and now uses 3x3
2x2 is stored as storing the value 1 twice
and 3x3 stores the value 2 twice
thats 4 range coded binary values more in the bitstream.
Its a bit surprising that these end up needing 2 bytes more though
but its possible if most of the other stuff is "1" and not "2" values
than the cost of storing a "2" can be higher
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Never trust a computer, one day, it may think you are the virus. -- Compn
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-04-07 12:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03 10:50 [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ffv1enc: Remove 65536 pixel per slice limit for remap Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 3/4] avcodec/ffv1enc: Consider 2s x s slice configurations Michael Niedermayer
2025-04-03 10:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specified Michael Niedermayer
2025-04-06 23:29 ` James Almer
2025-04-06 23:44 ` Michael Niedermayer
2025-04-07 1:13 ` James Almer
2025-04-07 12:35 ` Michael Niedermayer
2025-04-06 18:43 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1dec: Limit size of fltmap* to pixel number Michael Niedermayer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git