]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/adpcm_argo: add ff_adpcm_argo_expand_nibble() and cleanup parameters
authorZane van Iperen <zane@zanevaniperen.com>
Wed, 29 Jul 2020 12:58:52 +0000 (22:58 +1000)
committerZane van Iperen <zane@zanevaniperen.com>
Fri, 7 Aug 2020 13:04:25 +0000 (23:04 +1000)
Replaces adpcm_argo_expand_nibble(). Preparation for the encoder.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
libavcodec/adpcm.c
libavcodec/adpcm.h

index b77f4b8ef65dd84f5cfb36932c3c4c06ebda011c..1366932352be4104b67acf530a59afbfc5dc4570 100644 (file)
@@ -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;
index 580db7df8bf01ecbf931a0f61c8111a43d2b1ca3..dc0d49ac616fb0e8bcf753696a5fd0d3f45e2a08 100644 (file)
@@ -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 */