ADPCM IMA Radical decoder

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2013-05-10 16:53:50 -03:00
parent e5e86db178
commit 67fad0d221
12 changed files with 61 additions and 3 deletions

View File

@@ -27,6 +27,7 @@
static const AVCodecTag rsd_tags[] = {
{ AV_CODEC_ID_ADPCM_THP, MKTAG('G','A','D','P') },
{ AV_CODEC_ID_ADPCM_IMA_RAD, MKTAG('R','A','D','P') },
{ AV_CODEC_ID_PCM_S16BE, MKTAG('P','C','M','B') },
{ AV_CODEC_ID_PCM_S16LE, MKTAG('P','C','M',' ') },
{ AV_CODEC_ID_NONE, 0 },
@@ -34,7 +35,6 @@ static const AVCodecTag rsd_tags[] = {
static const uint32_t rsd_unsupported_tags[] = {
MKTAG('O','G','G',' '),
MKTAG('R','A','D','P'),
MKTAG('V','A','G',' '),
MKTAG('W','A','D','P'),
MKTAG('X','A','D','P'),
@@ -92,6 +92,11 @@ static int rsd_read_header(AVFormatContext *s)
avio_skip(pb, 4); // Unknown
switch (codec->codec_id) {
case AV_CODEC_ID_ADPCM_IMA_RAD:
codec->block_align = 20 * codec->channels;
if (pb->seekable)
st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_THP:
/* RSD3GADP is mono, so only alloc enough memory
to store the coeff table for a single channel. */
@@ -131,12 +136,16 @@ static int rsd_read_header(AVFormatContext *s)
static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
int ret, size = 1024;
if (url_feof(s->pb))
return AVERROR_EOF;
ret = av_get_packet(s->pb, pkt, size);
if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD)
ret = av_get_packet(s->pb, pkt, codec->block_align);
else
ret = av_get_packet(s->pb, pkt, size);
if (ret != size) {
if (ret < 0) {