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 3E30342EFC for ; Thu, 13 Jan 2022 02:39:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B1A168B81A; Thu, 13 Jan 2022 04:05:41 +0200 (EET) 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 5907968B7F5 for ; Thu, 13 Jan 2022 04:05:39 +0200 (EET) Received: by mail-qk1-f173.google.com with SMTP id s12so1128853qkg.6 for ; Wed, 12 Jan 2022 18:05:39 -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=DGm5dYZKEh8T5UhKgxG91cTus8/apJHdToE1NKj6I+o=; b=nLJT5TB2oBIjNoHXhPgDa5XWlWN0TTLUhXHPIc+tGEe9QNKjw8teAcPcZ/KexeIrBk Efdsrdekmttd85Lh5l/TdSQB5J9Gquco7u6Us6MeOxBCpNDZqtsUF0iA3+VZVe/CiLNF 2jMIac3cRIgsVLwZdK2lrKnKa2Syua5HeVgji6TzlBn1rSAZyOZhb8VBywFKBpy40LLJ 1DgrdUikXPM7ObR2fUIp0Zl4s8lU06TRckg8Y7r15z/bBL2bOk65HZcgxgFpc0WRezAY ZSGoOsZE4tEcPGKQe4TTv1rZb2Pf1MfEogQjDBSmATpNxkbjIpTHxa67KG5rAvnlts75 ZLXg== 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=DGm5dYZKEh8T5UhKgxG91cTus8/apJHdToE1NKj6I+o=; b=IFTuNuwkXORWi2cyFsSCWpftM6S9jE7xNCeWcYPLAuMdTnkj91RDsYxSnHRCM3+74I mmhpA8zCrcrJAhtDOTDj0F8Nm2TadNMU2F5gePvLmXd0jxR5zcH6JcpR4xis15uHV2/q lwBlMDCYpXtye1wFo9HJJ23fnMe4YrQV2VKCHCqngXrPhFE11QwopRAos6MfZUXqzut8 44OY6QFyQ/wpItGtHJZmmPZ45foERqeZzvUe/MoLfCjmBZYPP1FzolqylXaiSgLH0/95 MCFpEyVjwdKvTPQjwpRQqxv336VJQxk1UrZIApugsgV9i90tiQ+inVSjoyV8hbIw6JYf CPpg== X-Gm-Message-State: AOAM533LO3g4ysPxi4kLx56Az+DOPBdLvUthPvkYYylL+DRXHMZ/+Xgp 9ZEiTWIrWXrKR5xyxvUn3EaMEm75Ixw= X-Google-Smtp-Source: ABdhPJxCgXDZuiK7NBCCVgDzCX+T6vOv/gFYZlGzTHUNUjUI2Cg3O4BgTmFlrx02E6mz9hRZiDM+Zw== X-Received: by 2002:a05:620a:24c1:: with SMTP id m1mr1868149qkn.373.1642039537689; Wed, 12 Jan 2022 18:05:37 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id k9sm1264556qko.29.2022.01.12.18.05.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:05:37 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:04:54 -0300 Message-Id: <20220113020518.730-6-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 215/281] g729: 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/g729_parser.c | 2 +- libavcodec/g729dec.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c index 8c06ce4ee6..d66df141f9 100644 --- a/libavcodec/g729_parser.c +++ b/libavcodec/g729_parser.c @@ -48,7 +48,7 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx, s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE : G729_8K_BLOCK_SIZE; if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN) s->block_size++; - s->block_size *= avctx->channels; + s->block_size *= avctx->ch_layout.nb_channels; s->duration = avctx->frame_size; } diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index 7525ab7491..5a90f9fc1c 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -350,10 +350,11 @@ static av_cold int decoder_init(AVCodecContext * avctx) { G729Context *s = avctx->priv_data; G729ChannelContext *ctx; + int channels = avctx->ch_layout.nb_channels; int c,i,k; - 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 (channels < 1 || channels > 2) { + av_log(avctx, AV_LOG_ERROR, "Only mono and stereo are supported (requested channels: %d).\n", channels); return AVERROR(EINVAL); } avctx->sample_fmt = AV_SAMPLE_FMT_S16P; @@ -362,11 +363,11 @@ static av_cold int decoder_init(AVCodecContext * avctx) avctx->frame_size = SUBFRAME_SIZE << 1; ctx = - s->channel_context = av_mallocz(sizeof(G729ChannelContext) * avctx->channels); + s->channel_context = av_mallocz(sizeof(G729ChannelContext) * channels); if (!ctx) return AVERROR(ENOMEM); - for (c = 0; c < avctx->channels; c++) { + for (c = 0; c < channels; c++) { ctx->gain_coeff = 16384; // 1.0 in (1.14) for (k = 0; k < MA_NP + 1; k++) { @@ -412,6 +413,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, G729Formats packet_type; G729Context *s = avctx->priv_data; G729ChannelContext *ctx = s->channel_context; + int channels = avctx->ch_layout.nb_channels; int16_t lp[2][11]; // (3.12) uint8_t ma_predictor; ///< switched MA predictor of LSP quantizer uint8_t quantizer_1st; ///< first stage vector of quantizer @@ -430,14 +432,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - if (buf_size && buf_size % ((G729_8K_BLOCK_SIZE + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * avctx->channels) == 0) { + if (buf_size && buf_size % ((G729_8K_BLOCK_SIZE + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * channels) == 0) { packet_type = FORMAT_G729_8K; format = &format_g729_8k; //Reset voice decision ctx->onset = 0; ctx->voice_decision = DECISION_VOICE; av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729 @ 8kbit/s"); - } else if (buf_size == G729D_6K4_BLOCK_SIZE * avctx->channels && avctx->codec_id != AV_CODEC_ID_ACELP_KELVIN) { + } else if (buf_size == G729D_6K4_BLOCK_SIZE * channels && avctx->codec_id != AV_CODEC_ID_ACELP_KELVIN) { packet_type = FORMAT_G729D_6K4; format = &format_g729d_6k4; av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729D @ 6.4kbit/s"); @@ -446,13 +448,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, return AVERROR_INVALIDDATA; } - for (c = 0; c < avctx->channels; c++) { + for (c = 0; c < channels; c++) { int frame_erasure = 0; ///< frame erasure detected during decoding int bad_pitch = 0; ///< parity check failed int is_periodic = 0; ///< whether one of the subframes is declared as periodic or not out_frame = (int16_t*)frame->data[c]; if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN) { - if (*buf != ((avctx->channels - 1 - c) * 0x80 | 2)) + if (*buf != ((avctx->ch_layout.nb_channels - 1 - c) * 0x80 | 2)) avpriv_request_sample(avctx, "First byte value %x for channel %d", *buf, c); buf++; } @@ -739,7 +741,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, } *got_frame_ptr = 1; - return (format->block_size + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * avctx->channels; + return (format->block_size + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * channels; } static av_cold int decode_close(AVCodecContext *avctx) -- 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".