Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Rodger Combs authored on 2015/06/20 19:01:14... | ... |
@@ -105,6 +105,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) |
105 | 105 |
case AV_CODEC_ID_ADPCM_EA_R3: |
106 | 106 |
case AV_CODEC_ID_ADPCM_EA_XAS: |
107 | 107 |
case AV_CODEC_ID_ADPCM_THP: |
108 |
+ case AV_CODEC_ID_ADPCM_THP_LE: |
|
108 | 109 |
max_channels = 6; |
109 | 110 |
break; |
110 | 111 |
} |
... | ... |
@@ -145,6 +146,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) |
145 | 145 |
case AV_CODEC_ID_ADPCM_EA_R3: |
146 | 146 |
case AV_CODEC_ID_ADPCM_EA_XAS: |
147 | 147 |
case AV_CODEC_ID_ADPCM_THP: |
148 |
+ case AV_CODEC_ID_ADPCM_THP_LE: |
|
148 | 149 |
case AV_CODEC_ID_ADPCM_AFC: |
149 | 150 |
case AV_CODEC_ID_ADPCM_DTK: |
150 | 151 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16P; |
... | ... |
@@ -636,13 +638,16 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, |
636 | 636 |
break; |
637 | 637 |
} |
638 | 638 |
case AV_CODEC_ID_ADPCM_THP: |
639 |
+ case AV_CODEC_ID_ADPCM_THP_LE: |
|
639 | 640 |
if (avctx->extradata) { |
640 |
- nb_samples = buf_size / (8 * ch) * 14; |
|
641 |
+ nb_samples = buf_size * 14 / (8 * ch); |
|
641 | 642 |
break; |
642 | 643 |
} |
643 | 644 |
has_coded_samples = 1; |
644 | 645 |
bytestream2_skip(gb, 4); // channel size |
645 |
- *coded_samples = bytestream2_get_be32(gb); |
|
646 |
+ *coded_samples = (avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE) ? |
|
647 |
+ bytestream2_get_le32(gb) : |
|
648 |
+ bytestream2_get_be32(gb); |
|
646 | 649 |
*coded_samples -= *coded_samples % 14; |
647 | 650 |
nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14; |
648 | 651 |
break; |
... | ... |
@@ -1415,10 +1420,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, |
1415 | 1415 |
break; |
1416 | 1416 |
} |
1417 | 1417 |
case AV_CODEC_ID_ADPCM_THP: |
1418 |
+ case AV_CODEC_ID_ADPCM_THP_LE: |
|
1418 | 1419 |
{ |
1419 | 1420 |
int table[6][16]; |
1420 | 1421 |
int ch; |
1421 | 1422 |
|
1423 |
+#define THP_GET16(g) \ |
|
1424 |
+ sign_extend( \ |
|
1425 |
+ avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \ |
|
1426 |
+ bytestream2_get_le16u(&(g)) : \ |
|
1427 |
+ bytestream2_get_be16u(&(g)), 16) |
|
1428 |
+ |
|
1422 | 1429 |
if (avctx->extradata) { |
1423 | 1430 |
GetByteContext tb; |
1424 | 1431 |
if (avctx->extradata_size < 32 * avctx->channels) { |
... | ... |
@@ -1429,16 +1441,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, |
1429 | 1429 |
bytestream2_init(&tb, avctx->extradata, avctx->extradata_size); |
1430 | 1430 |
for (i = 0; i < avctx->channels; i++) |
1431 | 1431 |
for (n = 0; n < 16; n++) |
1432 |
- table[i][n] = sign_extend(bytestream2_get_be16u(&tb), 16); |
|
1432 |
+ table[i][n] = THP_GET16(tb); |
|
1433 | 1433 |
} else { |
1434 | 1434 |
for (i = 0; i < avctx->channels; i++) |
1435 | 1435 |
for (n = 0; n < 16; n++) |
1436 |
- table[i][n] = sign_extend(bytestream2_get_be16u(&gb), 16); |
|
1436 |
+ table[i][n] = THP_GET16(gb); |
|
1437 | 1437 |
|
1438 | 1438 |
/* Initialize the previous sample. */ |
1439 | 1439 |
for (i = 0; i < avctx->channels; i++) { |
1440 |
- c->status[i].sample1 = sign_extend(bytestream2_get_be16u(&gb), 16); |
|
1441 |
- c->status[i].sample2 = sign_extend(bytestream2_get_be16u(&gb), 16); |
|
1440 |
+ c->status[i].sample1 = THP_GET16(gb); |
|
1441 |
+ c->status[i].sample2 = THP_GET16(gb); |
|
1442 | 1442 |
} |
1443 | 1443 |
} |
1444 | 1444 |
|
... | ... |
@@ -1593,6 +1605,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, |
1593 | 1593 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, sample_fmts_s16, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit"); |
1594 | 1594 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_4, sample_fmts_s16, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit"); |
1595 | 1595 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SWF, sample_fmts_s16, adpcm_swf, "ADPCM Shockwave Flash"); |
1596 |
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP_LE, sample_fmts_s16p, adpcm_thp_le, "ADPCM Nintendo Gamecube THP (little-endian)"); |
|
1596 | 1597 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, sample_fmts_s16p, adpcm_thp, "ADPCM Nintendo Gamecube THP"); |
1597 | 1598 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_XA, sample_fmts_s16p, adpcm_xa, "ADPCM CDROM XA"); |
1598 | 1599 |
ADPCM_DECODER(AV_CODEC_ID_ADPCM_YAMAHA, sample_fmts_s16, adpcm_yamaha, "ADPCM Yamaha"); |
... | ... |
@@ -486,6 +486,7 @@ void avcodec_register_all(void) |
486 | 486 |
REGISTER_DECODER(ADPCM_SBPRO_4, adpcm_sbpro_4); |
487 | 487 |
REGISTER_ENCDEC (ADPCM_SWF, adpcm_swf); |
488 | 488 |
REGISTER_DECODER(ADPCM_THP, adpcm_thp); |
489 |
+ REGISTER_DECODER(ADPCM_THP_LE, adpcm_thp_le); |
|
489 | 490 |
REGISTER_DECODER(ADPCM_VIMA, adpcm_vima); |
490 | 491 |
REGISTER_DECODER(ADPCM_XA, adpcm_xa); |
491 | 492 |
REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha); |
... | ... |
@@ -401,6 +401,7 @@ enum AVCodecID { |
401 | 401 |
AV_CODEC_ID_ADPCM_DTK = MKBETAG('D','T','K',' '), |
402 | 402 |
AV_CODEC_ID_ADPCM_IMA_RAD = MKBETAG('R','A','D',' '), |
403 | 403 |
AV_CODEC_ID_ADPCM_G726LE = MKBETAG('6','2','7','G'), |
404 |
+ AV_CODEC_ID_ADPCM_THP_LE = MKBETAG('T','H','P','L'), |
|
404 | 405 |
|
405 | 406 |
/* AMR */ |
406 | 407 |
AV_CODEC_ID_AMR_NB = 0x12000, |
... | ... |
@@ -1824,6 +1824,13 @@ static const AVCodecDescriptor codec_descriptors[] = { |
1824 | 1824 |
.props = AV_CODEC_PROP_LOSSY, |
1825 | 1825 |
}, |
1826 | 1826 |
{ |
1827 |
+ .id = AV_CODEC_ID_ADPCM_THP_LE, |
|
1828 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
1829 |
+ .name = "adpcm_thp_le", |
|
1830 |
+ .long_name = NULL_IF_CONFIG_SMALL("ADPCM Nintendo Gamecube THP (Little-Endian)"), |
|
1831 |
+ .props = AV_CODEC_PROP_LOSSY, |
|
1832 |
+ }, |
|
1833 |
+ { |
|
1827 | 1834 |
.id = AV_CODEC_ID_ADPCM_IMA_AMV, |
1828 | 1835 |
.type = AVMEDIA_TYPE_AUDIO, |
1829 | 1836 |
.name = "adpcm_ima_amv", |
... | ... |
@@ -3431,6 +3431,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) |
3431 | 3431 |
case AV_CODEC_ID_ADPCM_IMA_AMV: |
3432 | 3432 |
return (frame_bytes - 8) * 2 / ch; |
3433 | 3433 |
case AV_CODEC_ID_ADPCM_THP: |
3434 |
+ case AV_CODEC_ID_ADPCM_THP_LE: |
|
3434 | 3435 |
if (avctx->extradata) |
3435 | 3436 |
return frame_bytes * 14 / (8 * ch); |
3436 | 3437 |
break; |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
#include "libavutil/version.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 56 |
32 |
-#define LIBAVCODEC_VERSION_MINOR 41 |
|
32 |
+#define LIBAVCODEC_VERSION_MINOR 42 |
|
33 | 33 |
#define LIBAVCODEC_VERSION_MICRO 100 |
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |