From e5ac70042e91d19110a04a52b7e6fa4703f61200 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 25 Nov 2024 13:30:45 +0000 Subject: [PATCH] avformat/aiff: add support for ADPCM N64 decoder (cherry picked from commit 0fdf549a890f276243ba62f194e0ec08b10df60f) Signed-off-by: Michael Niedermayer --- libavformat/aiff.c | 1 + libavformat/aiffdec.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/libavformat/aiff.c b/libavformat/aiff.c index 907f7d8d28..3e94dad671 100644 --- a/libavformat/aiff.c +++ b/libavformat/aiff.c @@ -50,6 +50,7 @@ const AVCodecTag ff_codec_aiff_tags[] = { { AV_CODEC_ID_CBD2_DPCM, MKTAG('C','B','D','2') }, { AV_CODEC_ID_SDX2_DPCM, MKTAG('S','D','X','2') }, { AV_CODEC_ID_ADPCM_IMA_WS, MKTAG('A','D','P','4') }, + { AV_CODEC_ID_ADPCM_N64, MKTAG('V','A','P','C') }, { AV_CODEC_ID_NONE, 0 }, }; diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index aeb00cccd0..d9d580bdb5 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -177,6 +177,9 @@ static int get_aiff_header(AVFormatContext *s, int64_t size, case AV_CODEC_ID_G728: par->block_align = 5; break; + case AV_CODEC_ID_ADPCM_N64: + par->block_align = 9; + break; default: aiff->block_duration = 1; break; @@ -353,6 +356,31 @@ static int aiff_read_header(AVFormatContext *s) goto got_sound; break; + case MKTAG('A','P','P','L'): + if (size > 4) { + uint32_t chunk = avio_rl32(pb); + + size -= 4; + if (chunk == MKTAG('s','t','o','c')) { + int len = avio_r8(pb); + + size--; + if (len == 11 && size > 11) { + uint8_t chunk[11]; + + ret = avio_read(pb, chunk, 11); + if (ret > 0) + size -= ret; + if (!memcmp(chunk, "VADPCMCODES", sizeof(chunk))) { + if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) + return ret; + size -= ret; + } + } + } + } + avio_skip(pb, size); + break; case 0: if (offset > 0 && st->codecpar->block_align) // COMM && SSND goto got_sound;