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 A95FA42EFC for ; Thu, 13 Jan 2022 02:39:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D51868B85B; Thu, 13 Jan 2022 04:05:46 +0200 (EET) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A671868AFBA for ; Thu, 13 Jan 2022 04:05:36 +0200 (EET) Received: by mail-qt1-f171.google.com with SMTP id q24so1568128qtp.5 for ; Wed, 12 Jan 2022 18:05:36 -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=MQZM1sMebmonMH9eiLdSNWrYPj9KYJ8PJoAl7zGjM4k=; b=GiGE0cCo7CXEPb4HWJUYPrdDgdo/3oj4Prh66HDASzxR/xY2VJaKgU4AfhUgFVmMPD waWXs1Mi0T2+ShDEU/6VeJZioQ30UKTBIQmFwOP654OKANKcD+uw9+7Cu35EGXNz1KcT rC5tq45B7X+1/8K2Z3S2EmwjPQEEb+y1w8EyfDwwLTZZxvf0vqDKpsjQyxaHMj0v2jIT NDNy3pBSIL1S6wAdllxqxeVoFMnmOoGyAFqdgR2BI8Gpqf1g0El5OPHC16AqzocRP2oR vUaX5fveRzjoL8oHMySWueSpiYHOVJK0Ydr3u/rTTH9Fo5ZDhAWkcAYjdLav/RpP3TcL JHxg== 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=MQZM1sMebmonMH9eiLdSNWrYPj9KYJ8PJoAl7zGjM4k=; b=ndSA5vuj49uUC5QJdhHVNaD22aop13XkexIx6Z1NeEO2nBFgmC8VztEzYFkGuopobW 9EWCvbWfa3c+gYTemQvHx6aH24IvK5D9SG57lC+d9HqijdGMdNkzFU8o80qV0peyQKua YxAGRKmO37jJG8XEkFgNr3T14BI7bQl1J8bJX44oxzLyyKlb7o0oG+rHJDWhL5vcF5I2 ZpfWuzdRTG48/RO7cLri9eP4IJLrUzyHNZV1j4YePS9NfFBAgOoAsHvjbpnqD/YN23im 7GE1qp1blso/2uk62O/LRs79EtpzLhNGIVVZH2edBhGv+yRRgZ8/KW9NJnbhyoqvYfse lj4Q== X-Gm-Message-State: AOAM531WSr+7eZ81h/SfeZ/U/ovraTM4oYR5Ha84c/YdbIrLdzwO1/d3 3MxKpJEf7YDxIiUt0TXIfF8p6MknzsA= X-Google-Smtp-Source: ABdhPJw4s1VQcOPTRFatvBxMknHzBi4PcZ7uE1wcCytPVbnULJiWUZt2tgjt8x8smqfK+Kfqy9Z+Iw== X-Received: by 2002:ac8:5f0a:: with SMTP id x10mr2086498qta.282.1642039535310; Wed, 12 Jan 2022 18:05:35 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id k9sm1264556qko.29.2022.01.12.18.05.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:05:35 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:04:52 -0300 Message-Id: <20220113020518.730-4-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 213/281] g723_1: 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: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavcodec/g723_1_parser.c | 2 +- libavcodec/g723_1dec.c | 19 ++++++++++--------- libavcodec/g723_1enc.c | 8 +++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/libavcodec/g723_1_parser.c b/libavcodec/g723_1_parser.c index b6b3fcb84b..2ed1a8ab19 100644 --- a/libavcodec/g723_1_parser.c +++ b/libavcodec/g723_1_parser.c @@ -37,7 +37,7 @@ static int g723_1_parse(AVCodecParserContext *s1, AVCodecContext *avctx, int next = END_NOT_FOUND; if (buf_size > 0) - next = frame_size[buf[0] & 3] * FFMAX(1, avctx->channels); + next = frame_size[buf[0] & 3] * FFMAX(1, avctx->ch_layout.nb_channels); if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) { *poutbuf = NULL; diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c index 7d75adbd7a..8f381b1331 100644 --- a/libavcodec/g723_1dec.c +++ b/libavcodec/g723_1dec.c @@ -117,12 +117,12 @@ static av_cold int g723_1_decode_init(AVCodecContext *avctx) G723_1_Context *s = avctx->priv_data; avctx->sample_fmt = AV_SAMPLE_FMT_S16P; - if (avctx->channels < 1 || avctx->channels > 2) { - av_log(avctx, AV_LOG_ERROR, "Only mono and stereo are supported (requested channels: %d).\n", avctx->channels); + if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2) { + av_log(avctx, AV_LOG_ERROR, "Only mono and stereo are supported (requested channels: %d).\n", + avctx->ch_layout.nb_channels); return AVERROR(EINVAL); } - avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { G723_1_ChannelContext *p = &s->ch[ch]; p->pf_gain = 1 << 12; @@ -932,6 +932,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int dec_mode = buf[0] & 3; + int channels = avctx->ch_layout.nb_channels; PPFParam ppf[SUBFRAMES]; int16_t cur_lsp[LPC_ORDER]; @@ -940,7 +941,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, int16_t *out; int bad_frame = 0, i, j, ret; - if (buf_size < frame_size[dec_mode] * avctx->channels) { + if (buf_size < frame_size[dec_mode] * channels) { if (buf_size) av_log(avctx, AV_LOG_WARNING, "Expected %d bytes, got %d - skipping packet\n", @@ -953,12 +954,12 @@ static int g723_1_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 < channels; ch++) { G723_1_ChannelContext *p = &s->ch[ch]; int16_t *audio = p->audio; - if (unpack_bitstream(p, buf + ch * (buf_size / avctx->channels), - buf_size / avctx->channels) < 0) { + if (unpack_bitstream(p, buf + ch * (buf_size / channels), + buf_size / channels) < 0) { bad_frame = 1; if (p->past_frame_type == ACTIVE_FRAME) p->cur_frame_type = ACTIVE_FRAME; @@ -1090,7 +1091,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, *got_frame_ptr = 1; - return frame_size[dec_mode] * avctx->channels; + return frame_size[dec_mode] * channels; } #define OFFSET(x) offsetof(G723_1_Context, x) diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index 2a8149b4cd..7e893fafc7 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -99,11 +99,6 @@ static av_cold int g723_1_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (avctx->channels != 1) { - av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); - return AVERROR(EINVAL); - } - if (avctx->bit_rate == 6300) { p->cur_rate = RATE_6300; } else if (avctx->bit_rate == 5300) { @@ -1256,5 +1251,8 @@ const AVCodec ff_g723_1_encoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .ch_layouts = (const AVChannelLayout[]){ + AV_CHANNEL_LAYOUT_MONO, { 0 } + }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; -- 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".