X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fadpcm.c;h=3da6b734cf2fa215742214379d411fbf5fb29401;hb=b9fff6e15e73dc995695db9be8db084238cca14c;hp=aa9c7c5c4f8f50664fa55265c7780494ef94c4de;hpb=44085b9951b06df1cab4105dcda004213988d84f;p=ffmpeg diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index aa9c7c5c4f8..3da6b734cf2 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -12,6 +12,11 @@ * EA ADPCM XAS decoder by Peter Ross (pross@xvid.org) * MAXIS EA ADPCM decoder by Robert Marston (rmarston@gmail.com) * THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl) + * 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) + * Cunning Developments decoder by Zane van Iperen (zane@zanevaniperen.com) * * This file is part of FFmpeg. * @@ -57,7 +62,7 @@ */ /* These are for CD-ROM XA ADPCM */ -static const int xa_adpcm_table[5][2] = { +static const int8_t xa_adpcm_table[5][2] = { { 0, 0 }, { 60, 0 }, { 115, -52 }, @@ -65,7 +70,7 @@ static const int xa_adpcm_table[5][2] = { { 122, -60 } }; -static const int ea_adpcm_table[] = { +static const int16_t ea_adpcm_table[] = { 0, 240, 460, 392, 0, 0, -208, -220, 0, 1, 3, 4, @@ -74,28 +79,44 @@ static const int ea_adpcm_table[] = { }; // padded to zero where table size is less then 16 -static const int swf_index_tables[4][16] = { +static const int8_t swf_index_tables[4][16] = { /*2*/ { -1, 2 }, /*3*/ { -1, -1, 2, 4 }, /*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 }, /*5*/ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 } }; +static const int8_t zork_index_table[8] = { + -1, -1, -1, 1, 4, 7, 10, 12, +}; + +static const int8_t mtf_index_table[16] = { + 8, 6, 4, 2, -1, -1, -1, -1, + -1, -1, -1, -1, 2, 4, 6, 8, +}; + /* end of tables */ typedef struct ADPCMDecodeContext { ADPCMChannelStatus status[14]; int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */ - int has_status; + int has_status; /**< Status flag. Reset to 0 after a flush. */ } ADPCMDecodeContext; +static void adpcm_flush(AVCodecContext *avctx); + static av_cold int adpcm_decode_init(AVCodecContext * avctx) { ADPCMDecodeContext *c = avctx->priv_data; unsigned int min_channels = 1; unsigned int max_channels = 2; + adpcm_flush(avctx); + switch(avctx->codec->id) { + case AV_CODEC_ID_ADPCM_IMA_AMV: + max_channels = 1; + break; case AV_CODEC_ID_ADPCM_DTK: case AV_CODEC_ID_ADPCM_EA: min_channels = 2; @@ -105,14 +126,21 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) case AV_CODEC_ID_ADPCM_EA_R2: case AV_CODEC_ID_ADPCM_EA_R3: case AV_CODEC_ID_ADPCM_EA_XAS: + case AV_CODEC_ID_ADPCM_MS: max_channels = 6; break; case AV_CODEC_ID_ADPCM_MTAF: min_channels = 2; max_channels = 8; + if (avctx->channels & 1) { + avpriv_request_sample(avctx, "channel count %d", avctx->channels); + return AVERROR_PATCHWELCOME; + } break; case AV_CODEC_ID_ADPCM_PSX: max_channels = 8; + if (avctx->channels <= 0 || avctx->block_align % (16 * avctx->channels)) + return AVERROR_INVALIDDATA; break; case AV_CODEC_ID_ADPCM_IMA_DAT4: case AV_CODEC_ID_ADPCM_THP: @@ -126,57 +154,102 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) } switch(avctx->codec->id) { - case AV_CODEC_ID_ADPCM_CT: - c->status[0].step = c->status[1].step = 511; - break; case AV_CODEC_ID_ADPCM_IMA_WAV: if (avctx->bits_per_coded_sample < 2 || avctx->bits_per_coded_sample > 5) return AVERROR_INVALIDDATA; break; - case AV_CODEC_ID_ADPCM_IMA_APC: - if (avctx->extradata && avctx->extradata_size >= 8) { - c->status[0].predictor = AV_RL32(avctx->extradata); - c->status[1].predictor = AV_RL32(avctx->extradata + 4); - } + case AV_CODEC_ID_ADPCM_ARGO: + if (avctx->bits_per_coded_sample != 4 || avctx->block_align != 17 * avctx->channels) + return AVERROR_INVALIDDATA; break; - case AV_CODEC_ID_ADPCM_IMA_WS: - if (avctx->extradata && avctx->extradata_size >= 2) - c->vqa_version = AV_RL16(avctx->extradata); + case AV_CODEC_ID_ADPCM_ZORK: + if (avctx->bits_per_coded_sample != 8) + return AVERROR_INVALIDDATA; break; default: break; } - switch(avctx->codec->id) { - case AV_CODEC_ID_ADPCM_AICA: - case AV_CODEC_ID_ADPCM_IMA_DAT4: - case AV_CODEC_ID_ADPCM_IMA_QT: - case AV_CODEC_ID_ADPCM_IMA_WAV: - case AV_CODEC_ID_ADPCM_4XM: - case AV_CODEC_ID_ADPCM_XA: - case AV_CODEC_ID_ADPCM_EA_R1: - case AV_CODEC_ID_ADPCM_EA_R2: - case AV_CODEC_ID_ADPCM_EA_R3: - case AV_CODEC_ID_ADPCM_EA_XAS: - case AV_CODEC_ID_ADPCM_THP: - case AV_CODEC_ID_ADPCM_THP_LE: - case AV_CODEC_ID_ADPCM_AFC: - case AV_CODEC_ID_ADPCM_DTK: - case AV_CODEC_ID_ADPCM_PSX: - case AV_CODEC_ID_ADPCM_MTAF: - avctx->sample_fmt = AV_SAMPLE_FMT_S16P; - break; - case AV_CODEC_ID_ADPCM_IMA_WS: - avctx->sample_fmt = c->vqa_version == 3 ? AV_SAMPLE_FMT_S16P : - AV_SAMPLE_FMT_S16; - break; - default: - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + switch (avctx->codec->id) { + case AV_CODEC_ID_ADPCM_AICA: + case AV_CODEC_ID_ADPCM_IMA_CUNNING: + case AV_CODEC_ID_ADPCM_IMA_DAT4: + case AV_CODEC_ID_ADPCM_IMA_QT: + case AV_CODEC_ID_ADPCM_IMA_WAV: + case AV_CODEC_ID_ADPCM_4XM: + case AV_CODEC_ID_ADPCM_XA: + case AV_CODEC_ID_ADPCM_EA_R1: + case AV_CODEC_ID_ADPCM_EA_R2: + case AV_CODEC_ID_ADPCM_EA_R3: + case AV_CODEC_ID_ADPCM_EA_XAS: + case AV_CODEC_ID_ADPCM_THP: + case AV_CODEC_ID_ADPCM_THP_LE: + case AV_CODEC_ID_ADPCM_AFC: + case AV_CODEC_ID_ADPCM_DTK: + case AV_CODEC_ID_ADPCM_PSX: + case AV_CODEC_ID_ADPCM_MTAF: + case AV_CODEC_ID_ADPCM_ARGO: + case AV_CODEC_ID_ADPCM_IMA_MOFLEX: + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; + break; + case AV_CODEC_ID_ADPCM_IMA_WS: + avctx->sample_fmt = c->vqa_version == 3 ? AV_SAMPLE_FMT_S16P : + AV_SAMPLE_FMT_S16; + break; + case AV_CODEC_ID_ADPCM_MS: + avctx->sample_fmt = avctx->channels > 2 ? AV_SAMPLE_FMT_S16P : + AV_SAMPLE_FMT_S16; + break; + default: + avctx->sample_fmt = AV_SAMPLE_FMT_S16; } - return 0; } +static inline int16_t adpcm_agm_expand_nibble(ADPCMChannelStatus *c, int8_t nibble) +{ + int delta, pred, step, add; + + pred = c->predictor; + delta = nibble & 7; + step = c->step; + add = (delta * 2 + 1) * step; + if (add < 0) + add = add + 7; + + if ((nibble & 8) == 0) + pred = av_clip(pred + (add >> 3), -32767, 32767); + else + pred = av_clip(pred - (add >> 3), -32767, 32767); + + switch (delta) { + case 7: + step *= 0x99; + break; + case 6: + c->step = av_clip(c->step * 2, 127, 24576); + c->predictor = pred; + return pred; + case 5: + step *= 0x66; + break; + case 4: + step *= 0x4d; + break; + default: + step *= 0x39; + break; + } + + if (step < 0) + step += 0x3f; + + c->step = step >> 6; + c->step = av_clip(c->step, 127, 24576); + c->predictor = pred; + return pred; +} + static inline int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift) { int step_index; @@ -203,6 +276,65 @@ 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_mtf_expand_nibble(ADPCMChannelStatus *c, int nibble) +{ + int step_index, step, delta, predictor; + + step = ff_adpcm_step_table[c->step_index]; + + delta = step * (2 * nibble - 15); + predictor = c->predictor + delta; + + step_index = c->step_index + mtf_index_table[(unsigned)nibble]; + c->predictor = av_clip_int16(predictor >> 4); + c->step_index = av_clip(step_index, 0, 88); + + return (int16_t)c->predictor; +} + +static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int8_t nibble) +{ + int step_index; + int predictor; + int step; + + nibble = sign_extend(nibble & 0xF, 4); + + step = ff_adpcm_ima_cunning_step_table[c->step_index]; + step_index = c->step_index + ff_adpcm_ima_cunning_index_table[abs(nibble)]; + step_index = av_clip(step_index, 0, 60); + + predictor = c->predictor + step * nibble; + + c->predictor = av_clip_int16(predictor); + c->step_index = step_index; + + return 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; @@ -226,7 +358,7 @@ static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitC return (int16_t)c->predictor; } -static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift) +static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble) { int step_index; int predictor; @@ -289,7 +421,7 @@ static inline int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nib c->predictor = av_clip_intp2(predictor, 11); c->step_index = step_index; - return c->predictor << 4; + return c->predictor * 16; } static inline int16_t adpcm_ct_expand_nibble(ADPCMChannelStatus *c, int8_t nibble) @@ -356,6 +488,41 @@ static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t ni return c->predictor; } +static inline int16_t adpcm_zork_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble) +{ + int16_t index = c->step_index; + uint32_t lookup_sample = ff_adpcm_step_table[index]; + int32_t sample = 0; + + if (nibble & 0x40) + sample += lookup_sample; + if (nibble & 0x20) + sample += lookup_sample >> 1; + if (nibble & 0x10) + sample += lookup_sample >> 2; + if (nibble & 0x08) + sample += lookup_sample >> 3; + if (nibble & 0x04) + sample += lookup_sample >> 4; + if (nibble & 0x02) + sample += lookup_sample >> 5; + if (nibble & 0x01) + sample += lookup_sample >> 6; + if (nibble & 0x80) + sample = -sample; + + sample += c->predictor; + sample = av_clip_int16(sample); + + index += zork_index_table[(nibble >> 4) & 7]; + index = av_clip(index, 0, 88); + + c->predictor = sample; + c->step_index = index; + + return sample; +} + static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, const uint8_t *in, ADPCMChannelStatus *left, ADPCMChannelStatus *right, int channels, int sample_offset) @@ -378,6 +545,10 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, avpriv_request_sample(avctx, "unknown XA-ADPCM filter %d", filter); filter=0; } + if (shift < 0) { + avpriv_request_sample(avctx, "unknown XA-ADPCM shift %d", shift); + shift = 0; + } f0 = xa_adpcm_table[filter][0]; f1 = xa_adpcm_table[filter][1]; @@ -388,7 +559,7 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, d = in[16+i+j*4]; t = sign_extend(d, 4); - s = ( t<>6); + s = t*(1<>6); s_2 = s_1; s_1 = av_clip_int16(s); out0[j] = s_1; @@ -403,10 +574,14 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, shift = 12 - (in[5+i*2] & 15); filter = in[5+i*2] >> 4; - if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) { + if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table) || shift < 0) { avpriv_request_sample(avctx, "unknown XA-ADPCM filter %d", filter); filter=0; } + if (shift < 0) { + avpriv_request_sample(avctx, "unknown XA-ADPCM shift %d", shift); + shift = 0; + } f0 = xa_adpcm_table[filter][0]; f1 = xa_adpcm_table[filter][1]; @@ -415,7 +590,7 @@ static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, d = in[16+i+j*4]; t = sign_extend(d >> 4, 4); - s = ( t<>6); + s = t*(1<>6); s_2 = s_1; s_1 = av_clip_int16(s); out1[j] = s_1; @@ -440,7 +615,7 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ { ADPCMDecodeContext *c = avctx->priv_data; GetBitContext gb; - const int *table; + const int8_t *table; int k0, signmask, nb_bits, count; int size = buf_size*8; int i; @@ -493,8 +668,25 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ } } +int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag) +{ + int sample = sign_extend(nibble, 4) * (1 << shift); + + if (flag) + sample += (8 * cs->sample1) - (4 * cs->sample2); + else + sample += 4 * cs->sample1; + + sample = av_clip_int16(sample >> 2); + + cs->sample2 = cs->sample1; + cs->sample1 = sample; + + return sample; +} + /** - * Get the number of samples that will be decoded from the packet. + * Get the number of samples (per channel) that will be decoded from the packet. * In one case, this is actually the maximum number of samples possible to * decode with the given buf_size. * @@ -534,11 +726,16 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, /* simple 4-bit adpcm */ case AV_CODEC_ID_ADPCM_CT: case AV_CODEC_ID_ADPCM_IMA_APC: + case AV_CODEC_ID_ADPCM_IMA_CUNNING: case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: case AV_CODEC_ID_ADPCM_IMA_OKI: case AV_CODEC_ID_ADPCM_IMA_WS: case AV_CODEC_ID_ADPCM_YAMAHA: 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: + case AV_CODEC_ID_ADPCM_IMA_MTF: nb_samples = buf_size * 2 / ch; break; } @@ -549,9 +746,10 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, header_size = 0; switch (avctx->codec->id) { case AV_CODEC_ID_ADPCM_4XM: + case AV_CODEC_ID_ADPCM_AGM: case AV_CODEC_ID_ADPCM_IMA_DAT4: + case AV_CODEC_ID_ADPCM_IMA_MOFLEX: case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break; - case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break; case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break; } if (header_size > 0) @@ -559,6 +757,13 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, /* more complex formats */ switch (avctx->codec->id) { + case AV_CODEC_ID_ADPCM_IMA_AMV: + bytestream2_skip(gb, 4); + has_coded_samples = 1; + *coded_samples = bytestream2_get_le32u(gb); + nb_samples = FFMIN((buf_size - 8) * 2, *coded_samples); + bytestream2_seek(gb, -8, SEEK_CUR); + break; case AV_CODEC_ID_ADPCM_EA: has_coded_samples = 1; *coded_samples = bytestream2_get_le32(gb); @@ -696,6 +901,12 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, case AV_CODEC_ID_ADPCM_PSX: nb_samples = buf_size / (16 * ch) * 28; break; + case AV_CODEC_ID_ADPCM_ARGO: + nb_samples = buf_size / avctx->block_align * 32; + break; + case AV_CODEC_ID_ADPCM_ZORK: + nb_samples = buf_size / ch; + break; } /* validate coded sample count */ @@ -782,8 +993,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (m = 0; m < 64; m += 2) { int byte = bytestream2_get_byteu(&gb); - samples[m ] = adpcm_ima_qt_expand_nibble(cs, byte & 0x0F, 3); - samples[m + 1] = adpcm_ima_qt_expand_nibble(cs, byte >> 4 , 3); + samples[m ] = adpcm_ima_qt_expand_nibble(cs, byte & 0x0F); + samples[m + 1] = adpcm_ima_qt_expand_nibble(cs, byte >> 4 ); } } break; @@ -863,46 +1074,82 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } break; + case AV_CODEC_ID_ADPCM_AGM: + for (i = 0; i < avctx->channels; i++) + c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); + for (i = 0; i < avctx->channels; i++) + c->status[i].step = sign_extend(bytestream2_get_le16u(&gb), 16); + + for (n = 0; n < nb_samples >> (1 - st); n++) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_agm_expand_nibble(&c->status[0], v & 0xF); + *samples++ = adpcm_agm_expand_nibble(&c->status[st], v >> 4 ); + } + break; case AV_CODEC_ID_ADPCM_MS: { int block_predictor; - block_predictor = bytestream2_get_byteu(&gb); - if (block_predictor > 6) { - av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[0] = %d\n", - block_predictor); - return AVERROR_INVALIDDATA; - } - c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; - c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; - if (st) { + if (avctx->channels > 2) { + for (channel = 0; channel < avctx->channels; channel++) { + samples = samples_p[channel]; + block_predictor = bytestream2_get_byteu(&gb); + if (block_predictor > 6) { + av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[%d] = %d\n", + channel, block_predictor); + return AVERROR_INVALIDDATA; + } + c->status[channel].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; + c->status[channel].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; + c->status[channel].idelta = sign_extend(bytestream2_get_le16u(&gb), 16); + c->status[channel].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16); + c->status[channel].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16); + *samples++ = c->status[channel].sample2; + *samples++ = c->status[channel].sample1; + for(n = (nb_samples - 2) >> 1; n > 0; n--) { + int byte = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ms_expand_nibble(&c->status[channel], byte >> 4 ); + *samples++ = adpcm_ms_expand_nibble(&c->status[channel], byte & 0x0F); + } + } + } else { block_predictor = bytestream2_get_byteu(&gb); if (block_predictor > 6) { - av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[1] = %d\n", + av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[0] = %d\n", block_predictor); return AVERROR_INVALIDDATA; } - c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; - c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; - } - c->status[0].idelta = sign_extend(bytestream2_get_le16u(&gb), 16); - if (st){ - c->status[1].idelta = sign_extend(bytestream2_get_le16u(&gb), 16); - } + c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; + c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; + if (st) { + block_predictor = bytestream2_get_byteu(&gb); + if (block_predictor > 6) { + av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[1] = %d\n", + block_predictor); + return AVERROR_INVALIDDATA; + } + c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; + c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; + } + c->status[0].idelta = sign_extend(bytestream2_get_le16u(&gb), 16); + if (st){ + c->status[1].idelta = sign_extend(bytestream2_get_le16u(&gb), 16); + } - c->status[0].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16); - if (st) c->status[1].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16); - c->status[0].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16); - if (st) c->status[1].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16); + c->status[0].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16); + if (st) c->status[1].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16); + c->status[0].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16); + if (st) c->status[1].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16); - *samples++ = c->status[0].sample2; - if (st) *samples++ = c->status[1].sample2; - *samples++ = c->status[0].sample1; - if (st) *samples++ = c->status[1].sample1; - for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) { - int byte = bytestream2_get_byteu(&gb); - *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], byte >> 4 ); - *samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F); + *samples++ = c->status[0].sample2; + if (st) *samples++ = c->status[1].sample2; + *samples++ = c->status[0].sample1; + if (st) *samples++ = c->status[1].sample1; + for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) { + int byte = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], byte >> 4 ); + *samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F); + } } break; } @@ -1035,6 +1282,29 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3); } break; + case AV_CODEC_ID_ADPCM_IMA_MOFLEX: + for (channel = 0; channel < avctx->channels; channel++) { + cs = &c->status[channel]; + cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); + cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); + if (cs->step_index > 88u){ + av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n", + channel, cs->step_index); + return AVERROR_INVALIDDATA; + } + } + + for (int subframe = 0; subframe < nb_samples / 256; subframe++) { + for (channel = 0; channel < avctx->channels; channel++) { + samples = samples_p[channel] + 256 * subframe; + for (n = 0; n < 256; n += 2) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); + *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); + } + } + } + break; case AV_CODEC_ID_ADPCM_IMA_DAT4: for (channel = 0; channel < avctx->channels; channel++) { cs = &c->status[channel]; @@ -1048,14 +1318,51 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_IMA_APC: - while (bytestream2_get_bytes_left(&gb) > 0) { + for (n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } break; + case AV_CODEC_ID_ADPCM_IMA_SSI: + for (n = nb_samples >> (1 - st); n > 0; n--) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0], v >> 4 ); + *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F); + } + break; + case AV_CODEC_ID_ADPCM_IMA_APM: + for (n = nb_samples / 2; n > 0; n--) { + for (channel = 0; channel < avctx->channels; channel++) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ima_qt_expand_nibble(&c->status[channel], v >> 4 ); + samples[st] = adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F); + } + 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_CUNNING: + for (channel = 0; channel < avctx->channels; channel++) { + int16_t *smp = samples_p[channel]; + for (n = 0; n < nb_samples / 2; n++) { + int v = bytestream2_get_byteu(&gb); + *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v & 0x0F); + *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v >> 4); + } + } + break; case AV_CODEC_ID_ADPCM_IMA_OKI: - while (bytestream2_get_bytes_left(&gb) > 0) { + for (n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_oki_expand_nibble(&c->status[0], v >> 4 ); *samples++ = adpcm_ima_oki_expand_nibble(&c->status[st], v & 0x0F); @@ -1093,16 +1400,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (n = nb_samples / 2; n > 0; n--) { int v = bytestream2_get_byteu(&gb); - *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); + *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); } } } else { for (n = nb_samples / 2; n > 0; n--) { for (channel = 0; channel < avctx->channels; channel++) { int v = bytestream2_get_byteu(&gb); - *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); - samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); + *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); + samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); } samples += avctx->channels; } @@ -1141,8 +1448,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } } - for (i=0; i<=st; i++) + for (i=0; i<=st; i++) { c->status[i].predictor = bytestream2_get_le32u(&gb); + if (FFABS((int64_t)c->status[i].predictor) > (1<<16)) + return AVERROR_INVALIDDATA; + } for (n = nb_samples >> (1 - st); n > 0; n--) { int byte = bytestream2_get_byteu(&gb); @@ -1189,8 +1499,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (count2 = 0; count2 < 28; count2++) { byte = bytestream2_get_byteu(&gb); - next_left_sample = sign_extend(byte >> 4, 4) << shift_left; - next_right_sample = sign_extend(byte, 4) << shift_right; + next_left_sample = sign_extend(byte >> 4, 4) * (1 << shift_left); + next_right_sample = sign_extend(byte, 4) * (1 << shift_right); next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + @@ -1229,7 +1539,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, if (st) byte[1] = bytestream2_get_byteu(&gb); for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */ for(channel = 0; channel < avctx->channels; channel++) { - int sample = sign_extend(byte[channel] >> i, 4) << shift[channel]; + int sample = sign_extend(byte[channel] >> i, 4) * (1 << shift[channel]); sample = (sample + c->status[channel].sample1 * coeff[channel][0] + c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8; @@ -1290,10 +1600,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (count2=0; count2<28; count2++) { if (count2 & 1) - next_sample = sign_extend(byte, 4) << shift; + next_sample = (unsigned)sign_extend(byte, 4) << shift; else { byte = bytestream2_get_byte(&gb); - next_sample = sign_extend(byte >> 4, 4) << shift; + next_sample = (unsigned)sign_extend(byte >> 4, 4) << shift; } next_sample += (current_sample * coeff1) + @@ -1344,11 +1654,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int level, pred; int byte = bytestream2_get_byteu(&gb); - level = sign_extend(byte >> 4, 4) << shift[n]; + level = sign_extend(byte >> 4, 4) * (1 << shift[n]); pred = s[-1] * coeff[0][n] + s[-2] * coeff[1][n]; s[0] = av_clip_int16((level + pred + 0x80) >> 8); - level = sign_extend(byte, 4) << shift[n]; + level = sign_extend(byte, 4) * (1 << shift[n]); pred = s[0] * coeff[0][n] + s[-1] * coeff[1][n]; s[1] = av_clip_int16((level + pred + 0x80) >> 8); } @@ -1356,6 +1666,18 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_IMA_AMV: + av_assert0(avctx->channels == 1); + + /* + * Header format: + * int16_t predictor; + * uint8_t step_index; + * uint8_t reserved; + * uint32_t frame_size; + * + * Some implementations have step_index as 16-bits, but others + * only use the lower 8 and store garbage in the upper 8. + */ c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); c->status[0].step_index = bytestream2_get_byteu(&gb); bytestream2_skipu(&gb, 5); @@ -1365,12 +1687,23 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - for (n = nb_samples >> (1 - st); n > 0; n--) { + for (n = nb_samples >> 1; n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v & 0xf, 3); } + + if (nb_samples & 1) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3); + + if (v & 0x0F) { + /* Holds true on all the http://samples.mplayerhq.hu/amv samples. */ + av_log(avctx, AV_LOG_WARNING, "Last nibble set on packet with odd sample count.\n"); + av_log(avctx, AV_LOG_WARNING, "Sample will be skipped.\n"); + } + } break; case AV_CODEC_ID_ADPCM_IMA_SMJPEG: for (i = 0; i < avctx->channels; i++) { @@ -1387,8 +1720,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); - *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4, 3); - *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf, 3); + *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4 ); + *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf); } break; case AV_CODEC_ID_ADPCM_CT: @@ -1453,11 +1786,6 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_AICA: - if (!c->has_status) { - for (channel = 0; channel < avctx->channels; channel++) - c->status[channel].step = 0; - c->has_status = 1; - } for (channel = 0; channel < avctx->channels; channel++) { samples = samples_p[channel]; for (n = nb_samples >> 1; n > 0; n--) { @@ -1505,8 +1833,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, sampledat = sign_extend(byte >> 4, 4); } - sampledat = ((prev1 * factor1 + prev2 * factor2) + - ((sampledat * scale) << 11)) >> 11; + sampledat = ((prev1 * factor1 + prev2 * factor2) >> 11) + + sampledat * scale; *samples = av_clip_int16(sampledat); prev2 = prev1; prev1 = *samples++; @@ -1568,8 +1896,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int byte = bytestream2_get_byteu(&gb); int index = (byte >> 4) & 7; unsigned int exp = byte & 0x0F; - int factor1 = table[ch][index * 2]; - int factor2 = table[ch][index * 2 + 1]; + int64_t factor1 = table[ch][index * 2]; + int64_t factor2 = table[ch][index * 2 + 1]; /* Decode 14 samples. */ for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) { @@ -1583,7 +1911,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } sampledat = ((c->status[ch].sample1 * factor1 - + c->status[ch].sample2 * factor2) >> 11) + (sampledat << exp); + + c->status[ch].sample2 * factor2) >> 11) + sampledat * (1 << exp); *samples = av_clip_int16(sampledat); c->status[ch].sample2 = c->status[ch].sample1; c->status[ch].sample1 = *samples++; @@ -1630,7 +1958,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, else sampledat = sign_extend(byte >> 4, 4); - sampledat = (((sampledat << 12) >> (header & 0xf)) << 6) + prev; + sampledat = ((sampledat * (1 << 12)) >> (header & 0xf)) * (1 << 6) + prev; *samples++ = av_clip_int16(sampledat >> 6); c->status[channel].sample2 = c->status[channel].sample1; c->status[channel].sample1 = sampledat; @@ -1641,43 +1969,99 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_PSX: - for (channel = 0; channel < avctx->channels; channel++) { - samples = samples_p[channel]; - - /* Read in every sample for this channel. */ - for (i = 0; i < nb_samples / 28; i++) { - int filter, shift, flag, byte; - - filter = bytestream2_get_byteu(&gb); - shift = filter & 0xf; - filter = filter >> 4; - if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) - return AVERROR_INVALIDDATA; - flag = bytestream2_get_byteu(&gb); - - /* Decode 28 samples. */ - for (n = 0; n < 28; n++) { - int sample = 0, scale; - - if (flag < 0x07) { - if (n & 1) { - scale = sign_extend(byte >> 4, 4); - } else { - byte = bytestream2_get_byteu(&gb); - scale = sign_extend(byte, 4); + for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * avctx->channels); block++) { + int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * avctx->channels) / (16 * avctx->channels); + for (channel = 0; channel < avctx->channels; channel++) { + samples = samples_p[channel] + block * nb_samples_per_block; + av_assert0((block + 1) * nb_samples_per_block <= nb_samples); + + /* Read in every sample for this channel. */ + for (i = 0; i < nb_samples_per_block / 28; i++) { + int filter, shift, flag, byte; + + filter = bytestream2_get_byteu(&gb); + shift = filter & 0xf; + filter = filter >> 4; + if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) + return AVERROR_INVALIDDATA; + flag = bytestream2_get_byteu(&gb); + + /* Decode 28 samples. */ + for (n = 0; n < 28; n++) { + int sample = 0, scale; + + if (flag < 0x07) { + if (n & 1) { + scale = sign_extend(byte >> 4, 4); + } else { + byte = bytestream2_get_byteu(&gb); + scale = sign_extend(byte, 4); + } + + scale = scale * (1 << 12); + sample = (int)((scale >> shift) + (c->status[channel].sample1 * xa_adpcm_table[filter][0] + c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64); } - - scale = scale << 12; - sample = (int)((scale >> shift) + (c->status[channel].sample1 * xa_adpcm_table[filter][0] + c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64); + *samples++ = av_clip_int16(sample); + c->status[channel].sample2 = c->status[channel].sample1; + c->status[channel].sample1 = sample; } - *samples++ = av_clip_int16(sample); - c->status[channel].sample2 = c->status[channel].sample1; - c->status[channel].sample1 = sample; } } } break; + case AV_CODEC_ID_ADPCM_ARGO: + /* + * The format of each block: + * uint8_t left_control; + * uint4_t left_samples[nb_samples]; + * ---- and if stereo ---- + * uint8_t right_control; + * uint4_t right_samples[nb_samples]; + * + * Format of the control byte: + * MSB [SSSSRDRR] LSB + * S = (Shift Amount - 2) + * D = Decoder flag. + * R = Reserved + * + * Each block relies on the previous two samples of each channel. + * They should be 0 initially. + */ + for (int block = 0; block < avpkt->size / avctx->block_align; block++) { + for (channel = 0; channel < avctx->channels; channel++) { + int control, shift; + samples = samples_p[channel] + block * 32; + cs = c->status + channel; + + /* Get the control byte and decode the samples, 2 at a time. */ + control = bytestream2_get_byteu(&gb); + shift = (control >> 4) + 2; + + for (n = 0; n < 16; n++) { + int sample = bytestream2_get_byteu(&gb); + *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; + case AV_CODEC_ID_ADPCM_ZORK: + for (n = 0; n < nb_samples * avctx->channels; n++) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v); + } + break; + case AV_CODEC_ID_ADPCM_IMA_MTF: + for (n = nb_samples / 2; n > 0; n--) { + for (channel = 0; channel < avctx->channels; channel++) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ima_mtf_expand_nibble(&c->status[channel], v >> 4); + samples[st] = adpcm_ima_mtf_expand_nibble(&c->status[channel], v & 0x0F); + } + samples += avctx->channels; + } + break; default: av_assert0(0); // unsupported codec_id should not happen } @@ -1700,7 +2084,42 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, static void adpcm_flush(AVCodecContext *avctx) { ADPCMDecodeContext *c = avctx->priv_data; - c->has_status = 0; + + /* Just nuke the entire state and re-init. */ + memset(c, 0, sizeof(ADPCMDecodeContext)); + + switch(avctx->codec_id) { + case AV_CODEC_ID_ADPCM_CT: + c->status[0].step = c->status[1].step = 511; + break; + + case AV_CODEC_ID_ADPCM_IMA_APC: + if (avctx->extradata && avctx->extradata_size >= 8) { + c->status[0].predictor = av_clip_intp2(AV_RL32(avctx->extradata ), 18); + c->status[1].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 4), 18); + } + break; + + case AV_CODEC_ID_ADPCM_IMA_APM: + if (avctx->extradata && avctx->extradata_size >= 28) { + c->status[0].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 16), 18); + c->status[0].step_index = av_clip(AV_RL32(avctx->extradata + 20), 0, 88); + c->status[1].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 4), 18); + c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 8), 0, 88); + } + break; + + case AV_CODEC_ID_ADPCM_IMA_WS: + if (avctx->extradata && avctx->extradata_size >= 2) + c->vqa_version = AV_RL16(avctx->extradata); + break; + default: + /* Other codecs may want to handle this during decoding. */ + c->has_status = 0; + return; + } + + c->has_status = 1; } @@ -1713,7 +2132,7 @@ static const enum AVSampleFormat sample_fmts_both[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }; #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \ -AVCodec ff_ ## name_ ## _decoder = { \ +const AVCodec ff_ ## name_ ## _decoder = { \ .name = #name_, \ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ .type = AVMEDIA_TYPE_AUDIO, \ @@ -1724,12 +2143,15 @@ AVCodec ff_ ## name_ ## _decoder = { \ .flush = adpcm_flush, \ .capabilities = AV_CODEC_CAP_DR1, \ .sample_fmts = sample_fmts_, \ + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, \ } /* Note: Do not forget to add new entries to the Makefile as well. */ ADPCM_DECODER(AV_CODEC_ID_ADPCM_4XM, sample_fmts_s16p, adpcm_4xm, "ADPCM 4X Movie"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_AFC, sample_fmts_s16p, adpcm_afc, "ADPCM Nintendo Gamecube AFC"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_AGM, sample_fmts_s16, adpcm_agm, "ADPCM AmuseGraphics Movie"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_AICA, sample_fmts_s16p, adpcm_aica, "ADPCM Yamaha AICA"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_ARGO, sample_fmts_s16p, adpcm_argo, "ADPCM Argonaut Games"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_CT, sample_fmts_s16, adpcm_ct, "ADPCM Creative Technology"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_DTK, sample_fmts_s16p, adpcm_dtk, "ADPCM Nintendo Gamecube DTK"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA, sample_fmts_s16, adpcm_ea, "ADPCM Electronic Arts"); @@ -1740,19 +2162,25 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3, sample_fmts_s16p, adpcm_ea_r3, ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16p, adpcm_ea_xas, "ADPCM Electronic Arts XAS"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16, adpcm_ima_apc, "ADPCM IMA CRYO APC"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APM, sample_fmts_s16, adpcm_ima_apm, "ADPCM IMA Ubisoft APM"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_CUNNING, sample_fmts_s16p, adpcm_ima_cunning, "ADPCM IMA Cunning Developments"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4, sample_fmts_s16, adpcm_ima_dat4, "ADPCM IMA Eurocom DAT4"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK3, sample_fmts_s16, adpcm_ima_dk3, "ADPCM IMA Duck DK3"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, "ADPCM IMA Duck DK4"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, sample_fmts_s16, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, sample_fmts_s16, adpcm_ima_iss, "ADPCM IMA Funcom ISS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_MOFLEX, sample_fmts_s16p, adpcm_ima_moflex, "ADPCM IMA MobiClip MOFLEX"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_MTF, sample_fmts_s16, adpcm_ima_mtf, "ADPCM IMA Capcom's MT Framework"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_OKI, sample_fmts_s16, adpcm_ima_oki, "ADPCM IMA Dialogic OKI"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, "ADPCM IMA QuickTime"); 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_s16, adpcm_ms, "ADPCM Microsoft"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_both, adpcm_ms, "ADPCM Microsoft"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_MTAF, sample_fmts_s16p, adpcm_mtaf, "ADPCM MTAF"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_PSX, sample_fmts_s16p, adpcm_psx, "ADPCM Playstation"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit"); @@ -1763,3 +2191,4 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP_LE, sample_fmts_s16p, adpcm_thp_le, ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, sample_fmts_s16p, adpcm_thp, "ADPCM Nintendo THP"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_XA, sample_fmts_s16p, adpcm_xa, "ADPCM CDROM XA"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_YAMAHA, sample_fmts_s16, adpcm_yamaha, "ADPCM Yamaha"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_ZORK, sample_fmts_s16, adpcm_zork, "ADPCM Zork");