Re: [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg_demux: merge streams in a LCEVC stream group
Quoting James Almer (2024-09-24 16:43:08) > Add the LCEVC data stream payloads as packet side data to the main video > stream, ensuring the former is always output by the demuxer even if not > used by the process. > > Signed-off-by: James Almer > --- > configure | 2 +- > fftools/ffmpeg.h | 6 + > fftools/ffmpeg_demux.c | 296 - > 3 files changed, 300 insertions(+), 4 deletions(-) Overall this patch seems like overgeneralizing from a single sample. Is there a reason to think a generic stream group would need its own bitstream filters? Or a "main stream for merged output"? It seems cleaner to me to just make all of this explicitly LCEVC-specific and not try to generalize until there actually is more than one user. > > diff --git a/configure b/configure > index d77a55b653..434c73776b 100755 > --- a/configure > +++ b/configure > @@ -4051,7 +4051,7 @@ ffmpeg_deps="avcodec avfilter avformat threads" > ffmpeg_select="aformat_filter anull_filter atrim_filter crop_filter > format_filter hflip_filter null_filter rotate_filter > transpose_filter trim_filter vflip_filter" > -ffmpeg_suggest="ole32 psapi shell32" > +ffmpeg_suggest="ole32 psapi shell32 lcevc_merge_bsf" > ffplay_deps="avcodec avformat avfilter swscale swresample sdl2" > ffplay_select="crop_filter transpose_filter hflip_filter vflip_filter > rotate_filter" > ffplay_suggest="shell32 libplacebo vulkan" > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h > index 733d551fa4..f598f6a46f 100644 > --- a/fftools/ffmpeg.h > +++ b/fftools/ffmpeg.h > @@ -492,6 +492,12 @@ typedef struct InputFile { > * if new streams appear dynamically during demuxing */ > InputStream**streams; > int nb_streams; > + > +/** > + * stream groups that ffmpeg is aware of > + */ > +struct InputStreamGroup **stream_groups; > +int nb_stream_groups; There seems to be no reason for this to be public, so it should not be. > } InputFile; > > enum forced_keyframes_const { > diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c > index 108a4a94bf..6aa194e7ad 100644 > --- a/fftools/ffmpeg_demux.c > +++ b/fftools/ffmpeg_demux.c > @@ -40,6 +40,18 @@ > > #include "libavformat/avformat.h" > > +// Defined here until it's needed in other modules and moved to ffmpeg.h "Local until/unless it needs to be public" applies to everything, not just this struct. > +typedef struct InputStreamGroup { > +const AVClass*class; > + > +/* parent source */ > +struct InputFile *file; > + > +int index; > + > +AVStreamGroup*stg; > +} InputStreamGroup; > + > typedef struct DemuxStream { > InputStream ist; > > @@ -56,7 +68,7 @@ typedef struct DemuxStream { > #define DECODING_FOR_OST1 > #define DECODING_FOR_FILTER 2 > > -/* true if stream data should be discarded */ > +/* non-0 if stream data is not strictly used by an output */ This is backwards, and highly confusing. It should be a bitmask of "how the stream is used". -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] swscale/aarch64: Fix rgb24toyv12 only works with aligned width
On Wed, 25 Sep 2024, Martin Storsjö wrote: On Wed, 25 Sep 2024, Zhao Zhili wrote: On Sep 25, 2024, at 16:01, Martin Storsjö wrote: On Tue, 24 Sep 2024, Zhao Zhili wrote: ffmpeg | branch: master | Zhao Zhili | Wed Sep 18 21:11:44 2024 +0800| [e18b46d95fadcbaaf450bda9f1871849f2b0c586] | committer: Zhao Zhili swscale/aarch64: Fix rgb24toyv12 only works with aligned width Since c0666d8b, rgb24toyv12 is broken for width non-aligned to 16. Add a simple wrapper to handle the non-aligned part. Co-authored-by: johzzy Signed-off-by: Zhao Zhili http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e18b46d95fadcbaaf450bda9f1871849f2b0c586 --- libswscale/aarch64/rgb2rgb.c | 23 ++- tests/checkasm/sw_rgb.c | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) --- a/tests/checkasm/sw_rgb.c +++ b/tests/checkasm/sw_rgb.c @@ -129,7 +129,7 @@ static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int a static void check_rgb24toyv12(struct SwsContext *ctx) { -static const int input_sizes[] = {16, 128, 512, MAX_LINE_SIZE, -MAX_LINE_SIZE}; +static const int input_sizes[] = {2, 16, 128, 540, MAX_LINE_SIZE, -MAX_LINE_SIZE}; LOCAL_ALIGNED_32(uint8_t, src, [BUFSIZE * 3]); LOCAL_ALIGNED_32(uint8_t, buf_y_0, [BUFSIZE]); These new test cases fail on x86_32; we have got a version of rgb24toyv12 which is specific to "#if ARCH_X86_32 && HAVE_7REGS". Can you have a look? Sorry for the break. I’m on a short vacation without access to x86_32 test environment. And I’m not familiar with x86 asm. I’m afraid removing the new test is what I can do for now, if that’s an option. Thanks - yeah I think that's the practically best thing to do at the moment. I guess this assembly has existed in this form for a very long time already, so while it probably is incorrect for these cases, it doesn't seem to be an urgent thing. (But I guess whatever case that was noted on aarch64 also would be noted on x86_32?) So silencing the test for now probably is simplest, until the assembly can be fixed. I pushed a commit to remove these testcases from checkasm, for now. Thanks! // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] configure: Add detection of assembler support for SVE/SVE2
On Tue, 17 Sep 2024, Martin Storsjö wrote: It turns out that recent versions of MS armasm64 does support some SVE instructions, but not all of them. Test for one of the instructions that it currently doesn't support. --- Just as disclaimer, I'm not currently actively planning on writing SVE/SVE2 optimizations. However, related projects such as x264 and dav1d do have a few functions using these extensions, so we might just as well add the framework support for these features in ffmpeg anyway, as functions needing this support will come sooner or later anyway. In the related projects, there's no really use of longer vectors (as there's very little such HW available anyway), but SVE gives widening loads (used in a couple places in x264) and 16 bit dot products (used in dav1d), which can be useful with 128 bit vectors. --- configure | 14 +- ffbuild/arch.mak| 2 ++ libavutil/aarch64/asm.S | 18 ++ 3 files changed, 33 insertions(+), 1 deletion(-) Planning on pushing this set later today. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: Fix missing EXT-X-DISCONTINUITY tag in subtitle streams
The EXT-X-DISCONTINUITY tag was not being added to subtitle streams, causing synchronization issues. This patch ensures that the tag is applied consistently across video and subtitle streams. --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 1e932b7..571d6b2 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1668,7 +1668,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs) ff_hls_write_playlist_header(hls->sub_m3u8_out, hls->version, hls->allowcache, target_duration, sequence, PLAYLIST_TYPE_NONE, 0); for (en = vs->segments; en; en = en->next) { -ret = ff_hls_write_file_entry(hls->sub_m3u8_out, 0, byterange_mode, +ret = ff_hls_write_file_entry(hls->sub_m3u8_out, en->discont, byterange_mode, en->duration, 0, en->size, en->pos, hls->baseurl, en->sub_filename, NULL, 0, 0, 0); if (ret < 0) { -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsplaylist: set stream name according to var_stream_map varname
From: jb-alvarado If name:* is set in var_stream_map variable, take that as NAME= variable. This helps gives better stream names in html players. --- libavformat/hlsenc.c | 2 +- libavformat/hlsplaylist.c | 9 +++-- libavformat/hlsplaylist.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 1e932b7..8e01721 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1533,7 +1533,7 @@ static int create_master_playlist(AVFormatContext *s, break; } -ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, vtt_m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1); +ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, vtt_m3u8_rel_name, vs->language, vs->varname, i, hls->has_default_key ? vs->is_default : 1); } if (!hls->has_default_key || !hls->has_video_m3u8) { diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c index f8a6977..2eedc32 100644 --- a/libavformat/hlsplaylist.c +++ b/libavformat/hlsplaylist.c @@ -57,13 +57,18 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, const char *filename, const char *language, - int name_id, int is_default) + const char *varname, int name_id, int is_default) { if (!out || !filename) return; avio_printf(out, "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"%s\"", sgroup); -avio_printf(out, ",NAME=\"subtitle_%d\",DEFAULT=%s,", name_id, is_default ? "YES" : "NO"); +if (varname) { +avio_printf(out, ",NAME=\"%s\",", varname); +} else { +avio_printf(out, ",NAME=\"subtitle_%d\",", name_id); +} +avio_printf(out, "DEFAULT=%s,", is_default ? "YES" : "NO"); if (language) { avio_printf(out, "LANGUAGE=\"%s\",", language); } diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h index d7aa44d..f181182 100644 --- a/libavformat/hlsplaylist.h +++ b/libavformat/hlsplaylist.h @@ -41,7 +41,7 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, int name_id, int is_default, int nb_channels); void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, const char *filename, const char *language, - int name_id, int is_default); + const char *varname, int name_id, int is_default); void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, int avg_bandwidth, const char *filename, const char *agroup, -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 1/3] aarch64/vvc: Add w_avg
From: Zhao Zhili w_avg_8_2x2_c: 0.0 ( 0.00x) w_avg_8_2x2_neon:0.0 ( 0.00x) w_avg_8_4x4_c: 0.2 ( 1.00x) w_avg_8_4x4_neon:0.0 ( 0.00x) w_avg_8_8x8_c: 1.2 ( 1.00x) w_avg_8_8x8_neon:0.2 ( 5.00x) w_avg_8_16x16_c: 4.2 ( 1.00x) w_avg_8_16x16_neon: 0.8 ( 5.67x) w_avg_8_32x32_c:16.2 ( 1.00x) w_avg_8_32x32_neon: 2.5 ( 6.50x) w_avg_8_64x64_c:64.5 ( 1.00x) w_avg_8_64x64_neon: 9.0 ( 7.17x) w_avg_8_128x128_c: 269.5 ( 1.00x) w_avg_8_128x128_neon: 35.5 ( 7.59x) w_avg_10_2x2_c: 0.2 ( 1.00x) w_avg_10_2x2_neon: 0.2 ( 1.00x) w_avg_10_4x4_c: 0.2 ( 1.00x) w_avg_10_4x4_neon: 0.2 ( 1.00x) w_avg_10_8x8_c: 1.0 ( 1.00x) w_avg_10_8x8_neon: 0.2 ( 4.00x) w_avg_10_16x16_c:4.2 ( 1.00x) w_avg_10_16x16_neon: 0.8 ( 5.67x) w_avg_10_32x32_c: 16.2 ( 1.00x) w_avg_10_32x32_neon: 2.5 ( 6.50x) w_avg_10_64x64_c: 66.2 ( 1.00x) w_avg_10_64x64_neon:10.0 ( 6.62x) w_avg_10_128x128_c:277.8 ( 1.00x) w_avg_10_128x128_neon: 39.8 ( 6.99x) w_avg_12_2x2_c: 0.0 ( 0.00x) w_avg_12_2x2_neon: 0.2 ( 0.00x) w_avg_12_4x4_c: 0.2 ( 1.00x) w_avg_12_4x4_neon: 0.0 ( 0.00x) w_avg_12_8x8_c: 1.2 ( 1.00x) w_avg_12_8x8_neon: 0.5 ( 2.50x) w_avg_12_16x16_c:4.8 ( 1.00x) w_avg_12_16x16_neon: 0.8 ( 6.33x) w_avg_12_32x32_c: 17.0 ( 1.00x) w_avg_12_32x32_neon: 2.8 ( 6.18x) w_avg_12_64x64_c: 64.0 ( 1.00x) w_avg_12_64x64_neon:10.0 ( 6.40x) w_avg_12_128x128_c:269.2 ( 1.00x) w_avg_12_128x128_neon: 42.0 ( 6.41x) --- libavcodec/aarch64/vvc/dsp_init.c | 34 +++ libavcodec/aarch64/vvc/inter.S| 99 +-- 2 files changed, 116 insertions(+), 17 deletions(-) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index ad767d17e2..41d0e02d62 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -52,6 +52,37 @@ void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1, int width, int height); +void ff_vvc_w_avg_8_neon(uint8_t *_dst, ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + int width, int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_10_neon(uint8_t *_dst, ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + int width, int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_12_neon(uint8_t *_dst, ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + int width, int height, + uintptr_t w0_w1, uintptr_t offset_shift); +/* When passing arguments to functions, Apple platforms diverge from the ARM64 + * standard ABI, that we can't implement the function directly in asm. + */ +#define W_AVG_FUN(bit_depth) \ +static void vvc_w_avg_ ## bit_depth(uint8_t *dst, ptrdiff_t dst_stride, \ +const int16_t *src0, const int16_t *src1, int width, int height, \ +int denom, int w0, int w1, int o0, int o1) \ +{ \ +const int shift = denom + FFMAX(3, 15 - bit_depth); \ +const int offset = ((o0 + o1) * (1 << (bit_depth - 8)) + 1) * (1 << (shift - 1)); \ +uintptr_t w0_w1 = ((uintptr_t)w0 << 32) | (uint32_t)w1; \ +uintptr_t offset_shift = ((uintptr_t)offset << 32) | (uint32_t)shift; \ +ff_vvc_w_avg_ ## bit_dep
[FFmpeg-devel] [PATCH v3 3/3] aarch64/vvc: Add dmvr
From: Zhao Zhili dmvr_8_12x20_c: 1.5 ( 1.00x) dmvr_8_12x20_neon: 0.2 ( 6.56x) dmvr_8_20x12_c: 1.0 ( 1.00x) dmvr_8_20x12_neon: 0.2 ( 4.33x) dmvr_8_20x20_c: 1.7 ( 1.00x) dmvr_8_20x20_neon: 0.5 ( 3.63x) dmvr_12_12x20_c: 2.2 ( 1.00x) dmvr_12_12x20_neon: 0.5 ( 4.68x) dmvr_12_20x12_c: 2.0 ( 1.00x) dmvr_12_20x12_neon: 0.5 ( 4.16x) dmvr_12_20x20_c: 3.7 ( 1.00x) dmvr_12_20x20_neon: 0.7 ( 5.14x) --- libavcodec/aarch64/vvc/dsp_init.c | 4 ++ libavcodec/aarch64/vvc/inter.S| 87 ++- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index 56226ae802..4f7ef65aa7 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -88,6 +88,8 @@ W_AVG_FUN(12) const uint8_t *_src, ptrdiff_t _src_stride, int height, \ intptr_t mx, intptr_t my, int width); +DMVR_FUN(, 8) +DMVR_FUN(, 12) DMVR_FUN(hv_, 8) DMVR_FUN(hv_, 10) DMVR_FUN(hv_, 12) @@ -164,6 +166,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) c->inter.avg = ff_vvc_avg_8_neon; c->inter.w_avg = vvc_w_avg_8; +c->inter.dmvr[0][0] = ff_vvc_dmvr_8_neon; c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon; for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++) @@ -213,6 +216,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) } else if (bd == 12) { c->inter.avg = ff_vvc_avg_12_neon; c->inter.w_avg = vvc_w_avg_12; +c->inter.dmvr[0][0] = ff_vvc_dmvr_12_neon; c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon; c->alf.filter[LUMA] = alf_filter_luma_12_neon; diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S index 4fc8def133..b6b079b569 100644 --- a/libavcodec/aarch64/vvc/inter.S +++ b/libavcodec/aarch64/vvc/inter.S @@ -235,7 +235,7 @@ vvc_avg w_avg, 12 * x5: intptr_t my * w6: int width */ -function ff_vvc_dmvr_hv_8_neon, export=1 +function ff_vvc_dmvr_8_neon, export=1 dst .req x0 src .req x1 src_stride .req x2 @@ -243,6 +243,91 @@ function ff_vvc_dmvr_hv_8_neon, export=1 mx .req x4 my .req x5 width .req w6 + +sxtwx6, w6 +mov x7, #(VVC_MAX_PB_SIZE * 2 + 8) +cmp width, #16 +sub src_stride, src_stride, x6 +csetw15, gt // width > 16 +moviv16.8h, #2 // DMVR_SHIFT +sub x7, x7, x6, lsl #1 +1: +cbz w15, 2f +ldr q0, [src], #16 +uxtlv1.8h, v0.8b +uxtl2 v2.8h, v0.16b +ushlv1.8h, v1.8h, v16.8h +ushlv2.8h, v2.8h, v16.8h +stp q1, q2, [dst], #32 +b 3f +2: +ldr d0, [src], #8 +uxtlv1.8h, v0.8b +ushlv1.8h, v1.8h, v16.8h +str q1, [dst], #16 +3: +subsheight, height, #1 +ldr s3, [src], #4 +uxtlv4.8h, v3.8b +ushlv4.4h, v4.4h, v16.4h +st1 {v4.4h}, [dst], x7 + +add src, src, src_stride +b.ne1b + +ret +endfunc + +function ff_vvc_dmvr_12_neon, export=1 +sxtwx6, w6 +mov x7, #(VVC_MAX_PB_SIZE * 2 + 8) +cmp width, #16 +sub src_stride, src_stride, x6, lsl #1 +csetw15, gt // width > 16 +moviv16.8h, #2 // offset4 +sub x7, x7, x6, lsl #1 +1: +cbz w15, 2f +ldp q0, q1, [src], #32 +uaddl v2.4s, v0.4h, v16.4h +uaddl2 v3.4s, v0.8h, v16.8h +uaddl v4.4s, v1.4h, v16.4h +uaddl2 v5.4s, v1.8h, v16.8h +ushrv2.4s, v2.4s, #2 +ushrv3.4s, v3.4s, #2 +ushrv4.4s, v4.4s, #2 +ushrv5.4s, v5.4s, #2 +uqxtn v2.4h, v2.4s +uqxtn2 v2.8h, v3.4s +uqxtn v4.4h, v4.4s +uqxtn2 v4.8h, v5.4s + +stp q2, q4, [dst], #32 +b
[FFmpeg-devel] [PATCH v3 1/3] aarch64/vvc: Add w_avg
From: Zhao Zhili w_avg_8_2x2_c: 0.0 ( 0.00x) w_avg_8_2x2_neon:0.0 ( 0.00x) w_avg_8_4x4_c: 0.2 ( 1.00x) w_avg_8_4x4_neon:0.0 ( 0.00x) w_avg_8_8x8_c: 1.2 ( 1.00x) w_avg_8_8x8_neon:0.2 ( 5.00x) w_avg_8_16x16_c: 4.2 ( 1.00x) w_avg_8_16x16_neon: 0.8 ( 5.67x) w_avg_8_32x32_c:16.2 ( 1.00x) w_avg_8_32x32_neon: 2.5 ( 6.50x) w_avg_8_64x64_c:64.5 ( 1.00x) w_avg_8_64x64_neon: 9.0 ( 7.17x) w_avg_8_128x128_c: 269.5 ( 1.00x) w_avg_8_128x128_neon: 35.5 ( 7.59x) w_avg_10_2x2_c: 0.2 ( 1.00x) w_avg_10_2x2_neon: 0.2 ( 1.00x) w_avg_10_4x4_c: 0.2 ( 1.00x) w_avg_10_4x4_neon: 0.2 ( 1.00x) w_avg_10_8x8_c: 1.0 ( 1.00x) w_avg_10_8x8_neon: 0.2 ( 4.00x) w_avg_10_16x16_c:4.2 ( 1.00x) w_avg_10_16x16_neon: 0.8 ( 5.67x) w_avg_10_32x32_c: 16.2 ( 1.00x) w_avg_10_32x32_neon: 2.5 ( 6.50x) w_avg_10_64x64_c: 66.2 ( 1.00x) w_avg_10_64x64_neon:10.0 ( 6.62x) w_avg_10_128x128_c:277.8 ( 1.00x) w_avg_10_128x128_neon: 39.8 ( 6.99x) w_avg_12_2x2_c: 0.0 ( 0.00x) w_avg_12_2x2_neon: 0.2 ( 0.00x) w_avg_12_4x4_c: 0.2 ( 1.00x) w_avg_12_4x4_neon: 0.0 ( 0.00x) w_avg_12_8x8_c: 1.2 ( 1.00x) w_avg_12_8x8_neon: 0.5 ( 2.50x) w_avg_12_16x16_c:4.8 ( 1.00x) w_avg_12_16x16_neon: 0.8 ( 6.33x) w_avg_12_32x32_c: 17.0 ( 1.00x) w_avg_12_32x32_neon: 2.8 ( 6.18x) w_avg_12_64x64_c: 64.0 ( 1.00x) w_avg_12_64x64_neon:10.0 ( 6.40x) w_avg_12_128x128_c:269.2 ( 1.00x) w_avg_12_128x128_neon: 42.0 ( 6.41x) --- libavcodec/aarch64/vvc/dsp_init.c | 34 +++ libavcodec/aarch64/vvc/inter.S| 99 +-- 2 files changed, 116 insertions(+), 17 deletions(-) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index ad767d17e2..41d0e02d62 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -52,6 +52,37 @@ void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1, int width, int height); +void ff_vvc_w_avg_8_neon(uint8_t *_dst, ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + int width, int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_10_neon(uint8_t *_dst, ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + int width, int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_12_neon(uint8_t *_dst, ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + int width, int height, + uintptr_t w0_w1, uintptr_t offset_shift); +/* When passing arguments to functions, Apple platforms diverge from the ARM64 + * standard ABI, that we can't implement the function directly in asm. + */ +#define W_AVG_FUN(bit_depth) \ +static void vvc_w_avg_ ## bit_depth(uint8_t *dst, ptrdiff_t dst_stride, \ +const int16_t *src0, const int16_t *src1, int width, int height, \ +int denom, int w0, int w1, int o0, int o1) \ +{ \ +const int shift = denom + FFMAX(3, 15 - bit_depth); \ +const int offset = ((o0 + o1) * (1 << (bit_depth - 8)) + 1) * (1 << (shift - 1)); \ +uintptr_t w0_w1 = ((uintptr_t)w0 << 32) | (uint32_t)w1; \ +uintptr_t offset_shift = ((uintptr_t)offset << 32) | (uint32_t)shift; \ +ff_vvc_w_avg_ ## bit_dep
[FFmpeg-devel] [PATCH v3 0/3] aarch64/vvc add w_avg and dmvr/dmvr_hv
From: Zhao Zhili v3: 1. Remove some const modifier in function prototypes 2. Use 'uaddl' to replace 'uxtl then add' in patch 3/3 Zhao Zhili (3): aarch64/vvc: Add w_avg aarch64/vvc: Add dmvr_hv aarch64/vvc: Add dmvr libavcodec/aarch64/vvc/dsp_init.c | 50 +++ libavcodec/aarch64/vvc/inter.S| 491 -- 2 files changed, 524 insertions(+), 17 deletions(-) -- 2.46.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 14/17] doc/examples/decode_filter_audio: switch to new buffersink options
Use a mix of av_opt_set() and av_opt_set_array() to demonstrate different ways the options can be set. --- doc/examples/decode_filter_audio.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/examples/decode_filter_audio.c b/doc/examples/decode_filter_audio.c index 6d148f7ab4..03e13ef66f 100644 --- a/doc/examples/decode_filter_audio.c +++ b/doc/examples/decode_filter_audio.c @@ -96,8 +96,7 @@ static int init_filters(const char *filters_descr) const AVFilter *abuffersink = avfilter_get_by_name("abuffersink"); AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); -static const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; -static const int out_sample_rates[] = { 8000, -1 }; +static const int out_sample_rate = 8000; const AVFilterLink *outlink; AVRational time_base = fmt_ctx->streams[audio_stream_index]->time_base; @@ -130,22 +129,22 @@ static int init_filters(const char *filters_descr) goto end; } -ret = av_opt_set_int_list(buffersink_ctx, "sample_fmts", out_sample_fmts, -1, - AV_OPT_SEARCH_CHILDREN); +ret = av_opt_set(buffersink_ctx, "sample_formats", "s16", + AV_OPT_SEARCH_CHILDREN); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n"); goto end; } -ret = av_opt_set(buffersink_ctx, "ch_layouts", "mono", - AV_OPT_SEARCH_CHILDREN); +ret = av_opt_set(buffersink_ctx, "channel_layouts", "mono", + AV_OPT_SEARCH_CHILDREN); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n"); goto end; } -ret = av_opt_set_int_list(buffersink_ctx, "sample_rates", out_sample_rates, -1, - AV_OPT_SEARCH_CHILDREN); +ret = av_opt_set_array(buffersink_ctx, "samplerates", AV_OPT_SEARCH_CHILDREN, + 0, 1, AV_OPT_TYPE_INT, &out_sample_rate); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n"); goto end; -- 2.43.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 13/17] lavfi/buffersink: add array-type options to replace "int-list" ones
"int-list" options are a hack that provides rudimentary support for array-type options by treating them as byte arrays (i.e. AV_OPT_TYPE_BINARY). Since we now have proper array-type options, they should replace "int-list" everywhere (which happens to be just buffersink). --- doc/APIchanges | 18 libavfilter/buffersink.c| 162 libavfilter/buffersink.h| 21 ++--- libavfilter/version.h | 2 +- libavfilter/version_major.h | 1 + 5 files changed, 175 insertions(+), 29 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index ddd4e6c9e0..a79353f79b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,24 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-xx - xx - lavfi 10.6.100 + Buffersink now has array-type options +- pixel_formats +- colorspaces +- colorranges + replacing the int-list options +- pix_fmts +- color_spaces +- color_ranges + abuffersink now has array-type options +- sample_formats +- samplerates +- channel_layouts + replacing the int-list/string options +- sample_fmts +- sample_rates +- ch_layouts + 8< - FFmpeg 7.1 was cut here 8< - 2024-09-23 - 6940a6de2f0 - lavu 59.38.100 - frame.h diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index af4dc38792..0cfac2abd5 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -28,6 +28,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/common.h" #include "libavutil/internal.h" +#include "libavutil/mem.h" #include "libavutil/opt.h" #include "audio.h" @@ -45,26 +46,46 @@ typedef struct BufferSinkContext { unsigned frame_size; /* only used for video */ +#if FF_API_BUFFERSINK_OPTS enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats int pixel_fmts_size; enum AVColorSpace *color_spaces;///< list of accepted color spaces int color_spaces_size; enum AVColorRange *color_ranges;///< list of accepted color ranges int color_ranges_size; +#endif + +enum AVPixelFormat *pixel_formats; +unsigned nb_pixel_formats; + +int*colorspaces; +unsigned nb_colorspaces; + +int*colorranges; +unsigned nb_colorranges; /* only used for audio */ +#if FF_API_BUFFERSINK_OPTS enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats int sample_fmts_size; char *channel_layouts_str; ///< list of accepted channel layouts int all_channel_counts; int *sample_rates; ///< list of accepted sample rates int sample_rates_size; +#endif + +enum AVSampleFormat *sample_formats; +unsigned nb_sample_formats; + +int *samplerates; +unsigned nb_samplerates; + +AVChannelLayout *channel_layouts; +unsigned nb_channel_layouts; AVFrame *peeked_frame; } BufferSinkContext; -#define NB_ITEMS(list) (list ## _size / sizeof(*list)) - int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame) { return av_buffersink_get_frame_flags(ctx, frame, 0); @@ -138,6 +159,39 @@ static av_cold int common_init(AVFilterContext *ctx) return 0; } +#define TERMINATE_ARRAY(arr, val) \ +if (s->arr) { \ +void *tmp = av_realloc_array(s->arr, s->nb_ ## arr + 1, sizeof(*s->arr)); \ +if (!tmp) \ +return AVERROR(ENOMEM); \ +s->arr = tmp; \ +s->arr[s->nb_ ## arr] = val; \ +} + +static int init_video(AVFilterContext *ctx) +{ +BufferSinkContext *s = ctx->priv; + +TERMINATE_ARRAY(pixel_formats, AV_PIX_FMT_NONE); +TERMINATE_ARRAY(colorranges, -1); +TERMINATE_ARRAY(colorspaces, -1); + +return common_init(ctx); +} + +static int init_audio(AVFilterContext *ctx) +{ +BufferSinkContext *s = ctx->priv; + +TERMINATE_ARRAY(sample_formats, AV_SAMPLE_FMT_NONE); +TERMINATE_ARRAY(samplerates, -1); +TERMINATE_ARRAY(channel_layouts, (AVChannelLayout){ .nb_channels = 0 }); + +return common_init(ctx); +} + +#undef TERMINATE_ARRAY + static void uninit(AVFilterContext *ctx) { BufferSinkContext *buf = ctx->priv; @@ -235,6 +289,9 @@ int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out return 0; } +#if FF_API_BUFFERSINK_OPTS +#define NB_ITEMS(list) (list ## _size / sizeof(*list)) + #define CHECK_LIST_SIZE(field) \ if (buf->field ## _size % sizeof(*bu
[FFmpeg-devel] [PATCH 15/17] doc/examples/decode_filter_video: switch to new buffersink options
--- doc/examples/decode_filter_video.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/examples/decode_filter_video.c b/doc/examples/decode_filter_video.c index 4a5247dbf2..aacc91c2f7 100644 --- a/doc/examples/decode_filter_video.c +++ b/doc/examples/decode_filter_video.c @@ -99,7 +99,6 @@ static int init_filters(const char *filters_descr) AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); AVRational time_base = fmt_ctx->streams[video_stream_index]->time_base; -enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; filter_graph = avfilter_graph_alloc(); if (!outputs || !inputs || !filter_graph) { @@ -129,8 +128,8 @@ static int init_filters(const char *filters_descr) goto end; } -ret = av_opt_set_int_list(buffersink_ctx, "pix_fmts", pix_fmts, - AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN); +ret = av_opt_set(buffersink_ctx, "pixel_formats", "gray8", + AV_OPT_SEARCH_CHILDREN); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n"); goto end; -- 2.43.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 12/17] lavu/opt: avoid accidentally propagating spurious errors
An error from read_number() is non-fatal here and should not be forwarded. --- libavutil/opt.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 02ed9d9fe9..93f2bb1320 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -2343,13 +2343,15 @@ int av_opt_set_array(void *obj, const char *name, int search_flags, int64_t intnum = 1; if (val_type == TYPE_BASE(o->type)) { +int err; + ret = opt_copy_elem(obj, val_type, dst, src); if (ret < 0) goto fail; // validate the range for numeric options -ret = read_number(o, dst, &num, &den, &intnum); -if (ret >= 0 && TYPE_BASE(o->type) != AV_OPT_TYPE_FLAGS && +err = read_number(o, dst, &num, &den, &intnum); +if (err >= 0 && TYPE_BASE(o->type) != AV_OPT_TYPE_FLAGS && (!den || o->max * den < num * intnum || o->min * den > num * intnum)) { num = den ? num * intnum / den : (num && intnum ? INFINITY : NAN); av_log(obj, AV_LOG_ERROR, "Cannot set array element %u for " -- 2.43.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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [Uncompressed MP4] Write uncC Tag
Hello, This patch is more of a RFC. I'm interested in generating uncompressed MP4 files in FFMPEG according to ISO/IEC 23001-17:2024 and wrote this as a first step towards implementation. Any feedback or help would be greatly appreciated. Thanks On Tue, Sep 24, 2024 at 2:51 PM Devon Sookhoo wrote: > From 5767e173414432d6079b1b581121622e874a26cd Mon Sep 17 00:00:00 2001 > From: dukesook > Date: Tue, 24 Sep 2024 12:27:31 -0600 > Subject: [PATCH] mov_write_uncC_tag() > > Initial function for writing the uncC, or uncopmressed codec box > --- > libavformat/movenc.c | 52 > 1 file changed, 52 insertions(+) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index d20e45cf81..da40442726 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -2602,6 +2602,58 @@ static int mov_write_aux_tag(AVIOContext *pb, const > char *aux_type) > return update_size(pb, pos); > } > > +static int mov_write_uncC_component(AVIOContext *pb, uint16_t index, > uint8_t bit_depth_minus_one, uint8_t format, uint8_t align_size) { > +avio_wb16(pb, index); > +avio_w8(pb, bit_depth_minus_one); > +avio_w8(pb, format); > +avio_w8(pb, align_size); > +return 0; > +} > + > +static int mov_write_uncC_tag(AVFormatContext *s, AVIOContext *pb, > MOVMuxContext *mov, MOVTrack *track) { > +int64_t pos = avio_tell(pb); > +uint8_t version = 0x0; > + > +avio_wb32(pb, 0); /* size */ > +ffio_wfourcc(pb, "uncC"); > + > +//FULL BOX > +avio_w8(pb, 0x00); // Flags > +avio_wb24(pb, 0x00); // Version > + > +avio_wb32(pb, 0x); // profile > + > +if (version == 1) { > +return update_size(pb, pos); > +} > +else if (version == 0) { > +avio_wb32(pb, 0x03); // component_count > +mov_write_uncC_component(pb, 0x, 0x07, 0x00, 0x00); //Red > +mov_write_uncC_component(pb, 0x0001, 0x07, 0x00, 0x00); //Green > +mov_write_uncC_component(pb, 0x0002, 0x07, 0x00, 0x00); //Blue > + > +avio_w8(pb, 0x00); //sampling_type. 0 = No subsampling > +avio_w8(pb, 0x00); //interleave_type. 0 = Planar, 1 = interleaved > +avio_w8(pb, 0x00); //block_size; > + > +// Pixel Layout Flags > +// bit(1) components_little_endian; > +// bit(1) block_pad_last; > +// bit(1) block_little_endian; > +// bit(1) block_reversed; > +// bit(1) pad_unknown; > +// bit(3) reserved = 0; > +avio_w8(pb, 0X00); > + > +avio_wb32(pb, 0x); // pixel_size; > +avio_wb32(pb, 0x); // row_align_size; > +avio_wb32(pb, 0x); // tile_align_size; > +avio_wb32(pb, 0x); // num_tile_cols_minus_one; > +avio_wb32(pb, 0x); // num_tile_rows_minus_one; > +} > +return update_size(pb, pos); > +} > + > static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, > MOVMuxContext *mov, MOVTrack *track) > { > int ret = AVERROR_BUG; > -- > 2.34.1 > > > > *ISO/IEC 23001-17:2024 Section 5.2.2 Syntax* > aligned(8) class UncompressedFrameConfigBox extends FullBox('uncC', 0, 0) > { > unsigned int(32) profile; > unsigned int(16) component_count; > { > unsigned int(16) component_index; > unsigned int(8) component_bit_depth_minus_one; > unsigned int(8) component_format; > unsigned int(8) component_align_size; > } [component_count]; > unsigned int(8) sampling_type; > unsigned int(8) interleave_type; > unsigned int(8) block_size; > bit(1) components_little_endian; > bit(1) block_pad_lsb; > bit(1) block_little_endian; > bit(1) block_reversed; > bit(1) pad_unknown; > bit(3) reserved = 0; > unsigned int(8) pixel_size; > unsigned int(32) row_align_size; > unsigned int(32) tile_align_size; > unsigned int(32) num_tile_cols_minus_one; > unsigned int(32) num_tile_rows_minus_one; > } > > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/17] lavu/opt: add missing 'else'
--- libavutil/opt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 45db4f484f..02ed9d9fe9 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -2362,7 +2362,7 @@ int av_opt_set_array(void *obj, const char *name, int search_flags, ret = opt_set_elem(obj, target_obj, o, *(const char **)src, dst); if (ret < 0) goto fail; -} if (val_type == AV_OPT_TYPE_INT || +} else if (val_type == AV_OPT_TYPE_INT || val_type == AV_OPT_TYPE_INT64|| val_type == AV_OPT_TYPE_FLOAT|| val_type == AV_OPT_TYPE_DOUBLE || -- 2.43.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 2/3] aarch64/vvc: Add dmvr_hv
From: Zhao Zhili dmvr_hv_8_12x20_c: 8.0 ( 1.00x) dmvr_hv_8_12x20_neon:1.2 ( 6.62x) dmvr_hv_8_20x12_c: 8.0 ( 1.00x) dmvr_hv_8_20x12_neon:0.9 ( 8.37x) dmvr_hv_8_20x20_c: 12.9 ( 1.00x) dmvr_hv_8_20x20_neon:1.7 ( 7.62x) dmvr_hv_10_12x20_c: 7.0 ( 1.00x) dmvr_hv_10_12x20_neon: 1.7 ( 4.09x) dmvr_hv_10_20x12_c: 7.0 ( 1.00x) dmvr_hv_10_20x12_neon: 1.7 ( 4.09x) dmvr_hv_10_20x20_c: 11.2 ( 1.00x) dmvr_hv_10_20x20_neon: 2.7 ( 4.15x) dmvr_hv_12_12x20_c: 6.5 ( 1.00x) dmvr_hv_12_12x20_neon: 1.7 ( 3.79x) dmvr_hv_12_20x12_c: 6.5 ( 1.00x) dmvr_hv_12_20x12_neon: 1.7 ( 3.79x) dmvr_hv_12_20x20_c: 10.2 ( 1.00x) dmvr_hv_12_20x20_neon: 2.2 ( 4.64x) --- libavcodec/aarch64/vvc/dsp_init.c | 12 ++ libavcodec/aarch64/vvc/inter.S| 307 ++ 2 files changed, 319 insertions(+) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index 41d0e02d62..56226ae802 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -83,6 +83,15 @@ W_AVG_FUN(8) W_AVG_FUN(10) W_AVG_FUN(12) +#define DMVR_FUN(fn, bd) \ +void ff_vvc_dmvr_ ## fn ## bd ## _neon(int16_t *dst, \ +const uint8_t *_src, ptrdiff_t _src_stride, int height, \ +intptr_t mx, intptr_t my, int width); + +DMVR_FUN(hv_, 8) +DMVR_FUN(hv_, 10) +DMVR_FUN(hv_, 12) + void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) { int cpu_flags = av_get_cpu_flags(); @@ -155,6 +164,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) c->inter.avg = ff_vvc_avg_8_neon; c->inter.w_avg = vvc_w_avg_8; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon; for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++) c->sao.band_filter[i] = ff_h26x_sao_band_filter_8x8_8_neon; @@ -196,12 +206,14 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) } else if (bd == 10) { c->inter.avg = ff_vvc_avg_10_neon; c->inter.w_avg = vvc_w_avg_10; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_10_neon; c->alf.filter[LUMA] = alf_filter_luma_10_neon; c->alf.filter[CHROMA] = alf_filter_chroma_10_neon; } else if (bd == 12) { c->inter.avg = ff_vvc_avg_12_neon; c->inter.w_avg = vvc_w_avg_12; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon; c->alf.filter[LUMA] = alf_filter_luma_12_neon; c->alf.filter[CHROMA] = alf_filter_chroma_12_neon; diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S index c4c6ab1a72..4fc8def133 100644 --- a/libavcodec/aarch64/vvc/inter.S +++ b/libavcodec/aarch64/vvc/inter.S @@ -226,3 +226,310 @@ vvc_avg avg, 12 vvc_avg w_avg, 8 vvc_avg w_avg, 10 vvc_avg w_avg, 12 + +/* x0: int16_t *dst + * x1: const uint8_t *_src + * x2: ptrdiff_t _src_stride + * w3: int height + * x4: intptr_t mx + * x5: intptr_t my + * w6: int width + */ +function ff_vvc_dmvr_hv_8_neon, export=1 +dst .req x0 +src .req x1 +src_stride .req x2 +height .req w3 +mx .req x4 +my .req x5 +width .req w6 +tmp0.req x7 +tmp1.req x8 + +sub sp, sp, #(VVC_MAX_PB_SIZE * 4) + +movrel x9, X(ff_vvc_inter_luma_dmvr_filters) +add x12, x9, mx, lsl #1 +ldrbw10, [x12] +ldrbw11, [x12, #1] +mov tmp0, sp +add tmp1, tmp0, #(VVC_MAX_PB_SIZE * 2) +// We know the value are positive +dup v0.8h, w10 // filter_x[0] +dup v1.8h, w11 // filter_x[1] + +add x12, x9, my, lsl #1 +ldrbw10, [x12] +ldrbw11, [x12, #1] +sxtwx6, w6 +moviv30.8h, #(1 << (8 - 7)) // offset1 +moviv31.8h, #8 // offset2 +dup v2.8h, w10 // filter_y[0] +dup v3.8h, w11 // filter_y[1] + +// Valid value for width can only be 8 + 4, 16 + 4 +cmp width, #16 +mov w10, #0 // start filter_y or not
[FFmpeg-devel] [PATCH 16/17] fftools/ffplay: switch to new buffersink options
--- fftools/ffplay.c | 30 -- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 349c6075da..6c3694a321 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -388,7 +388,6 @@ static const struct TextureFormatEntry { { AV_PIX_FMT_YUV420P,SDL_PIXELFORMAT_IYUV }, { AV_PIX_FMT_YUYV422,SDL_PIXELFORMAT_YUY2 }, { AV_PIX_FMT_UYVY422,SDL_PIXELFORMAT_UYVY }, -{ AV_PIX_FMT_NONE, SDL_PIXELFORMAT_UNKNOWN }, }; static int opt_add_vfilter(void *optctx, const char *opt, const char *arg) @@ -895,7 +894,7 @@ static void get_sdl_pix_fmt_and_blendmode(int format, Uint32 *sdl_pix_fmt, SDL_B format == AV_PIX_FMT_BGR32 || format == AV_PIX_FMT_BGR32_1) *sdl_blendmode = SDL_BLENDMODE_BLEND; -for (i = 0; i < FF_ARRAY_ELEMS(sdl_texture_format_map) - 1; i++) { +for (i = 0; i < FF_ARRAY_ELEMS(sdl_texture_format_map); i++) { if (format == sdl_texture_format_map[i].format) { *sdl_pix_fmt = sdl_texture_format_map[i].texture_fmt; return; @@ -1874,14 +1873,13 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c return AVERROR(ENOMEM); for (i = 0; i < renderer_info.num_texture_formats; i++) { -for (j = 0; j < FF_ARRAY_ELEMS(sdl_texture_format_map) - 1; j++) { +for (j = 0; j < FF_ARRAY_ELEMS(sdl_texture_format_map); j++) { if (renderer_info.texture_formats[i] == sdl_texture_format_map[j].texture_fmt) { pix_fmts[nb_pix_fmts++] = sdl_texture_format_map[j].format; break; } } } -pix_fmts[nb_pix_fmts] = AV_PIX_FMT_NONE; while ((e = av_dict_iterate(sws_dict, e))) { if (!strcmp(e->key, "sws_flags")) { @@ -1926,10 +1924,13 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c goto fail; } -if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0) +if ((ret = av_opt_set_array(filt_out, "pixel_formats", AV_OPT_SEARCH_CHILDREN, +0, nb_pix_fmts, AV_OPT_TYPE_PIXEL_FMT, pix_fmts)) < 0) goto fail; if (!vk_renderer && -(ret = av_opt_set_int_list(filt_out, "color_spaces", sdl_supported_color_spaces, AVCOL_SPC_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 0) +(ret = av_opt_set_array(filt_out, "colorspaces", AV_OPT_SEARCH_CHILDREN, +0, FF_ARRAY_ELEMS(sdl_supported_color_spaces), +AV_OPT_TYPE_INT, sdl_supported_color_spaces)) < 0) goto fail; ret = avfilter_init_dict(filt_out, NULL); @@ -2003,8 +2004,6 @@ fail: static int configure_audio_filters(VideoState *is, const char *afilters, int force_output_format) { -static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }; -int sample_rates[2] = { 0, -1 }; AVFilterContext *filt_asrc = NULL, *filt_asink = NULL; char aresample_swr_opts[512] = ""; const AVDictionaryEntry *e = NULL; @@ -2045,20 +2044,15 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for goto end; } -if ((ret = av_opt_set_int_list(filt_asink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0) -goto end; -if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 1, AV_OPT_SEARCH_CHILDREN)) < 0) +if ((ret = av_opt_set(filt_asink, "sample_formats", "s16", AV_OPT_SEARCH_CHILDREN)) < 0) goto end; if (force_output_format) { -av_bprint_clear(&bp); -av_channel_layout_describe_bprint(&is->audio_tgt.ch_layout, &bp); -sample_rates [0] = is->audio_tgt.freq; -if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 0, AV_OPT_SEARCH_CHILDREN)) < 0) +if ((ret = av_opt_set_array(filt_asink, "channel_layouts", AV_OPT_SEARCH_CHILDREN, +0, 1, AV_OPT_TYPE_CHLAYOUT, &is->audio_tgt.ch_layout)) < 0) goto end; -if ((ret = av_opt_set(filt_asink, "ch_layouts", bp.str, AV_OPT_SEARCH_CHILDREN)) < 0) -goto end; -if ((ret = av_opt_set_int_list(filt_asink, "sample_rates" , sample_rates , -1, AV_OPT_SEARCH_CHILDREN)) < 0) +if ((ret = av_opt_set_array(filt_asink, "samplerates", AV_OPT_SEARCH_CHILDREN, +0, 1, AV_OPT_TYPE_INT, &is->audio_tgt.freq)) < 0) goto end; } -- 2.43.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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] aarch64/vvc: Add w_avg
On Mon, 23 Sep 2024, Zhao Zhili wrote: From: Zhao Zhili w_avg_8_2x2_c: 0.0 ( 0.00x) w_avg_8_2x2_neon:0.0 ( 0.00x) w_avg_8_4x4_c: 0.2 ( 1.00x) w_avg_8_4x4_neon:0.0 ( 0.00x) w_avg_8_8x8_c: 1.2 ( 1.00x) w_avg_8_8x8_neon:0.2 ( 5.00x) w_avg_8_16x16_c: 4.2 ( 1.00x) w_avg_8_16x16_neon: 0.8 ( 5.67x) w_avg_8_32x32_c:16.2 ( 1.00x) w_avg_8_32x32_neon: 2.5 ( 6.50x) w_avg_8_64x64_c:64.5 ( 1.00x) w_avg_8_64x64_neon: 9.0 ( 7.17x) w_avg_8_128x128_c: 269.5 ( 1.00x) w_avg_8_128x128_neon: 35.5 ( 7.59x) w_avg_10_2x2_c: 0.2 ( 1.00x) w_avg_10_2x2_neon: 0.2 ( 1.00x) w_avg_10_4x4_c: 0.2 ( 1.00x) w_avg_10_4x4_neon: 0.2 ( 1.00x) w_avg_10_8x8_c: 1.0 ( 1.00x) w_avg_10_8x8_neon: 0.2 ( 4.00x) w_avg_10_16x16_c:4.2 ( 1.00x) w_avg_10_16x16_neon: 0.8 ( 5.67x) w_avg_10_32x32_c: 16.2 ( 1.00x) w_avg_10_32x32_neon: 2.5 ( 6.50x) w_avg_10_64x64_c: 66.2 ( 1.00x) w_avg_10_64x64_neon:10.0 ( 6.62x) w_avg_10_128x128_c:277.8 ( 1.00x) w_avg_10_128x128_neon: 39.8 ( 6.99x) w_avg_12_2x2_c: 0.0 ( 0.00x) w_avg_12_2x2_neon: 0.2 ( 0.00x) w_avg_12_4x4_c: 0.2 ( 1.00x) w_avg_12_4x4_neon: 0.0 ( 0.00x) w_avg_12_8x8_c: 1.2 ( 1.00x) w_avg_12_8x8_neon: 0.5 ( 2.50x) w_avg_12_16x16_c:4.8 ( 1.00x) w_avg_12_16x16_neon: 0.8 ( 6.33x) w_avg_12_32x32_c: 17.0 ( 1.00x) w_avg_12_32x32_neon: 2.8 ( 6.18x) w_avg_12_64x64_c: 64.0 ( 1.00x) w_avg_12_64x64_neon:10.0 ( 6.40x) w_avg_12_128x128_c:269.2 ( 1.00x) w_avg_12_128x128_neon: 42.0 ( 6.41x) --- libavcodec/aarch64/vvc/dsp_init.c | 34 +++ libavcodec/aarch64/vvc/inter.S| 99 +-- 2 files changed, 116 insertions(+), 17 deletions(-) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index ad767d17e2..b39ebb83fc 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -52,6 +52,37 @@ void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1, int width, int height); +void ff_vvc_w_avg_8_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); Including "const" on scalar parameters is entirely redundant, and we don't prescribe use of that elsewhere in ffmpeg, and just makes the whole declaration more noisy. +void ff_vvc_w_avg_10_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_12_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); +/* When passing arguments to functions, Apple platforms diverge from the ARM64 + * standard ABI, that we can't implement the function directly in asm. + */ It's fully possible to implement that in assembly, but it usually requires ugly ifdefs. That said, I'm ok with this kind of wrapper, as it avoids the problem kinda neatly, but ifdefs in the assembly can also be needed at times. +#define W_AVG_FUN(bit_depth) \ +static void vvc_w_
Re: [FFmpeg-devel] [PATCH v2 2/3] aarch64/vvc: Add dmvr_hv
On Mon, 23 Sep 2024, Zhao Zhili wrote: From: Zhao Zhili dmvr_hv_8_12x20_c: 8.0 ( 1.00x) dmvr_hv_8_12x20_neon:1.2 ( 6.62x) dmvr_hv_8_20x12_c: 8.0 ( 1.00x) dmvr_hv_8_20x12_neon:0.9 ( 8.37x) dmvr_hv_8_20x20_c: 12.9 ( 1.00x) dmvr_hv_8_20x20_neon:1.7 ( 7.62x) dmvr_hv_10_12x20_c: 7.0 ( 1.00x) dmvr_hv_10_12x20_neon: 1.7 ( 4.09x) dmvr_hv_10_20x12_c: 7.0 ( 1.00x) dmvr_hv_10_20x12_neon: 1.7 ( 4.09x) dmvr_hv_10_20x20_c: 11.2 ( 1.00x) dmvr_hv_10_20x20_neon: 2.7 ( 4.15x) dmvr_hv_12_12x20_c: 6.5 ( 1.00x) dmvr_hv_12_12x20_neon: 1.7 ( 3.79x) dmvr_hv_12_20x12_c: 6.5 ( 1.00x) dmvr_hv_12_20x12_neon: 1.7 ( 3.79x) dmvr_hv_12_20x20_c: 10.2 ( 1.00x) dmvr_hv_12_20x20_neon: 2.2 ( 4.64x) --- libavcodec/aarch64/vvc/dsp_init.c | 12 ++ libavcodec/aarch64/vvc/inter.S| 307 ++ 2 files changed, 319 insertions(+) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index b39ebb83fc..995e26d163 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -83,6 +83,15 @@ W_AVG_FUN(8) W_AVG_FUN(10) W_AVG_FUN(12) +#define DMVR_FUN(fn, bd) \ +void ff_vvc_dmvr_ ## fn ## bd ## _neon(int16_t *dst, \ +const uint8_t *_src, const ptrdiff_t _src_stride, const int height, \ +const intptr_t mx, const intptr_t my, const int width); Unnecessary const on scalar parameters + +DMVR_FUN(hv_, 8) +DMVR_FUN(hv_, 10) +DMVR_FUN(hv_, 12) + void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) { int cpu_flags = av_get_cpu_flags(); @@ -155,6 +164,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) c->inter.avg = ff_vvc_avg_8_neon; c->inter.w_avg = vvc_w_avg_8; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon; for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++) c->sao.band_filter[i] = ff_h26x_sao_band_filter_8x8_8_neon; @@ -196,12 +206,14 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) } else if (bd == 10) { c->inter.avg = ff_vvc_avg_10_neon; c->inter.w_avg = vvc_w_avg_10; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_10_neon; c->alf.filter[LUMA] = alf_filter_luma_10_neon; c->alf.filter[CHROMA] = alf_filter_chroma_10_neon; } else if (bd == 12) { c->inter.avg = ff_vvc_avg_12_neon; c->inter.w_avg = vvc_w_avg_12; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon; c->alf.filter[LUMA] = alf_filter_luma_12_neon; c->alf.filter[CHROMA] = alf_filter_chroma_12_neon; diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S index c4c6ab1a72..a0bb356f07 100644 --- a/libavcodec/aarch64/vvc/inter.S +++ b/libavcodec/aarch64/vvc/inter.S @@ -226,3 +226,310 @@ vvc_avg avg, 12 vvc_avg w_avg, 8 vvc_avg w_avg, 10 vvc_avg w_avg, 12 + +/* x0: int16_t *dst + * x1: const uint8_t *_src + * x2: const ptrdiff_t _src_stride + * w3: const int height + * x4: const intptr_t mx + * x5: const intptr_t my + * w6: const int width Unnecessary const + */ +function ff_vvc_dmvr_hv_8_neon, export=1 +dst .req x0 +src .req x1 +src_stride .req x2 +height .req w3 +mx .req x4 +my .req x5 +width .req w6 +tmp0.req x7 +tmp1.req x8 + +sub sp, sp, #(VVC_MAX_PB_SIZE * 4) + +movrel x9, X(ff_vvc_inter_luma_dmvr_filters) +add x12, x9, mx, lsl #1 +ldrbw10, [x12] +ldrbw11, [x12, #1] +mov tmp0, sp +add tmp1, tmp0, #(VVC_MAX_PB_SIZE * 2) +// We know the value are positive +dup v0.8h, w10 // filter_x[0] +dup v1.8h, w11 // filter_x[1] If we don't need these values in GPRs, we could also just do ld1r, although that requires incrementing the pointer (which probably can be done with a post-increment, [x12], #1) between the loads. Then again, I see you load 8 bits but you want them in 16 bit elements, so that would require a separate uxtl. So then I guess this use of GPRs for loading is reasonable. All in all, the patch seems fine, except for the unnecessary consts. // Martin
[FFmpeg-devel] [PATCH 1/3] avcodec: add an LCEVC merger bsf
Signed-off-by: James Almer --- doc/bitstream_filters.texi | 14 ++ libavcodec/bitstream_filters.c | 1 + libavcodec/bsf/Makefile | 1 + libavcodec/bsf/lcevc_merge_bsf.c | 273 +++ 4 files changed, 289 insertions(+) create mode 100644 libavcodec/bsf/lcevc_merge_bsf.c diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index e1cb87a522..b443890636 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -514,6 +514,20 @@ Please note that this filter is auto-inserted for MPEG-TS (muxer @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or @code{hevc}) output formats. +@section lcevc_merge + +Inject the payload of data packets from one stream as LCEVC side data +to video packets from another stream. Packets from either stream are +matched by PTS. Only the video packets with the merged data payload are +ever returned. + +@table @option +@item base_idx +stream index in the input packet to identify the video stream +@item enhancement_idx +stream index in the input packet to identify the data stream +@end table + @section imxdump Modifies the bitstream to fit in MOV and to be usable by the Final Cut diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index f923411bee..fdd4fcf01b 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -45,6 +45,7 @@ extern const FFBitStreamFilter ff_hapqa_extract_bsf; extern const FFBitStreamFilter ff_hevc_metadata_bsf; extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf; extern const FFBitStreamFilter ff_imx_dump_header_bsf; +extern const FFBitStreamFilter ff_lcevc_merge_bsf; extern const FFBitStreamFilter ff_media100_to_mjpegb_bsf; extern const FFBitStreamFilter ff_mjpeg2jpeg_bsf; extern const FFBitStreamFilter ff_mjpega_dump_header_bsf; diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile index 40b7fc6e9b..3d28da206b 100644 --- a/libavcodec/bsf/Makefile +++ b/libavcodec/bsf/Makefile @@ -22,6 +22,7 @@ OBJS-$(CONFIG_HEVC_METADATA_BSF) += bsf/h265_metadata.o OBJS-$(CONFIG_DOVI_RPU_BSF) += bsf/dovi_rpu.o OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF) += bsf/hevc_mp4toannexb.o OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= bsf/imx_dump_header.o +OBJS-$(CONFIG_LCEVC_MERGE_BSF)+= bsf/lcevc_merge_bsf.o OBJS-$(CONFIG_MEDIA100_TO_MJPEGB_BSF) += bsf/media100_to_mjpegb.o OBJS-$(CONFIG_MJPEG2JPEG_BSF) += bsf/mjpeg2jpeg.o OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += bsf/mjpega_dump_header.o diff --git a/libavcodec/bsf/lcevc_merge_bsf.c b/libavcodec/bsf/lcevc_merge_bsf.c new file mode 100644 index 00..269597bdf0 --- /dev/null +++ b/libavcodec/bsf/lcevc_merge_bsf.c @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2024 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/avassert.h" +#include "libavutil/attributes.h" +#include "libavutil/mem.h" +#include "libavutil/opt.h" +#include "libavutil/tree.h" + +#include "bsf.h" +#include "bsf_internal.h" +#include "container_fifo.h" + +typedef struct LCEVCMergeContext { +const AVClass *class; + +struct AVTreeNode *base; +struct AVTreeNode *enhancement; +ContainerFifo *nodes; + +int base_idx, enhancement_idx; +} LCEVCMergeContext; + +// AVTreeNode callbacks +static int cmp_insert(const void *_key, const void *_node) +{ +const AVPacket *key = _key, *node = _node; + +return FFDIFFSIGN(key->pts, node->pts); +} + +static int cmp_find(const void *_key, const void *_node) +{ +int64_t key = *(const int64_t *)_key; +const AVPacket *node = _node; + +return FFDIFFSIGN(key, node->pts); +} + +#define WARN_BUFFERED(type) \ +static int warn_##type##_buffered(void *logctx, void *elem) \ +{\ +const AVPacket *pkt = (const AVPacket *)elem;\ +av_log(logctx, AV_LOG_WARNING, #type" packet with PTS %"PRId64 \ + " left buffered at EOF\n", pkt->pts); \ +return 0;\ +} + +WARN_BUFFERED(base) +WARN_BUFFERED(enhance
Re: [FFmpeg-devel] [PATCH 3/4] avformat/mov: add referenced thumbnail streams to tile stream groups
Quoting James Almer (2024-09-26 16:33:48) > Use the reference information present in iref boxes of type thmb to include > the > relevant streams into a Tile Grid stream group. > This does not yet export the relation of a thumbnail and an independent stream > (not a grid). For this, a new Stream group type would probably be needed. So the stream group describing the tile grid would now also contain a single stream that is a thumbnail rather than a tile in the grid? That's not something I would expect. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/7] lavfi/buffersink: add a flag for retrieving stream parameters
James Almer (12024-09-25): > It still requires allocating it before using it, but since a normal > filterchain will have buffersrc -> [...] -> buffersink, the same allocated > struct can be used for both. A filter chain can have buffersinks but no buffersrc, if it uses other sources. Also, a dynamic allocation does the same damage to the code readability and reliability whether it is in a speed-critical part of the code or not. We should be trying to REMOVE instances where a dynamic allocation is necessary, not add to them. This consideration takes precedence over cosmetic considerations like internal consistency or adherence to established practices (aka coding like Java developers who see C for the first time). In this case, that means we should find a solution without dynamic allocation for buffersink and then implement it for buffersrc also rather than using the solution with dynamic allocation on both. And we should do that especially because it is very easy: two solutions came to me in the first few minutes, more could come. - Let callers allocate their structure as they wish, on the stack if necessary, pass sizeof(params) as an extra argument and use memcpy() to fetch/return it. - Have an instance of the struct in the buffersrc/sink and make it available for that use. Regards, -- Nicolas George ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Fix missing EXT-X-DISCONTINUITY tag in subtitle streams
Jonathan Baecker 于2024年9月26日周四 15:59写道: > > The EXT-X-DISCONTINUITY tag was not being added to subtitle streams, causing > synchronization issues. This patch ensures that the tag is applied > consistently across video and subtitle streams. > --- > libavformat/hlsenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 1e932b7..571d6b2 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -1668,7 +1668,7 @@ static int hls_window(AVFormatContext *s, int last, > VariantStream *vs) > ff_hls_write_playlist_header(hls->sub_m3u8_out, hls->version, > hls->allowcache, > target_duration, sequence, > PLAYLIST_TYPE_NONE, 0); > for (en = vs->segments; en; en = en->next) { > -ret = ff_hls_write_file_entry(hls->sub_m3u8_out, 0, > byterange_mode, > +ret = ff_hls_write_file_entry(hls->sub_m3u8_out, en->discont, > byterange_mode, >en->duration, 0, en->size, en->pos, >hls->baseurl, en->sub_filename, > NULL, 0, 0, 0); > if (ret < 0) { > -- > 2.46.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". LGTM Thanks ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avformat/avformat: add a new disposition to signal the stream is an HDR gainmap
Quoting James Almer (2024-09-26 14:06:25) > On 9/26/2024 3:00 AM, Anton Khirnov wrote: > > Quoting James Almer (2024-09-26 00:52:16) > >> HDR images photos taken by certain cameras split this as a separate image. > >> > >> Signed-off-by: James Almer > >> --- > >> libavformat/avformat.h | 5 + > >> libavformat/dump.c | 2 ++ > >> 2 files changed, 7 insertions(+) > >> > >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h > >> index 56c1c80289..6d9f5c4399 100644 > >> --- a/libavformat/avformat.h > >> +++ b/libavformat/avformat.h > >> @@ -718,6 +718,11 @@ typedef struct AVIndexEntry { > >>* Annex G/H, or HEVC Annex F). > >>*/ > >> #define AV_DISPOSITION_MULTILAYER (1 << 21) > >> +/** > >> + * The video stream contains an HDR gainmap. Only ever used with > >> + * AV_DISPOSITION_DEPENDENT. > >> + */ > >> +#define AV_DISPOSITION_GAINMAP (1 << 22) > > > > Presumably we want this information available in codecs and filters as > > well, so then should it not be side data instead? > > There is no other information than "This is a gainmap", and that's > container level information (Same as "This is a tile" for heif). How > would side data work for this? You could e.g. have side data that has no payload, and its presence signals the same information. > I'm including it in the tile grid stream group in patch 4/4, so that > should give the caller all the information they need. Assuming all they ever need is handle everything manually. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avformat/avformat: add a new disposition to signal the stream is an HDR gainmap
On 9/26/2024 11:17 AM, Anton Khirnov wrote: Quoting James Almer (2024-09-26 14:06:25) On 9/26/2024 3:00 AM, Anton Khirnov wrote: Quoting James Almer (2024-09-26 00:52:16) HDR images photos taken by certain cameras split this as a separate image. Signed-off-by: James Almer --- libavformat/avformat.h | 5 + libavformat/dump.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 56c1c80289..6d9f5c4399 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -718,6 +718,11 @@ typedef struct AVIndexEntry { * Annex G/H, or HEVC Annex F). */ #define AV_DISPOSITION_MULTILAYER (1 << 21) +/** + * The video stream contains an HDR gainmap. Only ever used with + * AV_DISPOSITION_DEPENDENT. + */ +#define AV_DISPOSITION_GAINMAP (1 << 22) Presumably we want this information available in codecs and filters as well, so then should it not be side data instead? There is no other information than "This is a gainmap", and that's container level information (Same as "This is a tile" for heif). How would side data work for this? You could e.g. have side data that has no payload, and its presence signals the same information. Is there precedent for this? Would it be a side data with size 0 (but data still pointing to an AVBufferRef)? I'm including it in the tile grid stream group in patch 4/4, so that should give the caller all the information they need. Assuming all they ever need is handle everything manually. I don't understand what you mean. A side data entry, assuming it's propagated to the decoder context and then the decoded frame, would indeed pass this information through but will still be missing what image this gainmap is for, so the caller still needs to be aware of it (This is what the group is for) and do some things manually, namely inserting an hypothetical filter for the merging process. OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 17/17] lavu: deprecate av_opt_set_int_list() and related infrastructure
It has no more users and is replaced by array-type options. --- doc/APIchanges | 5 + libavutil/avutil.h | 3 +++ libavutil/opt.h | 2 ++ libavutil/utils.c | 2 ++ libavutil/version.h | 1 + 5 files changed, 13 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index a79353f79b..f9a4d0e442 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-xx - xx - lavu 59 + Deprecate av_int_list_length_for_size(), av_int_list_length(), and + av_opt_set_int_list() without replacement. All AVOptions using these + should be replaced with AV_OPT_TYPE_FLAG_ARRAY. + 2024-09-xx - xx - lavfi 10.6.100 Buffersink now has array-type options - pixel_formats diff --git a/libavutil/avutil.h b/libavutil/avutil.h index d2900dcb48..ee709fbb2a 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -314,6 +314,7 @@ static inline void *av_x_if_null(const void *p, const void *x) return (void *)(intptr_t)(p ? p : x); } +#if FF_API_OPT_INT_LIST /** * Compute the length of an integer list. * @@ -322,6 +323,7 @@ static inline void *av_x_if_null(const void *p, const void *x) * @param listpointer to the list * @return length of the list, in elements, not counting the terminator */ +attribute_deprecated unsigned av_int_list_length_for_size(unsigned elsize, const void *list, uint64_t term) av_pure; @@ -334,6 +336,7 @@ unsigned av_int_list_length_for_size(unsigned elsize, */ #define av_int_list_length(list, term) \ av_int_list_length_for_size(sizeof(*(list)), list, term) +#endif /** * Return the fractional representation of the internal time base. diff --git a/libavutil/opt.h b/libavutil/opt.h index be189f7653..17374211a4 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -886,6 +886,7 @@ int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *layo */ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags); +#if FF_API_OPT_INT_LIST /** * Set a binary option to an integer list. * @@ -901,6 +902,7 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, in AVERROR(EINVAL) : \ av_opt_set_bin(obj, name, (const uint8_t *)(val), \ av_int_list_length(val, term) * sizeof(*(val)), flags)) +#endif /** * Add, replace, or remove elements for an array option. Which of these diff --git a/libavutil/utils.c b/libavutil/utils.c index 94d247bbee..162a4dee26 100644 --- a/libavutil/utils.c +++ b/libavutil/utils.c @@ -51,6 +51,7 @@ char av_get_picture_type_char(enum AVPictureType pict_type) } } +#if FF_API_OPT_INT_LIST unsigned av_int_list_length_for_size(unsigned elsize, const void *list, uint64_t term) { @@ -69,6 +70,7 @@ unsigned av_int_list_length_for_size(unsigned elsize, } return i; } +#endif char *av_fourcc_make_string(char *buf, uint32_t fourcc) { diff --git a/libavutil/version.h b/libavutil/version.h index 1ae3f4ef87..69519cfd06 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -115,6 +115,7 @@ #define FF_API_MOD_UINTP2 (LIBAVUTIL_VERSION_MAJOR < 60) #define FF_API_RISCV_FD_ZBA (LIBAVUTIL_VERSION_MAJOR < 60) #define FF_API_VULKAN_FIXED_QUEUES (LIBAVUTIL_VERSION_MAJOR < 60) +#define FF_API_OPT_INT_LIST (LIBAVUTIL_VERSION_MAJOR < 60) /** * @} -- 2.43.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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avformat/avformat: add a new disposition to signal the stream is an HDR gainmap
On 9/26/2024 3:00 AM, Anton Khirnov wrote: Quoting James Almer (2024-09-26 00:52:16) HDR images photos taken by certain cameras split this as a separate image. Signed-off-by: James Almer --- libavformat/avformat.h | 5 + libavformat/dump.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 56c1c80289..6d9f5c4399 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -718,6 +718,11 @@ typedef struct AVIndexEntry { * Annex G/H, or HEVC Annex F). */ #define AV_DISPOSITION_MULTILAYER (1 << 21) +/** + * The video stream contains an HDR gainmap. Only ever used with + * AV_DISPOSITION_DEPENDENT. + */ +#define AV_DISPOSITION_GAINMAP (1 << 22) Presumably we want this information available in codecs and filters as well, so then should it not be side data instead? There is no other information than "This is a gainmap", and that's container level information (Same as "This is a tile" for heif). How would side data work for this? I'm including it in the tile grid stream group in patch 4/4, so that should give the caller all the information they need. OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] aarch64/vvc: Add w_avg
> On Sep 26, 2024, at 19:25, Martin Storsjö wrote: > > On Mon, 23 Sep 2024, Zhao Zhili wrote: > >> From: Zhao Zhili >> >> w_avg_8_2x2_c: 0.0 ( 0.00x) >> w_avg_8_2x2_neon:0.0 ( 0.00x) >> w_avg_8_4x4_c: 0.2 ( 1.00x) >> w_avg_8_4x4_neon:0.0 ( 0.00x) >> w_avg_8_8x8_c: 1.2 ( 1.00x) >> w_avg_8_8x8_neon:0.2 ( 5.00x) >> w_avg_8_16x16_c: 4.2 ( 1.00x) >> w_avg_8_16x16_neon: 0.8 ( 5.67x) >> w_avg_8_32x32_c:16.2 ( 1.00x) >> w_avg_8_32x32_neon: 2.5 ( 6.50x) >> w_avg_8_64x64_c:64.5 ( 1.00x) >> w_avg_8_64x64_neon: 9.0 ( 7.17x) >> w_avg_8_128x128_c: 269.5 ( 1.00x) >> w_avg_8_128x128_neon: 35.5 ( 7.59x) >> w_avg_10_2x2_c: 0.2 ( 1.00x) >> w_avg_10_2x2_neon: 0.2 ( 1.00x) >> w_avg_10_4x4_c: 0.2 ( 1.00x) >> w_avg_10_4x4_neon: 0.2 ( 1.00x) >> w_avg_10_8x8_c: 1.0 ( 1.00x) >> w_avg_10_8x8_neon: 0.2 ( 4.00x) >> w_avg_10_16x16_c:4.2 ( 1.00x) >> w_avg_10_16x16_neon: 0.8 ( 5.67x) >> w_avg_10_32x32_c: 16.2 ( 1.00x) >> w_avg_10_32x32_neon: 2.5 ( 6.50x) >> w_avg_10_64x64_c: 66.2 ( 1.00x) >> w_avg_10_64x64_neon:10.0 ( 6.62x) >> w_avg_10_128x128_c:277.8 ( 1.00x) >> w_avg_10_128x128_neon: 39.8 ( 6.99x) >> w_avg_12_2x2_c: 0.0 ( 0.00x) >> w_avg_12_2x2_neon: 0.2 ( 0.00x) >> w_avg_12_4x4_c: 0.2 ( 1.00x) >> w_avg_12_4x4_neon: 0.0 ( 0.00x) >> w_avg_12_8x8_c: 1.2 ( 1.00x) >> w_avg_12_8x8_neon: 0.5 ( 2.50x) >> w_avg_12_16x16_c:4.8 ( 1.00x) >> w_avg_12_16x16_neon: 0.8 ( 6.33x) >> w_avg_12_32x32_c: 17.0 ( 1.00x) >> w_avg_12_32x32_neon: 2.8 ( 6.18x) >> w_avg_12_64x64_c: 64.0 ( 1.00x) >> w_avg_12_64x64_neon:10.0 ( 6.40x) >> w_avg_12_128x128_c:269.2 ( 1.00x) >> w_avg_12_128x128_neon: 42.0 ( 6.41x) >> --- >> libavcodec/aarch64/vvc/dsp_init.c | 34 +++ >> libavcodec/aarch64/vvc/inter.S| 99 +-- >> 2 files changed, 116 insertions(+), 17 deletions(-) >> >> diff --git a/libavcodec/aarch64/vvc/dsp_init.c >> b/libavcodec/aarch64/vvc/dsp_init.c >> index ad767d17e2..b39ebb83fc 100644 >> --- a/libavcodec/aarch64/vvc/dsp_init.c >> +++ b/libavcodec/aarch64/vvc/dsp_init.c >> @@ -52,6 +52,37 @@ void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t >> dst_stride, >>const int16_t *src0, const int16_t *src1, int width, >>int height); >> >> +void ff_vvc_w_avg_8_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, >> + const int16_t *src0, const int16_t *src1, >> + const int width, const int height, >> + uintptr_t w0_w1, uintptr_t offset_shift); > > Including "const" on scalar parameters is entirely redundant, and we don't > prescribe use of that elsewhere in ffmpeg, and just makes the whole > declaration more noisy. I see these “const” make clang-tidy not happy. They are here to keep consistent with the prototypes in vvc/dsp.h. There are three options: 1. Keep “const” as current state 2. Drop “const” only for these new functions 3. Remove “const” from vvc/dsp.h and all implementations I can’t decide which way to go. > >> +void ff_vvc_w_avg_10_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, >> + const int16_t *src0, const int16_t *src1, >> + const int width, const int height, >> + uintptr_t w0_w1, uintptr_t offset_shift); >> +void ff_vvc_w_avg_12_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, >> + const int16_t *src0, const int16_t
Re: [FFmpeg-devel] [PATCH] configure: Silence Xcode warnings about duplicate libraries
On Wed, 25 Sep 2024, Martin Storsjö wrote: Since Xcode 15, macOS developer tools use a new linker. The new linker by default warns for duplicate -l options. As this is a known and expected thing, not to be considered an issue, ask for the warning to be silenced. This silences linker warnings like this: ld: warning: ignoring duplicate libraries: '-lc++', '-lcrypto', '-lm', '-logg', '-lpthread', '-lssl', '-lvorbis', '-lvpx', '-lz' The linker can also warn about duplicate -rpath options, and there's currently no option to silence those warnings. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index d77a55b653..a450b3c8d8 100755 --- a/configure +++ b/configure @@ -6480,6 +6480,7 @@ check_cc intrinsics_sse2 emmintrin.h "__m128i test = _mm_setzero_si128()" check_ldflags -Wl,--as-needed check_ldflags -Wl,-z,noexecstack +check_ldflags -Wl,-no_warn_duplicate_libraries OK'd by Marvin on irc, will push in a day or two. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] aarch64/vvc: Add w_avg
> On Sep 26, 2024, at 20:17, Martin Storsjö wrote: > > On Thu, 26 Sep 2024, Zhao Zhili wrote: > >> --- a/libavcodec/aarch64/vvc/dsp_init.c >> +++ b/libavcodec/aarch64/vvc/dsp_init.c >> @@ -52,6 +52,37 @@ void ff_vvc_avg_12_neon(uint8_t *dst, >> ptrdiff_t dst_stride, >> const int16_t *src0, const int16_t >> *src1, int width, >> int height); >> >> +void ff_vvc_w_avg_8_neon(uint8_t *_dst, const ptrdiff_t >> _dst_stride, >> + const int16_t *src0, const >> int16_t *src1, >> + const int width, const int >> height, >> + uintptr_t w0_w1, uintptr_t >> offset_shift); >> Including "const" on scalar parameters is entirely redundant, and we >> don't prescribe use of that elsewhere in ffmpeg, and just makes the >> whole declaration more noisy. >> I see these “const” make clang-tidy not happy. They are here to keep >> consistent with the prototypes >> in vvc/dsp.h. > > Hmm, I don't quite understand this comment - so you say that clang-tidy, in > addition to me, also complain about them? But they are added manually to keep > the prototypes exactly in sync? Or does clang-tidy complain about differences > here, if we differ on the constness here? Clang-tidy complains about these “const” be added: Clang-Tidy: Parameter 'block_w' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions > >> There are three options: >> 1. Keep “const” as current state >> 2. Drop “const” only for these new functions >> 3. Remove “const” from vvc/dsp.h and all implementations >> I can’t decide which way to go. > > I would go for 3, at least long term. > > If you need to keep the const within the function prototypes here for now to > please some tool (I think most compilers wouldn't complain about differences > in const on scalar parameters, although I think old MSVC did that), that's > ok, but I would remove it from the unnecessary places (the local variables in > the function, the parameter/register mappings in assembly). > > Then we can try to do 3 as a later step. > > // Martin > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avformat/mov: add referenced thumbnail streams to tile stream groups
Use the reference information present in iref boxes of type thmb to include the relevant streams into a Tile Grid stream group. This does not yet export the relation of a thumbnail and an independent stream (not a grid). For this, a new Stream group type would probably be needed. Signed-off-by: James Almer --- libavformat/dump.c | 9 -- libavformat/isom.h | 3 +- libavformat/mov.c | 71 +++--- 3 files changed, 64 insertions(+), 19 deletions(-) diff --git a/libavformat/dump.c b/libavformat/dump.c index 5178f19685..ba30b92aaf 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -784,11 +784,16 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed, dump_disposition(stg->disposition, AV_LOG_INFO); av_log(NULL, AV_LOG_INFO, "\n"); dump_metadata(NULL, stg->metadata, "", AV_LOG_INFO); -for (int i = 0; i < stg->nb_streams; i++) { -const AVStream *st = stg->streams[i]; +for (int i = 0; i < tile_grid->nb_tiles; i++) { +const AVStream *st = stg->streams[tile_grid->offsets[i].idx]; dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE); printed[st->index] = 1; } +for (int i = 0; i < stg->nb_streams; i++) { +const AVStream *st = stg->streams[i]; +if (!printed[st->index]) +dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE); +} break; } case AV_STREAM_GROUP_PARAMS_LCEVC: { diff --git a/libavformat/isom.h b/libavformat/isom.h index 5076bc5da7..1cf69ed042 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -279,6 +279,8 @@ typedef struct HEIFItem { AVStream *st; char *name; int item_id; +struct HEIFItem **ref_item_list; +int nb_ref_item_list; int64_t extent_length; int64_t extent_offset; int width; @@ -360,7 +362,6 @@ typedef struct MOVContext { int nb_heif_item; HEIFGrid *heif_grid; int nb_heif_grid; -int thmb_item_id; int64_t idat_offset; int interleaved_read; } MOVContext; diff --git a/libavformat/mov.c b/libavformat/mov.c index bd502d489a..8a257ba535 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8844,23 +8844,55 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version) return 0; } +static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, + HEIFItem *from_item) +{ +HEIFItem **ref_item_list, *to_item = NULL; +int to_item_id = version ? avio_rb32(pb) : avio_rb16(pb); + +for (int j = 0; j < c->nb_heif_item; j++) { +if (c->heif_item[j].item_id != to_item_id) +continue; +to_item = &c->heif_item[j]; +} +if (!to_item) { +av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); +return AVERROR_INVALIDDATA; +} + +ref_item_list = av_realloc_array(to_item->ref_item_list, to_item->nb_ref_item_list + 1U, + sizeof(*to_item->ref_item_list)); +if (!ref_item_list) +return AVERROR(ENOMEM); +to_item->ref_item_list = ref_item_list; +to_item->ref_item_list[to_item->nb_ref_item_list++] = from_item; + +return 0; +} + static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version) { +HEIFItem *from_item = NULL; int entries; -int to_item_id, from_item_id = version ? avio_rb32(pb) : avio_rb16(pb); +int from_item_id = version ? avio_rb32(pb) : avio_rb16(pb); -entries = avio_rb16(pb); -if (entries > 1) { -avpriv_request_sample(c->fc, "thmb in iref referencing several items"); -return AVERROR_PATCHWELCOME; +for (int i = 0; i < c->nb_heif_item; i++) { +if (c->heif_item[i].item_id != from_item_id) +continue; +from_item = &c->heif_item[i]; +} +if (!from_item) { +av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); +return AVERROR_INVALIDDATA; } -/* 'to' item ids */ -to_item_id = version ? avio_rb32(pb) : avio_rb16(pb); - -if (to_item_id != c->primary_item_id) -return 0; -c->thmb_item_id = from_item_id; +entries = avio_rb16(pb); +/* 'to' item ids */ +for (int i = 0; i < entries; i++) { +int ret = mov_add_ref_to_item(c, pb, version, from_item); +if (ret < 0) +return ret; +} av_log(c->fc, AV_LOG_TRACE, "thmb: from_item_id %d, entries %d\n", from_item_id, entries); @@ -9718,6 +9750,7 @@ static int mov_read_close(AVFormatContext *s) for (i = 0; i < mov->nb_heif_item; i++) { av_freep(&mov->heif_item[i].name); av_freep(&mov->heif_item[i].aux_type); +av_freep(&mov->heif_item[i].ref_item_list); } av_freep(&mov->heif_item); for (i = 0; i < mov->nb_heif_grid; i++) { @@ -10074,6
Re: [FFmpeg-devel] [PATCH 1/4] avformat/avformat: add a new disposition to signal the stream is an HDR gainmap
Quoting James Almer (2024-09-26 16:25:11) > On 9/26/2024 11:17 AM, Anton Khirnov wrote: > > Quoting James Almer (2024-09-26 14:06:25) > >> On 9/26/2024 3:00 AM, Anton Khirnov wrote: > >>> Quoting James Almer (2024-09-26 00:52:16) > HDR images photos taken by certain cameras split this as a separate > image. > > Signed-off-by: James Almer > --- > libavformat/avformat.h | 5 + > libavformat/dump.c | 2 ++ > 2 files changed, 7 insertions(+) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 56c1c80289..6d9f5c4399 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -718,6 +718,11 @@ typedef struct AVIndexEntry { > * Annex G/H, or HEVC Annex F). > */ > #define AV_DISPOSITION_MULTILAYER (1 << 21) > +/** > + * The video stream contains an HDR gainmap. Only ever used with > + * AV_DISPOSITION_DEPENDENT. > + */ > +#define AV_DISPOSITION_GAINMAP (1 << 22) > >>> > >>> Presumably we want this information available in codecs and filters as > >>> well, so then should it not be side data instead? > >> > >> There is no other information than "This is a gainmap", and that's > >> container level information (Same as "This is a tile" for heif). How > >> would side data work for this? > > > > You could e.g. have side data that has no payload, and its presence > > signals the same information. > > Is there precedent for this? Not as far as I know. But I also don't see why couldn't it be done. > Would it be a side data with size 0 (but data still pointing to an > AVBufferRef)? Packet side data is not refcounted. Otherwise yes, I imagine it would have 0 size, unless we figure out some useful content. > > > >> I'm including it in the tile grid stream group in patch 4/4, so that > >> should give the caller all the information they need. > > > > Assuming all they ever need is handle everything manually. > > I don't understand what you mean. What I mean is - if we ever want to propagate this information to decoders/filters, we probably want it to be side data. Then the disposition would be redudundant. And since we are not far from running out of disposition space, we might as well make it side data only. It could also conceivably be a frame/packet flag. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avformat/mov: support parsing auxl iref type
Use the reference information present in iref boxes of type auxl to include the relevant streams into a Tile Grid stream group. These streams are "auxiliar", which can be things like separate alpha planes and HDR gain maps. This does not yet export the relation of a said auxiliary streams and an independent stream (not a grid). For this, a new Stream group type would probably be needed. Signed-off-by: James Almer --- libavformat/mov.c | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8a257ba535..f1274392f3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8844,8 +8844,8 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version) return 0; } -static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, - HEIFItem *from_item) +static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, uint32_t type, + int version, HEIFItem *from_item) { HEIFItem **ref_item_list, *to_item = NULL; int to_item_id = version ? avio_rb32(pb) : avio_rb16(pb); @@ -8856,7 +8856,8 @@ static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, to_item = &c->heif_item[j]; } if (!to_item) { -av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); +av_log(c->fc, AV_LOG_ERROR, "%s in iref references a non-existent item\n", + av_fourcc2str(type)); return AVERROR_INVALIDDATA; } @@ -8870,7 +8871,8 @@ static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, return 0; } -static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version) +static int mov_read_iref_generic(MOVContext *c, AVIOContext *pb, uint32_t type, + int version) { HEIFItem *from_item = NULL; int entries; @@ -8882,20 +8884,21 @@ static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version) from_item = &c->heif_item[i]; } if (!from_item) { -av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); +av_log(c->fc, AV_LOG_ERROR, "%s in iref references a non-existent item\n", + av_fourcc2str(type)); return AVERROR_INVALIDDATA; } entries = avio_rb16(pb); /* 'to' item ids */ for (int i = 0; i < entries; i++) { -int ret = mov_add_ref_to_item(c, pb, version, from_item); +int ret = mov_add_ref_to_item(c, pb, type, version, from_item); if (ret < 0) return ret; } -av_log(c->fc, AV_LOG_TRACE, "thmb: from_item_id %d, entries %d\n", - from_item_id, entries); +av_log(c->fc, AV_LOG_TRACE, "%s: from_item_id %d, entries %d\n", + av_fourcc2str(type), from_item_id, entries); return 0; } @@ -8924,8 +8927,9 @@ static int mov_read_iref(MOVContext *c, AVIOContext *pb, MOVAtom atom) case MKTAG('d','i','m','g'): mov_read_iref_dimg(c, pb, version); break; +case MKTAG('a','u','x','l'): case MKTAG('t','h','m','b'): -mov_read_iref_thmb(c, pb, version); +mov_read_iref_generic(c, pb, type, version); break; default: av_log(c->fc, AV_LOG_DEBUG, "Unknown iref type %s size %"PRIu32"\n", -- 2.46.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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC] 7.1 Release
On Tue, 24 Sept 2024 at 23:48, Michael Niedermayer wrote: > if someone can help with reviewing and applying, thats certainly welcome > I dont think i will find the time for alot of non trivial patches before > the release but a bigger problem is that the release branch is for bugfixes > mainly not for feature additions, exceptions are possible, and i would not > mind if people want this, but as said i wont have the time for this, theres > too many other things iam trying to work on, someone else would have to do > this > > thx > Hi, Does this mean this non-breaking bugfix will be merged? https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333854.html https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333857.html It's 9 days old if that matters. I wanted to know when I'll be able to use it. Thanks, Filip ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 3/3] aarch64/vvc: Add dmvr
On Mon, 23 Sep 2024, Zhao Zhili wrote: From: Zhao Zhili dmvr_8_12x20_c: 2.2 ( 1.00x) dmvr_8_12x20_neon: 0.5 ( 4.50x) dmvr_8_20x12_c: 2.0 ( 1.00x) dmvr_8_20x12_neon: 0.2 ( 8.00x) dmvr_8_20x20_c: 3.2 ( 1.00x) dmvr_8_20x20_neon: 0.5 ( 6.50x) dmvr_12_12x20_c: 2.2 ( 1.00x) dmvr_12_12x20_neon: 0.5 ( 4.50x) dmvr_12_20x12_c: 2.2 ( 1.00x) dmvr_12_20x12_neon: 0.5 ( 4.50x) dmvr_12_20x20_c: 3.2 ( 1.00x) dmvr_12_20x20_neon: 0.8 ( 4.33x) --- libavcodec/aarch64/vvc/dsp_init.c | 4 ++ libavcodec/aarch64/vvc/inter.S| 94 ++- 2 files changed, 97 insertions(+), 1 deletion(-) This looks ok to me. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] aarch64/vvc: Add w_avg
On Thu, 26 Sep 2024, Zhao Zhili wrote: --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -52,6 +52,37 @@ void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1, int width, int height); +void ff_vvc_w_avg_8_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); Including "const" on scalar parameters is entirely redundant, and we don't prescribe use of that elsewhere in ffmpeg, and just makes the whole declaration more noisy. I see these “const” make clang-tidy not happy. They are here to keep consistent with the prototypes in vvc/dsp.h. Hmm, I don't quite understand this comment - so you say that clang-tidy, in addition to me, also complain about them? But they are added manually to keep the prototypes exactly in sync? Or does clang-tidy complain about differences here, if we differ on the constness here? There are three options: 1. Keep “const” as current state 2. Drop “const” only for these new functions 3. Remove “const” from vvc/dsp.h and all implementations I can’t decide which way to go. I would go for 3, at least long term. If you need to keep the const within the function prototypes here for now to please some tool (I think most compilers wouldn't complain about differences in const on scalar parameters, although I think old MSVC did that), that's ok, but I would remove it from the unnecessary places (the local variables in the function, the parameter/register mappings in assembly). Then we can try to do 3 as a later step. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] 7.1 Release
On 25.09.2024 00:48, Michael Niedermayer wrote: On Wed, Sep 25, 2024 at 12:38:29AM +0300, Dennis Mungai wrote: On Tue, 24 Sept 2024, 22:24 Ingo Oppermann, wrote: "Leavitt" (https://en.wikipedia.org/wiki/Henrietta_Swan_Leavitt) On 24 Sep 2024, at 17:47, Michael Niedermayer wrote: On Wed, Aug 14, 2024 at 02:41:55PM +0200, Michael Niedermayer wrote: Hi all Are there any upcoming LTS releases that want to/could include FFmpeg 7.1 ? If so please reply here and list the date before which we would have to finish the 7.1 release so it can be included with no problems Otherwise, are there any preferrances of the general/approximate release date? all blocking issues where closed, excpet one long standing one, so release/7.1 Branch finally made I intend to make the 7.1 release from that branch within a week! anyone has a suggestion/preferrance for a name ? thx There is also this patchset on enhanced RTMP with multi-track/multi-channel flv support that should be ideally reviewed and merged before this point release. https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11851 Michael, any comments? if someone can help with reviewing and applying, thats certainly welcome I dont think i will find the time for alot of non trivial patches before the release but I already replied to this mail, but no idea where the reply went, it seems to be lost in the ether. Anyway, enhanced-rtmp v2 is still in alpha and the final spec is still subject to change. So the patchset cannot be merged yet. It'll re-send it for review and merge once the spec is final. Which will likely not be anywhere near the 7.1 release. a bigger problem is that the release branch is for bugfixes mainly not for feature additions, exceptions are possible, and i would not mind if people want this, but as said i wont have the time for this, theres too many other things iam trying to work on, someone else would have to do this thx [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/ffv1: Implement CRC with -1 initial and final value
Hi Traneptora On Wed, Sep 25, 2024 at 06:52:52PM -0400, Leo Izen wrote: > On 9/25/24 4:06 AM, Michael Niedermayer wrote: > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/ffv1.h| 1 + > > libavcodec/ffv1dec.c | 10 ++ > > libavcodec/ffv1enc.c | 12 +--- > > 3 files changed, 16 insertions(+), 7 deletions(-) > > > > diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h > > index 9aa04529228..06125d2be5f 100644 > > --- a/libavcodec/ffv1.h > > +++ b/libavcodec/ffv1.h > > @@ -118,6 +118,7 @@ typedef struct FFV1Context { > > int64_t picture_number; > > int key_frame; > > ProgressFrame picture, last_picture; > > +int crcref; > > Do we require sizeof(int) == 4? > May be more readable to declare this as an int32_t anyway (or even uint32_t) > to make it more clear that it's a 32-bit value and not a flag, especially > considering that av_crc takes uint32_t as an argument. will become uint32_t > > > > const AVFrame *cur_enc_frame; > > int plane_count; > > diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c > > index 0afdeabd915..2463d2b934e 100644 > > --- a/libavcodec/ffv1dec.c > > +++ b/libavcodec/ffv1dec.c > > @@ -502,15 +502,17 @@ static int read_extra_header(FFV1Context *f) > > if (f->version > 2) { > > f->ec = get_symbol(&c, state, 0); > > +if (f->ec >= 2) > > +f->crcref = -1; > > How backward-compatible is this? Or is it not, which is why it needs a new > version? An old decoder encountering a file using ec=2 will likely detect every CRC protected block as damaged and discard them, thus not decoding the file. Technically a decoder could be smart and ignore the new unknown ec type but thats not what our decoder does > > > if (f->micro_version > 2) > > f->intra = get_symbol(&c, state, 0); > > } > > if (f->version > 2) { > > unsigned v; > > -v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, > > +v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, > > f->avctx->extradata, f->avctx->extradata_size); > > -if (v || f->avctx->extradata_size < 4) { > > +if (v != f->crcref || f->avctx->extradata_size < 4) { > > av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); > > return AVERROR_INVALIDDATA; > > } > > @@ -948,8 +950,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame > > *rframe, > > buf_p -= v; > > if (f->ec) { > > -unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, > > buf_p, v); > > -if (crc) { > > +unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), > > f->crcref, buf_p, v); > > Do we require sizeof(unsigned int) == 4? no > Whether or not, it may be more readable to declare crc as a uint32_t maybe, but that belongs in a seperate patch > > > > +if (crc != f->crcref) { > > int64_t ts = avpkt->pts != AV_NOPTS_VALUE ? avpkt->pts : > > avpkt->dts; > > av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %X!", > > crc); > > if (ts != AV_NOPTS_VALUE && avctx->pkt_timebase.num) { > > diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c > > index a6f405289eb..f4bbdd9b943 100644 > > --- a/libavcodec/ffv1enc.c > > +++ b/libavcodec/ffv1enc.c > > @@ -458,7 +458,7 @@ static int write_extradata(FFV1Context *f) > > } > > f->avctx->extradata_size = ff_rac_terminate(&c, 0); > > -v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, > > f->avctx->extradata_size); > > +v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, > > f->avctx->extradata, f->avctx->extradata_size) ^ (f->crcref&0x4964AF46); > > Nitpick: should probably be (f->crcref & 0x4964af46), the space makes it a > bit more readable. code is different in the next revission thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/ffv1: Implement CRC with -1 initial and final value
On Thu, Sep 26, 2024 at 09:51:48PM +0200, Michael Niedermayer wrote: > Hi Traneptora > > On Wed, Sep 25, 2024 at 06:52:52PM -0400, Leo Izen wrote: > > On 9/25/24 4:06 AM, Michael Niedermayer wrote: > > > Signed-off-by: Michael Niedermayer [...] > > > if (f->ec) { > > > -unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, > > > buf_p, v); > > > -if (crc) { > > > +unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), > > > f->crcref, buf_p, v); > > > > Do we require sizeof(unsigned int) == 4? > > no > > > > Whether or not, it may be more readable to declare crc as a uint32_t > > maybe, but that belongs in a seperate patch it seems to have the opposit effect see: (especially the av_log()) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index b4d719a7eec..9efc926092c 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -509,11 +509,11 @@ static int read_extra_header(FFV1Context *f) } if (f->version > 2) { -unsigned v; +uint32_t v; v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, f->avctx->extradata, f->avctx->extradata_size); if (v != f->crcref || f->avctx->extradata_size < 4) { -av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); +av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %"PRIX32"!\n", v); return AVERROR_INVALIDDATA; } crc = AV_RB32(f->avctx->extradata + f->avctx->extradata_size - 4); @@ -950,10 +950,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, buf_p -= v; if (f->ec) { -unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v); +uint32_t crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v); if (crc != f->crcref) { int64_t ts = avpkt->pts != AV_NOPTS_VALUE ? avpkt->pts : avpkt->dts; -av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %X!", crc); +av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %"PRIX32"!", crc); if (ts != AV_NOPTS_VALUE && avctx->pkt_timebase.num) { av_log(f->avctx, AV_LOG_ERROR, "at %f seconds\n", ts*av_q2d(avctx->pkt_timebase)); } else if (ts != AV_NOPTS_VALUE) { [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] Respect `append_list` flag in subtitle playlists
Ensure that when the `-hls_flags append_list` option is set, that *.vtt files in stream_vtt.m3u8 are correctly updated. This fixes https://trac.ffmpeg.org/ticket/11208 This is a bit of an ugly fix, let me know what you think. --- libavformat/hlsenc.c | 37 + 1 file changed, 37 insertions(+) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 1e932b7..e93af4c 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1202,6 +1202,22 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, return 0; } +static int extract_number(const char *filename) { +const char *dot = strrchr(filename, '.'); +const char *num_start = dot - 1; + +while (num_start > filename && *num_start >= '0' && *num_start <= '9') { +num_start--; +} + +num_start++; + +if (num_start == dot) +return -1; + +return atoi(num_start); +} + static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs) { HLSContext *hls = s->priv_data; @@ -1294,6 +1310,27 @@ static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs ret = AVERROR(ENOMEM); goto fail; } +if (vs->has_subtitle) { +int vtt_index = extract_number(line); +char *vtt_file = av_asprintf(av_basename(vs->vtt_basename), vtt_index); +char *new_vtt; + +if (!vtt_file) { +ret = AVERROR(ENOMEM); +goto fail; +} + +new_vtt = av_strdup(vtt_file); +av_free(vtt_file); + +if (!new_vtt) { +ret = AVERROR(ENOMEM); +goto fail; +} + +ff_format_set_url(vs->vtt_avf, new_vtt); +} + ff_format_set_url(vs->avf, new_file); is_segment = 0; new_start_pos = avio_tell(vs->avf->pb); -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/5] compat/stdckdint: remove C++ version and the non checked generic fallback
We only want these to be available for C source files. additionally, the generic fallback exists for non-C11 compilers, which we no longer support. Signed-off-by: James Almer --- compat/stdckdint/stdckdint.h | 270 +-- 1 file changed, 1 insertion(+), 269 deletions(-) diff --git a/compat/stdckdint/stdckdint.h b/compat/stdckdint/stdckdint.h index 2d36e8ad89..d5fda2fee6 100644 --- a/compat/stdckdint/stdckdint.h +++ b/compat/stdckdint/stdckdint.h @@ -99,270 +99,6 @@ typedef unsigned __ckd_intmax __ckd_uintmax_t; #define ckd_sub(res, x, y) __builtin_sub_overflow((x), (y), (res)) #define ckd_mul(res, x, y) __builtin_mul_overflow((x), (y), (res)) -#elif (defined(__cplusplus) && \ - (__cplusplus >= 201103L || \ -(defined(_MSC_VER) && __cplusplus >= 199711L && \ - __ckd_has_include() &&\ - __ckd_has_include( -#include -#include - -template -inline bool ckd_add(__T *__res, __U __a, __V __b) { - static_assert(std::is_integral<__T>::value && -std::is_integral<__U>::value && -std::is_integral<__V>::value, -"non-integral types not allowed"); - static_assert(!std::is_same<__T, bool>::value && -!std::is_same<__U, bool>::value && -!std::is_same<__V, bool>::value, -"checked booleans not supported"); - static_assert(!std::is_same<__T, char>::value && -!std::is_same<__U, char>::value && -!std::is_same<__V, char>::value, -"unqualified char type is ambiguous"); - __ckd_uintmax_t __x = __a; - __ckd_uintmax_t __y = __b; - __ckd_uintmax_t __z = __x + __y; - *__res = __z; - if (sizeof(__z) > sizeof(__U) && sizeof(__z) > sizeof(__V)) { -if (sizeof(__z) > sizeof(__T) || std::is_signed<__T>::value) { - return static_cast<__ckd_intmax_t>(__z) != static_cast<__T>(__z); -} else if (!std::is_same<__T, __ckd_uintmax_t>::value) { - return (__z != static_cast<__T>(__z) || - ((std::is_signed<__U>::value || -std::is_signed<__V>::value) && - static_cast<__ckd_intmax_t>(__z) < 0)); -} - } - bool __truncated = false; - if (sizeof(__T) < sizeof(__ckd_intmax_t)) { -__truncated = __z != static_cast<__ckd_uintmax_t>(static_cast<__T>(__z)); - } - switch (std::is_signed<__T>::value << 2 | // - std::is_signed<__U>::value << 1 | // - std::is_signed<__V>::value) { -case 0: // u = u + u - return __truncated | (__z < __x); -case 1: // u = u + s - __y ^= std::numeric_limits<__ckd_intmax_t>::min(); - return __truncated | - (static_cast<__ckd_intmax_t>((__z ^ __x) & - (__z ^ __y)) < 0); -case 2: // u = s + u - __x ^= std::numeric_limits<__ckd_intmax_t>::min(); - return __truncated | - (static_cast<__ckd_intmax_t>((__z ^ __x) & - (__z ^ __y)) < 0); -case 3: // u = s + s - return __truncated | - (static_cast<__ckd_intmax_t>(((__z | __x) & __y) | - ((__z & __x) & ~__y)) < 0); -case 4: // s = u + u - return __truncated | (__z < __x) | (static_cast<__ckd_intmax_t>(__z) < 0); -case 5: // s = u + s - __y ^= std::numeric_limits<__ckd_intmax_t>::min(); - return __truncated | (__x + __y < __y); -case 6: // s = s + u - __x ^= std::numeric_limits<__ckd_intmax_t>::min(); - return __truncated | (__x + __y < __x); -case 7: // s = s + s - return __truncated | - (static_cast<__ckd_intmax_t>((__z ^ __x) & - (__z ^ __y)) < 0); -default: - for (;;) (void)0; - } -} - -template -inline bool ckd_sub(__T *__res, __U __a, __V __b) { - static_assert(std::is_integral<__T>::value && -std::is_integral<__U>::value && -std::is_integral<__V>::value, -"non-integral types not allowed"); - static_assert(!std::is_same<__T, bool>::value && -!std::is_same<__U, bool>::value && -!std::is_same<__V, bool>::value, -"checked booleans not supported"); - static_assert(!std::is_same<__T, char>::value && -!std::is_same<__U, char>::value && -!std::is_same<__V, char>::value, -"unqualified char type is ambiguous"); - __ckd_uintmax_t __x = __a; - __ckd_uintmax_t __y = __b; - __ckd_uintmax_t __z = __x - __y; - *__res = __z; - if (sizeof(__z) > sizeof(__U) && sizeof(__z) > sizeof(__V)) { -if (sizeof(__z) > sizeof(__T) || std::is_signed<__T>::value) { - return static_cast<__ckd_intmax_t>(__z) != static_cast<__T>(__z); -} else if (!std::is_same<__T, __ckd_uintmax_t>::value) { - return (__z != static_cast<__T>(__z) || - ((std::is_signed<__U>::value || -
[FFmpeg-devel] [PATCH 4/5] configure: include compat/stdckdint.h when required
Signed-off-by: James Almer --- configure | 4 1 file changed, 4 insertions(+) diff --git a/configure b/configure index 643ffddd19..b87e400fe4 100755 --- a/configure +++ b/configure @@ -7802,6 +7802,10 @@ check_builtin stdbit "stdbit.h assert.h" \ 'static_assert(__STDC_VERSION_STDBIT_H__ >= 202311L, "Compiler lacks stdbit.h")' || \ add_cppflags '-I\$(SRC_PATH)/compat/stdbit' +check_builtin stdckdint "stdckdint.h assert.h" \ +'static_assert(__STDC_VERSION_STDCKDINT_H__ >= 202311L, "Compiler lacks stdckdint.h")' || \ +add_cppflags '-I\$(SRC_PATH)/compat/stdckdint' + # Check if requested libraries were found. for lib in $AUTODETECT_LIBS; do requested $lib && ! enabled $lib && die "ERROR: $lib requested but not found"; -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/5] compat/stdckdint: remove check for system stdckdint.h
We will check for it during configure. Signed-off-by: James Almer --- compat/stdckdint/stdckdint.h | 15 +-- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/compat/stdckdint/stdckdint.h b/compat/stdckdint/stdckdint.h index d5fda2fee6..1994d2e5cf 100644 --- a/compat/stdckdint/stdckdint.h +++ b/compat/stdckdint/stdckdint.h @@ -54,19 +54,7 @@ * @version 0.1 (2023-07-22) */ -#ifndef JTCKDINT_H_ -#define JTCKDINT_H_ - -#ifdef __has_include -#define __ckd_has_include(x) __has_include(x) -#else -#define __ckd_has_include(x) 0 -#endif - -#if __ckd_has_include() -#include -#else - +#ifndef __STDC_VERSION_STDCKDINT_H__ #define __STDC_VERSION_STDCKDINT_H__ 202311L #if ((defined(__llvm__) || \ @@ -392,4 +380,3 @@ __ckd_declare_mul(__ckd_mul_uint128, unsigned __int128) #endif /* GNU */ #endif /* stdckdint.h */ -#endif /* JTCKDINT_H_ */ -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/5] avformat/mov: use checked arithmetic functions in mov_read_stts()
Signed-off-by: James Almer --- libavformat/mov.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index a2333ac1fd..bfb6d8d72c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "libavutil/attributes.h" #include "libavutil/bprint.h" @@ -3521,15 +3522,15 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->stts_data[i].duration = 1; corrected_dts += (delta_magnitude < 0 ? (int64_t)delta_magnitude : 1) * sample_count; } else { -corrected_dts += sample_duration * (int64_t)sample_count; +ckd_add(&corrected_dts, sample_duration * (int64_t)sample_count, corrected_dts); } -current_dts += sc->stts_data[i].duration * (int64_t)sample_count; +ckd_add(¤t_dts, current_dts, sc->stts_data[i].duration * (int64_t)sample_count); if (current_dts > corrected_dts) { int64_t drift = (current_dts - corrected_dts)/FFMAX(sample_count, 1); uint32_t correction = (sc->stts_data[i].duration > drift) ? drift : sc->stts_data[i].duration - 1; -current_dts -= correction * (uint64_t)sample_count; +ckd_sub(¤t_dts, correction * (int64_t)sample_count, current_dts); sc->stts_data[i].duration -= correction; } -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] MAINTAINERS: remove libopenjpeg decoder entry
On Wed, Sep 25, 2024 at 09:18:56PM +0530, Gyan Doshi wrote: > The decoder wrapper was removed in 60ccb3fe78 > --- > MAINTAINERS | 1 - > 1 file changed, 1 deletion(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] 7.1 Release
On Thu, Sep 26, 2024 at 12:27:58PM +0100, Filip Mašić wrote: > On Tue, 24 Sept 2024 at 23:48, Michael Niedermayer > wrote: > > > if someone can help with reviewing and applying, thats certainly welcome > > I dont think i will find the time for alot of non trivial patches before > > the release but a bigger problem is that the release branch is for bugfixes > > mainly not for feature additions, exceptions are possible, and i would not > > mind if people want this, but as said i wont have the time for this, theres > > too many other things iam trying to work on, someone else would have to do > > this > > > > thx > > > > Hi, > > Does this mean this non-breaking bugfix will be merged? > https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333854.html > https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333857.html > It's 9 days old if that matters. I wanted to know when I'll be able to use > it. if someone applies it and backports, yes. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "I am not trying to be anyone's saviour, I'm trying to think about the future and not be sad" - Elon Musk signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] avcodec/videotoolbox: add AV1 hardware acceleration
From: Jan Ekström Use AV1DecContext's current_obu to access the original OBUs, and feed them to videotoolbox, rather than the bare slice data passed via decode_slice. This requires a small addition to AV1DecContext, for keeping track of the current range of OBUs that belong to the current frame. Co-authored-by: Ruslan Chernenko Co-authored-by: Martin Storsjö --- v3: Adjust where nb_unit/start_unit are set, add code comments explaining the roles of nb_unit/start_unit. --- configure | 4 ++ libavcodec/Makefile | 1 + libavcodec/av1dec.c | 22 ++- libavcodec/av1dec.h | 3 +- libavcodec/hwaccels.h | 1 + libavcodec/videotoolbox.c | 34 +++ libavcodec/videotoolbox_av1.c | 104 ++ libavcodec/vt_internal.h | 4 ++ 8 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 libavcodec/videotoolbox_av1.c diff --git a/configure b/configure index 643ffddd19..9d0c1423f1 100755 --- a/configure +++ b/configure @@ -2467,6 +2467,7 @@ TYPES_LIST=" kCMVideoCodecType_HEVC kCMVideoCodecType_HEVCWithAlpha kCMVideoCodecType_VP9 +kCMVideoCodecType_AV1 kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange @@ -3174,6 +3175,8 @@ av1_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferAV1_bit_depth_idx" av1_vaapi_hwaccel_select="av1_decoder" av1_vdpau_hwaccel_deps="vdpau VdpPictureInfoAV1" av1_vdpau_hwaccel_select="av1_decoder" +av1_videotoolbox_hwaccel_deps="videotoolbox" +av1_videotoolbox_hwaccel_select="av1_decoder" av1_vulkan_hwaccel_deps="vulkan" av1_vulkan_hwaccel_select="av1_decoder" h263_vaapi_hwaccel_deps="vaapi" @@ -6707,6 +6710,7 @@ enabled videotoolbox && { check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia" check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia" check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_VP9 "-framework CoreMedia" +check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_AV1 "-framework CoreMedia" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a4fcce3b42..21188b2479 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1008,6 +1008,7 @@ OBJS-$(CONFIG_AV1_D3D12VA_HWACCEL)+= dxva2_av1.o d3d12va_av1.o OBJS-$(CONFIG_AV1_NVDEC_HWACCEL) += nvdec_av1.o OBJS-$(CONFIG_AV1_VAAPI_HWACCEL) += vaapi_av1.o OBJS-$(CONFIG_AV1_VDPAU_HWACCEL) += vdpau_av1.o +OBJS-$(CONFIG_AV1_VIDEOTOOLBOX_HWACCEL) += videotoolbox_av1.o OBJS-$(CONFIG_AV1_VULKAN_HWACCEL) += vulkan_decode.o vulkan_av1.o OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 80e52d1bea..bc4ef63e68 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -543,6 +543,7 @@ static int get_pixel_format(AVCodecContext *avctx) CONFIG_AV1_NVDEC_HWACCEL + \ CONFIG_AV1_VAAPI_HWACCEL + \ CONFIG_AV1_VDPAU_HWACCEL + \ + CONFIG_AV1_VIDEOTOOLBOX_HWACCEL + \ CONFIG_AV1_VULKAN_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; @@ -570,6 +571,9 @@ static int get_pixel_format(AVCodecContext *avctx) #if CONFIG_AV1_VDPAU_HWACCEL *fmtp++ = AV_PIX_FMT_VDPAU; #endif +#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL +*fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif #if CONFIG_AV1_VULKAN_HWACCEL *fmtp++ = AV_PIX_FMT_VULKAN; #endif @@ -594,6 +598,9 @@ static int get_pixel_format(AVCodecContext *avctx) #if CONFIG_AV1_VDPAU_HWACCEL *fmtp++ = AV_PIX_FMT_VDPAU; #endif +#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL +*fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif #if CONFIG_AV1_VULKAN_HWACCEL *fmtp++ = AV_PIX_FMT_VULKAN; #endif @@ -1441,6 +1448,10 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (raw_tile_group && (s->tile_num == raw_tile_group->tg_end + 1)) { int show_frame = s->raw_frame_header->show_frame; +// Set nb_unit to point at the next OBU, to indicate which +// OBUs have been processed for this current frame. (If this +// frame gets output, we set nb_unit to this value later too.) +s->nb_unit = i + 1; if (avctx->hwa
[FFmpeg-devel] [PATCH] Respect `omit_endlist` flag in subtitle playlists
Ensure that when the `-hls_flags omit_endlist` option is set, the `#EXT-X-ENDLIST` tag is also omitted from the `stream_vtt.m3u8` subtitle playlist. This maintains consistency with the behavior in other playlists when `omit_endlist` is specified. --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 1e932b7..528ba0f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1676,7 +1676,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs) } } -if (last) +if (last && (hls->flags & HLS_OMIT_ENDLIST)==0) ff_hls_write_end_list(hls->sub_m3u8_out); } -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] doc: Add email URLs for Fate samples-request
On Tue, Sep 24, 2024 at 08:30:07PM +0200, martin schitter wrote: > > > On 24.09.24 01:48, martin schitter wrote: > > > they should be T: > > > feel free to send a patch fixing that, or ill fix it later > > Although you fixed one occurrence of this issue by f2aba7 it's still present > on the next line. > > My patch would have fixed both of them. ;) I didnt apply it because it contained unrelated changes, i thought i would help if i fix that seperate issue so only realted remain ... thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is a danger to trust the dream we wish for rather than the science we have, -- Dr. Kenneth Brown signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/5] compat: add a fallback implementation of C23 stdckdint.h
From: Justine Tunney Header contents taken from https://github.com/jart/jtckdint/commit/62df1fc0966926299253b7af46c23e345545 Signed-off-by: James Almer --- compat/stdckdint/stdckdint.h | 663 +++ tests/ref/fate/source| 1 + 2 files changed, 664 insertions(+) create mode 100644 compat/stdckdint/stdckdint.h diff --git a/compat/stdckdint/stdckdint.h b/compat/stdckdint/stdckdint.h new file mode 100644 index 00..2d36e8ad89 --- /dev/null +++ b/compat/stdckdint/stdckdint.h @@ -0,0 +1,663 @@ +/* + * Copyright 2023 Justine Alexandra Roberts Tunney + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * @fileoverview C23 Checked Arithmetic + * + * This header defines three type generic functions: + * + * - `bool ckd_add(res, a, b)` + * - `bool ckd_sub(res, a, b)` + * - `bool ckd_mul(res, a, b)` + * + * Which allow integer arithmetic errors to be detected. There are many + * kinds of integer errors, e.g. overflow, truncation, etc. These funcs + * catch them all. Here's an example of how it works: + * + * uint32_t c; + * int32_t a = 0x7fff; + * int32_t b = 2; + * assert(!ckd_add(&c, a, b)); + * assert(c == 0x8001u); + * + * Experienced C / C++ users should find this example counter-intuitive + * because the expression `0x7fff + 2` not only overflows it's also + * undefined behavior. However here we see it's specified, and does not + * result in an error. That's because C23 checked arithmetic is not the + * arithmetic you're used to. The new standard changes the mathematics. + * + * C23 checked arithmetic is defined as performing the arithmetic using + * infinite precision and then checking if the resulting value will fit + * in the output type. Our example above did not result in an error due + * to `0x8001` being a legal value for `uint32_t`. + * + * This implementation will use the GNU compiler builtins, when they're + * available, only if you don't use build flags like `-std=c11` because + * they define `__STRICT_ANSI__` and GCC extensions aren't really ANSI. + * Instead, you'll get a pretty good pure C11 and C++11 implementation. + * + * @see https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf + * @version 0.1 (2023-07-22) + */ + +#ifndef JTCKDINT_H_ +#define JTCKDINT_H_ + +#ifdef __has_include +#define __ckd_has_include(x) __has_include(x) +#else +#define __ckd_has_include(x) 0 +#endif + +#if __ckd_has_include() +#include +#else + +#define __STDC_VERSION_STDCKDINT_H__ 202311L + +#if ((defined(__llvm__) || \ + (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406)) && \ + !defined(__STRICT_ANSI__)) +#define __ckd_have_int128 +#define __ckd_intmax __int128 +#elif ((defined(__cplusplus) && __cplusplus >= 201103L) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)) +#define __ckd_intmax long long +#else +#define __ckd_intmax long +#endif + +typedef signed __ckd_intmax __ckd_intmax_t; +typedef unsigned __ckd_intmax __ckd_uintmax_t; + +#ifdef __has_builtin +#define __ckd_has_builtin(x) __has_builtin(x) +#else +#define __ckd_has_builtin(x) 0 +#endif + +#if (!defined(__STRICT_ANSI__) && \ + ((defined(__GNUC__) && __GNUC__ >= 5 && !defined(__ICC)) ||\ + (__ckd_has_builtin(__builtin_add_overflow) && \ + __ckd_has_builtin(__builtin_sub_overflow) && \ + __ckd_has_builtin(__builtin_mul_overflow +#define ckd_add(res, x, y) __builtin_add_overflow((x), (y), (res)) +#define ckd_sub(res, x, y) __builtin_sub_overflow((x), (y), (res)) +#define ckd_mul(res, x, y) __builtin_mul_overflow((x), (y), (res)) + +#elif (defined(__cplusplus) && \ + (__cplusplus >= 201103L || \ +(defined(_MSC_VER) && __cplusplus >= 199711L && \ + __ckd_has_include() &&\ + __ckd_has_include( +#include +#include + +template +inline bool ckd_add(__T *__res, __U __a, __V __b) { + static_assert(std::is_integral<__T>::value && +std::is_integral<__U>::value && +std::is_integral<__V>::value, +"non-integral types not all
[FFmpeg-devel] [PATCH v2] avcodec/ffv1: Implement CRC with non zero initial and final value
Signed-off-by: Michael Niedermayer --- libavcodec/ffv1.h| 1 + libavcodec/ffv1dec.c | 10 ++ libavcodec/ffv1enc.c | 12 +--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 9aa04529228..c22325d2510 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -118,6 +118,7 @@ typedef struct FFV1Context { int64_t picture_number; int key_frame; ProgressFrame picture, last_picture; +uint32_t crcref; const AVFrame *cur_enc_frame; int plane_count; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 0afdeabd915..b4d719a7eec 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -502,15 +502,17 @@ static int read_extra_header(FFV1Context *f) if (f->version > 2) { f->ec = get_symbol(&c, state, 0); +if (f->ec >= 2) +f->crcref = 0x7a8c4079; if (f->micro_version > 2) f->intra = get_symbol(&c, state, 0); } if (f->version > 2) { unsigned v; -v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, +v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, f->avctx->extradata, f->avctx->extradata_size); -if (v || f->avctx->extradata_size < 4) { +if (v != f->crcref || f->avctx->extradata_size < 4) { av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); return AVERROR_INVALIDDATA; } @@ -948,8 +950,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, buf_p -= v; if (f->ec) { -unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, buf_p, v); -if (crc) { +unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, v); +if (crc != f->crcref) { int64_t ts = avpkt->pts != AV_NOPTS_VALUE ? avpkt->pts : avpkt->dts; av_log(f->avctx, AV_LOG_ERROR, "slice CRC mismatch %X!", crc); if (ts != AV_NOPTS_VALUE && avctx->pkt_timebase.num) { diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index a6f405289eb..2267a01816e 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -458,7 +458,7 @@ static int write_extradata(FFV1Context *f) } f->avctx->extradata_size = ff_rac_terminate(&c, 0); -v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size); +v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, f->avctx->extradata, f->avctx->extradata_size) ^ (f->crcref ? 0x8CD88196 : 0); AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v); f->avctx->extradata_size += 4; @@ -544,7 +544,13 @@ static av_cold int encode_init(AVCodecContext *avctx) } if (s->ec < 0) { -s->ec = (s->version >= 3); +if (s->version >= 4) { +s->ec = 2; +s->crcref = 0x7a8c4079; +} else if (s->version >= 3) { +s->ec = 1; +} else +s->ec = 0; } // CRC requires version 3+ @@ -1230,7 +1236,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (f->ec) { unsigned v; buf_p[bytes++] = 0; -v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, buf_p, bytes); +v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), f->crcref, buf_p, bytes) ^ (f->crcref ? 0x8CD88196 : 0); AV_WL32(buf_p + bytes, v); bytes += 4; } -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".