From patchwork Thu Sep 1 18:17:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Graczyk X-Patchwork-Id: 388 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp1047633vsd; Thu, 1 Sep 2016 11:17:58 -0700 (PDT) X-Received: by 10.194.17.65 with SMTP id m1mr5324264wjd.131.1472753878253; Thu, 01 Sep 2016 11:17:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y136si2886718wmc.14.2016.09.01.11.17.55; Thu, 01 Sep 2016 11:17:58 -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=@google.com; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 66B65689CC9; Thu, 1 Sep 2016 21:17:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 06F80689CAC for ; Thu, 1 Sep 2016 21:17:34 +0300 (EEST) Received: by mail-pa0-f46.google.com with SMTP id fu3so24324753pad.3 for ; Thu, 01 Sep 2016 11:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z+T0aXDywWDLwFoHPD/V8Z49Ftp9rdQbtqKseO9pozA=; b=gdoH14HH9Nqt+J5k/9kEw0/qgKbyPwVhVG1t8kZFk21+HR6F04/PjBrhHvOZ8Mn4gM CJ1sTCIN3JwlmPQ0JzyXY3AQ3tnRq6F+r8p6Fj8ojAzWKMFnOrrtqmZB81w/vsCTraDY eJCObRj1L43qXzYavNhCJqSCVWT/uWUn0pQWLISekDNrFzBzqWNvBqevHpgUSCfaCoou kPX2/BzZy6Po6/ek6DLeq7epB7rLceTWldSWZZkKWCaXjZ8oiWWKIHkEeDLb2umMbvW7 DuEzy1fkxFJomNW9YKbKxAgLC5saV1E5BXcUKWU1WlUKwQnpRGon2qiYoMzXwQwy2F0/ Dclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z+T0aXDywWDLwFoHPD/V8Z49Ftp9rdQbtqKseO9pozA=; b=GTY2d+kJjYOhYihYGr/zB1V6Afyy8sdgS7kwBnZ6ZbTvnHaV5CK+xn/XngnMTUk4Iy dsiVGe2pkv7yhZOcdMaO0DfcjBsRZ90jQCVHTSKWOzNycPePFHucPN6DGs+2D+oalufO OkFY0VJzUMi407HSSzjpqfbvpRH5Fd7MgZqTpCP+nwkGZdtXZyt70DvgCxl5KKNrLANY QAaUTZvdl/ncKKdfIwqOGevZgFsPE7aq78yo2uRBRgQZjLIZ32wMoYxmKzXj3nM7Rs7F IecAvLXV6AD4cy2W08Unw51cV/mzs03BdUREAqPyY7aeEsspB95JSU1kTuCmQcVKikRQ KcfA== X-Gm-Message-State: AE9vXwOqkWhL2eQr9N6sZchKX7yaa838BH4MoXbjnOH5w1rYYNhUWrsD0JmnCezOLJ1RmeQY X-Received: by 10.66.191.199 with SMTP id ha7mr28942401pac.21.1472753859764; Thu, 01 Sep 2016 11:17:39 -0700 (PDT) Received: from mgraczyk.mtv.corp.google.com ([172.22.112.111]) by smtp.gmail.com with ESMTPSA id xx7sm9331838pac.3.2016.09.01.11.17.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Sep 2016 11:17:39 -0700 (PDT) From: mgraczyk-at-google.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 Sep 2016 11:17:30 -0700 Message-Id: <1472753850-14834-2-git-send-email-mgraczyk@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1472753850-14834-1-git-send-email-mgraczyk@google.com> References: <20160831210848.GC4692@nb4> <1472753850-14834-1-git-send-email-mgraczyk@google.com> Subject: [FFmpeg-devel] [PATCH] libavcodec/opus: Add channel mapping 2 to extradata parser X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Michael Graczyk MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Michael Graczyk This allows libavcodec/opus to demux ambisonics in an ogg/opus container. Channel mapping family 2 is being added in this standards track IETF draft: tools.ietf.org/html/draft-ietf-codec-ambisonics-00 --- libavcodec/opus.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/opus.c b/libavcodec/opus.c index 703d2e8..da015ec 100644 --- a/libavcodec/opus.c +++ b/libavcodec/opus.c @@ -347,7 +347,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, streams = 1; stereo_streams = channels - 1; channel_map = default_channel_map; - } else if (map_type == 1 || map_type == 255) { + } else if (map_type == 1 || map_type == 2 || map_type == 255) { if (extradata_size < 21 + channels) { av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n", extradata_size); @@ -371,6 +371,15 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, } layout = ff_vorbis_channel_layouts[channels - 1]; channel_reorder = channel_reorder_vorbis; + } else if (map_type == 2) { + int ambisonic_order = ff_sqrt(channels) - 1; + if (channels != (ambisonic_order + 1) * (ambisonic_order + 1)) { + av_log(avctx, AV_LOG_ERROR, + "Channel mapping 2 is only specified for channel counts" + " which can be written as (n + 1)^2 for nonnegative integer n\n"); + return AVERROR_INVALIDDATA; + } + layout = 0; } else layout = 0;