diff options
author | Robert Marston <rmarston@gmail.com> | 2008-04-14 14:31:43 +0000 |
---|---|---|
committer | Benoit Fouet <benoit.fouet@free.fr> | 2008-04-14 14:31:43 +0000 |
commit | 861c63a21694e6a1c889c6fb8b98ff265ee4d67d (patch) | |
tree | a8ecc408c0fd1103e240bb041430064727f36679 /libavcodec | |
parent | 6f7b915a0d69ea33a6777c35f720cf31f122ed02 (diff) | |
download | ffmpeg-861c63a21694e6a1c889c6fb8b98ff265ee4d67d.tar.gz |
Maxis XA demuxer and decoder.
Patch by Robert Marston rmarston (\at/) gmail point com
Original thread: [FFmpeg-soc] [Patch] Maxis EA XA decoder - GSoC Task
Date: 04/08/2008 01:36 AM
Originally committed as revision 12817 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/adpcm.c | 27 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 1 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 1 |
3 files changed, 28 insertions, 1 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 3a4a2d062b..f214477d30 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -34,6 +34,7 @@ * EA IMA EACS decoder by Peter Ross (pross@xvid.org) * EA IMA SEAD decoder by Peter Ross (pross@xvid.org) * 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) * * Features and limitations: @@ -666,7 +667,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, static av_cold int adpcm_decode_init(AVCodecContext * avctx) { ADPCMContext *c = avctx->priv_data; - unsigned int max_channels = 2; + unsigned int max_channels = 2, channel; switch(avctx->codec->id) { case CODEC_ID_ADPCM_EA_R1: @@ -900,6 +901,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, int32_t coeff1l, coeff2l, coeff1r, coeff2r; uint8_t shift_left, shift_right; int count1, count2; + int coeff[2][2], shift[2];//used in EA MAXIS ADPCM if (!buf_size) return 0; @@ -1235,6 +1237,28 @@ static int adpcm_decode_frame(AVCodecContext *avctx, } } break; + case CODEC_ID_ADPCM_EA_MAXIS_XA: + for(channel = 0; channel < avctx->channels; channel++) { + for (i=0; i<2; i++) + coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i]; + shift[channel] = (*src & 0x0F) + 8; + src++; + } + for (count1 = 0; count1 < (buf_size - avctx->channels) / avctx->channels; count1++) { + for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */ + for(channel = 0; channel < avctx->channels; channel++) { + int32_t sample = (int32_t)(((*(src+channel) >> i) & 0x0F) << 0x1C) >> shift[channel]; + sample = (sample + + c->status[channel].sample1 * coeff[channel][0] + + c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8; + c->status[channel].sample2 = c->status[channel].sample1; + c->status[channel].sample1 = av_clip_int16(sample); + *samples++ = c->status[channel].sample1; + } + } + src+=avctx->channels; + } + break; case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: { @@ -1613,6 +1637,7 @@ ADPCM_ENCODER(id,name) ADPCM_DECODER(id,name) ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm); ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct); ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea); +ADPCM_DECODER(CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa); ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1); ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2); ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3); diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ec806b18ad..f36bae78c4 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -244,6 +244,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (ADPCM_ADX, adpcm_adx); REGISTER_DECODER (ADPCM_CT, adpcm_ct); REGISTER_DECODER (ADPCM_EA, adpcm_ea); + REGISTER_DECODER (ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa); REGISTER_DECODER (ADPCM_EA_R1, adpcm_ea_r1); REGISTER_DECODER (ADPCM_EA_R2, adpcm_ea_r2); REGISTER_DECODER (ADPCM_EA_R3, adpcm_ea_r3); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 118542ef68..ce03cabde4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -235,6 +235,7 @@ enum CodecID { CODEC_ID_ADPCM_IMA_EA_SEAD, CODEC_ID_ADPCM_IMA_EA_EACS, CODEC_ID_ADPCM_EA_XAS, + CODEC_ID_ADPCM_EA_MAXIS_XA, /* AMR */ CODEC_ID_AMR_NB= 0x12000, |