mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
Merge commit '6f273093e54cba130f3ffde3d6433e74baa4ad89'
* commit '6f273093e54cba130f3ffde3d6433e74baa4ad89':
LucasArts SMUSH VIMA audio decoder
Conflicts:
Changelog
libavcodec/avcodec.h
libavcodec/codec_desc.c
libavcodec/version.h
libavcodec/vima.c
This commit adds a AV_CODEC_ID_ADPCM_VIMA alias in addition to the previously
used AV_CODEC_ID_VIMA, as well as a AVCodec with name "adpcm_vima" in addition
to the previously used name "vima"
These changes are needed for compatibility with the renamed codec in libav
See: b18357326c
and others
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
787be6d074
@ -278,6 +278,7 @@ version 1.0:
|
||||
- RTMPTE protocol support
|
||||
- showwaves and showspectrum filter
|
||||
- LucasArts SMUSH SANM playback support
|
||||
- LucasArts SMUSH VIMA audio decoder (ADPCM)
|
||||
- SAMI, RealText and SubViewer demuxers and decoders
|
||||
- Heart Of Darkness PAF playback support
|
||||
- iec61883 device
|
||||
|
@ -864,6 +864,8 @@ following image formats are supported:
|
||||
@item ADPCM Sound Blaster Pro 2-bit @tab @tab X
|
||||
@item ADPCM Sound Blaster Pro 2.6-bit @tab @tab X
|
||||
@item ADPCM Sound Blaster Pro 4-bit @tab @tab X
|
||||
@item ADPCM VIMA
|
||||
@tab Used in LucasArts SMUSH animations.
|
||||
@item ADPCM Westwood Studios IMA @tab @tab X
|
||||
@tab Used in Westwood Studios games like Command and Conquer.
|
||||
@item ADPCM Yamaha @tab X @tab X
|
||||
|
@ -617,6 +617,7 @@ OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_SWF_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_SWF_ENCODER) += adpcmenc.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_XA_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o adpcm_data.o
|
||||
OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcmenc.o adpcm_data.o
|
||||
|
@ -464,6 +464,7 @@ void avcodec_register_all(void)
|
||||
REGISTER_DECODER(ADPCM_SBPRO_4, adpcm_sbpro_4);
|
||||
REGISTER_ENCDEC (ADPCM_SWF, adpcm_swf);
|
||||
REGISTER_DECODER(ADPCM_THP, adpcm_thp);
|
||||
REGISTER_DECODER(ADPCM_VIMA, adpcm_vima);
|
||||
REGISTER_DECODER(ADPCM_XA, adpcm_xa);
|
||||
REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha);
|
||||
REGISTER_DECODER(VIMA, vima);
|
||||
|
@ -389,6 +389,8 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_ADPCM_IMA_ISS,
|
||||
AV_CODEC_ID_ADPCM_G722,
|
||||
AV_CODEC_ID_ADPCM_IMA_APC,
|
||||
AV_CODEC_ID_ADPCM_VIMA_DEPRECATED,
|
||||
AV_CODEC_ID_ADPCM_VIMA = MKBETAG('V','I','M','A'),
|
||||
AV_CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
|
||||
AV_CODEC_ID_ADPCM_AFC = MKBETAG('A','F','C',' '),
|
||||
AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
|
||||
|
@ -1893,6 +1893,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
|
||||
.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"),
|
||||
.props = AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
{
|
||||
.id = AV_CODEC_ID_ADPCM_VIMA,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.name = "adpcm_vima",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
|
||||
.props = AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
|
||||
/* AMR */
|
||||
{
|
||||
@ -2386,13 +2393,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
|
||||
.long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"),
|
||||
.props = AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
{
|
||||
.id = AV_CODEC_ID_VIMA,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.name = "vima",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
|
||||
.props = AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
{
|
||||
.id = AV_CODEC_ID_FFWAVESYNTH,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
|
@ -2681,6 +2681,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
|
||||
case AV_CODEC_ID_PAF_AUDIO_DEPRECATED : return AV_CODEC_ID_PAF_AUDIO;
|
||||
case AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S24LE_PLANAR;
|
||||
case AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S32LE_PLANAR;
|
||||
case AV_CODEC_ID_ADPCM_VIMA_DEPRECATED : return AV_CODEC_ID_ADPCM_VIMA;
|
||||
case AV_CODEC_ID_ESCAPE130_DEPRECATED : return AV_CODEC_ID_ESCAPE130;
|
||||
case AV_CODEC_ID_EXR_DEPRECATED : return AV_CODEC_ID_EXR;
|
||||
case AV_CODEC_ID_G2M_DEPRECATED : return AV_CODEC_ID_G2M;
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 55
|
||||
#define LIBAVCODEC_VERSION_MINOR 57
|
||||
#define LIBAVCODEC_VERSION_MICRO 102
|
||||
#define LIBAVCODEC_VERSION_MINOR 58
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
|
@ -26,16 +26,16 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
|
||||
#include "adpcm_data.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "internal.h"
|
||||
#include "adpcm_data.h"
|
||||
|
||||
static int predict_table_init = 0;
|
||||
static uint16_t predict_table[5786 * 2];
|
||||
|
||||
static const uint8_t size_table[] =
|
||||
{
|
||||
static const uint8_t size_table[] = {
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
@ -44,64 +44,42 @@ static const uint8_t size_table[] =
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
|
||||
};
|
||||
|
||||
static const int8_t index_table1[] =
|
||||
{
|
||||
static const int8_t index_table1[] = {
|
||||
-1, 4, -1, 4
|
||||
};
|
||||
|
||||
static const int8_t index_table2[] =
|
||||
{
|
||||
static const int8_t index_table2[] = {
|
||||
-1, -1, 2, 6, -1, -1, 2, 6
|
||||
};
|
||||
|
||||
static const int8_t index_table3[] =
|
||||
{
|
||||
-1, -1, -1, -1, 1, 2, 4, 6,
|
||||
-1, -1, -1, -1, 1, 2, 4, 6
|
||||
static const int8_t index_table3[] = {
|
||||
-1, -1, -1, -1, 1, 2, 4, 6, -1, -1, -1, -1, 1, 2, 4, 6
|
||||
};
|
||||
|
||||
static const int8_t index_table4[] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 2, 2, 4, 5, 6,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 2, 2, 4, 5, 6
|
||||
static const int8_t index_table4[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 2, 2, 4, 5, 6,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 2, 2, 4, 5, 6
|
||||
};
|
||||
|
||||
static const int8_t index_table5[] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 2, 2, 2,
|
||||
2, 4, 4, 4, 5, 5, 6, 6,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 2, 2, 2,
|
||||
2, 4, 4, 4, 5, 5, 6, 6
|
||||
static const int8_t index_table5[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 5, 5, 6, 6,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 5, 5, 6, 6
|
||||
};
|
||||
|
||||
static const int8_t index_table6[] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 6, 6, 6, 6,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 6, 6, 6, 6
|
||||
static const int8_t index_table6[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6
|
||||
};
|
||||
|
||||
static const int8_t* const step_index_tables[] =
|
||||
{
|
||||
static const int8_t *const step_index_tables[] = {
|
||||
index_table1, index_table2, index_table3,
|
||||
index_table4, index_table5, index_table6
|
||||
};
|
||||
@ -140,12 +118,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
int *got_frame_ptr, AVPacket *pkt)
|
||||
{
|
||||
GetBitContext gb;
|
||||
AVFrame *frame = data;
|
||||
int16_t pcm_data[2];
|
||||
uint32_t samples;
|
||||
int8_t channel_hint[2];
|
||||
int ret, chan, channels = 1;
|
||||
GetBitContext gb;
|
||||
AVFrame *frame = data;
|
||||
int16_t pcm_data[2];
|
||||
uint32_t samples;
|
||||
int8_t channel_hint[2];
|
||||
int ret, chan;
|
||||
int channels = 1;
|
||||
|
||||
if (pkt->size < 13)
|
||||
return AVERROR_INVALIDDATA;
|
||||
@ -168,12 +147,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
channels = 2;
|
||||
}
|
||||
avctx->channels = channels;
|
||||
avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO :
|
||||
AV_CH_LAYOUT_MONO;
|
||||
avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO
|
||||
: AV_CH_LAYOUT_MONO;
|
||||
pcm_data[0] = get_sbits(&gb, 16);
|
||||
if (channels > 1) {
|
||||
channel_hint[1] = get_sbits(&gb, 8);
|
||||
pcm_data[1] = get_sbits(&gb, 16);
|
||||
pcm_data[1] = get_sbits(&gb, 16);
|
||||
}
|
||||
|
||||
frame->nb_samples = samples;
|
||||
@ -181,7 +160,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
return ret;
|
||||
|
||||
for (chan = 0; chan < channels; chan++) {
|
||||
uint16_t *dest = (uint16_t*)frame->data[0] + chan;
|
||||
uint16_t *dest = (uint16_t *)frame->data[0] + chan;
|
||||
int step_index = channel_hint[chan];
|
||||
int output = pcm_data[chan];
|
||||
int sample;
|
||||
@ -211,9 +190,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (lookup)
|
||||
diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1);
|
||||
if (highbit)
|
||||
diff = -diff;
|
||||
diff = -diff;
|
||||
|
||||
output = av_clip_int16(output + diff);
|
||||
output = av_clip_int16(output + diff);
|
||||
}
|
||||
|
||||
*dest = output;
|
||||
@ -223,17 +202,27 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
*got_frame_ptr = 1;
|
||||
|
||||
return pkt->size;
|
||||
}
|
||||
|
||||
AVCodec ff_vima_decoder = {
|
||||
.name = "vima",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = AV_CODEC_ID_VIMA,
|
||||
.init = decode_init,
|
||||
.decode = decode_frame,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
AVCodec ff_adpcm_vima_decoder = {
|
||||
.name = "adpcm_vima",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = AV_CODEC_ID_ADPCM_VIMA,
|
||||
.init = decode_init,
|
||||
.decode = decode_frame,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
};
|
||||
|
||||
AVCodec ff_vima_decoder = {
|
||||
.name = "vima",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.id = AV_CODEC_ID_ADPCM_VIMA,
|
||||
.init = decode_init,
|
||||
.decode = decode_frame,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user