PR #24454 opened by ffmpeg-devel URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24454 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24454.patch
**Backport:** https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24410 The lavf AV1 CBS implementation disables metadata, tile lists and padding, but movenccenc.c sees the default AV1RawOBU definition. On 32-bit MinGW, the metadata member raises the union alignment from four to eight bytes, placing obu at offset 16 in the caller instead of offset 12 in CBS. Consequently AV1 CENC reads the wrong fields and fails to write tiles. Move the feature definitions into the common lavf CBS header so that the parser and its callers use the same AV1RawOBU layout. Keep the reduced set of parsed OBU types. Add a FATE encryption/decryption test using the existing nonuniform-tile AV1 sample. The test fails before this change with GCC -m32 -malign-double (which reproduces the relevant MinGW layout) and passes afterwards with the same reference on that configuration and AArch64. Fixes #23069. >From a8e6953bd26dbc07668c7156c7beabc65c2cb19a Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Mon, 7 Sep 2026 17:05:38 -0300 Subject: [PATCH 1/2] avformat/cbs: move AV1 feature definition to their own header The lavf AV1 CBS implementation disables metadata, tile lists and padding, but movenccenc.c sees the default AV1RawOBU definition. On 32-bit MinGW, the metadata member raises the union alignment from four to eight bytes, placing obu at offset 16 in the caller instead of offset 12 in CBS. Consequently AV1 CENC reads the wrong fields and fails to write tiles. Move the feature definitions into the common lavf CBS header so that the parser and its callers use the same AV1RawOBU layout. Keep the reduced set of parsed OBU types. Add a FATE encryption/decryption test using the existing nonuniform-tile AV1 sample. The test fails before this change with GCC -m32 -malign-double (which reproduces the relevant MinGW layout) and passes afterwards with the same reference on that configuration and AArch64. Fixes #23069. Assisted-by: Fairy Signed-off-by: James Almer <[email protected]> (cherry picked from commit 05bd55ff6eaeb1a352ee40bed58c4ad5740d64e9) --- libavformat/cbs_av1.c | 5 +---- libavformat/cbs_av1.h | 30 ++++++++++++++++++++++++++++++ libavformat/movenccenc.c | 2 +- tests/fate/mov.mak | 5 +++++ tests/ref/fate/mov-av1-cenc | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 libavformat/cbs_av1.h create mode 100644 tests/ref/fate/mov-av1-cenc diff --git a/libavformat/cbs_av1.c b/libavformat/cbs_av1.c index efaed7dfd0..93bcbb878d 100644 --- a/libavformat/cbs_av1.c +++ b/libavformat/cbs_av1.c @@ -16,8 +16,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define CBS_AV1_OBU_TILE_LIST 0 -#define CBS_AV1_OBU_METADATA 0 -#define CBS_AV1_OBU_PADDING 0 -#include "cbs.h" +#include "cbs_av1.h" #include "libavcodec/cbs_av1.c" diff --git a/libavformat/cbs_av1.h b/libavformat/cbs_av1.h new file mode 100644 index 0000000000..0d5e28d388 --- /dev/null +++ b/libavformat/cbs_av1.h @@ -0,0 +1,30 @@ +/* + * 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 + */ + +#ifndef AVFORMAT_CBS_AV1_H +#define AVFORMAT_CBS_AV1_H + +#include "cbs.h" + +#define CBS_AV1_OBU_TILE_LIST 0 +#define CBS_AV1_OBU_METADATA 0 +#define CBS_AV1_OBU_PADDING 0 + +#include "libavcodec/cbs_av1.h" + +#endif /* AVFORMAT_CBS_AV1_H */ diff --git a/libavformat/movenccenc.c b/libavformat/movenccenc.c index 4e1f31d2b5..4808b59773 100644 --- a/libavformat/movenccenc.c +++ b/libavformat/movenccenc.c @@ -21,7 +21,7 @@ #include "movenccenc.h" #include "libavcodec/av1_parse.h" #include "libavcodec/bytestream.h" -#include "libavcodec/cbs_av1.h" +#include "libavformat/cbs_av1.h" #include "libavutil/attributes.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 3bc075f608..56dc3763c0 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -198,6 +198,11 @@ fate-mov-mp4-fragmented-ttml-dfxp: CMD = transcode srt $(TARGET_SAMPLES)/sub/Sub "-f lavfi -i smptehdbars=duration=24.5245:size=320x180:rate=24000/1001,format=yuv420p" \ "" "" "data" +FATE_MOV_FFMPEG_SAMPLES-$(call REMUX, MP4 IVF, MOV_DEMUXER AV1_PARSER EXTRACT_EXTRADATA_BSF) += fate-mov-av1-cenc +fate-mov-av1-cenc: CMD = transcode ivf $(TARGET_SAMPLES)/av1/non_uniform_tiling.ivf mp4 \ + "-c:v copy -encryption_scheme cenc-aes-ctr -encryption_key 00112233445566778899aabbccddeeff -encryption_kid 00112233445566778899aabbccddeeff" \ + "-c:v copy" "" "" "-decryption_key 00112233445566778899aabbccddeeff" + # avif demuxing - still image with 1 item. FATE_MOV_FFMPEG_SAMPLES-$(call FRAMECRC, MOV, AV1, AV1_PARSER) \ += fate-mov-avif-demux-still-image-1-item diff --git a/tests/ref/fate/mov-av1-cenc b/tests/ref/fate/mov-av1-cenc new file mode 100644 index 0000000000..785ea598e3 --- /dev/null +++ b/tests/ref/fate/mov-av1-cenc @@ -0,0 +1,32 @@ +4c0d58049d04303b98cd7c07013a1183 *tests/data/fate/mov-av1-cenc.mp4 +39366 tests/data/fate/mov-av1-cenc.mp4 +#extradata 0: 17, 0x197103ea +#tb 0: 1/12288 +#media_type 0: video +#codec_id 0: av1 +#dimensions 0: 720x300 +#sar 0: 1/1 +0, 0, 0, 512, 17049, 0x6d66f097 +0, 512, 512, 512, 8365, 0x9c48024d, F=0x0 +0, 1024, 1024, 512, 77, 0x88251d4e, F=0x0 +0, 1536, 1536, 512, 232, 0x3c31706f, F=0x0 +0, 2048, 2048, 512, 245, 0x8195753f, F=0x0 +0, 2560, 2560, 512, 271, 0x134f86cc, F=0x0 +0, 3072, 3072, 512, 246, 0x04b777cf, F=0x0 +0, 3584, 3584, 512, 143, 0x6cbd43a3, F=0x0 +0, 4096, 4096, 512, 215, 0x88d66733, F=0x0 +0, 4608, 4608, 512, 83, 0xb2d22362, F=0x0 +0, 5120, 5120, 512, 50, 0x75d211e2, F=0x0 +0, 5632, 5632, 512, 5087, 0x505ec5f3, F=0x0 +0, 6144, 6144, 512, 242, 0x70fe6f2c, F=0x0 +0, 6656, 6656, 512, 366, 0xcb0caedc, F=0x0 +0, 7168, 7168, 512, 644, 0xf72e3623, F=0x0 +0, 7680, 7680, 512, 668, 0x0cff4537, F=0x0 +0, 8192, 8192, 512, 239, 0x364c77a4, F=0x0 +0, 8704, 8704, 512, 400, 0x7e3bbaef, F=0x0 +0, 9216, 9216, 512, 404, 0x175cb5db, F=0x0 +0, 9728, 9728, 512, 277, 0x113185c5, F=0x0 +0, 10240, 10240, 512, 46, 0x0c860cfa, F=0x0 +0, 10752, 10752, 512, 659, 0x501b392a, F=0x0 +0, 11264, 11264, 512, 478, 0x0503e8ec, F=0x0 +0, 11776, 11776, 512, 1132, 0x952a1543, F=0x0 -- 2.52.0 >From 5d5b450d2c760e3e185fcd23283837e74ae7ba2e Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Tue, 8 Sep 2026 22:10:18 -0300 Subject: [PATCH 2/2] tests/fate/mov: add more CENC tests This covers h264 and hevc for both Annex B and ISOBMFF input codepaths. Signed-off-by: James Almer <[email protected]> (cherry picked from commit 5b614efc7e6134274fa5d05e240736be2dc203cc) --- tests/fate/mov.mak | 12 ++++++++++-- tests/ref/fate/mov-h264-cenc | 25 +++++++++++++++++++++++++ tests/ref/fate/mov-h264_iso-cenc | 13 +++++++++++++ tests/ref/fate/mov-hevc-cenc | 9 +++++++++ tests/ref/fate/mov-hevc_iso-cenc | 10 ++++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 tests/ref/fate/mov-h264-cenc create mode 100644 tests/ref/fate/mov-h264_iso-cenc create mode 100644 tests/ref/fate/mov-hevc-cenc create mode 100644 tests/ref/fate/mov-hevc_iso-cenc diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 56dc3763c0..87882756c1 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -198,10 +198,18 @@ fate-mov-mp4-fragmented-ttml-dfxp: CMD = transcode srt $(TARGET_SAMPLES)/sub/Sub "-f lavfi -i smptehdbars=duration=24.5245:size=320x180:rate=24000/1001,format=yuv420p" \ "" "" "data" -FATE_MOV_FFMPEG_SAMPLES-$(call REMUX, MP4 IVF, MOV_DEMUXER AV1_PARSER EXTRACT_EXTRADATA_BSF) += fate-mov-av1-cenc -fate-mov-av1-cenc: CMD = transcode ivf $(TARGET_SAMPLES)/av1/non_uniform_tiling.ivf mp4 \ +define FATE_MOV_CENC_TEST +FATE_MOV_FFMPEG_SAMPLES-$(call REMUX, MP4 $(4), MOV_DEMUXER $(2)_PARSER EXTRACT_EXTRADATA_BSF) += fate-mov-$(1)-cenc +fate-mov-$(1)-cenc: CMD = transcode $(3) $(TARGET_SAMPLES)/$(5) mp4 \ "-c:v copy -encryption_scheme cenc-aes-ctr -encryption_key 00112233445566778899aabbccddeeff -encryption_kid 00112233445566778899aabbccddeeff" \ "-c:v copy" "" "" "-decryption_key 00112233445566778899aabbccddeeff" +endef + +$(eval $(call FATE_MOV_CENC_TEST,av1,AV1,ivf,IVF,av1/non_uniform_tiling.ivf)) +$(eval $(call FATE_MOV_CENC_TEST,h264,H264,h264,H264,h264-conformance/CAMACI3_Sony_C.jsv)) +$(eval $(call FATE_MOV_CENC_TEST,h264_iso,H264,matroska,MATROSKA,h264/dts_5frames.mkv)) +$(eval $(call FATE_MOV_CENC_TEST,hevc,HEVC,hevc,HEVC,hevc-conformance/ipcm_A_NEC_3.bit)) +$(eval $(call FATE_MOV_CENC_TEST,hevc_iso,HEVC,mov,MOV,hevc/extradata-reload-multi-stsd.mov)) # avif demuxing - still image with 1 item. FATE_MOV_FFMPEG_SAMPLES-$(call FRAMECRC, MOV, AV1, AV1_PARSER) \ diff --git a/tests/ref/fate/mov-h264-cenc b/tests/ref/fate/mov-h264-cenc new file mode 100644 index 0000000000..75c15e7238 --- /dev/null +++ b/tests/ref/fate/mov-h264-cenc @@ -0,0 +1,25 @@ +59561bc01461cbcb947281c091cac9ee *tests/data/fate/mov-h264-cenc.mp4 +72996 tests/data/fate/mov-h264-cenc.mp4 +#extradata 0: 25, 0x5c9d073a +#tb 0: 1/1200000 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 192x128 +#sar 0: 0/1 +0, -96000, -96000, 48000, 5183, 0x9bc6204f, F=0x5 +0, -48000, -48000, 48000, 4528, 0x9e28ce6e, F=0x4 +0, 0, 0, 48000, 4660, 0x1ff41c2a, F=0x0 +0, 48000, 48000, 48000, 3740, 0x8cec5062, F=0x0 +0, 96000, 96000, 48000, 3492, 0x8471c705, F=0x0 +0, 144000, 144000, 48000, 4793, 0xab1b7855, F=0x0 +0, 192000, 192000, 48000, 3351, 0xad2783f0, F=0x0 +0, 240000, 240000, 48000, 3396, 0xe0908da6, F=0x0 +0, 288000, 288000, 48000, 4846, 0x03a36085, F=0x0 +0, 336000, 336000, 48000, 3870, 0xdd6fa409, F=0x0 +0, 384000, 384000, 48000, 4022, 0x2a85ee8e, F=0x0 +0, 432000, 432000, 48000, 5641, 0x60cfe0ca, F=0x0 +0, 480000, 480000, 48000, 4221, 0x97733c38, F=0x0 +0, 528000, 528000, 48000, 4068, 0xfc65fe01, F=0x0 +0, 576000, 576000, 48000, 3971, 0x1b7aa573, F=0x0 +0, 624000, 624000, 48000, 3964, 0x4abab2ed, F=0x0 +0, 672000, 672000, 48000, 3867, 0xf12f9612, F=0x0 diff --git a/tests/ref/fate/mov-h264_iso-cenc b/tests/ref/fate/mov-h264_iso-cenc new file mode 100644 index 0000000000..96a6e9a723 --- /dev/null +++ b/tests/ref/fate/mov-h264_iso-cenc @@ -0,0 +1,13 @@ +03e458edc426f90f52b560e175ad32d2 *tests/data/fate/mov-h264_iso-cenc.mp4 +15542 tests/data/fate/mov-h264_iso-cenc.mp4 +#extradata 0: 40, 0xcd870951 +#tb 0: 1/16000 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 2672, 14428, 0x1c626b86 +0, 2672, 2672, 2656, 11, 0x08f901f1, F=0x0 +0, 5328, 5328, 2672, 11, 0x09990211, F=0x0 +0, 8000, 8000, 2672, 11, 0x0a390231, F=0x0 +0, 10672, 10672, 2672, 11, 0x0ad90251, F=0x0 diff --git a/tests/ref/fate/mov-hevc-cenc b/tests/ref/fate/mov-hevc-cenc new file mode 100644 index 0000000000..c823b24ed5 --- /dev/null +++ b/tests/ref/fate/mov-hevc-cenc @@ -0,0 +1,9 @@ +67d984d1166e68b085e85dabac1d69fb *tests/data/fate/mov-hevc-cenc.mp4 +6166 tests/data/fate/mov-hevc-cenc.mp4 +#extradata 0: 101, 0x8d351483 +#tb 0: 1/1200000 +#media_type 0: video +#codec_id 0: hevc +#dimensions 0: 416x240 +#sar 0: 0/1 +0, 0, 0, 48000, 5155, 0x18ffdb5c diff --git a/tests/ref/fate/mov-hevc_iso-cenc b/tests/ref/fate/mov-hevc_iso-cenc new file mode 100644 index 0000000000..2a1a3dcc19 --- /dev/null +++ b/tests/ref/fate/mov-hevc_iso-cenc @@ -0,0 +1,10 @@ +3b47c19a63210cf0bc2be5bf51fa36ad *tests/data/fate/mov-hevc_iso-cenc.mp4 +5548 tests/data/fate/mov-hevc_iso-cenc.mp4 +#extradata 0: 110, 0xb3a41478 +#tb 0: 1/12800 +#media_type 0: video +#codec_id 0: hevc +#dimensions 0: 128x128 +#sar 0: 1/1 +0, 0, 0, 512, 2108, 0x57c38f64 +0, 512, 512, 512, 31, 0xabe10d25, F=0x0 -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
