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 A66E048DBF for ; Fri, 26 Apr 2024 15:51:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 940CC68D3CD; Fri, 26 Apr 2024 18:51:29 +0300 (EEST) 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-Google-Smtp-Source: AGHT+IH9BF4QRPJLb9lfA405CfJQMplkE3hFtbLomQfpCMs7aLoqcq0MVFX74YFCkSPSReia2HZlfQ== 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 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: 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; } -- 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".