From patchwork Thu Jan 13 02:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 33459 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp37502iog; Wed, 12 Jan 2022 18:33:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxriLMCYeZDSK4clg+swc4DugeB3HttWic4YqzramjuoZMu/Kxb7RMJOqzkvWRZTGMH1KHb X-Received: by 2002:a17:906:3acc:: with SMTP id z12mr1914400ejd.10.1642041221599; Wed, 12 Jan 2022 18:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642041221; cv=none; d=google.com; s=arc-20160816; b=kcl9n2qdAmFpc85cJifnIMy6qf4gdZzbY10xM0dFak74ZWn2TpLGBboA8hvNbfvD6k BSI0MvlavbXfH4ldUcItgrmSBLor5uOhEPHok+wRCM3FjOUAae5YxY8ZxRjlUrlQR6Oy c1GtYACSfijf/IcPCqMA8SqY+5djjOETl7kDMzOSoxaIGdY9Ohc8V3KDpKZYYbZi0OGy xEmE8ee2mhdsoNap3o84vzLHs0SWxLi0hShI+H+yDSGGQCJH/XUZTc1Dq0TiZhXm/Avo oq8wedQuVyneIo3n3CM73PcgAY69Ccvye81tmjk51YyZZBp9kZ7mp6HL3OKn30fWeLsN 6okA== 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=zwBtSgSiS/FOA7kD72B6/YspvGXiWnsf6AjOIQXWt3c=; b=u9mn4gT+T0XGYGjHD6F42L5ZtQ35cyLlexEE6CIdPJUjFOArhHX5W8bFQv7HktoZAG q3IPSqas0SDa7BzNno0eR0nRMDROUhiBVnqzXtLs6h7KGVeJ3PVMcjHibwm2By3ucRoH 9GpyV/q27gjXAfTGAoxCpk0J2k+YQyeJ/SemWF7OtH4SqNcUWaASP0rTbRMtLiSOe0iV 9hAT3wEm2R0qZN1kyrOH3WcM8myTSvi1eCY5V233ZLpKiY7rdC1Ifx1S/TtIs+ojnReb ZzKVqXtC66RNo7yH6NFDJe70m14PZP+a4WePgyUPukJg9wMw0DaNGTjVA2SW2IwChjXx rFKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=lec1dNSv; 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 cz16si839262edb.53.2022.01.12.18.33.41; Wed, 12 Jan 2022 18:33:41 -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=lec1dNSv; 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 17A3668B5F5; Thu, 13 Jan 2022 04:03:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C22668B5CD for ; Thu, 13 Jan 2022 04:03:08 +0200 (EET) Received: by mail-qt1-f176.google.com with SMTP id c7so1764883qtc.11 for ; Wed, 12 Jan 2022 18:03:08 -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=uuiU1Iqka94CZWV0GDrkb8jp2BgJr72KwnOVAV9NSLM=; b=lec1dNSvcxoVn3OTrhk7EBf2b83EJOkWxonagrEKoDASV1YW3GU4BY6xKaoQFzIKSQ 80pR2zykphKGjBpky4L8T+BUGc9h37lgMc5kf4+u4tgQkQUp2T8OtvgBLlriloPJv9Ks 1Ee0GjSgC7IhAq4CyyJtB63wmgULIQDvyUW6BGMwGPUoohj+wjwbq9uVhp7x5zjIIAC4 hbFMIAcrTFULtAK0EREUFTJU72Q2YhqS7+Su8AUrVMAhVV2zmZiJjSoYWkD696MDAczb 8sJkM8Vk99eYzyaSAR5E/jzNtPV5DTTRjYzjr9OMCsK/vtPN9qQFMmehZbUhCQZRntz6 e2Qg== 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=uuiU1Iqka94CZWV0GDrkb8jp2BgJr72KwnOVAV9NSLM=; b=097EK3fJbOE5pw/jBHRyy47ogDMoZejSQD101HOXsjnqCxG8YwrF+rxBJGsj0gq7Qs hCfwryADmITTmiAOvfJYDVo/sLMbajuq0ua+uLefbnMwASrXz8uCqrHPRfP78YhAxfPq DiWaHjZdrqSnqYTSjSyda9uz2jF+x1JqghwgEsXluM71DlZK37FCeVWXiPuhA6Ljxpwx 3zn5HRGh+jPPPi6IYJeW1dPWWFnuxtHUyoI0olBplaPn40u9HC5Ve1DT9hUGZBMpQ46j mUsEnSZF81PQKTqZKAmmnes/UD9Nj9Zv2+EmcyMfAG+e3/v5lushVpL6SOmtPcn5AEtf CHHg== X-Gm-Message-State: AOAM531apErU9bZC8/iMtgIQj7qsCuF04B2tZnOOlqq8fQHm1RJlP0I8 NqTzbGXf24T62SEjZBYukq2YaocnTsw= X-Received: by 2002:a05:622a:164c:: with SMTP id y12mr1973836qtj.677.1642039386979; Wed, 12 Jan 2022 18:03:06 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id v1sm1045961qtc.95.2022.01.12.18.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:03:06 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:02:21 -0300 Message-Id: <20220113020242.661-9-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 188/281] amr: 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: IX8UpDO6VPya From: Anton Khirnov Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavcodec/amr_parser.c | 10 +++++----- libavcodec/amrnbdec.c | 12 ++++++------ libavcodec/amrwbdec.c | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c index c0b14700e2..9484d720ee 100644 --- a/libavcodec/amr_parser.c +++ b/libavcodec/amr_parser.c @@ -63,9 +63,9 @@ static int amr_parse(AVCodecParserContext *s1, *poutbuf_size = 0; *poutbuf = NULL; - if (!avctx->channels) { - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + if (!avctx->ch_layout.nb_channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) { @@ -73,7 +73,7 @@ static int amr_parse(AVCodecParserContext *s1, } else { int ch, offset = 0; - for (ch = s->current_channel; ch < avctx->channels; ch++) { + for (ch = s->current_channel; ch < avctx->ch_layout.nb_channels; ch++) { if (s->remaining >= 0) { next = s->remaining; } else { @@ -96,7 +96,7 @@ static int amr_parse(AVCodecParserContext *s1, } } - s->current_channel = ch % avctx->channels; + s->current_channel = ch % avctx->ch_layout.nb_channels; if (s->remaining < 0) next = offset; diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index d8e0370a3b..c6df87bffa 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -166,20 +166,20 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx) AMRChannelsContext *s = avctx->priv_data; int i; - if (avctx->channels > 2) { + if (avctx->ch_layout.nb_channels > 2) { avpriv_report_missing_feature(avctx, ">2 channel AMR"); return AVERROR_PATCHWELCOME; } - if (!avctx->channels) { - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + if (!avctx->ch_layout.nb_channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } if (!avctx->sample_rate) avctx->sample_rate = 8000; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRContext *p = &s->ch[ch]; // p->excitation always points to the same position in p->excitation_buf p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1]; @@ -969,7 +969,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRContext *p = &s->ch[ch]; float fixed_gain_factor; AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 3ff4077f7f..ad62c541c5 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -102,20 +102,20 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx) AMRWBChannelsContext *s = avctx->priv_data; int i; - if (avctx->channels > 2) { + if (avctx->ch_layout.nb_channels > 2) { avpriv_report_missing_feature(avctx, ">2 channel AMR"); return AVERROR_PATCHWELCOME; } - if (!avctx->channels) { - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + if (!avctx->ch_layout.nb_channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } if (!avctx->sample_rate) avctx->sample_rate = 16000; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRWBContext *ctx = &s->ch[ch]; av_lfg_init(&ctx->prng, 1); @@ -1115,7 +1115,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRWBContext *ctx = &s->ch[ch]; AMRWBFrame *cf = &ctx->frame; int expected_fr_size, header_size;