From patchwork Sun Oct 27 22:47:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 52536 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:8182:0:b0:48e:c0f8:d0de with SMTP id o2csp20134vqg; Mon, 28 Oct 2024 14:14:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXydFogBOIv5bOLBOehrhn17GfeP+gLVsg6i4SqbUpFN8XCSLc5Kf0LSJTXMWnppu6E1nEtaTbzmgYplC618HI8@gmail.com X-Google-Smtp-Source: AGHT+IHazPIR1BJlqP8pNLusdmmb6tuRxVykw2tuNYFJoWUbOOmsP3Jt0SGdB9IvcRdy51qpir5Z X-Received: by 2002:a05:6512:3a82:b0:536:a275:9d58 with SMTP id 2adb3069b0e04-53b3490d0c6mr1245715e87.7.1730150090325; Mon, 28 Oct 2024 14:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730150090; cv=none; d=google.com; s=arc-20240605; b=FmKdt2vMHU9DjYFpP2Vjq3Dr2lr76sf6Eu/UTIXVkQMAK/vzYYDR4tWCC6Pxkfr6T/ fHZMlXPlG8jnz/HX5YcjrfaiKc+XktLnKR+9MkJod3tBCRPNhFd0xdeKIve3vlikiLz3 jboz1KISSi3hkljSgIjGzFYZliV5VQFC2uUeJ+L2aSEjRXRRVJAIKNi2os6P6zF7w0hg oYCT1PF4f5+EQWeVrrmUQSKQtTlEpyuyED2CrDsFSo22b6CNtCLUYRmubFXIMFP20Mf4 5F6DQsGY02I7b0z9ejsXhkyKQnYoeMbkS/76hRFCXE0WF/yymMgedTuWCHcB4vMbelH0 nvug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=EdJ0Ln8Xtd5pq1y69WRq0+K4sNfQP6v5Ix7pPQsDAAY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OhcUe3u/iLaIXQc/S6KZkU4wjpWN5Ddy/av4celitKhfPZyQ2L4ERaCeN+iOnul1QQ iuQwcZe5Ar9Gugtmp282ljv4a+CH+z1FF/PDgPaKa+tjh1z27kv51lmoEbsFxKYn3z9z DHNPEY48UP7Q9bL6fah1w/ZnnWnXgy7rG3G1/gMR2AzfD2R+JuuTYX1afWAEnx9uzN2M UgeuNlflAmKIbHGY/0BzHGhcFpX9ycG0+QACw0uJYsp7J5KInn9Mf4uWMc7H7j1Y8Shq uul5aRS3DXfd/N4jiUVNzQIyeuR/Rj9F0G4OrEnnqiPJj84DQkS+oo5BCvHijMDEmmKr XdnA==; 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=SjUaH3FT; 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 2adb3069b0e04-53b2e12c78asi2857153e87.183.2024.10.28.14.14.49; Mon, 28 Oct 2024 14:14:50 -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=SjUaH3FT; 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 2D24368D49E; Mon, 28 Oct 2024 21:16:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2CCFB68D49E for ; Mon, 28 Oct 2024 21:15:59 +0200 (EET) Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-46090640f0cso39706791cf.0 for ; Mon, 28 Oct 2024 12:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730142958; x=1730747758; 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=PrX6Xn1n4zjZRpQxo7Ugf3U7lB5jVjMu1tzPzrNEvhw=; b=SjUaH3FTeyan/YhG1WhBlCXqRrjac+5IUPsL3TTZFBKD6iY9r2IFWaCvmaLwiWDOiV xTvH+N7MziEmQobeMorxm6u4vH0hxY2WJc5C2h1pc8n18ZKcOIk1aVikmdI7gAXOuERu l7/UQ8ZgGZxZEg2JW0Hh4BYP8+kbYrDkCJM/buavWeILYR7BSAxRAanfEKFLKNyuYreL 5rl/unwyhtWehGcDp+NINpisaeu0WV9NAf75m1EiGKHS3JtjhZfthUnWCqmh5u35PEnl m3H/bJvG3bRL1t7tudWZ3ElyuvnW0hZCwPgW+Y6ayspUlWJZapCrQzt6mUBNhiZ7F6JR blgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730142958; x=1730747758; 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=PrX6Xn1n4zjZRpQxo7Ugf3U7lB5jVjMu1tzPzrNEvhw=; b=ZhE/t6rP8Kt1fZaS0/XUC3ITAUL+ZFE+vl6rPkh6fe32UaQrjrtce2M7JG1WOlwHTH 1JHh8uOfmSlNlTJ+NwNSFF/W7hp7klv472aaBs8UKjLft9cPGDsNFVgtAjFnunN2A24U 6fNwcfO2DTRIsJsYVJdYYjcuC2HPzquIwEJwZ2vitaT7nNEDoWIO0t4V64GIH4nEFYAX 1PUXOsNJHfiRgzDfZVlmC96U7t3smugahnp2CJI+qSl9ELxXfODxEivQdZmm6LnqBdQk UeebhBrJcscEAkWwA+HJQbtwvxYB1BRbchGuN4SE6PJ8MUSeMIymtnQDJumi+4Cpqmb/ Ds5w== X-Gm-Message-State: AOJu0YyMwU9IOiBnirqox2+rl3NrQx0mCvqoQFkp4/+NT+sbIp6/A9p8 k8armctOwp/p+UdukfnCa1PL322owxeJvrHlWfJkGjoXgigMtNhHKXSnvw== X-Received: by 2002:a05:6a20:e18a:b0:1d9:2bed:c7e7 with SMTP id adf61e73a8af0-1d9a84d785amr8450188637.39.1730069301050; Sun, 27 Oct 2024 15:48:21 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72057921983sm4633106b3a.10.2024.10.27.15.48.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 15:48:20 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Oct 2024 19:47:48 -0300 Message-ID: <20241027224748.9189-2-jamrial@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241027224748.9189-1-jamrial@gmail.com> References: <20241027224748.9189-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/iamf: use the new Binaural channel layout 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: ZHYRAu/uMrZL Signed-off-by: James Almer --- libavformat/dump.c | 6 +++--- libavformat/iamf.c | 2 +- libavformat/iamf_parse.c | 3 ++- libavformat/iamf_writer.c | 3 +++ libavutil/iamf.h | 10 +++++++--- tests/ref/fate/iamf-stereo | 2 +- tests/ref/fate/mov-mp4-iamf-stereo | 2 +- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/libavformat/dump.c b/libavformat/dump.c index 7dc7f0ad5a..b7125a652f 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -752,12 +752,12 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed, for (int k = 0; k < sub_mix->nb_layouts; k++) { const AVIAMFSubmixLayout *submix_layout = sub_mix->layouts[k]; av_log(NULL, AV_LOG_INFO, " Layout #%d:", k); - if (submix_layout->layout_type == 2) { + if (submix_layout->layout_type == 2 || + submix_layout->layout_type == 3) { ret = av_channel_layout_describe(&submix_layout->sound_system, buf, sizeof(buf)); if (ret >= 0) av_log(NULL, AV_LOG_INFO, " %s", buf); - } else if (submix_layout->layout_type == 3) - av_log(NULL, AV_LOG_INFO, " Binaural"); + } av_log(NULL, AV_LOG_INFO, "\n"); } } diff --git a/libavformat/iamf.c b/libavformat/iamf.c index 5de70dc082..3fcf145a85 100644 --- a/libavformat/iamf.c +++ b/libavformat/iamf.c @@ -42,7 +42,7 @@ const AVChannelLayout ff_iamf_scalable_ch_layouts[10] = { // Front subset of "Loudspeaker configuration for Sound System J" AV_CHANNEL_LAYOUT_3POINT1POINT2, // Binaural - AV_CHANNEL_LAYOUT_STEREO, + AV_CHANNEL_LAYOUT_BINAURAL, }; const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13] = { diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index e0a138a07d..4aed894796 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -956,7 +956,8 @@ static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int le goto fail; } av_channel_layout_copy(&submix_layout->sound_system, &ff_iamf_sound_system_map[sound_system].layout); - } + } else + submix_layout->sound_system = (AVChannelLayout)AV_CHANNEL_LAYOUT_BINAURAL; info_type = avio_r8(pbc); submix_layout->integrated_loudness = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8); diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c index 1b620c38ee..7703729e07 100644 --- a/libavformat/iamf_writer.c +++ b/libavformat/iamf_writer.c @@ -817,6 +817,9 @@ static int iamf_write_mixing_presentation(const IAMFContext *iamf, av_log(log_ctx, AV_LOG_ERROR, "Invalid Sound System value in a submix\n"); return AVERROR(EINVAL); } + } else if (submix_layout->layout_type != AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL) { + av_log(log_ctx, AV_LOG_ERROR, "Unsupported Layout Type value in a submix\n"); + return AVERROR(EINVAL); } init_put_bits(&pbc, header, sizeof(header)); put_bits(&pbc, 2, submix_layout->layout_type); // layout_type diff --git a/libavutil/iamf.h b/libavutil/iamf.h index 1fa73893cd..2ed7b0f2d8 100644 --- a/libavutil/iamf.h +++ b/libavutil/iamf.h @@ -493,10 +493,14 @@ typedef struct AVIAMFSubmixElement { enum AVIAMFSubmixLayoutType { /** * The layout follows the loudspeaker sound system convention of ITU-2051-3. + * @ref AVIAMFSubmixLayout.sound_system must be set. */ AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS = 2, /** * The layout is binaural. + * + * @note @ref AVIAMFSubmixLayout.sound_system may be set to + * AV_CHANNEL_LAYOUT_BINAURAL to simplify API usage, but it's not mandatory. */ AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL = 3, }; @@ -514,9 +518,9 @@ typedef struct AVIAMFSubmixLayout { /** * Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus - * 7.1.2ch and 3.1.2ch - * If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS, this field - * is undefined. + * 7.1.2ch, 3.1.2ch, and binaural. + * If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS or + * AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL, this field is undefined. */ AVChannelLayout sound_system; /** diff --git a/tests/ref/fate/iamf-stereo b/tests/ref/fate/iamf-stereo index 9b3f7e0a79..843d1525e5 100644 --- a/tests/ref/fate/iamf-stereo +++ b/tests/ref/fate/iamf-stereo @@ -135,7 +135,7 @@ duration=0 constant_subblock_duration=0 [/PIECE] [PIECE] -sound_system=0 channels +sound_system=binaural integrated_loudness=0/256 digital_peak=0/256 true_peak=0/1 diff --git a/tests/ref/fate/mov-mp4-iamf-stereo b/tests/ref/fate/mov-mp4-iamf-stereo index e40d164fc4..ca8f6a76f5 100644 --- a/tests/ref/fate/mov-mp4-iamf-stereo +++ b/tests/ref/fate/mov-mp4-iamf-stereo @@ -157,7 +157,7 @@ duration=0 constant_subblock_duration=0 [/PIECE] [PIECE] -sound_system=0 channels +sound_system=binaural integrated_loudness=0/256 digital_peak=0/256 true_peak=0/1