|
|
|
@@ -15,6 +15,7 @@ |
|
|
|
* Argonaut Games ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) |
|
|
|
* Simon & Schuster Interactive ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) |
|
|
|
* Ubisoft ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) |
|
|
|
* High Voltage Software ALP decoder by Zane van Iperen (zane@zanevaniperen.com) |
|
|
|
* |
|
|
|
* This file is part of FFmpeg. |
|
|
|
* |
|
|
|
@@ -280,6 +281,29 @@ static inline int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibb |
|
|
|
return (int16_t)c->predictor; |
|
|
|
} |
|
|
|
|
|
|
|
static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift) |
|
|
|
{ |
|
|
|
int step_index; |
|
|
|
int predictor; |
|
|
|
int sign, delta, diff, step; |
|
|
|
|
|
|
|
step = ff_adpcm_step_table[c->step_index]; |
|
|
|
step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble]; |
|
|
|
step_index = av_clip(step_index, 0, 88); |
|
|
|
|
|
|
|
sign = nibble & 8; |
|
|
|
delta = nibble & 7; |
|
|
|
diff = (delta * step) >> shift; |
|
|
|
predictor = c->predictor; |
|
|
|
if (sign) predictor -= diff; |
|
|
|
else predictor += diff; |
|
|
|
|
|
|
|
c->predictor = av_clip_int16(predictor); |
|
|
|
c->step_index = step_index; |
|
|
|
|
|
|
|
return (int16_t)c->predictor; |
|
|
|
} |
|
|
|
|
|
|
|
static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) |
|
|
|
{ |
|
|
|
int nibble, step_index, predictor, sign, delta, diff, step, shift; |
|
|
|
@@ -675,6 +699,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, |
|
|
|
case AV_CODEC_ID_ADPCM_AICA: |
|
|
|
case AV_CODEC_ID_ADPCM_IMA_SSI: |
|
|
|
case AV_CODEC_ID_ADPCM_IMA_APM: |
|
|
|
case AV_CODEC_ID_ADPCM_IMA_ALP: |
|
|
|
nb_samples = buf_size * 2 / ch; |
|
|
|
break; |
|
|
|
} |
|
|
|
@@ -1247,6 +1272,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
samples += avctx->channels; |
|
|
|
} |
|
|
|
break; |
|
|
|
case AV_CODEC_ID_ADPCM_IMA_ALP: |
|
|
|
for (n = nb_samples / 2; n > 0; n--) { |
|
|
|
for (channel = 0; channel < avctx->channels; channel++) { |
|
|
|
int v = bytestream2_get_byteu(&gb); |
|
|
|
*samples++ = adpcm_ima_alp_expand_nibble(&c->status[channel], v >> 4 , 2); |
|
|
|
samples[st] = adpcm_ima_alp_expand_nibble(&c->status[channel], v & 0x0F, 2); |
|
|
|
} |
|
|
|
samples += avctx->channels; |
|
|
|
} |
|
|
|
break; |
|
|
|
case AV_CODEC_ID_ADPCM_IMA_OKI: |
|
|
|
while (bytestream2_get_bytes_left(&gb) > 0) { |
|
|
|
int v = bytestream2_get_byteu(&gb); |
|
|
|
@@ -1997,6 +2032,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16, adpcm_ima_rad, "ADPCM IMA Radical"); |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SSI, sample_fmts_s16, adpcm_ima_ssi, "ADPCM IMA Simon & Schuster Interactive"); |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG"); |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ALP, sample_fmts_s16, adpcm_ima_alp, "ADPCM IMA High Voltage Software ALP"); |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV"); |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood"); |
|
|
|
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_both, adpcm_ms, "ADPCM Microsoft"); |
|
|
|
|