From patchwork Wed Jul 17 01:49:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50606 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:40f5:b0:482:c625:d099 with SMTP id lb53csp643596vqb; Tue, 16 Jul 2024 18:49:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIx7S8c8aDlLzKUN13SppJ/bJYzjkw47IEOxyxjlqyRO3atiml+ToUUcRdwdZxaa55nvb6lBEbHKxK4rNSJ5cdz4be87l0m0u8Nw== X-Google-Smtp-Source: AGHT+IGb0PZFA9QfXxmIW6RGPEVzw3pVYJzSt09ckGs3U/TepyR0oWA0cPVjf+AiwdGjlF+bNtFV X-Received: by 2002:a05:651c:10a3:b0:2ec:440c:4e1c with SMTP id 38308e7fff4ca-2eefd0f2d73mr1464531fa.11.1721180988276; Tue, 16 Jul 2024 18:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721180988; cv=none; d=google.com; s=arc-20160816; b=kEs0xLQ2khxsIQEqLCTwEkSoiVDtS8O6bW8Uf3nH99OC5iXnl3bHFxxjnKKtamSv8u o385+t05t7N+g0V2L2Bt2z8QPLF6jN5VbgsUjQGXcJf1eEPxkbq9tjcgag93l0ugo28z 8/cCkkg6ExDjjTCZjd0SSylVAPWzEPa+XA0OjMgM2t1M6w6RYCND2JuvESqnlCw5qNU7 u+uTzJmb1C6lX56RV3sjCXARVEv3s2wReFqzpZmb7zHb7+8Fi/SGw3+TIKZ2Aa0N7vN/ 6ZkVa8vigEmVftU40WmcNgShSUBm5djREtqKJMzNFConNNByevRgOjvExzUmgCPzBrDU dI4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=EU536joXxYubwEIAWhIZy4fOsPtl7rWUO/rtrOs1fcs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=wRIqvj26xwKB1oPovTEF5fD5wsF2C5Yj19ZADPCuwBgJ9OappDcKwjKiz0kFQ7KGl6 faF5Xeu0xwc1s0Ghf8mXN8p6r4iMaHnS6ciP0Pb56QXiiYYl7iao513Cvla33eYdDXAa 1j3iG3I0eykpudERENbxcTOYqBEVKbHEn2e8qMgNRB8jocZK3PhNxpAv6buGeffZnYgI H8ISEnT0Wu1WA7QkTQA9NK82964cMLw5wIXUjIr1TceFqyST/WNO1VC/R5xG9mFnttx0 jIh1qUFs1W/dXgTtm3R7+dmDjSG0kGvadHRU3cR/X0LL6lTgDTctN6Gj7GDAcsJTe+IN 0MYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=UmaVTxvn; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2eee192add0si21880011fa.390.2024.07.16.18.49.47; Tue, 16 Jul 2024 18:49:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=UmaVTxvn; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9AC5A68DA97; Wed, 17 Jul 2024 04:49:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC5B568D7D2 for ; Wed, 17 Jul 2024 04:49:36 +0300 (EEST) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70b703eda27so2860621b3a.3 for ; Tue, 16 Jul 2024 18:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721180975; x=1721785775; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=TBUW5tN0QHp+6+k502sBmWuj4i8lcCN/Xzo4uRpDTD4=; b=UmaVTxvn58ac/surZnFAfsLJHmWJhPH32va+v2PhFkO8sDUKSeNeFsWiN2WDVlyq7Y 3lqLmvRZJ84g04gEJ5PmPfub7vJ33479/AORGCuEPIlBjcN+Ooa3fwEiSe51rYUaQIo4 28zErDEw3SJ1KsWts1D8qaVl0X7fZoi0cMlNDYNF2lb6kMtAL7faYUORgYLYBJzh/RR+ i4I3D+pn9fXt3zD29PWdlmxsRnMo9ZoqogFGRNtYvRn51Gp9Sau5fQcaHmIfWeBRNS3Q CqtlbPK9KaacIonkSPv6UL5/cecZ2zxcXs0nOEgN2D5yrOf27dQRsczszUw/iKC72i9H Z7Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721180975; x=1721785775; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TBUW5tN0QHp+6+k502sBmWuj4i8lcCN/Xzo4uRpDTD4=; b=sn2uFHu2BBb9HEaNjTqQBQasi0Zyj2ggpsBMsmLcCoHrxG6YwhSeiSVoY1BxqJwY3l RiYig6PjtaFaxccz0OHIZ7L0rvyXaaHEVvG//gLz/Rxgnli014TqtAA/br0uQXNddY5t Zxc8iQk6VtR2TF6OvtoqA8nym61JNEzvwJjGkRKs8cWdBI6vA/A2DhCfq/1vT2aTZ7om Meysj92Hp8sv7cW73w1r2YXZD/u+2fOy9aS+k+ToTeJ3rYuQV7FLzpO77ybZaaBa+vr6 iK3s0dN3a7elBXsVGGS+hsKhMyPQUMpzDXI8fv0G1Wpb326ywqg9cfUrgx7lOZyLUgWN UYsw== X-Gm-Message-State: AOJu0YwDKBBZP9fR7zElJDWj7KZesaG08IaUr1ytgO19P0fCspTu7dG2 xeObsCkW6a6PTN902HLNqDIXNwp6r8EgsnCW99JW6tr5RrhNFq85TiGiDg== X-Received: by 2002:a05:6a00:3a0f:b0:706:a87f:98ae with SMTP id d2e1a72fcca58-70ce4f1c984mr271780b3a.24.1721180974355; Tue, 16 Jul 2024 18:49:34 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca7545sm7025815b3a.153.2024.07.16.18.49.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 18:49:33 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Jul 2024 22:49:22 -0300 Message-ID: <20240717014925.16517-1-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] avformat/movenc: fix channel count and samplerate fields for IAMF tracks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: us3WaqJLr65Q From: Felicia Lim Clause 6.2.3 of IAMF[1] states both of these shall be set to 0. [1]https://aomediacodec.github.io/iamf/v1.0.0-errata.html#iasampleentry-section --- libavformat/movenc.c | 15 +++++++++++++++ tests/ref/fate/mov-mp4-iamf-5_1_4 | 2 +- tests/ref/fate/mov-mp4-iamf-7_1_4 | 2 +- tests/ref/fate/mov-mp4-iamf-ambisonic_1 | 2 +- tests/ref/fate/mov-mp4-iamf-stereo | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 2bea55e33d..5de188f4cf 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1399,6 +1399,11 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex avio_wb16(pb, 16); avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */ } else { /* reserved for mp4/3gp */ +#if CONFIG_IAMFENC + if (track->tag == MKTAG('i','a','m','f')) + avio_wb16(pb, 0); /* channelcount must be 0 for IAMF */ + else +#endif avio_wb16(pb, track->par->ch_layout.nb_channels); if (track->par->codec_id == AV_CODEC_ID_FLAC || track->par->codec_id == AV_CODEC_ID_ALAC) { @@ -1410,6 +1415,11 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex } avio_wb16(pb, 0); /* packet size (= 0) */ +#if CONFIG_IAMFENC + if (track->tag == MKTAG('i','a','m','f')) + avio_wb16(pb, 0); /* samplerate must be 0 for IAMF */ + else +#endif if (track->par->codec_id == AV_CODEC_ID_OPUS) avio_wb16(pb, 48000); else if (track->par->codec_id == AV_CODEC_ID_TRUEHD) @@ -5158,6 +5168,11 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat param_write_int(pb, "AudioTag", ff_codec_get_tag(ff_codec_wav_tags, track->par->codec_id)); param_write_int(pb, "Channels", track->par->ch_layout.nb_channels); +#if CONFIG_IAMFENC + if (track->tag == MKTAG('i','a','m','f')) + param_write_int(pb, "SamplingRate", 0); + else +#endif param_write_int(pb, "SamplingRate", track->par->sample_rate); param_write_int(pb, "BitsPerSample", 16); param_write_int(pb, "PacketSize", track->par->block_align ? diff --git a/tests/ref/fate/mov-mp4-iamf-5_1_4 b/tests/ref/fate/mov-mp4-iamf-5_1_4 index afaa620621..36106528ab 100644 --- a/tests/ref/fate/mov-mp4-iamf-5_1_4 +++ b/tests/ref/fate/mov-mp4-iamf-5_1_4 @@ -1,4 +1,4 @@ -5585ed23481b6f28437b3707a1ed632d *tests/data/fate/mov-mp4-iamf-5_1_4.mp4 +0316d0a483480ccd582fd20f06c77420 *tests/data/fate/mov-mp4-iamf-5_1_4.mp4 86340 tests/data/fate/mov-mp4-iamf-5_1_4.mp4 #extradata 0: 34, 0xafa70d5e #extradata 1: 34, 0xafa70d5e diff --git a/tests/ref/fate/mov-mp4-iamf-7_1_4 b/tests/ref/fate/mov-mp4-iamf-7_1_4 index e8b859121d..51494222fc 100644 --- a/tests/ref/fate/mov-mp4-iamf-7_1_4 +++ b/tests/ref/fate/mov-mp4-iamf-7_1_4 @@ -1,4 +1,4 @@ -690d2b7a15b5489c59a9148fcd7975be *tests/data/fate/mov-mp4-iamf-7_1_4.mp4 +d9ef5d14bbd37c5a06c1494cacdb8f29 *tests/data/fate/mov-mp4-iamf-7_1_4.mp4 100588 tests/data/fate/mov-mp4-iamf-7_1_4.mp4 #extradata 0: 34, 0xafa70d5e #extradata 1: 34, 0xafa70d5e diff --git a/tests/ref/fate/mov-mp4-iamf-ambisonic_1 b/tests/ref/fate/mov-mp4-iamf-ambisonic_1 index 8de90c868f..d0877f73c7 100644 --- a/tests/ref/fate/mov-mp4-iamf-ambisonic_1 +++ b/tests/ref/fate/mov-mp4-iamf-ambisonic_1 @@ -1,4 +1,4 @@ -2b3517591f7bf20e0f74f3ec1381af1e *tests/data/fate/mov-mp4-iamf-ambisonic_1.mp4 +b0f4accdb8f1f3dfe594a6cbd6c00603 *tests/data/fate/mov-mp4-iamf-ambisonic_1.mp4 57743 tests/data/fate/mov-mp4-iamf-ambisonic_1.mp4 #extradata 0: 34, 0xad120cfe #extradata 1: 34, 0xad120cfe diff --git a/tests/ref/fate/mov-mp4-iamf-stereo b/tests/ref/fate/mov-mp4-iamf-stereo index 32027e6daf..e40d164fc4 100644 --- a/tests/ref/fate/mov-mp4-iamf-stereo +++ b/tests/ref/fate/mov-mp4-iamf-stereo @@ -1,4 +1,4 @@ -88c2b547f069f2d4a11d24f7f922251a *tests/data/fate/mov-mp4-iamf-stereo.mp4 +87c17d1a9fd07e16c369d386d39c3249 *tests/data/fate/mov-mp4-iamf-stereo.mp4 15163 tests/data/fate/mov-mp4-iamf-stereo.mp4 #extradata 0: 34, 0xafa70d5e #tb 0: 1/44100