From patchwork Fri Sep 18 12:04:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 22470 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 194D244A11F for ; Fri, 18 Sep 2020 15:05:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 095DD68B8F8; Fri, 18 Sep 2020 15:05:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3126C68B78A for ; Fri, 18 Sep 2020 15:04:53 +0300 (EEST) Date: Fri, 18 Sep 2020 12:04:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail2; t=1600430692; bh=HT880qD7N1Zbw4qW3W0tqT3xgcybxOFI8wqe0TrTjYk=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=FnU+AXpoLUFHKN1ReNvXy2k5ZWJAfOZo5qXU4HrCiEl7vH7/tl8aKsh06tNCnA8Vf laPs0zMN8QaKJSkgemmUri/5a1NQ7KJAgyuCrG4C+ewixTeD42EEG6nLkN03dgxQDU Te0lvYEXu4c8h4Ahs9o0aY6BAG+qZGQVtWbm29l6YDJG7zWcJ/NI2gc8iGSRtYCl4e KPF5rZ/jQWSJrazNYTnAqCy8NAjv4PJ0eWtA8VM2HKzekfArHibLupe9xKe27E1j6q uQBrA7cR0zJJZEp8LKcYbZeCMFFxZQ/164+aes1A8pg7TuHojLQDA0mrbBldsQSHei C1d+zbKBY+moA== To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200918120416.7319-2-zane@zanevaniperen.com> In-Reply-To: <20200918120416.7319-1-zane@zanevaniperen.com> References: <20200918120416.7319-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 1/7] avcodec/adpcm_argo: support decoding multiple frames X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Increases decode speed significantly. Signed-off-by: Zane van Iperen --- libavcodec/adpcm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index e409a3aa6a..14be1f4f88 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -181,7 +181,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) c->vqa_version = AV_RL16(avctx->extradata); break; case AV_CODEC_ID_ADPCM_ARGO: - if (avctx->bits_per_coded_sample != 4) + if (avctx->bits_per_coded_sample != 4 || avctx->block_align != 17 * avctx->channels) return AVERROR_INVALIDDATA; break; case AV_CODEC_ID_ADPCM_ZORK: @@ -745,11 +745,6 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, return 0; nb_samples = 64; break; - case AV_CODEC_ID_ADPCM_ARGO: - if (buf_size < 17 * ch) - return 0; - nb_samples = 32; - break; /* simple 4-bit adpcm */ case AV_CODEC_ID_ADPCM_CT: case AV_CODEC_ID_ADPCM_IMA_APC: @@ -922,6 +917,9 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, case AV_CODEC_ID_ADPCM_PSX: nb_samples = buf_size / (16 * ch) * 28; break; + case AV_CODEC_ID_ADPCM_ARGO: + nb_samples = buf_size / avctx->block_align * 32; + break; case AV_CODEC_ID_ADPCM_ZORK: nb_samples = buf_size / ch; break; @@ -2023,22 +2021,24 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, * Each block relies on the previous two samples of each channel. * They should be 0 initially. */ + for (int block = 0; block < avpkt->size / avctx->block_align; block++) { for (channel = 0; channel < avctx->channels; channel++) { int control, shift; - samples = samples_p[channel]; + samples = samples_p[channel] + block * 32; cs = c->status + channel; /* Get the control byte and decode the samples, 2 at a time. */ control = bytestream2_get_byteu(&gb); shift = (control >> 4) + 2; - for (n = 0; n < nb_samples / 2; n++) { + for (n = 0; n < 16; n++) { int sample = bytestream2_get_byteu(&gb); *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04); *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04); } } + } break; case AV_CODEC_ID_ADPCM_ZORK: if (!c->has_status) {