aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2025-02-18 19:24:48 +0800
committerZhao Zhili <zhilizhao@tencent.com>2025-03-04 17:01:58 +0800
commita053516e644e07d1e625901539671c3682c7af49 (patch)
treee9ed4cead708c3acca80a4342d9f56e1525b16ea /libavformat/movenc.c
parent71a91485fa05c1ca478de153d8839794606f8edc (diff)
downloadffmpeg-a053516e644e07d1e625901539671c3682c7af49.tar.gz
avformat/movenc: Add AVS3 support
'avs3' is registered at mp4ra.org. The Avs3ConfigurationBox 'av3c' inside 'avs3' hasn't been registered yet, but is specified by the AVS3 spec. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 76dce9e6e5..af013e1fc6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1540,6 +1540,38 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
return update_size(pb, pos);
}
+/* AVS3 Intelligent Media Coding
+ * Information Technology - Intelligent Media Coding
+ * Part 6: Intelligent Media Format
+ */
+static int mov_write_av3c(AVIOContext *pb, const uint8_t *data, int len)
+{
+ if (len < 4)
+ return AVERROR_INVALIDDATA;
+
+ if (data[0] == 1) {
+ // In Avs3DecoderConfigurationRecord format
+ avio_write(pb, data, len);
+ return 0;
+ }
+
+ avio_w8(pb, 1); // version
+ avio_wb16(pb, len); // sequence_header_length
+ avio_write(pb, data, len); // sequence_header
+ avio_w8(pb, 0xFC); // Only support library_dependency_idc = 0
+
+ return 0;
+}
+
+static int mov_write_av3c_tag(AVIOContext *pb, MOVTrack *track)
+{
+ int64_t pos = avio_tell(pb);
+ avio_wb32(pb, 0);
+ ffio_wfourcc(pb, "av3c");
+ mov_write_av3c(pb, track->vos_data, track->vos_len);
+ return update_size(pb, pos);
+}
+
static int mov_write_vpcc_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
@@ -2738,6 +2770,8 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
} else if (track->par->codec_id == AV_CODEC_ID_R10K) {
if (track->par->codec_tag == MKTAG('R','1','0','k'))
mov_write_dpxe_tag(pb, track);
+ } else if (track->par->codec_id == AV_CODEC_ID_AVS3) {
+ mov_write_av3c_tag(pb, track);
} else if (track->vos_len > 0)
mov_write_glbl_tag(pb, track);
@@ -8646,6 +8680,8 @@ static const AVCodecTag codec_mp4_tags[] = {
{ AV_CODEC_ID_PCM_F64BE, MOV_MP4_FPCM_TAG },
{ AV_CODEC_ID_PCM_F64LE, MOV_MP4_FPCM_TAG },
+ { AV_CODEC_ID_AVS3, MKTAG('a', 'v', 's', '3') },
+
{ AV_CODEC_ID_NONE, 0 },
};
#if CONFIG_MP4_MUXER || CONFIG_PSP_MUXER