diff options
author | Zane van Iperen <zane@zanevaniperen.com> | 2020-07-29 22:58:52 +1000 |
---|---|---|
committer | Zane van Iperen <zane@zanevaniperen.com> | 2020-08-07 23:04:25 +1000 |
commit | 5d1e1dd6bd1b21d6ccce13eb1cf691d3dfc0710d (patch) | |
tree | f265965153532795352983c8d74588ad801866c6 /libavcodec | |
parent | b0b87f28c34502aa8b0feae2294966760428e3ab (diff) | |
download | ffmpeg-5d1e1dd6bd1b21d6ccce13eb1cf691d3dfc0710d.tar.gz |
avcodec/adpcm_argo: add ff_adpcm_argo_expand_nibble() and cleanup parameters
Replaces adpcm_argo_expand_nibble(). Preparation for the encoder.
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/adpcm.c | 10 | ||||
-rw-r--r-- | 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 */ |