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 From patchwork Wed Jul 17 01:49:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50607 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:40f5:b0:482:c625:d099 with SMTP id lb53csp649370vqb; Tue, 16 Jul 2024 19:06:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVFpZvi66fNebE0BEdr6sIS6f7tl1hlBgLFVCjEpEoVmFnm0mcCj34/zahcNe9L8xVHiBC9oDlCeEMIQgO9/v+by/IPWtWJjdlHWw== X-Google-Smtp-Source: AGHT+IEhJG/7wuTrVB9lnW/Tza1/CRf5r5lco0ovS4NknAMiTRcVAvJu5rF5HpED+EVsMq5Pab2i X-Received: by 2002:a2e:944b:0:b0:2ee:db2c:5753 with SMTP id 38308e7fff4ca-2eefd165eb0mr1539901fa.42.1721182011378; Tue, 16 Jul 2024 19:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721182011; cv=none; d=google.com; s=arc-20160816; b=v04Vy53SR2rcmv9rqhM7jZQTe9FnhPOLmzu0jb2lqEnQius717HJn1WGW3jRLFqoij GgCuJMU2dnU7D1fD3wkmRaYI+YyoEUxcDpIHGIyvPTKQypUydrHxXCVIanEAocvJyA/M 0rFaQpj5hzd1v+avO5p3YWYOJJWelPHA32jx0cov7TUBoROwan0ASBwqmIO6+s86ToF1 iZMQU2yz9tx7uvieFH3q6FA8HgFIhjEtLAK9+sBY4eShafcmqr0rfySCdJZfaeQJgkBo +h1sL0KKwOKT+62TaAU//XtqYZ65HnPJveIOEyPVdqnHq5uetAwnEqd8fGLNAqNpqn+j ehPw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=TodwqXy8zGBMgENp4K5M2/akXyJ50x1F8+xCmzKGHwc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=pe18aSggIq9OueNNG5FJCypttGD39xoO7rc7Vz5sB0KAl0Zaiq1cVdIEtTuna9O84r plcxYjlJp4OeTbQytybU2D4Af+PYIIeBPRf2HX1MU040YSFatpiISwfHlZncFh0yLYxG 1eNHS/yYqraoDXvXp+RAphPUn2eqCIAJNQrOxfzL6sOGiyUo6qIyTq9E+sRUxKuiS6ix lYQlEneEqIKm2rYtWP1uWRnISOjnSHOfGoY27aJ5S0Ba4D/9ZW3bxfutMRRB0LXp2RDe vYMKAzUjc+yTAcfc+cyNPUBq+Tx69lVMY421vzR+PoTAOjzTeqqeqNfpclBnllsbk+nY 9ihQ==; 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="kM4/rBoM"; 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 4fb4d7f45d1cf-59c4fcc0a3esi3578817a12.509.2024.07.16.19.06.50; Tue, 16 Jul 2024 19:06:51 -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="kM4/rBoM"; 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 E34BB68D7D2; Wed, 17 Jul 2024 04:49:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFB0868D88C for ; Wed, 17 Jul 2024 04:49:37 +0300 (EEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-70af8128081so4224874b3a.1 for ; Tue, 16 Jul 2024 18:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721180976; x=1721785776; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2LHuI10KjKe3Ry8Um3RNxpnrqK1FlihdMvzikZJ1r98=; b=kM4/rBoMQKPPOozp28Ohmr3mOL8FNFimMdXHk1Hh1vnI9sIpuuuaqwYpJK+/uMGh0H 3fhhDZMgLOetcgl8OIZlcMVz83Qxq8JHYlt+gIHbJriCUHIrqPnUc/7YvNCm1fOjBCAP Br559LiY0oow/bCtPXdPv8x0CPI+NhHuyJk+lecQdLU59aqYI30XPsGnGhy6pnE0NIER KKDlLUp8iqtKQAavAf01FZoUC3sFROD9mrvn0Z7nTWsvB+n7NN/5UjMFJMP8qE3sa3LT vPB2GR2yIv2ATQbYurthJjSzGNRtQaPzUh8bwduHigjh8JLKmT4tWTXOT+alMJ4K2bcX CVuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721180976; x=1721785776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2LHuI10KjKe3Ry8Um3RNxpnrqK1FlihdMvzikZJ1r98=; b=OAN2Iv+P/oG5RoiltglKSx6d8JZtQREFhB4MYOrTfzWh2vNdqn33dXe8pOQ+HksTBg Kojqn+bgPcMhC/+27oisM4So4pBh1FdcXPxF+moT+Vy/o8L9RjL4HNO+fYciSnwYDbBa M92hdDVcxbwuSMpcxb8qKG11PGQ3z1uZJeZPYnDc8DuoLWbZr1qBwEQntHkvkw70FpE3 DNKIq2w+sOzX/LE9befryu0ekWyQ0HuUCDCUBQkCQdKyvdOSu8cradVm17srjDGtK3yP TJOsXZK2NJUtb6PSdRXBOofEZ5WGZbrfyB3JTdPnf38MxPYEGsGuvVCUWvLPJBmuTdfn Aokg== X-Gm-Message-State: AOJu0Yz6UNolyCzv35aIdoNiEXGAh/EAxupqpIAli+RbE69d6HacQBkM dWgQQdwDfnrYfDAZ1AVcnfVrmAtB4yB+i6Yuf7cQDMeEOAJlgY2nvlf3TQ== X-Received: by 2002:a05:6a00:3c8c:b0:704:2811:62 with SMTP id d2e1a72fcca58-70ce4fbae2dmr247554b3a.13.1721180975791; Tue, 16 Jul 2024 18:49:35 -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.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 18:49:35 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Jul 2024 22:49:23 -0300 Message-ID: <20240717014925.16517-2-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717014925.16517-1-jamrial@gmail.com> References: <20240717014925.16517-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] avformat/iamf_writer: fix PCM endian-ness flag 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: KpK52gSBgmMJ From: Felicia Lim The value was swapped from what's defined in clause 3.11.4 of IAMF[1] [1]https://aomediacodec.github.io/iamf/#lpcm-specific --- libavformat/iamf_writer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c index 6d4e4082eb..35db078147 100644 --- a/libavformat/iamf_writer.c +++ b/libavformat/iamf_writer.c @@ -441,32 +441,32 @@ static int iamf_write_codec_config(const IAMFContext *iamf, avio_write(dyn_bc, codec_config->extradata, codec_config->extradata_size); break; case AV_CODEC_ID_PCM_S16LE: - avio_w8(dyn_bc, 0); + avio_w8(dyn_bc, 1); avio_w8(dyn_bc, 16); avio_wb32(dyn_bc, codec_config->sample_rate); break; case AV_CODEC_ID_PCM_S24LE: - avio_w8(dyn_bc, 0); + avio_w8(dyn_bc, 1); avio_w8(dyn_bc, 24); avio_wb32(dyn_bc, codec_config->sample_rate); break; case AV_CODEC_ID_PCM_S32LE: - avio_w8(dyn_bc, 0); + avio_w8(dyn_bc, 1); avio_w8(dyn_bc, 32); avio_wb32(dyn_bc, codec_config->sample_rate); break; case AV_CODEC_ID_PCM_S16BE: - avio_w8(dyn_bc, 1); + avio_w8(dyn_bc, 0); avio_w8(dyn_bc, 16); avio_wb32(dyn_bc, codec_config->sample_rate); break; case AV_CODEC_ID_PCM_S24BE: - avio_w8(dyn_bc, 1); + avio_w8(dyn_bc, 0); avio_w8(dyn_bc, 24); avio_wb32(dyn_bc, codec_config->sample_rate); break; case AV_CODEC_ID_PCM_S32BE: - avio_w8(dyn_bc, 1); + avio_w8(dyn_bc, 0); avio_w8(dyn_bc, 32); avio_wb32(dyn_bc, codec_config->sample_rate); break; From patchwork Wed Jul 17 01:49:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50608 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:40f5:b0:482:c625:d099 with SMTP id lb53csp643695vqb; Tue, 16 Jul 2024 18:50:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWY1rzQcbqjy3QSwuSMjfbOZoLs+VKczZYkN2al4wVApY1KaS3vtMvYbjX1QgjGhjj7Jsmii80rKcScRhIGdO6KJSn1AoVbgSBJ1A== X-Google-Smtp-Source: AGHT+IF+qVKqjPnKB6D5gbsVVcOmBEnitLTpEeg+7M19rOLABkzuR8XLWDklLktCriRJvoItQILM X-Received: by 2002:a05:6512:b9a:b0:52e:7f23:5d8d with SMTP id 2adb3069b0e04-52ee53db883mr137743e87.30.1721181006224; Tue, 16 Jul 2024 18:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721181006; cv=none; d=google.com; s=arc-20160816; b=KLAmJTgpDd9beP2te00mTgcBELH1RBu3irJDFs7dE2P8I4yONnIrLhTKi19LhvjJ9K p3v/S3en52fb69JJhBwyNn1kfT+LpAeTKqRhYhqm1nNqdgeO/9Xg3NSIFVneV3e5ww9G Nn1PkDV0vWqfp37X1wjTBERsqFIJfri7h1baXhFlQEUKIw79HF6sEiLrRdl/6lx0t/YM N78vrZuXrH8HViBQ7ucykkEHnWNiUljOTbs4DpC8iQ/VOUL41MCMnlohJ8ZlFoZvTJ9e kMCq7Fhuo6U0PyyJw9+zvFy0pGXWlHKuNR+lXWR5i8OeM8JSms5qjFGmwT9MRhmSw2g1 zmXQ== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=/1dPcgXpJ7besUK0CUJWCoZ0/KvqCQbYE93w4mhESdg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=eD65BqWXfJCrq865J9n8s2VVqeMx6P9G1K+cOxs5SKiFXw3ikbeJ0uRBcUyil7Bfcy ERNoY7l4mbE+Snj4ShjF9jCFMquhHUFXTVZXbDrcWHK9yQIdZK4PNx/RtAt9WjO+RqPi pIJY3QbjfHNYcU4j4YpdUUAh5pfyNJYOOfFtfOZg38nnwRA1xDHoKpWes0u4HvEqRoHZ nB1PfCXNjmwKGelX4Hpx7n0vQh/NMI9stxDaSqAAUslXJUn7Im5dGAqeRzZBJ1d19+3z rWZTCXzFY+wwvoX+NFrNJ7PPJtiEiGDiVGZCwttmhcuQH50MEwIYTD5c5oBRn57+jBFl CKjQ==; 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="II/0+onK"; 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 a640c23a62f3a-a79c2bff84dsi394363666b.363.2024.07.16.18.50.05; Tue, 16 Jul 2024 18:50:06 -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="II/0+onK"; 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 43E4468DAB7; Wed, 17 Jul 2024 04:49:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 76B7968D7D2 for ; Wed, 17 Jul 2024 04:49:39 +0300 (EEST) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-70b07bdbfbcso259823b3a.0 for ; Tue, 16 Jul 2024 18:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721180977; x=1721785777; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=MllPA9i0vqvVuvvpG5D4UlFzPXlwZPfkAlh5WHYG0CM=; b=II/0+onKtc9keNTpqwQQ69bF4ZjtWbPn0Vm8S8jJ+5v+mz5ILfmMjVsZ79QMrY2kNE EA1EdLi5U7Cb7P/k3NX+fLBU0b/RBQO+OxMOGerKMByzGVjVN3DZHBiQOZaYP3hvJKAu SoSjcukBKu9h2j+VeFesRVCpqMpcfElBSfPVLablWraB/AMpkB/A4ktbycX6oDktL3L7 CsZmhExEjF87ykYKs/YxHUnB2iXetNkYw3ge7vu6tH8+tDgwTgO+YOsNREQ4YN6M+wo0 pbV9w0QtE09fV/1AAPmpa1nKBtffO4isBrUwMJ69rcs+HIKUcDD66kCQHNTPe6akY5f0 DIXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721180977; x=1721785777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MllPA9i0vqvVuvvpG5D4UlFzPXlwZPfkAlh5WHYG0CM=; b=kwRW6UwuiCrXoqEWeLHMBGW/Xdi8ufX4xPXG6L+63/ghESiIwxiom4gDwl2ihQZRYS xW80yO5RRMJLdli5Gq8lf1Rd4alkMhsqE32k5oQwgVY/mEkujx0LQ/xu9cx2aZZNxnPj gIeYpY3TxDNx9C1HaasxqiuPu5TcwbbrsbXn1IHXzRuohbX7CawrS6VIqZwp3T1Im6KG y07peWL0sojtFZ+wZ6lEhw4WYGR/OCWr+LED7POm5sgT/CyJEdqacVFppD7O94iUAVXv 9eC3Zur4Ou3o9LzIudLp/Gw2oL8Gx0uhNdQXp2hoAjNfp0pkUPoo7A4Nd3iuIrYQYoZ1 Lepg== X-Gm-Message-State: AOJu0YxJpA21RQcu0EKvmszHngocER6Cpg2zegpFG/J3bPejp+XLeD/c yckPp03GmenjZlqiyDEbCbBVwGmkxCEi5DI4L7IQcNLukKDgz8sKGwVcNA== X-Received: by 2002:a05:6a20:729b:b0:1c2:8a69:338f with SMTP id adf61e73a8af0-1c3fdfda0dfmr579303637.12.1721180977230; Tue, 16 Jul 2024 18:49:37 -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.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 18:49:36 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Jul 2024 22:49:24 -0300 Message-ID: <20240717014925.16517-3-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717014925.16517-1-jamrial@gmail.com> References: <20240717014925.16517-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avformat/iamf_writer: fix coded audio_roll_distance values 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: fVyZmg20fPdY From: Felicia Lim 'seek_preroll' corresponds to 'audio_roll_distance' in IAMF[]1 [1]https://aomediacodec.github.io/iamf/v1.0.0-errata.html#audio_roll_distance --- libavformat/iamf_parse.c | 2 +- libavformat/iamf_writer.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index a69d4a2f3a..2674a5186d 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -683,7 +683,7 @@ static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len) substream->codecpar->codec_id = codec_config->codec_id; substream->codecpar->frame_size = codec_config->nb_samples; substream->codecpar->sample_rate = codec_config->sample_rate; - substream->codecpar->seek_preroll = codec_config->seek_preroll; + substream->codecpar->seek_preroll = -codec_config->seek_preroll * codec_config->nb_samples; switch(substream->codecpar->codec_id) { case AV_CODEC_ID_AAC: diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c index 35db078147..af837ccb1f 100644 --- a/libavformat/iamf_writer.c +++ b/libavformat/iamf_writer.c @@ -72,6 +72,34 @@ static int update_extradata(IAMFCodecConfig *codec_config) return 0; } +static int populate_default_seek_preroll(IAMFCodecConfig *codec_config) +{ + switch (codec_config->codec_id) { + case AV_CODEC_ID_OPUS: + if (!codec_config->nb_samples) + return AVERROR(EINVAL); + // ceil(3840 / nb_samples) + codec_config->seek_preroll = -(1 + ((3840 - 1) / codec_config->nb_samples)); + break; + case AV_CODEC_ID_AAC: + codec_config->seek_preroll = -1; + break; + case AV_CODEC_ID_FLAC: + case AV_CODEC_ID_PCM_S16BE: + case AV_CODEC_ID_PCM_S24BE: + case AV_CODEC_ID_PCM_S32BE: + case AV_CODEC_ID_PCM_S16LE: + case AV_CODEC_ID_PCM_S24LE: + case AV_CODEC_ID_PCM_S32LE: + codec_config->seek_preroll = 0; + break; + default: + return AVERROR(EINVAL); + } + + return 0; +} + static int fill_codec_config(IAMFContext *iamf, const AVStreamGroup *stg, IAMFCodecConfig *codec_config) { @@ -83,7 +111,7 @@ static int fill_codec_config(IAMFContext *iamf, const AVStreamGroup *stg, codec_config->sample_rate = st->codecpar->sample_rate; codec_config->codec_tag = st->codecpar->codec_tag; codec_config->nb_samples = st->codecpar->frame_size; - codec_config->seek_preroll = st->codecpar->seek_preroll; + populate_default_seek_preroll(codec_config); if (st->codecpar->extradata_size) { codec_config->extradata = av_memdup(st->codecpar->extradata, st->codecpar->extradata_size); if (!codec_config->extradata) From patchwork Wed Jul 17 01:49:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50609 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:40f5:b0:482:c625:d099 with SMTP id lb53csp643746vqb; Tue, 16 Jul 2024 18:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4e2D+ZetSS5AjFRgLkv2TirKARL9f11Vslq6xK2HKDH2nXzDssVSddLAgHurjvrfnJumxdoAJ0rQhBCqSSEmuJQDYIepMBmsSGg== X-Google-Smtp-Source: AGHT+IFREbJARpgccppf4vSG0tMDr5yw+PxR0g/uVboE+iL4FsG97AC7u0xbIn20VHhU5qsq9/3f X-Received: by 2002:a2e:9b53:0:b0:2ee:6a72:f006 with SMTP id 38308e7fff4ca-2eefd1206e5mr1471491fa.21.1721181015245; Tue, 16 Jul 2024 18:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721181015; cv=none; d=google.com; s=arc-20160816; b=QCLmbdTrjX6Dw+Ksq6YN2QIg5GFDqnZRZm9iGdyOc9YKqe/CjlU7GLlxKCG73gx6QD r6I9HtWFlK2pvwggoYZMPiEmDR8bbWi3uGv8+h4xudTSsb+aW4Kh5v8lduRSeF8jWR1k /F7/JYwSxbGqb0F6fXDzH8gECkUBx3oAcfolmiEomfGXKJ/n8C8T3+PAH4nWI6rdUxy6 yKXWRI/jPCQyCLLF6Q/0jjemO21WZEU313AgjektgYZj8j8V8lpKIpOn4WIJtvLri0uj TRc/9QSiKwQYbcJ3MbxpTmtpaw5T+CUOawWyxXRCidJG1oWbxoxG4L57WfSSGaTq32xY xHjw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=Mabx/VM1r7w/E9RRlRxVInguoVLOgc8CQbPPh7hJ4Ec=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=q4tQjQAcrZoK4+uJQcCTSjLA40eL01zeqZ7uHWOcnZl54K+aO/N9B+vOCW7IMDqtSG 0MmNBpIda8jAoffPYu6aysbUoj1iYYXooHgXAPWOiGYfZa8dILXrNENhD7q+U4izjybZ jNRUQmPzdyl8jQPiWJkAzSnZ/nwC6qGMztNdd/EAhFqax9bcSox4F/Fk8GrXo/UT3yPj d1L77DurJJObOLiF7k4RtZ8uSLEa5kuJUyp2oj30BDC1B27ckCIGif/6o+9N1LwlR00S xdzvePQthbVMxpedMmKdZnHXQ/T8mtGQ1+rl7VtXy1zHyQHJz6I6p3rUaPGgcbHLiZca 350A==; 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=KgWuvkvS; 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 4fb4d7f45d1cf-59b2705abcesi4595993a12.480.2024.07.16.18.50.14; Tue, 16 Jul 2024 18:50:15 -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=KgWuvkvS; 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 6728E68DAC2; Wed, 17 Jul 2024 04:49:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B617568DAA8 for ; Wed, 17 Jul 2024 04:49:41 +0300 (EEST) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-78512d44a17so4448625a12.3 for ; Tue, 16 Jul 2024 18:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721180979; x=1721785779; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HjiJgIi8Y5iLVRHS/9Luw0DKHpEbdJEqtOJuwJt7BRI=; b=KgWuvkvSdQaKil8xSJwUuQdG7WDHj5PB8VuuMmZVM3hsRskWaRzFyvCvnEUCMKD631 Mh6NPuCmoumRBWlujphciUNuidjtzMcaryPBqRBfKEvfSSMBXkuup2QGxWxNCi+JADbC u74rIu0450PW88YiAIAYt6oORVCg+t+Y/mwTw7JWFohRV4OiCsvmiPpRA3E+4EPABHFn 3I2b4uUs49OJwA4gwjh1oXXxbyhLiGh5y6qO7SK/tWS/rp01MIGQ3wGUFsn9x9uOw02W bjZE3UPv85vFDq1KLY70/EXmevvhHxr1KT+iwZX7dh0RC1VBNQKd++xiTx1z8jRe/PNp 6d8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721180979; x=1721785779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HjiJgIi8Y5iLVRHS/9Luw0DKHpEbdJEqtOJuwJt7BRI=; b=w188q2aZSvEtIt3ZZexiIo2wFoU7/fzArx2XeZPgUp7CrJUs4F2kDfxY1tH9cfuuwa LQ6CJikhqENF/Z17V+sVSFUQ7kF5U8JZMyp/+6AqxZ23UQHBfYB9qk4qmYC0GaL1gF0Q 68n76jPRitQP12kos2eLzBGGD0A6/gAr1agPOd+F6y09R7I0u176bzqMElxVApHrFhXx oINzvvkfCV6TDaViAWmZKOAStsQBlARI7Hg3TGhpq85dsdAV/Ay08xaaD7OnP0UdLy6E t6etHeDzcW8N+/M9bic7FBKOGvy7b6kkCAGZnaTVSYwbWbKBNCwnWGeQ60yLx5cGq62N UvSQ== X-Gm-Message-State: AOJu0YzdIbXdjxvg9wHo5NcTPuZx/EFKGOdRpAq3ydB5WFPqR4xyVBoz 5cYypv/43E+NJh2G/nexNe6V1UGUi/9RVIew993ObfJ2rKt8y7TMfaHgTA== X-Received: by 2002:a05:6a20:c888:b0:1c3:a446:160 with SMTP id adf61e73a8af0-1c3fdddcea5mr453324637.56.1721180978660; Tue, 16 Jul 2024 18:49:38 -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.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 18:49:38 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Jul 2024 22:49:25 -0300 Message-ID: <20240717014925.16517-4-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717014925.16517-1-jamrial@gmail.com> References: <20240717014925.16517-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/iamf: byteswap values in OpusHeader 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: IZ8tnNGa3xj1 Clause 3.11.1 of IAMF[1] states the values are stored in big endian, in contrast to the Ogg Encapsulation for Opus[2] where they are in little endian. [1]https://aomediacodec.github.io/iamf/v1.0.0-errata.html#opus-specific [2]https://datatracker.ietf.org/doc/html/rfc7845#section-5.1 Signed-off-by: James Almer --- libavformat/iamf_parse.c | 3 +++ libavformat/iamf_writer.c | 8 ++++++-- tests/ref/fate/iamf-5_1-copy | 8 ++++---- tests/ref/fate/iamf-5_1-demux | 8 ++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index 2674a5186d..8e9c48568f 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -272,6 +272,9 @@ static int update_extradata(AVCodecParameters *codecpar) switch(codecpar->codec_id) { case AV_CODEC_ID_OPUS: AV_WB8(codecpar->extradata + 9, codecpar->ch_layout.nb_channels); + AV_WL16(codecpar->extradata + 10, AV_RB16(codecpar->extradata + 10)); // Byte swap pre-skip + AV_WL32(codecpar->extradata + 12, AV_RB32(codecpar->extradata + 12)); // Byte swap sample rate + AV_WL16(codecpar->extradata + 16, AV_RB16(codecpar->extradata + 16)); // Byte swap Output Gain break; case AV_CODEC_ID_AAC: { uint8_t buf[5]; diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c index af837ccb1f..7522f15548 100644 --- a/libavformat/iamf_writer.c +++ b/libavformat/iamf_writer.c @@ -42,8 +42,12 @@ static int update_extradata(IAMFCodecConfig *codec_config) if (codec_config->extradata_size < 19) return AVERROR_INVALIDDATA; codec_config->extradata_size -= 8; - memmove(codec_config->extradata, codec_config->extradata + 8, codec_config->extradata_size); - AV_WB8(codec_config->extradata + 1, 2); // set channels to stereo + AV_WB8(codec_config->extradata + 0, AV_RL8(codec_config->extradata + 8)); // version + AV_WB8(codec_config->extradata + 1, 2); // set channels to stereo + AV_WB16(codec_config->extradata + 2, AV_RL16(codec_config->extradata + 10)); // Byte swap pre-skip + AV_WB32(codec_config->extradata + 4, AV_RL32(codec_config->extradata + 12)); // Byte swap sample rate + AV_WB16(codec_config->extradata + 8, 0); // set Output Gain to 0 + AV_WB8(codec_config->extradata + 10, AV_RL8(codec_config->extradata + 18)); // Mapping family break; case AV_CODEC_ID_FLAC: { uint8_t buf[13]; diff --git a/tests/ref/fate/iamf-5_1-copy b/tests/ref/fate/iamf-5_1-copy index bc4df7c57f..ed2046fe3b 100644 --- a/tests/ref/fate/iamf-5_1-copy +++ b/tests/ref/fate/iamf-5_1-copy @@ -1,7 +1,7 @@ -#extradata 0: 19, 0x379c0490 -#extradata 1: 19, 0x379c0490 -#extradata 2: 19, 0x3792048f -#extradata 3: 19, 0x3792048f +#extradata 0: 19, 0x3a0e0490 +#extradata 1: 19, 0x3a0e0490 +#extradata 2: 19, 0x3a04048f +#extradata 3: 19, 0x3a04048f #tb 0: 1/48000 #media_type 0: audio #codec_id 0: opus diff --git a/tests/ref/fate/iamf-5_1-demux b/tests/ref/fate/iamf-5_1-demux index bc4df7c57f..ed2046fe3b 100644 --- a/tests/ref/fate/iamf-5_1-demux +++ b/tests/ref/fate/iamf-5_1-demux @@ -1,7 +1,7 @@ -#extradata 0: 19, 0x379c0490 -#extradata 1: 19, 0x379c0490 -#extradata 2: 19, 0x3792048f -#extradata 3: 19, 0x3792048f +#extradata 0: 19, 0x3a0e0490 +#extradata 1: 19, 0x3a0e0490 +#extradata 2: 19, 0x3a04048f +#extradata 3: 19, 0x3a04048f #tb 0: 1/48000 #media_type 0: audio #codec_id 0: opus