[FFmpeg-devel] [PATCH 1/2] avcodec: add ADPCM AICA decoder
Paul B Mahol
onemda at gmail.com
Wed Oct 28 22:12:02 CET 2015
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavcodec/Makefile | 1 +
libavcodec/adpcm.c | 13 +++++++++++++
libavcodec/allcodecs.c | 1 +
libavcodec/avcodec.h | 1 +
libavcodec/codec_desc.c | 7 +++++++
5 files changed, 23 insertions(+)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5f38ebb..8162447 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -662,6 +662,7 @@ OBJS-$(CONFIG_ADPCM_4XM_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_ADX_DECODER) += adxdec.o adx.o
OBJS-$(CONFIG_ADPCM_ADX_ENCODER) += adxenc.o adx.o
OBJS-$(CONFIG_ADPCM_AFC_DECODER) += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_AICA_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_CT_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_DTK_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 98af171..64ef5e4 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -143,6 +143,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
}
switch(avctx->codec->id) {
+ case AV_CODEC_ID_ADPCM_AICA:
case AV_CODEC_ID_ADPCM_IMA_QT:
case AV_CODEC_ID_ADPCM_IMA_WAV:
case AV_CODEC_ID_ADPCM_4XM:
@@ -521,6 +522,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
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:
nb_samples = buf_size * 2 / ch;
break;
}
@@ -1380,6 +1382,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
*samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
}
break;
+ case AV_CODEC_ID_ADPCM_AICA:
+ for (channel = 0; channel < avctx->channels; channel++) {
+ samples = samples_p[channel];
+ for (n = nb_samples >> 1; n > 0; n--) {
+ int v = bytestream2_get_byteu(&gb);
+ *samples++ = adpcm_yamaha_expand_nibble(&c->status[channel], v & 0x0F);
+ *samples++ = adpcm_yamaha_expand_nibble(&c->status[channel], v >> 4 );
+ }
+ }
+ break;
case AV_CODEC_ID_ADPCM_AFC:
{
int samples_per_block;
@@ -1642,6 +1654,7 @@ AVCodec ff_ ## name_ ## _decoder = { \
/* 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_AICA, sample_fmts_s16p, adpcm_aica, "ADPCM Yamaha AICA");
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");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4b54615..49478a1 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -488,6 +488,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(ADPCM_4XM, adpcm_4xm);
REGISTER_ENCDEC (ADPCM_ADX, adpcm_adx);
REGISTER_DECODER(ADPCM_AFC, adpcm_afc);
+ REGISTER_DECODER(ADPCM_AICA, adpcm_aica);
REGISTER_DECODER(ADPCM_CT, adpcm_ct);
REGISTER_DECODER(ADPCM_DTK, adpcm_dtk);
REGISTER_DECODER(ADPCM_EA, adpcm_ea);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c4104cf..b82a0c2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -396,6 +396,7 @@ enum AVCodecID {
AV_CODEC_ID_ADPCM_G726LE,
AV_CODEC_ID_ADPCM_THP_LE,
AV_CODEC_ID_ADPCM_PSX,
+ AV_CODEC_ID_ADPCM_AICA,
/* AMR */
AV_CODEC_ID_AMR_NB = 0x12000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index ac64a4b..bf7c425 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1999,6 +1999,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("ADPCM Playstation"),
.props = AV_CODEC_PROP_LOSSY,
},
+ {
+ .id = AV_CODEC_ID_ADPCM_AICA,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "adpcm_aica",
+ .long_name = NULL_IF_CONFIG_SMALL("ADPCM Yamaha AICA"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
/* AMR */
{
--
1.9.1
More information about the ffmpeg-devel
mailing list