From patchwork Fri Apr 26 15:51:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 48275 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1509:b0:1a9:af23:56c1 with SMTP id nq9csp461569pzb; Fri, 26 Apr 2024 08:51:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWT7SZuOGtKQh8E395TVcu0+EuNrp+Z1V7b9c0VIFvVPLDRASXrW5twPTDmhJpw416UlIUCKI6XlWuXwyDmlhurGbkUIjZ9ujkNdA== X-Google-Smtp-Source: AGHT+IFHXqgesVW3awjG+F30w4BX1L5AaVEZvqwaDYfJ06k45Ey/LzXm2QP2vC4A5Ct5RV1hasUj X-Received: by 2002:a2e:9801:0:b0:2de:9c32:b98b with SMTP id a1-20020a2e9801000000b002de9c32b98bmr1790586ljj.2.1714146695534; Fri, 26 Apr 2024 08:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714146695; cv=none; d=google.com; s=arc-20160816; b=dRGvc7+H3V8R9jBhAeyiM+y2o3kVTqgsFA8CgEjqqCX6gZK7FKjsTLmXKR4nO10L2O RRdUpum9at3MWHG/7WgvT50241bn6/gVbKyXj2QA0L3e07HpzvhA+llwlufZPS9Y6PeQ A9b1IoqrDaJmj+ur4XFYPy91KP4GOuPTtTQCKCgYQ+a9tPO7ZB84PXpCDlTEBcTZ11Sp zwdjDBzoQi5Dp77mIO3NjjhPBPWRiDMGVJpG2vRRDuBbjA9z4Y6XSC/fU7u6jPpw/ESE u8QD2C+feaiv+TBZUNFOInfleqWDHSDbJGEAxiSxn3qDXg+znC20iQDuDtegVxkkWHkw IsYw== 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=Pn4hC+GY6zmFS8DBoXU3hRF/ErYhj5qjtZTo8R+pFyY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=vMix9f1UgS39wWU0DfZtDwnrfnKl4bjp8/7jQns74OEJxbW18O13RLRAfto+z4KW9g ruS6J4JGYJk4ARowS5Tw8VxGKCUHJ1rNmwNQmMNHeUU4RONTnsiWgOSpGWWJQiho9Kh3 ULTYbE2m0DCHffVlkuZZ14AZm9sqE9kqAHxqRNAthnGtMktsUGODm+00VhBE2AZeah2V ddR7j9wv62+9FJLVeehzOD+0y0BDjUO5fZhjyxTm04AxYrsiDAvEyfQ0/3etZTBsIPHg LFmT4u1EQAjCuTu8ZbDfULxO8L6GbeFm3KA0pb1rclXWjUjZWGQfNINPKqiwlXr+pV08 K7Gg==; 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=MsNXuZwb; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h26-20020a2e901a000000b002d40e6dab63si5402479ljg.494.2024.04.26.08.51.35; Fri, 26 Apr 2024 08:51:35 -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=MsNXuZwb; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F190F68D3D1; Fri, 26 Apr 2024 18:51:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CBB4868D234 for ; Fri, 26 Apr 2024 18:51:22 +0300 (EEST) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1e51398cc4eso21256665ad.2 for ; Fri, 26 Apr 2024 08:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714146679; x=1714751479; 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=XPUiLCpVaKuI8DTaKE+1yoLDUSucHftEj/NAHGnwiO4=; b=MsNXuZwbLro7dJG8B+dxMtHaUyUu8k8VY1Nofix53jltt+b49KZHBeYkiTtj3Q18+T EJlTPZJIDw7ILyCZR6hQVkuDY0jMUtIeT/q0InHRu/mJn8j+WvNpJG+OlirMAQhaltHX Bx15VVuSnzE+HL+wrxpOOpPWFxrupzIvLeMxPDnOtXLQvaNHFrvZmr8puqkqzYFGLtvu kHjk0DdRP1BgcJw8IZGameGCnH814Bj6RUkDW0k/QiQVjaf91ZMqGGJu1Q4pivJPzRia T2lLJdnw0zKexX5dMfc6UUuZ6ZsUS6aaWmWD6ov2LTAGGQQ1Jxi4PhyB3uPu2UVBMsG7 kj9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714146679; x=1714751479; 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=XPUiLCpVaKuI8DTaKE+1yoLDUSucHftEj/NAHGnwiO4=; b=hqaX0p65AP45pbsIc/Huof8+qGhpbZJLDJd4SERNh+g/peciaObjg0EI2gInpYYWQn Tyy6LkXaSvJU06bxtfKolvLSmcSwvrWci7MJyEwYBA/TUdYyKey5PTApjTGgvypXvCiU d+BKNV4SE6jfJdqD3mUQaQSBbcNd8/GYsRk41rp+/etw3ckRHzGwQlzZkSgLUWkHRmh6 zwjvANY/uMi53EkwvGNGaKUPYuBLZUYIwMkBSYF7B03DTU4W8uM+q8ujrVFUcC2VIyMb m9gRPo28q79sejspni5PfEcCONUQHsiagOyrU91owjyZx8RCW3xPa296Gr5fcsWN7jKE h0pg== X-Gm-Message-State: AOJu0Yy74fIW0IjYX3h3PFv+GPznS+SwREfdIqxeLpaSbIR08qV/ckBo 7QvXTUVSwL3aGK7SnzIV3FZtxy4+KU7qFVKmR8hSQck/y8ONXcDssAeIQg== X-Received: by 2002:a17:903:181:b0:1e7:b7b7:7b44 with SMTP id z1-20020a170903018100b001e7b7b77b44mr4630835plg.15.1714146679291; Fri, 26 Apr 2024 08:51:19 -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.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:51:18 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Apr 2024 12:51:03 -0300 Message-ID: <20240426155104.599-1-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mov: support SpatialAudioBox ambisonic layouts with arbitrary channel mapping 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: efpc8zEWRh7n We can safely export custom channels layout now, so there's no reason to reject valid layouts defined in this box. Signed-off-by: James Almer --- Untested. libavformat/mov.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ecd29a7d08..d0ee6201a5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7925,7 +7925,8 @@ cleanup: static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; - int i, version, type; + AVChannelLayout ch_layout = { 0 }; + int ret, i, version, type; int ambisonic_order, channel_order, normalization, channel_count; if (c->fc->nb_streams < 1) @@ -7975,17 +7976,29 @@ static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } + ret = av_channel_layout_custom_init(&ch_layout, channel_count); + if (ret < 0) + return ret; + for (i = 0; i < channel_count; i++) { - if (i != avio_rb32(pb)) { - av_log(c->fc, AV_LOG_WARNING, - "Ambisonic channel reordering is not supported\n"); + unsigned channel = avio_rb32(pb); + + if (channel >= channel_count || + channel > INT_MAX - AV_CHAN_AMBISONIC_BASE) { + av_log(c->fc, AV_LOG_ERROR, "Invalid channel index (%d / %d)\n", + channel, ambisonic_order); + av_channel_layout_uninit(&ch_layout); return 0; } + 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); + if (ret < 0) + return ret; + av_channel_layout_uninit(&st->codecpar->ch_layout); - st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_AMBISONIC; - st->codecpar->ch_layout.nb_channels = channel_count; + st->codecpar->ch_layout = ch_layout; return 0; } From patchwork Fri Apr 26 15:51:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 48276 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1509:b0:1a9:af23:56c1 with SMTP id nq9csp461670pzb; Fri, 26 Apr 2024 08:51:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXzplmLgw8e4OM+Ecrpq9atEWW31xqp9SPxL7i5b6pxIincjIQNw6wbyUpeOrn1sf5ixWdgCIpUI6iTjB1WM7+FYfesOPOFt5PEhg== X-Google-Smtp-Source: AGHT+IEmHWfh2oWrTIP5aRNumKUtK4RVxw94SVaZ3vBS6t1WuD2tURToJN5zjLEoEIRUxVaYVX9j X-Received: by 2002:a50:d547:0:b0:568:8e22:4eff with SMTP id f7-20020a50d547000000b005688e224effmr1877425edj.37.1714146704681; Fri, 26 Apr 2024 08:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714146704; cv=none; d=google.com; s=arc-20160816; b=yRXGpaRkVq1O/EYeRR8rUulFywlIpuwu4D3jvqYwA9+tyTyEAJASMsgtwt0k0F8olJ 1nZbuzh5TkUrQzDmOERXNgkcVdl0JnNmBeDxLeYc9OKWl7E8w17MHOFU91QENEif66t7 DbvhVUK45UqhdK2frk52gKau1UJHixQAc1mBpZfZMJs4Ib2P0EYfszzWUbm9XdzoHOeR y43T0GQvHWzfkGP3XW5lMRE1kC+PuO9zFzbROAlkrjHzcS6UskBAkMyfynvbN4krUXvu KCm61vY4ldeLz433kcAM7KQRzw4cl3vIBvwJn8i3FihI1KtAlqNJeRZIOiE43ZCgHc0m GXhA== 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=ATS7m3pGLw/KuHtBJTgS53wui4VRKalL45LWBBrLYtA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=sMpHIxKSh+HS+rx2maEi+BrLwxX5MRG2unDfMtFinY4QHwZwgdADda73+/wm7SYYhV 8o8NHJ/2oT4O3qhy8HO62r9lTsE3r7y9ibNp1TZQh32KYrXsm1YtoDd4x6okN8QZlSeE FJLDSVqwNCodCcmTCYJk2PotQS1IPQrUuRAkBaW7i02drxgeWqEiYlVNFSfY+99Ld1XF GoeZp6uPEbDhw/cXTSh7aGCyM72H3iIu2UBKD4YeizzTJj1qrbOYgdL7e+KdudJ/rYp3 S1lJ66DVl3HRy1r78Z10/pWwcD3xWyn+thuQvbpuZp4hCj+KFIUkTe3/uod/h4h7dbFY 8MYA==; 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=BtXE64TC; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 26-20020a50875a000000b005721e7edb08si5126683edv.46.2024.04.26.08.51.44; Fri, 26 Apr 2024 08:51:44 -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=BtXE64TC; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 425FD68D3EA; Fri, 26 Apr 2024 18:51:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: m+8vPSoIoIz6 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);