1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Zane van Iperen 2020-07-29 22:58:52 +10:00
parent b0b87f28c3
commit 5d1e1dd6bd
No known key found for this signature in database
GPG Key ID: 68616B2D8AC4DCC5
2 changed files with 7 additions and 5 deletions

View 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); sample += (8 * cs->sample1) - (4 * cs->sample2);
else else
sample += 4 * cs->sample1; 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++) { for (n = 0; n < nb_samples / 2; n++) {
int sample = bytestream2_get_byteu(&gb); int sample = bytestream2_get_byteu(&gb);
*samples++ = adpcm_argo_expand_nibble(cs, sign_extend(sample >> 4, 4), control, shift); *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04);
*samples++ = adpcm_argo_expand_nibble(cs, sign_extend(sample >> 0, 4), control, shift); *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04);
} }
} }
break; break;

View File

@ -45,4 +45,6 @@ typedef struct ADPCMChannelStatus {
int idelta; int idelta;
} ADPCMChannelStatus; } ADPCMChannelStatus;
int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag);
#endif /* AVCODEC_ADPCM_H */ #endif /* AVCODEC_ADPCM_H */