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 B646642F40 for ; Thu, 13 Jan 2022 02:47:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 19DE468B9BA; Thu, 13 Jan 2022 04:07:48 +0200 (EET) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4769A68B9B7 for ; Thu, 13 Jan 2022 04:07:46 +0200 (EET) Received: by mail-qk1-f178.google.com with SMTP id e25so5562030qkl.12 for ; Wed, 12 Jan 2022 18:07:45 -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=R4nHs1L/jnzh6gB+KjLly/YWMVIUkOyWvy9WYiZsGto=; b=YpSGwLbtVsvueSxtmKt/1haiRjm5U58VPetkT+wj19kIGC/uGbeuGQcIXaHJhMOKGO VV0Ff/cu8lOgfxkULqMqoPa6p5NDStOEz1nHScGwX0z+5XxvJh6ht8QeB7Ut6ebs6fnE tNXVTNThMveBJ5b1B4hslgqkM6YplblCoguvhVeuJnDzP+4SyXszy6as/pq8+5xd30Tn Rvy8n15v66ZAa6xi76R8tmbjlFOfvJetv67hnSHS1RWOcFrA0Tkgk7E0ToycjkZJJczA Dx28Qkl2WEOGZph1Npn5jzYzLC9B2gkPi0e31G8dNfcTI5ITY5ChzjfvLhRNsrHgFDjP i+Zw== 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=R4nHs1L/jnzh6gB+KjLly/YWMVIUkOyWvy9WYiZsGto=; b=keIjyepvxj3aMWiwaqdib5quzi7M5AJKohJ4SGJKFiuEfeJNnd9guy/poAIfqw2zj9 EYWnjW6BnK7bdU9xXIL1E7fdVvCDWW3jh7sz3SalJKCOOMpjWrCBv2FBr/A0K1dWsdav DKjwzd95JUQAXihC7QV5l3CCZg9IzngotMf2PcYeuntFKLW1qVtsywoxPWbNjZ3OvqM6 7/Uup+ZMbf5rpW+YLsCw1qdU/CeUFWhVrdrYdkHZ8PVgac8aybtxDvEfEhD+PUgtRvSd Mgr3u2Sqzk0hEy6gkYcVwFi1jtCq+7ELtad067yZaLjz9FSO+2zBIOv1tKMRyuXX4lJh 2ylg== X-Gm-Message-State: AOAM531LnpWnVxxZbz83UzYgonYzoakDJqZxqMR21QhrKC6A34iYZt29 xge2XNcvXONQFE/X5VwVWAfa24cjSkU= X-Google-Smtp-Source: ABdhPJxceZJhDQVDag4o0Nh4EAhnIyd/RHstXEx/6R2dYGU+1WP+E9R4Hn4Hsw32Z4Teo++Eh3XccQ== X-Received: by 2002:a05:620a:372c:: with SMTP id de44mr1927826qkb.338.1642039664637; Wed, 12 Jan 2022 18:07:44 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id a16sm1085946qta.13.2022.01.12.18.07.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:07:44 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:06:57 -0300 Message-Id: <20220113020713.801-14-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 253/281] roqaudioenc: 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: James Almer --- libavcodec/roqaudioenc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 530e6b68d8..d482fd213a 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -54,8 +54,9 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx) static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) { ROQDPCMContext *context = avctx->priv_data; + int channels = avctx->ch_layout.nb_channels; - if (avctx->channels > 2) { + if (channels > 2) { av_log(avctx, AV_LOG_ERROR, "Audio must be mono or stereo\n"); return AVERROR(EINVAL); } @@ -65,10 +66,10 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) } avctx->frame_size = ROQ_FRAME_SIZE; - avctx->bit_rate = (ROQ_HEADER_SIZE + ROQ_FRAME_SIZE * avctx->channels) * + avctx->bit_rate = (ROQ_HEADER_SIZE + ROQ_FRAME_SIZE * channels) * (22050 / ROQ_FRAME_SIZE) * 8; - context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * avctx->channels * + context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * channels * sizeof(*context->frame_buffer)); if (!context->frame_buffer) return AVERROR(ENOMEM); @@ -123,17 +124,18 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, { int i, stereo, data_size, ret; const int16_t *in = frame ? (const int16_t *)frame->data[0] : NULL; + int channels = avctx->ch_layout.nb_channels; uint8_t *out; ROQDPCMContext *context = avctx->priv_data; - stereo = (avctx->channels == 2); + stereo = (channels == 2); if (!in && context->input_frames >= 8) return 0; if (in && context->input_frames < 8) { - memcpy(&context->frame_buffer[context->buffered_samples * avctx->channels], - in, avctx->frame_size * avctx->channels * sizeof(*in)); + memcpy(&context->frame_buffer[context->buffered_samples * channels], + in, avctx->frame_size * channels * sizeof(*in)); context->buffered_samples += avctx->frame_size; if (context->input_frames == 0) context->first_pts = frame->pts; @@ -151,9 +153,9 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } if (context->input_frames == 7) - data_size = avctx->channels * context->buffered_samples; + data_size = channels * context->buffered_samples; else - data_size = avctx->channels * avctx->frame_size; + data_size = channels * avctx->frame_size; ret = ff_get_encode_buffer(avctx, avpkt, ROQ_HEADER_SIZE + data_size, 0); if (ret < 0) @@ -175,7 +177,7 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, *out++ = dpcm_predict(&context->lastSample[i & 1], *in++); avpkt->pts = context->input_frames <= 7 ? context->first_pts : frame->pts; - avpkt->duration = data_size / avctx->channels; + avpkt->duration = data_size / channels; context->input_frames++; if (!in) -- 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".