From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0FF0F48DAA for ; Fri, 26 Apr 2024 15:51:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 00E9268D3E1; Fri, 26 Apr 2024 18:51:31 +0300 (EEST) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACCC268D234 for ; Fri, 26 Apr 2024 18:51:23 +0300 (EEST) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1e51398cc4eso21256955ad.2 for ; Fri, 26 Apr 2024 08:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714146681; x=1714751481; 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=Hyduo43ixhhhyJ8yZb9HFdntawUj1lSx2FlEkRnKDWI=; b=BtXE64TCzM0T8Xj51SijRovZRPhahSIjxZXq8B0Q+lP+eVGC6IC/ia4eMmPvkwlTAL YgOsGkSiSRfiO7WYrn7sq20cGjuL2Ew5QNQURaGs4/hYYm3UqrrGZlxVs0owEx3hLk5R SMBLP6t+20/j/ydNVp+S6PbFV4nTh/59BkTlM0LC9naQBrhgK6mTZ+zj5ZzlI34W1See dvNeDwjupT2LNnzuTb7UDTfwxz6ray8d7xRmOXRhhzlD7AX1Bp4HSJKGPSBYFeJMxgWK u8QVsD08WXtD4/bF3rn4sCFzcoRlSYN9PxNWw1vdLXjhmvZdQFKAVTzmy3pBgbtw6LJM 1gvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714146681; x=1714751481; 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=Hyduo43ixhhhyJ8yZb9HFdntawUj1lSx2FlEkRnKDWI=; b=APPdaC/I9Rea2Ttyk3BClqlIEx9Wkk8bhWYHL3DuGwOh/zOihlhb4ioGY7tUMD62Mu cWaarLQbWZEU9tuRWgaR9KS+MnFasrqA7/e92Gsp9h/ViQhkWcNNA4G+4KKKpbOjzcg3 fTZK8N40tySEcaJ923x/UVElxjcyDQzFupa3yjHFuS4Ambi4ODs10LlArtNYlFrIap/A MOLo8frdPxnjRCLRrjhzgQOHH7fJWW99lp9vaGPbvQmBRLzjiDr2CR+Wt26PSKEqf/H3 WtabaIAfTW6q9gbr9S8xXxjJJVd6UdvXdYT58THolo/oQwF93SdZKgd6Nf7mUCBDgMw5 ysxg== X-Gm-Message-State: AOJu0YxhJO41j1D9Qc8hjtNnBqJ9HsWm9liDweBId9bj9sJcGvX1TtPO oBlLY+D4dhe8aIMWvCFhuCT65eJ8wPvksxYFUxYTLD7uFkswq7qbooA8NQ== X-Google-Smtp-Source: AGHT+IELYh8kD4mFJgXsyGPNnnNirT9cF4fL5GLlrZdn8xEFgDPQ13jHWkodYbsF/71KJ2GJIQEZwg== X-Received: by 2002:a17:902:e945:b0:1e3:c327:35c0 with SMTP id b5-20020a170902e94500b001e3c32735c0mr5072583pll.2.1714146681104; Fri, 26 Apr 2024 08:51:21 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id k17-20020a170902c41100b001e00285b727sm15649331plk.294.2024.04.26.08.51.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:51:20 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Apr 2024 12:51:04 -0300 Message-ID: <20240426155104.599-2-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240426155104.599-1-jamrial@gmail.com> References: <20240426155104.599-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mov: support SpatialAudioBox ambisonic layouts with non-diegetic channels 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: According to https://github.com/google/spatial-media/blob/master/docs/spatial-audio-rfc.md the first bit in ambisonic_type is a flag to signal the presence of non-diegetic channels in the audio track in addition to the ambisonic ones, so support this case too. Signed-off-by: James Almer --- Untested, and the spec could use some clarification/improvement for this field. libavformat/mov.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index d0ee6201a5..e52a83c82e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7928,6 +7928,7 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) AVChannelLayout ch_layout = { 0 }; int ret, i, version, type; int ambisonic_order, channel_order, normalization, channel_count; + int ambi_channels, non_diegetic_channels; if (c->fc->nb_streams < 1) return 0; @@ -7946,11 +7947,12 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) } type = avio_r8(pb); - if (type) { + if (type & 0x7f) { av_log(c->fc, AV_LOG_WARNING, - "Unsupported ambisonic type %d\n", type); + "Unsupported ambisonic type %d\n", type & 0x7f); return 0; } + non_diegetic_channels = !!(type & 0x80) * 2; ambisonic_order = avio_rb32(pb); @@ -7969,12 +7971,14 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) } channel_count = avio_rb32(pb); - if (ambisonic_order < 0 || channel_count != (ambisonic_order + 1LL) * (ambisonic_order + 1LL)) { + if (ambisonic_order < 0 || channel_count != ((ambisonic_order + 1LL) * (ambisonic_order + 1LL) + + non_diegetic_channels)) { av_log(c->fc, AV_LOG_ERROR, "Invalid number of channels (%d / %d)\n", channel_count, ambisonic_order); return 0; } + ambi_channels = channel_count - non_diegetic_channels; ret = av_channel_layout_custom_init(&ch_layout, channel_count); if (ret < 0) @@ -7990,7 +7994,10 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_channel_layout_uninit(&ch_layout); return 0; } - ch_layout.u.map[i].id = AV_CHAN_AMBISONIC_BASE + channel; + if (channel >= ambi_channels) + ch_layout.u.map[i].id = channel - ambi_channels; + else + ch_layout.u.map[i].id = AV_CHAN_AMBISONIC_BASE + channel; } ret = av_channel_layout_retype(&ch_layout, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); -- 2.44.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".