From patchwork Tue Aug 4 23:09:02 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: 21481 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 B5C44449E51 for ; Wed, 5 Aug 2020 02:09:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9965368B9D2; Wed, 5 Aug 2020 02:09:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40136.protonmail.ch (mail-40136.protonmail.ch [185.70.40.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 806C768B9A6 for ; Wed, 5 Aug 2020 02:09:09 +0300 (EEST) Date: Tue, 04 Aug 2020 23:09:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1596582548; bh=ZTKBDQaPRY1HTbRJ6auMSbuSj+o6oiAFG2Yoid9I7AE=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=jw/2j9RZpenS+RHnNSDn7SjH7nuPK3pnR7+Vu/XhPP7O5sDcijAns3npwWCz8Gxlw nRKN2PLcLnlikp18fYEVzbVjPX/vE9RS1ib/eiXgRFTXBIrO6hQT8oZaFM7XW+w2Jj JwKY2pAox5iTujMJGLNdSpkMnKrnjJ9AUW4ytzuA= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200804230836.2082467-3-zane@zanevaniperen.com> In-Reply-To: <20200804230836.2082467-1-zane@zanevaniperen.com> References: <20200804230836.2082467-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=7.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 mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v3 2/6] avcodec/adpcm_argo: add ff_adpcm_argo_expand_nibble() and cleanup parameters 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" Replaces adpcm_argo_expand_nibble(). Preparation for the encoder. Signed-off-by: Zane van Iperen --- libavcodec/adpcm.c | 10 +++++----- libavcodec/adpcm.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index b77f4b8ef6..1366932352 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -689,11 +689,11 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ } } -static inline int16_t adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int control, int shift) +int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag) { - int sample = nibble * (1 << shift); + int sample = sign_extend(nibble, 4) * (1 << shift); - if (control & 0x04) + if (flag) sample += (8 * cs->sample1) - (4 * cs->sample2); else sample += 4 * cs->sample1; @@ -2007,8 +2007,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (n = 0; n < nb_samples / 2; n++) { int sample = bytestream2_get_byteu(&gb); - *samples++ = adpcm_argo_expand_nibble(cs, sign_extend(sample >> 4, 4), control, shift); - *samples++ = adpcm_argo_expand_nibble(cs, sign_extend(sample >> 0, 4), control, shift); + *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; diff --git a/libavcodec/adpcm.h b/libavcodec/adpcm.h index 580db7df8b..dc0d49ac61 100644 --- a/libavcodec/adpcm.h +++ b/libavcodec/adpcm.h @@ -45,4 +45,6 @@ typedef struct ADPCMChannelStatus { int idelta; } ADPCMChannelStatus; +int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag); + #endif /* AVCODEC_ADPCM_H */