1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avformat/wavarc: demux only data chunk content

This commit is contained in:
Paul B Mahol 2023-02-09 11:32:19 +01:00
parent 5bad485603
commit 8ed1d6b5e4
2 changed files with 26 additions and 6 deletions

View File

@ -598,7 +598,7 @@ OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o
OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o w64.o pcm.o
OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o
OBJS-$(CONFIG_WADY_DEMUXER) += wady.o pcm.o
OBJS-$(CONFIG_WAVARC_DEMUXER) += wavarc.o rawdec.o
OBJS-$(CONFIG_WAVARC_DEMUXER) += wavarc.o
OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o
OBJS-$(CONFIG_WAV_MUXER) += wavenc.o
OBJS-$(CONFIG_WC3_DEMUXER) += wc3movie.o

View File

@ -24,7 +24,10 @@
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "rawdec.h"
typedef struct WavArcContext {
int64_t data_end;
} WavArcContext;
static int wavarc_probe(const AVProbeData *p)
{
@ -51,6 +54,7 @@ static int wavarc_probe(const AVProbeData *p)
static int wavarc_read_header(AVFormatContext *s)
{
WavArcContext *w = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecParameters *par;
int filename_len, fmt_len, ret;
@ -91,7 +95,8 @@ static int wavarc_read_header(AVFormatContext *s)
if (id != MKTAG('d','a','t','a'))
avio_skip(pb, avio_rl32(pb));
} while (id != MKTAG('d','a','t','a') && !avio_feof(pb));
avio_skip(pb, 4);
w->data_end = avio_rl32(pb);
w->data_end += avio_tell(pb);
if (AV_RL32(par->extradata + 16) != MKTAG('R','I','F','F'))
return AVERROR_INVALIDDATA;
@ -108,15 +113,30 @@ static int wavarc_read_header(AVFormatContext *s)
return 0;
}
static int wavarc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
WavArcContext *w = s->priv_data;
AVIOContext *pb = s->pb;
int64_t size, left = w->data_end - avio_tell(pb);
int ret;
size = FFMIN(left, 1024);
if (size <= 0)
return AVERROR_EOF;
ret = av_get_packet(pb, pkt, size);
pkt->stream_index = 0;
return ret;
}
const AVInputFormat ff_wavarc_demuxer = {
.name = "wavarc",
.long_name = NULL_IF_CONFIG_SMALL("Waveform Archiver"),
.priv_data_size = sizeof(WavArcContext),
.read_probe = wavarc_probe,
.read_packet = ff_raw_read_partial_packet,
.read_packet = wavarc_read_packet,
.flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
.read_header = wavarc_read_header,
.extensions = "wa",
.raw_codec_id = AV_CODEC_ID_WAVARC,
.priv_data_size = sizeof(FFRawDemuxerContext),
.priv_class = &ff_raw_demuxer_class,
};