Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2016/05/16 03:45:04... | ... |
@@ -707,6 +707,7 @@ OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER) += adpcmenc.o adpcm_data.o |
707 | 707 |
OBJS-$(CONFIG_ADPCM_IMA_WS_DECODER) += adpcm.o adpcm_data.o |
708 | 708 |
OBJS-$(CONFIG_ADPCM_MS_DECODER) += adpcm.o adpcm_data.o |
709 | 709 |
OBJS-$(CONFIG_ADPCM_MS_ENCODER) += adpcmenc.o adpcm_data.o |
710 |
+OBJS-$(CONFIG_ADPCM_MTAF_DECODER) += adpcm.o adpcm_data.o |
|
710 | 711 |
OBJS-$(CONFIG_ADPCM_PSX_DECODER) += adpcm.o adpcm_data.o |
711 | 712 |
OBJS-$(CONFIG_ADPCM_SBPRO_2_DECODER) += adpcm.o adpcm_data.o |
712 | 713 |
OBJS-$(CONFIG_ADPCM_SBPRO_3_DECODER) += adpcm.o adpcm_data.o |
... | ... |
@@ -107,6 +107,10 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) |
107 | 107 |
case AV_CODEC_ID_ADPCM_EA_XAS: |
108 | 108 |
max_channels = 6; |
109 | 109 |
break; |
110 |
+ case AV_CODEC_ID_ADPCM_MTAF: |
|
111 |
+ min_channels = 2; |
|
112 |
+ max_channels = 8; |
|
113 |
+ break; |
|
110 | 114 |
case AV_CODEC_ID_ADPCM_PSX: |
111 | 115 |
max_channels = 8; |
112 | 116 |
break; |
... | ... |
@@ -159,6 +163,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) |
159 | 159 |
case AV_CODEC_ID_ADPCM_AFC: |
160 | 160 |
case AV_CODEC_ID_ADPCM_DTK: |
161 | 161 |
case AV_CODEC_ID_ADPCM_PSX: |
162 |
+ case AV_CODEC_ID_ADPCM_MTAF: |
|
162 | 163 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16P; |
163 | 164 |
break; |
164 | 165 |
case AV_CODEC_ID_ADPCM_IMA_WS: |
... | ... |
@@ -342,6 +347,15 @@ static inline int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t |
342 | 342 |
return c->predictor; |
343 | 343 |
} |
344 | 344 |
|
345 |
+static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble) |
|
346 |
+{ |
|
347 |
+ c->predictor += ff_adpcm_mtaf_stepsize[c->step][nibble]; |
|
348 |
+ c->predictor = av_clip_int16(c->predictor); |
|
349 |
+ c->step += ff_adpcm_index_table[nibble]; |
|
350 |
+ c->step = av_clip_uintp2(c->step, 5); |
|
351 |
+ return c->predictor; |
|
352 |
+} |
|
353 |
+ |
|
345 | 354 |
static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, |
346 | 355 |
const uint8_t *in, ADPCMChannelStatus *left, |
347 | 356 |
ADPCMChannelStatus *right, int channels, int sample_offset) |
... | ... |
@@ -617,6 +631,11 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, |
617 | 617 |
buf_size = FFMIN(buf_size, avctx->block_align); |
618 | 618 |
nb_samples = (buf_size - 6 * ch) * 2 / ch; |
619 | 619 |
break; |
620 |
+ case AV_CODEC_ID_ADPCM_MTAF: |
|
621 |
+ if (avctx->block_align > 0) |
|
622 |
+ buf_size = FFMIN(buf_size, avctx->block_align); |
|
623 |
+ nb_samples = (buf_size - 16 * (ch / 2)) * 2 / ch; |
|
624 |
+ break; |
|
620 | 625 |
case AV_CODEC_ID_ADPCM_SBPRO_2: |
621 | 626 |
case AV_CODEC_ID_ADPCM_SBPRO_3: |
622 | 627 |
case AV_CODEC_ID_ADPCM_SBPRO_4: |
... | ... |
@@ -887,6 +906,27 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, |
887 | 887 |
} |
888 | 888 |
break; |
889 | 889 |
} |
890 |
+ case AV_CODEC_ID_ADPCM_MTAF: |
|
891 |
+ for (channel = 0; channel < avctx->channels; channel+=2) { |
|
892 |
+ bytestream2_skipu(&gb, 4); |
|
893 |
+ c->status[channel ].step = bytestream2_get_le16u(&gb); |
|
894 |
+ c->status[channel + 1].step = bytestream2_get_le16u(&gb); |
|
895 |
+ c->status[channel ].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
|
896 |
+ bytestream2_skipu(&gb, 2); |
|
897 |
+ c->status[channel + 1].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
|
898 |
+ bytestream2_skipu(&gb, 2); |
|
899 |
+ for (n = 0; n < nb_samples; n+=2) { |
|
900 |
+ int v = bytestream2_get_byteu(&gb); |
|
901 |
+ samples_p[channel][n ] = adpcm_mtaf_expand_nibble(&c->status[channel], v & 0x0F); |
|
902 |
+ samples_p[channel][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel], v >> 4 ); |
|
903 |
+ } |
|
904 |
+ for (n = 0; n < nb_samples; n+=2) { |
|
905 |
+ int v = bytestream2_get_byteu(&gb); |
|
906 |
+ samples_p[channel + 1][n ] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v & 0x0F); |
|
907 |
+ samples_p[channel + 1][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v >> 4 ); |
|
908 |
+ } |
|
909 |
+ } |
|
910 |
+ break; |
|
890 | 911 |
case AV_CODEC_ID_ADPCM_IMA_DK4: |
891 | 912 |
for (channel = 0; channel < avctx->channels; channel++) { |
892 | 913 |
cs = &c->status[channel]; |
... | ... |
@@ -1706,6 +1746,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, |
1706 | 1706 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV"); |
1707 | 1707 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood"); |
1708 | 1708 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_s16, adpcm_ms, "ADPCM Microsoft"); |
1709 |
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_MTAF, sample_fmts_s16p, adpcm_mtaf, "ADPCM MTAF"); |
|
1709 | 1710 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_PSX, sample_fmts_s16p, adpcm_psx, "ADPCM Playstation"); |
1710 | 1711 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit"); |
1711 | 1712 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, sample_fmts_s16, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit"); |
... | ... |
@@ -110,3 +110,70 @@ const int16_t ff_adpcm_afc_coeffs[2][16] = { |
110 | 110 |
{ 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, 64512, 64512, 63488 }, |
111 | 111 |
{ 0, 0, 2048, 1024, 63488, 64000, 64512, 62976, 63288, 63236, 62464, 63488, 64512, 1024, 0, 0 } |
112 | 112 |
}; |
113 |
+ |
|
114 |
+const int16_t ff_adpcm_mtaf_stepsize[32][16] = { |
|
115 |
+ { 1, 5, 9, 13, 16, 20, 24, 28, |
|
116 |
+ -1, -5, -9, -13, -16, -20, -24, -28, }, |
|
117 |
+ { 2, 6, 11, 15, 20, 24, 29, 33, |
|
118 |
+ -2, -6, -11, -15, -20, -24, -29, -33, }, |
|
119 |
+ { 2, 7, 13, 18, 23, 28, 34, 39, |
|
120 |
+ -2, -7, -13, -18, -23, -28, -34, -39, }, |
|
121 |
+ { 3, 9, 15, 21, 28, 34, 40, 46, |
|
122 |
+ -3, -9, -15, -21, -28, -34, -40, -46, }, |
|
123 |
+ { 3, 11, 18, 26, 33, 41, 48, 56, |
|
124 |
+ -3, -11, -18, -26, -33, -41, -48, -56, }, |
|
125 |
+ { 4, 13, 22, 31, 40, 49, 58, 67, |
|
126 |
+ -4, -13, -22, -31, -40, -49, -58, -67, }, |
|
127 |
+ { 5, 16, 26, 37, 48, 59, 69, 80, |
|
128 |
+ -5, -16, -26, -37, -48, -59, -69, -80, }, |
|
129 |
+ { 6, 19, 31, 44, 57, 70, 82, 95, |
|
130 |
+ -6, -19, -31, -44, -57, -70, -82, -95, }, |
|
131 |
+ { 7, 22, 38, 53, 68, 83, 99, 114, |
|
132 |
+ -7, -22, -38, -53, -68, -83, -99, -114, }, |
|
133 |
+ { 9, 27, 45, 63, 81, 99, 117, 135, |
|
134 |
+ -9, -27, -45, -63, -81, -99, -117, -135, }, |
|
135 |
+ { 10, 32, 53, 75, 96, 118, 139, 161, |
|
136 |
+ -10, -32, -53, -75, -96, -118, -139, -161, }, |
|
137 |
+ { 12, 38, 64, 90, 115, 141, 167, 193, |
|
138 |
+ -12, -38, -64, -90, -115, -141, -167, -193, }, |
|
139 |
+ { 15, 45, 76, 106, 137, 167, 198, 228, |
|
140 |
+ -15, -45, -76, -106, -137, -167, -198, -228, }, |
|
141 |
+ { 18, 54, 91, 127, 164, 200, 237, 273, |
|
142 |
+ -18, -54, -91, -127, -164, -200, -237, -273, }, |
|
143 |
+ { 21, 65, 108, 152, 195, 239, 282, 326, |
|
144 |
+ -21, -65, -108, -152, -195, -239, -282, -326, }, |
|
145 |
+ { 25, 77, 129, 181, 232, 284, 336, 388, |
|
146 |
+ -25, -77, -129, -181, -232, -284, -336, -388, }, |
|
147 |
+ { 30, 92, 153, 215, 276, 338, 399, 461, |
|
148 |
+ -30, -92, -153, -215, -276, -338, -399, -461, }, |
|
149 |
+ { 36, 109, 183, 256, 329, 402, 476, 549, |
|
150 |
+ -36, -109, -183, -256, -329, -402, -476, -549, }, |
|
151 |
+ { 43, 130, 218, 305, 392, 479, 567, 654, |
|
152 |
+ -43, -130, -218, -305, -392, -479, -567, -654, }, |
|
153 |
+ { 52, 156, 260, 364, 468, 572, 676, 780, |
|
154 |
+ -52, -156, -260, -364, -468, -572, -676, -780, }, |
|
155 |
+ { 62, 186, 310, 434, 558, 682, 806, 930, |
|
156 |
+ -62, -186, -310, -434, -558, -682, -806, -930, }, |
|
157 |
+ { 73, 221, 368, 516, 663, 811, 958, 1106, |
|
158 |
+ -73, -221, -368, -516, -663, -811, -958, -1106, }, |
|
159 |
+ { 87, 263, 439, 615, 790, 966, 1142, 1318, |
|
160 |
+ -87, -263, -439, -615, -790, -966, -1142, -1318, }, |
|
161 |
+ { 104, 314, 523, 733, 942, 1152, 1361, 1571, |
|
162 |
+ -104, -314, -523, -733, -942, -1152, -1361, -1571, }, |
|
163 |
+ { 124, 374, 623, 873, 1122, 1372, 1621, 1871, |
|
164 |
+ -124, -374, -623, -873, -1122, -1372, -1621, -1871, }, |
|
165 |
+ { 148, 445, 743, 1040, 1337, 1634, 1932, 2229, |
|
166 |
+ -148, -445, -743, -1040, -1337, -1634, -1932, -2229, }, |
|
167 |
+ { 177, 531, 885, 1239, 1593, 1947, 2301, 2655, |
|
168 |
+ -177, -531, -885, -1239, -1593, -1947, -2301, -2655, }, |
|
169 |
+ { 210, 632, 1053, 1475, 1896, 2318, 2739, 3161, |
|
170 |
+ -210, -632, -1053, -1475, -1896, -2318, -2739, -3161, }, |
|
171 |
+ { 251, 753, 1255, 1757, 2260, 2762, 3264, 3766, |
|
172 |
+ -251, -753, -1255, -1757, -2260, -2762, -3264, -3766, }, |
|
173 |
+ { 299, 897, 1495, 2093, 2692, 3290, 3888, 4486, |
|
174 |
+ -299, -897, -1495, -2093, -2692, -3290, -3888, -4486, }, |
|
175 |
+ { 356, 1068, 1781, 2493, 3206, 3918, 4631, 5343, |
|
176 |
+ -356, -1068, -1781, -2493, -3206, -3918, -4631, -5343, }, |
|
177 |
+ { 424, 1273, 2121, 2970, 3819, 4668, 5516, 6365, |
|
178 |
+ -424, -1273, -2121, -2970, -3819, -4668, -5516, -6365, }, |
|
179 |
+}; |
... | ... |
@@ -41,5 +41,6 @@ extern const int8_t ff_adpcm_AdaptCoeff2[]; |
41 | 41 |
extern const int16_t ff_adpcm_yamaha_indexscale[]; |
42 | 42 |
extern const int8_t ff_adpcm_yamaha_difflookup[]; |
43 | 43 |
extern const int16_t ff_adpcm_afc_coeffs[2][16]; |
44 |
+extern const int16_t ff_adpcm_mtaf_stepsize[32][16]; |
|
44 | 45 |
|
45 | 46 |
#endif /* AVCODEC_ADPCM_DATA_H */ |
... | ... |
@@ -524,6 +524,7 @@ void avcodec_register_all(void) |
524 | 524 |
REGISTER_ENCDEC (ADPCM_IMA_WAV, adpcm_ima_wav); |
525 | 525 |
REGISTER_DECODER(ADPCM_IMA_WS, adpcm_ima_ws); |
526 | 526 |
REGISTER_ENCDEC (ADPCM_MS, adpcm_ms); |
527 |
+ REGISTER_DECODER(ADPCM_MTAF, adpcm_mtaf); |
|
527 | 528 |
REGISTER_DECODER(ADPCM_PSX, adpcm_psx); |
528 | 529 |
REGISTER_DECODER(ADPCM_SBPRO_2, adpcm_sbpro_2); |
529 | 530 |
REGISTER_DECODER(ADPCM_SBPRO_3, adpcm_sbpro_3); |
... | ... |
@@ -2690,6 +2690,13 @@ static const AVCodecDescriptor codec_descriptors[] = { |
2690 | 2690 |
.long_name = NULL_IF_CONFIG_SMALL("DST (Direct Stream Transfer)"), |
2691 | 2691 |
.props = AV_CODEC_PROP_LOSSLESS, |
2692 | 2692 |
}, |
2693 |
+ { |
|
2694 |
+ .id = AV_CODEC_ID_ADPCM_MTAF, |
|
2695 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
2696 |
+ .name = "adpcm_mtaf", |
|
2697 |
+ .long_name = NULL_IF_CONFIG_SMALL("ADPCM MTAF"), |
|
2698 |
+ .props = AV_CODEC_PROP_LOSSY, |
|
2699 |
+ }, |
|
2693 | 2700 |
|
2694 | 2701 |
/* subtitle codecs */ |
2695 | 2702 |
{ |
... | ... |
@@ -3601,6 +3601,8 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, |
3601 | 3601 |
return blocks * ((ba - 4 * ch) * 2 / ch); |
3602 | 3602 |
case AV_CODEC_ID_ADPCM_MS: |
3603 | 3603 |
return blocks * (2 + (ba - 7 * ch) * 2 / ch); |
3604 |
+ case AV_CODEC_ID_ADPCM_MTAF: |
|
3605 |
+ return blocks * (ba - 16) * 2 / ch; |
|
3604 | 3606 |
} |
3605 | 3607 |
} |
3606 | 3608 |
|
... | ... |
@@ -28,7 +28,7 @@ |
28 | 28 |
#include "libavutil/version.h" |
29 | 29 |
|
30 | 30 |
#define LIBAVCODEC_VERSION_MAJOR 57 |
31 |
-#define LIBAVCODEC_VERSION_MINOR 42 |
|
31 |
+#define LIBAVCODEC_VERSION_MINOR 43 |
|
32 | 32 |
#define LIBAVCODEC_VERSION_MICRO 100 |
33 | 33 |
|
34 | 34 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |