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 B51EE42F92 for ; Thu, 13 Jan 2022 02:51:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA3A768BA58; Thu, 13 Jan 2022 04:08:07 +0200 (EET) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F1E8B68BA3A for ; Thu, 13 Jan 2022 04:08:04 +0200 (EET) Received: by mail-qt1-f182.google.com with SMTP id b14so2447085qtb.12 for ; Wed, 12 Jan 2022 18:08:04 -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=9LZfA+u5/p+T6BEVAbw2TfiQrp3VswisD7c/RutLAjs=; b=WyUwaE+cyPCyvEY/Fy+gK6nHfg/JtUkT9cUk3ahMzcD4aNEC4U2wNadER+NAC6yUaG r1uo6hX0LbWKOBY+Xg3C/ktI2q20lg+2X1AeaAVw7+YyodgrZmO1iNLnFoXW97m4oFCH 3O8np/MjE+lY5GlJ/qlvFDjzlinZNtfbU4U3gTn30Vxd8M6puZ/fYZEyo4VrD6YMMHK/ wWe5H0fz0JmTX/zZ+WyzsOpzEUFMv+J+30+D7JLlgOcNCNhbxoRq6smB1R9z622+RXCe nySzxlelWOsDcwtaZ/bOqG2g8synTnUb3QkPGJF+GOkEcjZcZTEYItYyFod0m36W5fJN eYsA== 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=9LZfA+u5/p+T6BEVAbw2TfiQrp3VswisD7c/RutLAjs=; b=LOQyRToqlMINka55iOb7yhx/QzTxx5jbG4wRAUfe39mvHtlqYC+Ne4uvlXEN91OGnM Ey5emAbsII0wGO/i/H2YkoWABmNKoNlcBIBUoG5ZgGn77iLApCbtIU01DqNE6pchpPHG Rm+92gVV1ff9rMBc449dxYU73cYi7Owa0PT7yRHEGiCBsqCnENqXYVambmtC8OTWcFkX Nj7PrcDgScPUaeezadyD9TiK9d0WNF7pqOug+a0lj8QkvWdcba3NYS7nSZltVESZ1VV2 AXgROCofSwo9e/qtU8IInVstPz1d1211YVA9SN6KTPbI/noNIMwA9dXcwCKG5JbYl6gx R+Qg== X-Gm-Message-State: AOAM533asX17g3GT8KNnzwh4mif5ScyrWUOdqfHjnUf/60IB3gihPD4n fUlyUUnmWfO2aE3Ncm92368RpQYNzTA= X-Google-Smtp-Source: ABdhPJzitpr1PZrEFUHzu3gmi9BnxPls7GsG8aHaDKMou7x2ZrjbTs715FrzxtNtHlQdBgLuIb2/lg== X-Received: by 2002:ac8:5ad0:: with SMTP id d16mr1972184qtd.557.1642039683433; Wed, 12 Jan 2022 18:08:03 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id a16sm1085946qta.13.2022.01.12.18.08.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:08:03 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:07:12 -0300 Message-Id: <20220113020713.801-29-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 268/281] vorbis: 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 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: From: Anton Khirnov Signed-off-by: James Almer --- libavcodec/vorbisdec.c | 27 +++++++++++++++++---------- libavcodec/vorbisenc.c | 7 ++++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 6e07bc5a8a..d961dc37b9 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1077,12 +1077,14 @@ static av_cold int vorbis_decode_init(AVCodecContext *avctx) return ret; } - if (vc->audio_channels > 8) - avctx->channel_layout = 0; - else - avctx->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1]; + av_channel_layout_uninit(&avctx->ch_layout); + if (vc->audio_channels > 8) { + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avctx->ch_layout.nb_channels = vc->audio_channels; + } else { + av_channel_layout_copy(&avctx->ch_layout, &ff_vorbis_ch_layouts[vc->audio_channels - 1]); + } - avctx->channels = vc->audio_channels; avctx->sample_rate = vc->audio_samplerate; return 0; @@ -1788,12 +1790,14 @@ static int vorbis_decode_frame(AVCodecContext *avctx, void *data, return ret; } - if (vc->audio_channels > 8) - avctx->channel_layout = 0; - else - avctx->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1]; + av_channel_layout_uninit(&avctx->ch_layout); + if (vc->audio_channels > 8) { + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avctx->ch_layout.nb_channels = vc->audio_channels; + } else { + av_channel_layout_copy(&avctx->ch_layout, &ff_vorbis_ch_layouts[vc->audio_channels - 1]); + } - avctx->channels = vc->audio_channels; avctx->sample_rate = vc->audio_samplerate; return buf_size; } @@ -1892,7 +1896,10 @@ const AVCodec ff_vorbis_decoder = { .flush = vorbis_decode_flush, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +#if FF_API_OLD_CHANNEL_LAYOUT .channel_layouts = ff_vorbis_channel_layouts, +#endif + .ch_layouts = ff_vorbis_ch_layouts, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 858c6ac6dd..30b75ab3f6 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -276,7 +276,7 @@ static int create_vorbis_context(vorbis_enc_context *venc, const uint8_t *clens, *quant; int i, book, ret; - venc->channels = avctx->channels; + venc->channels = avctx->ch_layout.nb_channels; venc->sample_rate = avctx->sample_rate; venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11; @@ -1038,7 +1038,8 @@ static AVFrame *spawn_empty_frame(AVCodecContext *avctx, int channels) f->format = avctx->sample_fmt; f->nb_samples = avctx->frame_size; - f->channel_layout = avctx->channel_layout; + f->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + f->ch_layout.nb_channels = channels; if (av_frame_get_buffer(f, 4)) { av_frame_free(&f); @@ -1267,7 +1268,7 @@ static av_cold int vorbis_encode_init(AVCodecContext *avctx) vorbis_enc_context *venc = avctx->priv_data; int ret; - if (avctx->channels != 2) { + if (avctx->ch_layout.nb_channels != 2) { av_log(avctx, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n"); return -1; } -- 2.34.1 _______________________________________________ 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".