mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-02-04 14:30:55 +08:00
avformat/adxdec: add AHX support
(cherry picked from commit b40bb6ad1e5739dd7927f3be5c2a06fb8aeef0cb) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -92,7 +92,7 @@ OBJS-$(CONFIG_ADP_DEMUXER) += adp.o
|
||||
OBJS-$(CONFIG_ADS_DEMUXER) += ads.o
|
||||
OBJS-$(CONFIG_ADTS_MUXER) += adtsenc.o apetag.o img2.o \
|
||||
id3v2enc.o
|
||||
OBJS-$(CONFIG_ADX_DEMUXER) += adxdec.o
|
||||
OBJS-$(CONFIG_ADX_DEMUXER) += adxdec.o rawdec.o
|
||||
OBJS-$(CONFIG_ADX_MUXER) += rawenc.o
|
||||
OBJS-$(CONFIG_AEA_DEMUXER) += aeadec.o pcm.o
|
||||
OBJS-$(CONFIG_AEA_MUXER) += aeaenc.o rawenc.o
|
||||
|
||||
@@ -27,11 +27,13 @@
|
||||
#include "avformat.h"
|
||||
#include "demux.h"
|
||||
#include "internal.h"
|
||||
#include "rawdec.h"
|
||||
|
||||
#define BLOCK_SIZE 18
|
||||
#define BLOCK_SAMPLES 32
|
||||
|
||||
typedef struct ADXDemuxerContext {
|
||||
FFRawDemuxerContext rawctx;
|
||||
int header_size;
|
||||
} ADXDemuxerContext;
|
||||
|
||||
@@ -54,6 +56,9 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
AVCodecParameters *par = s->streams[0]->codecpar;
|
||||
int ret, size;
|
||||
|
||||
if (par->codec_id == AV_CODEC_ID_AHX)
|
||||
return ff_raw_read_partial_packet(s, pkt);
|
||||
|
||||
if (avio_feof(s->pb))
|
||||
return AVERROR_EOF;
|
||||
|
||||
@@ -85,6 +90,7 @@ static int adx_read_header(AVFormatContext *s)
|
||||
{
|
||||
ADXDemuxerContext *c = s->priv_data;
|
||||
AVCodecParameters *par;
|
||||
FFStream *sti;
|
||||
int ret;
|
||||
int channels;
|
||||
|
||||
@@ -118,12 +124,25 @@ static int adx_read_header(AVFormatContext *s)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
sti = ffstream(st);
|
||||
par->ch_layout.nb_channels = channels;
|
||||
par->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
par->codec_id = AV_CODEC_ID_ADPCM_ADX;
|
||||
par->bit_rate = (int64_t)par->sample_rate * par->ch_layout.nb_channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
|
||||
|
||||
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
|
||||
switch (par->extradata[4]) {
|
||||
case 3:
|
||||
sti->need_parsing = AVSTREAM_PARSE_FULL_RAW;
|
||||
par->codec_id = AV_CODEC_ID_ADPCM_ADX;
|
||||
par->bit_rate = (int64_t)par->sample_rate * par->ch_layout.nb_channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
|
||||
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
|
||||
break;
|
||||
case 16:
|
||||
sti->need_parsing = AVSTREAM_PARSE_FULL_RAW;
|
||||
par->codec_id = AV_CODEC_ID_AHX;
|
||||
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
|
||||
break;
|
||||
default:
|
||||
av_log(s, AV_LOG_ERROR, "Unsupported format: %d\n", par->extradata[4]);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -132,10 +151,10 @@ const FFInputFormat ff_adx_demuxer = {
|
||||
.p.name = "adx",
|
||||
.p.long_name = NULL_IF_CONFIG_SMALL("CRI ADX"),
|
||||
.p.extensions = "adx",
|
||||
.p.priv_class = &ff_raw_demuxer_class,
|
||||
.p.flags = AVFMT_GENERIC_INDEX,
|
||||
.read_probe = adx_probe,
|
||||
.priv_data_size = sizeof(ADXDemuxerContext),
|
||||
.read_header = adx_read_header,
|
||||
.read_packet = adx_read_packet,
|
||||
.raw_codec_id = AV_CODEC_ID_ADPCM_ADX,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user