PR #24410 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24410 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24410.patch
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 fb490520bf63d2bed5c5f4ce1004e363dc06800a Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Mon, 7 Sep 2026 17:05:38 -0300 Subject: [PATCH] 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]> --- libavformat/cbs_av1.h | 30 ++++++++++++++++++++++++++++++ libavformat/movenccenc.c | 2 +- tests/fate/mov.mak | 5 +++++ tests/ref/fate/mov-av1-cenc | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 libavformat/cbs_av1.h create mode 100644 tests/ref/fate/mov-av1-cenc 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 1a81962626..aa56f1ac2e 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -208,6 +208,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 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
