mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avcodec: add decoder for Rayman 2's ADPCM variant
Adds support for the ADPCM variant used in Rayman 2's files. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
This commit is contained in:
parent
56df8296f5
commit
af65357207
@ -835,6 +835,7 @@ OBJS-$(CONFIG_ADPCM_G726LE_DECODER) += g726.o
|
||||
OBJS-$(CONFIG_ADPCM_G726LE_ENCODER) += g726.o
|
||||
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o
|
||||
|
@ -14,6 +14,7 @@
|
||||
* 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)
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -150,6 +151,14 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
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 >= 16) {
|
||||
c->status[0].predictor = AV_RL32(avctx->extradata + 0);
|
||||
c->status[0].step_index = AV_RL32(avctx->extradata + 4);
|
||||
c->status[1].predictor = AV_RL32(avctx->extradata + 8);
|
||||
c->status[1].step_index = AV_RL32(avctx->extradata + 12);
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_IMA_WS:
|
||||
if (avctx->extradata && avctx->extradata_size >= 2)
|
||||
c->vqa_version = AV_RL16(avctx->extradata);
|
||||
@ -665,6 +674,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
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:
|
||||
nb_samples = buf_size * 2 / ch;
|
||||
break;
|
||||
}
|
||||
@ -1227,6 +1237,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F, 3);
|
||||
}
|
||||
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 , 3);
|
||||
samples[st] = adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F, 3);
|
||||
}
|
||||
samples += avctx->channels;
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_IMA_OKI:
|
||||
while (bytestream2_get_bytes_left(&gb) > 0) {
|
||||
int v = bytestream2_get_byteu(&gb);
|
||||
@ -1965,6 +1985,7 @@ 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_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");
|
||||
|
@ -600,6 +600,7 @@ extern AVCodec ff_adpcm_g726le_encoder;
|
||||
extern AVCodec ff_adpcm_g726le_decoder;
|
||||
extern AVCodec ff_adpcm_ima_amv_decoder;
|
||||
extern AVCodec ff_adpcm_ima_apc_decoder;
|
||||
extern AVCodec ff_adpcm_ima_apm_decoder;
|
||||
extern AVCodec ff_adpcm_ima_dat4_decoder;
|
||||
extern AVCodec ff_adpcm_ima_dk3_decoder;
|
||||
extern AVCodec ff_adpcm_ima_dk4_decoder;
|
||||
|
@ -549,6 +549,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_ADPCM_ARGO,
|
||||
AV_CODEC_ID_ADPCM_IMA_SSI,
|
||||
AV_CODEC_ID_ADPCM_ZORK,
|
||||
AV_CODEC_ID_ADPCM_IMA_APM,
|
||||
|
||||
/* AMR */
|
||||
AV_CODEC_ID_AMR_NB = 0x12000,
|
||||
|
@ -2318,6 +2318,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ADPCM Zork"),
|
||||
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
{
|
||||
.id = AV_CODEC_ID_ADPCM_IMA_APM,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.name = "adpcm_ima_apm",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Ubisoft APM"),
|
||||
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
|
||||
/* AMR */
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 58
|
||||
#define LIBAVCODEC_VERSION_MINOR 71
|
||||
#define LIBAVCODEC_VERSION_MINOR 72
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
|
Loading…
x
Reference in New Issue
Block a user