| @@ -15,6 +15,7 @@ · 14 unmodified lines |
| 15 | * Argonaut Games ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) | 15 | * Argonaut Games ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) |
| 16 | * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) | 16 | * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) |
| 17 | * Ubisoft ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) | 17 | * Ubisoft ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com) |
| | 18 | * High Voltage Software ALP decoder by Zane van Iperen (zane@zanevaniperen.com) |
| 18 | * | 19 | * |
| 19 | * This file is part of FFmpeg. | 20 | * This file is part of FFmpeg. |
| 20 | * | 21 | * |
| @@ -280,6 +281,29 @@ static inline int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibb · 259 unmodified lines |
| 280 | return (int16_t)c->predictor; | 281 | return (int16_t)c->predictor; |
| 281 | } | 282 | } |
| 282 | | 283 | |
| | 284 | static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift) |
| | 285 | { |
| | 286 | int step_index; |
| | 287 | int predictor; |
| | 288 | int sign, delta, diff, step; |
| | 289 | |
| | 290 | step = ff_adpcm_step_table[c->step_index]; |
| | 291 | step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble]; |
| | 292 | step_index = av_clip(step_index, 0, 88); |
| | 293 | |
| | 294 | sign = nibble & 8; |
| | 295 | delta = nibble & 7; |
| | 296 | diff = (delta * step) >> shift; |
| | 297 | predictor = c->predictor; |
| | 298 | if (sign) predictor -= diff; |
| | 299 | else predictor += diff; |
| | 300 | |
| | 301 | c->predictor = av_clip_int16(predictor); |
| | 302 | c->step_index = step_index; |
| | 303 | |
| | 304 | return (int16_t)c->predictor; |
| | 305 | } |
| | 306 | |
| 283 | static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) | 307 | static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) |
| 284 | { | 308 | { |
| 285 | int nibble, step_index, predictor, sign, delta, diff, step, shift; | 309 | int nibble, step_index, predictor, sign, delta, diff, step, shift; |
| @@ -675,6 +699,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, · 389 unmodified lines |
| 675 | case AV_CODEC_ID_ADPCM_AICA: | 699 | case AV_CODEC_ID_ADPCM_AICA: |
| 676 | case AV_CODEC_ID_ADPCM_IMA_SSI: | 700 | case AV_CODEC_ID_ADPCM_IMA_SSI: |
| 677 | case AV_CODEC_ID_ADPCM_IMA_APM: | 701 | case AV_CODEC_ID_ADPCM_IMA_APM: |
| | 702 | case AV_CODEC_ID_ADPCM_IMA_ALP: |
| 678 | nb_samples = buf_size * 2 / ch; | 703 | nb_samples = buf_size * 2 / ch; |
| 679 | break; | 704 | break; |
| 680 | } | 705 | } |
| @@ -1247,6 +1272,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 566 unmodified lines |
| 1247 | samples += avctx->channels; | 1272 | samples += avctx->channels; |
| 1248 | } | 1273 | } |
| 1249 | break; | 1274 | break; |
| | 1275 | case AV_CODEC_ID_ADPCM_IMA_ALP: |
| | 1276 | for (n = nb_samples / 2; n > 0; n--) { |
| | 1277 | for (channel = 0; channel < avctx->channels; channel++) { |
| | 1278 | int v = bytestream2_get_byteu(&gb); |
| | 1279 | *samples++ = adpcm_ima_alp_expand_nibble(&c->status[channel], v >> 4 , 2); |
| | 1280 | samples[st] = adpcm_ima_alp_expand_nibble(&c->status[channel], v & 0x0F, 2); |
| | 1281 | } |
| | 1282 | samples += avctx->channels; |
| | 1283 | } |
| | 1284 | break; |
| 1250 | case AV_CODEC_ID_ADPCM_IMA_OKI: | 1285 | case AV_CODEC_ID_ADPCM_IMA_OKI: |
| 1251 | while (bytestream2_get_bytes_left(&gb) > 0) { | 1286 | while (bytestream2_get_bytes_left(&gb) > 0) { |
| 1252 | int v = bytestream2_get_byteu(&gb); | 1287 | int v = bytestream2_get_byteu(&gb); |
| @@ -1997,6 +2032,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, · 744 unmodified lines |
| 1997 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16, adpcm_ima_rad, "ADPCM IMA Radical"); | 2032 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16, adpcm_ima_rad, "ADPCM IMA Radical"); |
| 1998 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SSI, sample_fmts_s16, adpcm_ima_ssi, "ADPCM IMA Simon & Schuster Interactive"); | 2033 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SSI, sample_fmts_s16, adpcm_ima_ssi, "ADPCM IMA Simon & Schuster Interactive"); |
| 1999 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG"); | 2034 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG"); |
| | 2035 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ALP, sample_fmts_s16, adpcm_ima_alp, "ADPCM IMA High Voltage Software ALP"); |
| 2000 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV"); | 2036 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV"); |
| 2001 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood"); | 2037 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood"); |
| 2002 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_both, adpcm_ms, "ADPCM Microsoft"); | 2038 | ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_both, adpcm_ms, "ADPCM Microsoft"); |