Browse code

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: b18357326ca1522d7fb7f4276ddebfccc29ce72c and others

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/04/07 05:46:29
Showing 9 changed files
... ...
@@ -278,6 +278,7 @@ version 1.0:
278 278
 - RTMPTE protocol support
279 279
 - showwaves and showspectrum filter
280 280
 - LucasArts SMUSH SANM playback support
281
+- LucasArts SMUSH VIMA audio decoder (ADPCM)
281 282
 - SAMI, RealText and SubViewer demuxers and decoders
282 283
 - Heart Of Darkness PAF playback support
283 284
 - iec61883 device
... ...
@@ -864,6 +864,8 @@ following image formats are supported:
864 864
 @item ADPCM Sound Blaster Pro 2-bit  @tab     @tab  X
865 865
 @item ADPCM Sound Blaster Pro 2.6-bit  @tab     @tab  X
866 866
 @item ADPCM Sound Blaster Pro 4-bit  @tab     @tab  X
867
+@item ADPCM VIMA
868
+    @tab Used in LucasArts SMUSH animations.
867 869
 @item ADPCM Westwood Studios IMA @tab     @tab  X
868 870
     @tab Used in Westwood Studios games like Command and Conquer.
869 871
 @item ADPCM Yamaha           @tab  X  @tab  X
... ...
@@ -617,6 +617,7 @@ OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER)      += adpcm.o adpcm_data.o
617 617
 OBJS-$(CONFIG_ADPCM_SWF_DECODER)          += adpcm.o adpcm_data.o
618 618
 OBJS-$(CONFIG_ADPCM_SWF_ENCODER)          += adpcmenc.o adpcm_data.o
619 619
 OBJS-$(CONFIG_ADPCM_THP_DECODER)          += adpcm.o adpcm_data.o
620
+OBJS-$(CONFIG_ADPCM_VIMA_DECODER)         += vima.o adpcm_data.o
620 621
 OBJS-$(CONFIG_ADPCM_XA_DECODER)           += adpcm.o adpcm_data.o
621 622
 OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)       += adpcm.o adpcm_data.o
622 623
 OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)       += adpcmenc.o adpcm_data.o
... ...
@@ -464,6 +464,7 @@ void avcodec_register_all(void)
464 464
     REGISTER_DECODER(ADPCM_SBPRO_4,     adpcm_sbpro_4);
465 465
     REGISTER_ENCDEC (ADPCM_SWF,         adpcm_swf);
466 466
     REGISTER_DECODER(ADPCM_THP,         adpcm_thp);
467
+    REGISTER_DECODER(ADPCM_VIMA,        adpcm_vima);
467 468
     REGISTER_DECODER(ADPCM_XA,          adpcm_xa);
468 469
     REGISTER_ENCDEC (ADPCM_YAMAHA,      adpcm_yamaha);
469 470
     REGISTER_DECODER(VIMA,              vima);
... ...
@@ -389,6 +389,8 @@ enum AVCodecID {
389 389
     AV_CODEC_ID_ADPCM_IMA_ISS,
390 390
     AV_CODEC_ID_ADPCM_G722,
391 391
     AV_CODEC_ID_ADPCM_IMA_APC,
392
+    AV_CODEC_ID_ADPCM_VIMA_DEPRECATED,
393
+    AV_CODEC_ID_ADPCM_VIMA = MKBETAG('V','I','M','A'),
392 394
     AV_CODEC_ID_VIMA       = MKBETAG('V','I','M','A'),
393 395
     AV_CODEC_ID_ADPCM_AFC  = MKBETAG('A','F','C',' '),
394 396
     AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
... ...
@@ -1893,6 +1893,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
1893 1893
         .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"),
1894 1894
         .props     = AV_CODEC_PROP_LOSSY,
1895 1895
     },
1896
+    {
1897
+        .id        = AV_CODEC_ID_ADPCM_VIMA,
1898
+        .type      = AVMEDIA_TYPE_AUDIO,
1899
+        .name      = "adpcm_vima",
1900
+        .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
1901
+        .props     = AV_CODEC_PROP_LOSSY,
1902
+    },
1896 1903
 
1897 1904
     /* AMR */
1898 1905
     {
... ...
@@ -2387,13 +2394,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
2387 2387
         .props     = AV_CODEC_PROP_LOSSY,
2388 2388
     },
2389 2389
     {
2390
-        .id        = AV_CODEC_ID_VIMA,
2391
-        .type      = AVMEDIA_TYPE_AUDIO,
2392
-        .name      = "vima",
2393
-        .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
2394
-        .props     = AV_CODEC_PROP_LOSSY,
2395
-    },
2396
-    {
2397 2390
         .id        = AV_CODEC_ID_FFWAVESYNTH,
2398 2391
         .type      = AVMEDIA_TYPE_AUDIO,
2399 2392
         .name      = "wavesynth",
... ...
@@ -2681,6 +2681,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
2681 2681
         case AV_CODEC_ID_PAF_AUDIO_DEPRECATED : return AV_CODEC_ID_PAF_AUDIO;
2682 2682
         case AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S24LE_PLANAR;
2683 2683
         case AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S32LE_PLANAR;
2684
+        case AV_CODEC_ID_ADPCM_VIMA_DEPRECATED : return AV_CODEC_ID_ADPCM_VIMA;
2684 2685
         case AV_CODEC_ID_ESCAPE130_DEPRECATED : return AV_CODEC_ID_ESCAPE130;
2685 2686
         case AV_CODEC_ID_EXR_DEPRECATED : return AV_CODEC_ID_EXR;
2686 2687
         case AV_CODEC_ID_G2M_DEPRECATED : return AV_CODEC_ID_G2M;
... ...
@@ -29,8 +29,8 @@
29 29
 #include "libavutil/version.h"
30 30
 
31 31
 #define LIBAVCODEC_VERSION_MAJOR 55
32
-#define LIBAVCODEC_VERSION_MINOR  57
33
-#define LIBAVCODEC_VERSION_MICRO 102
32
+#define LIBAVCODEC_VERSION_MINOR  58
33
+#define LIBAVCODEC_VERSION_MICRO 100
34 34
 
35 35
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
36 36
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -26,16 +26,16 @@
26 26
  */
27 27
 
28 28
 #include "libavutil/channel_layout.h"
29
+
30
+#include "adpcm_data.h"
29 31
 #include "avcodec.h"
30 32
 #include "get_bits.h"
31 33
 #include "internal.h"
32
-#include "adpcm_data.h"
33 34
 
34 35
 static int predict_table_init = 0;
35 36
 static uint16_t predict_table[5786 * 2];
36 37
 
37
-static const uint8_t size_table[] =
38
-{
38
+static const uint8_t size_table[] = {
39 39
     4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
40 40
     4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
41 41
     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[] =
44 44
     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
45 45
 };
46 46
 
47
-static const int8_t index_table1[] =
48
-{
47
+static const int8_t index_table1[] = {
49 48
     -1, 4, -1, 4
50 49
 };
51 50
 
52
-static const int8_t index_table2[] =
53
-{
51
+static const int8_t index_table2[] = {
54 52
     -1, -1, 2, 6, -1, -1, 2, 6
55 53
 };
56 54
 
57
-static const int8_t index_table3[] =
58
-{
59
-    -1, -1, -1, -1, 1, 2, 4, 6,
60
-    -1, -1, -1, -1, 1, 2, 4, 6
55
+static const int8_t index_table3[] = {
56
+    -1, -1, -1, -1, 1, 2, 4, 6, -1, -1, -1, -1, 1, 2, 4, 6
61 57
 };
62 58
 
63
-static const int8_t index_table4[] =
64
-{
65
-    -1, -1, -1, -1, -1, -1, -1, -1,
66
-     1,  1,  1,  2,  2,  4,  5,  6,
67
-    -1, -1, -1, -1, -1, -1, -1, -1,
68
-     1,  1,  1,  2,  2,  4,  5,  6
59
+static const int8_t index_table4[] = {
60
+    -1, -1, -1, -1, -1, -1, -1, -1, 1,  1,  1,  2,  2,  4,  5,  6,
61
+    -1, -1, -1, -1, -1, -1, -1, -1, 1,  1,  1,  2,  2,  4,  5,  6
69 62
 };
70 63
 
71
-static const int8_t index_table5[] =
72
-{
73
-    -1, -1, -1, -1, -1, -1, -1, -1,
74
-    -1, -1, -1, -1, -1, -1, -1, -1,
75
-     1,  1,  1,  1,  1,  2,  2,  2,
76
-     2,  4,  4,  4,  5,  5,  6,  6,
77
-    -1, -1, -1, -1, -1, -1, -1, -1,
78
-    -1, -1, -1, -1, -1, -1, -1, -1,
79
-     1,  1,  1,  1,  1,  2,  2,  2,
80
-     2,  4,  4,  4,  5,  5,  6,  6
64
+static const int8_t index_table5[] = {
65
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
66
+     1,  1,  1,  1,  1,  2,  2,  2,  2,  4,  4,  4,  5,  5,  6,  6,
67
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
68
+     1,  1,  1,  1,  1,  2,  2,  2,  2,  4,  4,  4,  5,  5,  6,  6
81 69
 };
82 70
 
83
-static const int8_t index_table6[] =
84
-{
85
-    -1, -1, -1, -1, -1, -1, -1, -1,
86
-    -1, -1, -1, -1, -1, -1, -1, -1,
87
-    -1, -1, -1, -1, -1, -1, -1, -1,
88
-    -1, -1, -1, -1, -1, -1, -1, -1,
89
-     1,  1,  1,  1,  1,  1,  1,  1,
90
-     1,  1,  2,  2,  2,  2,  2,  2,
91
-     2,  2,  4,  4,  4,  4,  4,  4,
92
-     5,  5,  5,  5,  6,  6,  6,  6,
93
-    -1, -1, -1, -1, -1, -1, -1, -1,
94
-    -1, -1, -1, -1, -1, -1, -1, -1,
95
-    -1, -1, -1, -1, -1, -1, -1, -1,
96
-    -1, -1, -1, -1, -1, -1, -1, -1,
97
-     1,  1,  1,  1,  1,  1,  1,  1,
98
-     1,  1,  2,  2,  2,  2,  2,  2,
99
-     2,  2,  4,  4,  4,  4,  4,  4,
100
-     5,  5,  5,  5,  6,  6,  6,  6
71
+static const int8_t index_table6[] = {
72
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
73
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
74
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,
75
+     2,  2,  4,  4,  4,  4,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6,
76
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
77
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
78
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,
79
+     2,  2,  4,  4,  4,  4,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6
101 80
 };
102 81
 
103
-static const int8_t* const step_index_tables[] =
104
-{
82
+static const int8_t *const step_index_tables[] = {
105 83
     index_table1, index_table2, index_table3,
106 84
     index_table4, index_table5, index_table6
107 85
 };
... ...
@@ -140,12 +118,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
140 140
 static int decode_frame(AVCodecContext *avctx, void *data,
141 141
                         int *got_frame_ptr, AVPacket *pkt)
142 142
 {
143
-    GetBitContext  gb;
144
-    AVFrame        *frame = data;
145
-    int16_t        pcm_data[2];
146
-    uint32_t       samples;
147
-    int8_t         channel_hint[2];
148
-    int            ret, chan, channels = 1;
143
+    GetBitContext gb;
144
+    AVFrame *frame = data;
145
+    int16_t pcm_data[2];
146
+    uint32_t samples;
147
+    int8_t channel_hint[2];
148
+    int ret, chan;
149
+    int channels = 1;
149 150
 
150 151
     if (pkt->size < 13)
151 152
         return AVERROR_INVALIDDATA;
... ...
@@ -168,12 +147,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
168 168
         channels = 2;
169 169
     }
170 170
     avctx->channels = channels;
171
-    avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO :
172
-                                              AV_CH_LAYOUT_MONO;
171
+    avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO
172
+                                            : AV_CH_LAYOUT_MONO;
173 173
     pcm_data[0] = get_sbits(&gb, 16);
174 174
     if (channels > 1) {
175 175
         channel_hint[1] = get_sbits(&gb, 8);
176
-        pcm_data[1] = get_sbits(&gb, 16);
176
+        pcm_data[1]     = get_sbits(&gb, 16);
177 177
     }
178 178
 
179 179
     frame->nb_samples = samples;
... ...
@@ -181,7 +160,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
181 181
         return ret;
182 182
 
183 183
     for (chan = 0; chan < channels; chan++) {
184
-        uint16_t *dest = (uint16_t*)frame->data[0] + chan;
184
+        uint16_t *dest = (uint16_t *)frame->data[0] + chan;
185 185
         int step_index = channel_hint[chan];
186 186
         int output = pcm_data[chan];
187 187
         int sample;
... ...
@@ -211,9 +190,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
211 211
                 if (lookup)
212 212
                     diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1);
213 213
                 if (highbit)
214
-                    diff  = -diff;
214
+                    diff = -diff;
215 215
 
216
-                output  = av_clip_int16(output + diff);
216
+                output = av_clip_int16(output + diff);
217 217
             }
218 218
 
219 219
             *dest = output;
... ...
@@ -223,17 +202,27 @@ static int decode_frame(AVCodecContext *avctx, void *data,
223 223
         }
224 224
     }
225 225
 
226
-    *got_frame_ptr   = 1;
226
+    *got_frame_ptr = 1;
227 227
 
228 228
     return pkt->size;
229 229
 }
230 230
 
231
+AVCodec ff_adpcm_vima_decoder = {
232
+    .name         = "adpcm_vima",
233
+    .long_name    = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
234
+    .type         = AVMEDIA_TYPE_AUDIO,
235
+    .id           = AV_CODEC_ID_ADPCM_VIMA,
236
+    .init         = decode_init,
237
+    .decode       = decode_frame,
238
+    .capabilities = CODEC_CAP_DR1,
239
+};
240
+
231 241
 AVCodec ff_vima_decoder = {
232
-    .name           = "vima",
233
-    .long_name      = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
234
-    .type           = AVMEDIA_TYPE_AUDIO,
235
-    .id             = AV_CODEC_ID_VIMA,
236
-    .init           = decode_init,
237
-    .decode         = decode_frame,
238
-    .capabilities   = CODEC_CAP_DR1,
242
+    .name         = "vima",
243
+    .long_name    = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
244
+    .type         = AVMEDIA_TYPE_AUDIO,
245
+    .id           = AV_CODEC_ID_ADPCM_VIMA,
246
+    .init         = decode_init,
247
+    .decode       = decode_frame,
248
+    .capabilities = CODEC_CAP_DR1,
239 249
 };