From patchwork Tue Aug 30 21:48:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Graczyk X-Patchwork-Id: 342 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp53076vsd; Tue, 30 Aug 2016 14:48:33 -0700 (PDT) X-Received: by 10.194.79.198 with SMTP id l6mr5767317wjx.84.1472593713702; Tue, 30 Aug 2016 14:48:33 -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 i19si645620wmd.55.2016.08.30.14.48.26; Tue, 30 Aug 2016 14:48:33 -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 0A44C689D3D; Wed, 31 Aug 2016 00:48:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A8D1A689D00 for ; Wed, 31 Aug 2016 00:48:11 +0300 (EEST) Received: by mail-pa0-f45.google.com with SMTP id cy9so11294447pac.0 for ; Tue, 30 Aug 2016 14:48:18 -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; bh=XBsdoFBmpREZ0F9PLg8QRpWU7Z6/NGN/vd/HsfS/PFI=; b=Okl+s5gE75IXmNI47wCrwwO5xanXG7bgHzkjRqATAq2njOs1zsIasZaEfhmiG+iX7o eh21fxD5sAlp7tk/tCilJUqsPCNUhmqFppBn23xFEV5t3gd3hYCesEIHNYNm7En7Nuwq FcliZDGsN+cJb1aQgPAlxf3agnPhPvzhlrGApFgFo+IYt30Qjmu/GZKxBcN6gFzNlF/N CEJ8+c9afJuYgW34n7h3ApXpYbcP819TUFg+bREZZQ7a748iONuIc3Jf1uXmWSj9Og/z Ag4/VT3Br2LDYy3I41QyQe95wZnq14v5pMYctawoPfbReQENrMn2Jq7cAYbdysYC1o8G 0HXw== 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; bh=XBsdoFBmpREZ0F9PLg8QRpWU7Z6/NGN/vd/HsfS/PFI=; b=nLi7zMm+GUsj5btqnq7K3uSdTN///OXkfiNcAbEEP7FfOK2QYf6G5T0FW/2kzYX89U ZuayGpbWj9MEeZQDcaxtVRFljZHk5uXKpTkEWTgWmPx8+WWYJD78T6xapsJ1dQRsQLop Cwz3Vpd397Jn8rKdXmnUL2lguAZpBr37oUbl7blZZ3h7OdVw+Tn4H792qbXHND12YfYD cEVEmUD4rmDsAfaw3qivX1MbNMNn8/kxUji2bCOtHrh7RZkKipEDgNgHcvnkQ2zdMw6T dmbxNb52GRdt3ifcgqC0gkPcTneICuJUqyrX13UEEuM52LOslE9caRzg2M9L6C5ZqD+b 7fUw== X-Gm-Message-State: AE9vXwP9IybAR2ORWVmRlGAn8ijYjMxjixtiXvT+xhZqo122RpKli7fyPSEl703uts3iUuoo X-Received: by 10.66.138.74 with SMTP id qo10mr10362631pab.135.1472593696337; Tue, 30 Aug 2016 14:48:16 -0700 (PDT) Received: from mgraczyk.mtv.corp.google.com ([172.22.112.111]) by smtp.gmail.com with ESMTPSA id h1sm59557736pay.48.2016.08.30.14.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Aug 2016 14:48:15 -0700 (PDT) From: Michael Graczyk To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Aug 2016 14:48:07 -0700 Message-Id: <1472593687-2407-1-git-send-email-mgraczyk@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 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" 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavcodec/opus.c b/libavcodec/opus.c index 703d2e8..db758e9 100644 --- a/libavcodec/opus.c +++ b/libavcodec/opus.c @@ -328,7 +328,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, channels = avctx->extradata ? extradata[9] : (avctx->channels == 1) ? 1 : 2; if (!channels) { - av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extadata\n"); + av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extradata\n"); return AVERROR_INVALIDDATA; } @@ -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 = ((int)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;