From patchwork Thu Jan 13 02:05:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 33503 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp42496iog; Wed, 12 Jan 2022 18:43:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbjST+qqHKoioPEiIEKAgtW9vJUuR38RcFONXcZ+/yz77/sX1AIlu6WgMAipk8teNJn5VO X-Received: by 2002:aa7:df18:: with SMTP id c24mr2325970edy.164.1642041813221; Wed, 12 Jan 2022 18:43:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642041813; cv=none; d=google.com; s=arc-20160816; b=YzmD2+7Xt9m3FC65p9SPxhckEmYhhRqAhCmlPwkDJUjqAcMOFu7fHAdszX1wI5zWmS 4qglEa+FN+WsO4I2mFnLf1Z9VPWsRkIV0+Sk9WrrrOr6rJg/HKpjST9VddP/jJZne5l8 dMk31XuhBB8TtAgvcMqHSA5a8GZTZWryH5vvCVI1sIOUCDY1SUj2Tkg0O49lI5rnKFOR Xmoc1ski3GnjO4JzFMlykIhqOEmd5qX2yeNvpJG4Cx2Liz3lkI/unJBmvhyw6u52mU4D 6aDKlc3BolYOGY5IWPIHG0BEMJMm7JChTgGpERV6ryQovBRxQUar5y15JfXPZe9dKezk 512w== 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=Rurz02SYuPsjCEFo+XePYH+MTwZsNZKz3IhAphpGiOc=; b=POLUsLAWMKQlhpbQg+vCjPZUmFkcV8fdE3FyMCwMu+wz2vDigIwyQ682v2zenRs5+l wNiFKN0lMy7awJ966Q9nbuWMVzpXZVoLcf/fdjgV7k0WKCv4SRq5BlrYDa6743GAdETG wo781TVtTet4ukohHVQ0LoRgoN4x4Xb8y2mzk42fP3eUrMjUuqy8rHShQxWF0PSopKRM YPDrudf8OFxQISbYX/Vg743QA2QatFzQ28igrkCUryBb3LVRyYmPlXI3qRx+ngbUMsgh si6oA4DcMG40G7Y6r07EDnTbpZ5jyQtmOfCVOYm7aFSeFDFBwpUGI8dMjGIbKxaOW8pk copQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="EqCh/lOI"; 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 sc30si894627ejc.791.2022.01.12.18.43.32; Wed, 12 Jan 2022 18:43:33 -0800 (PST) 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=20210112 header.b="EqCh/lOI"; 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 6A31268B901; Thu, 13 Jan 2022 04:06:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5AA4368B8FC for ; Thu, 13 Jan 2022 04:06:02 +0200 (EET) Received: by mail-qk1-f173.google.com with SMTP id t66so5590292qkb.4 for ; Wed, 12 Jan 2022 18:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lFd3ZZa33sHZ0pkumvdcZnlAStHa9Aciz7CsC20f6Nk=; b=EqCh/lOIM3HLyPiHl0InWYEEY+OjKEAKzxaFwszGsdNRaUBc3n+lGYHiyjHwaxwgVM JJP4wux8NLBmC9HnvmRLNN6PRQOGgoBn7/tcPzf3sSs4RIpKScQ425jw0ZHd/NHK52fJ fqBtM2jT1hj9C/pK99q1NzboclqgEzw9PAZCbyz4JUOJGKXp9bVjHRA/5xGOsdLAKZxp HTh8xOKMs942oV/k5lZ6sz+atVBSlTev97lT/LlPlTctqDa5AMgpdcWw8wPJ/PpEUOIC v3kTMd4b+iYF2Gbfa7d3p4UT5S+CAay4r6c8MGvCg2Z3FXlLVKhi5os9a8d66N5eqqtg T5OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lFd3ZZa33sHZ0pkumvdcZnlAStHa9Aciz7CsC20f6Nk=; b=i/Stc+gmfP+qUlxE+gk8IzaiL2UxIXXTLdcO2ygvC+McGDmTGXk0ZMWcnoNVgp0zC+ 1XFxV6BzhhWjiucVdZfgEb27R7dvRGpQAwKL4qCT6EBoy3c7428jbw8iLEraIMUt/GeR IbGZ3ICbbYt9tszEVrQym0Dc9Y/H9+RO0DKb+DnrFqvhmdbsi4ISjgT/0FOzZ5TRUwfB RyAgH58qenA4kY8CBedNuzxOgxbQ4QSpVRLnGa+VzeJ7sFL/D2hqKeENxgMMsb2kmKq7 q2RHPZUSNQM2my1SBD+pPMD6Fl2HshbQYvxJYN6IqhiV7/dO9bD044ZLi2ZpwQR1JcrD V3CA== X-Gm-Message-State: AOAM532+VId2e6xXpgk5OM1R9i0L8wWeRVaiWQ6deLFmT9Vgg9RJhK/2 WX3A+g8AiIrrqe7FOqA/JR/odEbsCNM= X-Received: by 2002:a05:620a:44d1:: with SMTP id y17mr1917793qkp.678.1642039560760; Wed, 12 Jan 2022 18:06:00 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id k9sm1264556qko.29.2022.01.12.18.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:06:00 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:05:13 -0300 Message-Id: <20220113020518.730-25-jamrial@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220113015101.4-1-jamrial@gmail.com> References: <20220113015101.4-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 234/281] libvorbis: convert to new channel layout API 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: Ao7qZW6rHOfc From: Anton Khirnov Signed-off-by: James Almer --- libavcodec/libvorbisdec.c | 4 +++- libavcodec/libvorbisenc.c | 42 +++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/libavcodec/libvorbisdec.c b/libavcodec/libvorbisdec.c index 5686aaf096..7317b71ed6 100644 --- a/libavcodec/libvorbisdec.c +++ b/libavcodec/libvorbisdec.c @@ -112,7 +112,9 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) { } } - avccontext->channels = context->vi.channels; + av_channel_layout_uninit(&avccontext->ch_layout); + avccontext->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avccontext->ch_layout.nb_channels = context->vi.channels; avccontext->sample_rate = context->vi.rate; avccontext->sample_fmt = AV_SAMPLE_FMT_S16; avccontext->time_base= (AVRational){1, avccontext->sample_rate}; diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index fa0d5f4b42..640c7f1bf9 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -96,6 +96,7 @@ static int vorbis_error_to_averror(int ov_err) static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx) { LibvorbisEncContext *s = avctx->priv_data; + int channels = avctx->ch_layout.nb_channels; double cfreq; int ret; @@ -108,7 +109,7 @@ static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx) /* default to 3 if the user did not set quality or bitrate */ if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) q = 3.0; - if ((ret = vorbis_encode_setup_vbr(vi, avctx->channels, + if ((ret = vorbis_encode_setup_vbr(vi, channels, avctx->sample_rate, q / 10.0))) goto error; @@ -117,7 +118,7 @@ static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx) int maxrate = avctx->rc_max_rate > 0 ? avctx->rc_max_rate : -1; /* average bitrate */ - if ((ret = vorbis_encode_setup_managed(vi, avctx->channels, + if ((ret = vorbis_encode_setup_managed(vi, channels, avctx->sample_rate, maxrate, avctx->bit_rate, minrate))) goto error; @@ -141,32 +142,31 @@ static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx) goto error; } - if (avctx->channels == 3 && - avctx->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) || - avctx->channels == 4 && - avctx->channel_layout != AV_CH_LAYOUT_2_2 && - avctx->channel_layout != AV_CH_LAYOUT_QUAD || - avctx->channels == 5 && - avctx->channel_layout != AV_CH_LAYOUT_5POINT0 && - avctx->channel_layout != AV_CH_LAYOUT_5POINT0_BACK || - avctx->channels == 6 && - avctx->channel_layout != AV_CH_LAYOUT_5POINT1 && - avctx->channel_layout != AV_CH_LAYOUT_5POINT1_BACK || - avctx->channels == 7 && - avctx->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) || - avctx->channels == 8 && - avctx->channel_layout != AV_CH_LAYOUT_7POINT1) { - if (avctx->channel_layout) { + if ((channels == 3 && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND)) || + (channels == 4 && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_2) && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD)) || + (channels == 5 && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0) && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK)) || + (channels == 6 && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1) && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK)) || + (channels == 7 && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1)) || + (channels == 8 && + av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1))) { + if (avctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) { char name[32]; - av_get_channel_layout_string(name, sizeof(name), avctx->channels, - avctx->channel_layout); + av_channel_layout_describe(&avctx->ch_layout, name, sizeof(name)); av_log(avctx, AV_LOG_ERROR, "%s not supported by Vorbis: " "output stream will have incorrect " "channel layout.\n", name); } else { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The encoder " "will use Vorbis channel layout for " - "%d channels.\n", avctx->channels); + "%d channels.\n", channels); } }