mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avformat/rawdec: Make the raw packet size configurable
This allows testing parsers with a wider range of input packet sizes. Which is important and usefull for regression testing, some of our parsers in fact to not work if the packet size is changed from 1024 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
827faa18cf
commit
f6d1b18b3d
@ -102,6 +102,7 @@ static int ac3_probe(const AVProbeData *p)
|
||||
return ac3_eac3_probe(p, AV_CODEC_ID_AC3);
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(ac3)
|
||||
AVInputFormat ff_ac3_demuxer = {
|
||||
.name = "ac3",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw AC-3"),
|
||||
@ -111,6 +112,8 @@ AVInputFormat ff_ac3_demuxer = {
|
||||
.flags= AVFMT_GENERIC_INDEX,
|
||||
.extensions = "ac3",
|
||||
.raw_codec_id = AV_CODEC_ID_AC3,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &ac3_demuxer_class,
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -120,6 +123,7 @@ static int eac3_probe(const AVProbeData *p)
|
||||
return ac3_eac3_probe(p, AV_CODEC_ID_EAC3);
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(eac3)
|
||||
AVInputFormat ff_eac3_demuxer = {
|
||||
.name = "eac3",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw E-AC-3"),
|
||||
@ -129,5 +133,7 @@ AVInputFormat ff_eac3_demuxer = {
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "eac3",
|
||||
.raw_codec_id = AV_CODEC_ID_EAC3,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &eac3_demuxer_class,
|
||||
};
|
||||
#endif
|
||||
|
@ -60,6 +60,7 @@ static int acm_read_header(AVFormatContext *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(acm)
|
||||
AVInputFormat ff_acm_demuxer = {
|
||||
.name = "acm",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Interplay ACM"),
|
||||
@ -69,4 +70,6 @@ AVInputFormat ff_acm_demuxer = {
|
||||
.flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
|
||||
.extensions = "acm",
|
||||
.raw_codec_id = AV_CODEC_ID_INTERPLAY_ACM,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &acm_demuxer_class,
|
||||
};
|
||||
|
@ -127,6 +127,7 @@ static int dts_probe(const AVProbeData *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(dts)
|
||||
AVInputFormat ff_dts_demuxer = {
|
||||
.name = "dts",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw DTS"),
|
||||
@ -136,4 +137,5 @@ AVInputFormat ff_dts_demuxer = {
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "dts",
|
||||
.raw_codec_id = AV_CODEC_ID_DTS,
|
||||
};
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &dts_demuxer_class,};
|
||||
|
@ -31,6 +31,8 @@
|
||||
#define SEEKPOINT_SIZE 18
|
||||
|
||||
typedef struct FLACDecContext {
|
||||
AVClass *class;
|
||||
int raw_packet_size;
|
||||
int found_seektable;
|
||||
} FLACDecContext;
|
||||
|
||||
@ -327,6 +329,7 @@ static int flac_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
|
||||
return -1;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(flac)
|
||||
AVInputFormat ff_flac_demuxer = {
|
||||
.name = "flac",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw FLAC"),
|
||||
@ -339,4 +342,5 @@ AVInputFormat ff_flac_demuxer = {
|
||||
.extensions = "flac",
|
||||
.raw_codec_id = AV_CODEC_ID_FLAC,
|
||||
.priv_data_size = sizeof(FLACDecContext),
|
||||
.priv_class = &flac_demuxer_class,
|
||||
};
|
||||
|
@ -46,6 +46,7 @@ static int g722_read_header(AVFormatContext *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(g722)
|
||||
AVInputFormat ff_g722_demuxer = {
|
||||
.name = "g722",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw G.722"),
|
||||
@ -54,4 +55,5 @@ AVInputFormat ff_g722_demuxer = {
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "g722,722",
|
||||
.raw_codec_id = AV_CODEC_ID_ADPCM_G722,
|
||||
};
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &g722_demuxer_class,};
|
||||
|
@ -83,6 +83,7 @@ static int loas_read_header(AVFormatContext *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(loas)
|
||||
AVInputFormat ff_loas_demuxer = {
|
||||
.name = "loas",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("LOAS AudioSyncStream"),
|
||||
@ -91,4 +92,6 @@ AVInputFormat ff_loas_demuxer = {
|
||||
.read_packet = ff_raw_read_partial_packet,
|
||||
.flags= AVFMT_GENERIC_INDEX,
|
||||
.raw_codec_id = AV_CODEC_ID_AAC_LATM,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &loas_demuxer_class,
|
||||
};
|
||||
|
@ -56,6 +56,7 @@ static int mlp_probe(const AVProbeData *p)
|
||||
return mlp_thd_probe(p, 0xf8726fbb);
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(mlp)
|
||||
AVInputFormat ff_mlp_demuxer = {
|
||||
.name = "mlp",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw MLP"),
|
||||
@ -65,6 +66,8 @@ AVInputFormat ff_mlp_demuxer = {
|
||||
.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
|
||||
.extensions = "mlp",
|
||||
.raw_codec_id = AV_CODEC_ID_MLP,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &mlp_demuxer_class,
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -74,6 +77,7 @@ static int thd_probe(const AVProbeData *p)
|
||||
return mlp_thd_probe(p, 0xf8726fba);
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(truehd)
|
||||
AVInputFormat ff_truehd_demuxer = {
|
||||
.name = "truehd",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"),
|
||||
@ -83,6 +87,8 @@ AVInputFormat ff_truehd_demuxer = {
|
||||
.flags = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
|
||||
.extensions = "thd",
|
||||
.raw_codec_id = AV_CODEC_ID_TRUEHD,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &truehd_demuxer_class,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -34,9 +34,10 @@
|
||||
|
||||
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
FFRawDemuxerContext *raw = s->priv_data;
|
||||
int ret, size;
|
||||
|
||||
size = RAW_PACKET_SIZE;
|
||||
size = raw->raw_packet_size;
|
||||
|
||||
if (av_new_packet(pkt, size) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
@ -119,10 +120,17 @@ int ff_raw_data_read_header(AVFormatContext *s)
|
||||
#define DEC AV_OPT_FLAG_DECODING_PARAM
|
||||
const AVOption ff_rawvideo_options[] = {
|
||||
{ "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC},
|
||||
{ "raw_packet_size", "", OFFSET(raw_packet_size), AV_OPT_TYPE_INT, {.i64 = RAW_PACKET_SIZE }, 1, INT_MAX, DEC},
|
||||
{ NULL },
|
||||
};
|
||||
const AVOption ff_raw_options[] = {
|
||||
{ "raw_packet_size", "", OFFSET(raw_packet_size), AV_OPT_TYPE_INT, {.i64 = RAW_PACKET_SIZE }, 1, INT_MAX, DEC},
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
#if CONFIG_DATA_DEMUXER
|
||||
FF_RAW_DEMUXER_CLASS(raw_data)
|
||||
|
||||
AVInputFormat ff_data_demuxer = {
|
||||
.name = "data",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw data"),
|
||||
@ -130,6 +138,8 @@ AVInputFormat ff_data_demuxer = {
|
||||
.read_packet = ff_raw_read_partial_packet,
|
||||
.raw_codec_id = AV_CODEC_ID_NONE,
|
||||
.flags = AVFMT_NOTIMESTAMPS,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),\
|
||||
.priv_class = &raw_data_demuxer_class,\
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -28,12 +28,19 @@
|
||||
|
||||
typedef struct FFRawVideoDemuxerContext {
|
||||
const AVClass *class; /**< Class for private options. */
|
||||
int raw_packet_size;
|
||||
char *video_size; /**< String describing video size, set by a private option. */
|
||||
char *pixel_format; /**< Set by a private option. */
|
||||
AVRational framerate; /**< AVRational describing framerate, set by a private option. */
|
||||
} FFRawVideoDemuxerContext;
|
||||
|
||||
typedef struct FFRawDemuxerContext {
|
||||
const AVClass *class; /**< Class for private options. */
|
||||
int raw_packet_size;
|
||||
} FFRawDemuxerContext;
|
||||
|
||||
extern const AVOption ff_rawvideo_options[];
|
||||
extern const AVOption ff_raw_options[];
|
||||
|
||||
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt);
|
||||
|
||||
@ -45,6 +52,14 @@ int ff_raw_subtitle_read_header(AVFormatContext *s);
|
||||
|
||||
int ff_raw_data_read_header(AVFormatContext *s);
|
||||
|
||||
#define FF_RAW_DEMUXER_CLASS(name)\
|
||||
static const AVClass name ## _demuxer_class = {\
|
||||
.class_name = #name " demuxer",\
|
||||
.item_name = av_default_item_name,\
|
||||
.option = ff_raw_options,\
|
||||
.version = LIBAVUTIL_VERSION_INT,\
|
||||
};
|
||||
|
||||
#define FF_RAWVIDEO_DEMUXER_CLASS(name)\
|
||||
static const AVClass name ## _demuxer_class = {\
|
||||
.class_name = #name " demuxer",\
|
||||
@ -75,7 +90,7 @@ FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, AVFMT_GENERIC_INDE
|
||||
static const AVClass name ## _demuxer_class = {\
|
||||
.class_name = #name " demuxer",\
|
||||
.item_name = av_default_item_name,\
|
||||
.option = NULL,\
|
||||
.option = ff_raw_options,\
|
||||
.version = LIBAVUTIL_VERSION_INT,\
|
||||
};
|
||||
|
||||
@ -90,7 +105,7 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\
|
||||
.extensions = ext,\
|
||||
.flags = flag,\
|
||||
.raw_codec_id = id,\
|
||||
.priv_data_size = 0,\
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),\
|
||||
.priv_class = &shortname ## _demuxer_class,\
|
||||
};
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "avformat.h"
|
||||
#include "rawdec.h"
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(sbc)
|
||||
AVInputFormat ff_sbc_demuxer = {
|
||||
.name = "sbc",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw SBC (low-complexity subband codec)"),
|
||||
@ -30,4 +31,6 @@ AVInputFormat ff_sbc_demuxer = {
|
||||
.read_header = ff_raw_audio_read_header,
|
||||
.read_packet = ff_raw_read_partial_packet,
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &sbc_demuxer_class,
|
||||
};
|
||||
|
@ -59,6 +59,7 @@ static int shn_probe(const AVProbeData *p)
|
||||
return AVPROBE_SCORE_EXTENSION + 1;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(shorten)
|
||||
AVInputFormat ff_shorten_demuxer = {
|
||||
.name = "shn",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw Shorten"),
|
||||
@ -68,4 +69,6 @@ AVInputFormat ff_shorten_demuxer = {
|
||||
.flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
|
||||
.extensions = "shn",
|
||||
.raw_codec_id = AV_CODEC_ID_SHORTEN,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &shorten_demuxer_class,
|
||||
};
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "rawdec.h"
|
||||
|
||||
typedef struct TAKDemuxContext {
|
||||
AVClass *class;
|
||||
int raw_packet_size;
|
||||
int mlast_frame;
|
||||
int64_t data_end;
|
||||
} TAKDemuxContext;
|
||||
@ -211,6 +213,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return ret;
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(tak)
|
||||
AVInputFormat ff_tak_demuxer = {
|
||||
.name = "tak",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw TAK"),
|
||||
@ -221,4 +224,5 @@ AVInputFormat ff_tak_demuxer = {
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "tak",
|
||||
.raw_codec_id = AV_CODEC_ID_TAK,
|
||||
.priv_class = &tak_demuxer_class,
|
||||
};
|
||||
|
@ -161,6 +161,7 @@ static int wsd_read_header(AVFormatContext *s)
|
||||
return avio_seek(pb, data_offset, SEEK_SET);
|
||||
}
|
||||
|
||||
FF_RAW_DEMUXER_CLASS(wsd)
|
||||
AVInputFormat ff_wsd_demuxer = {
|
||||
.name = "wsd",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Wideband Single-bit Data (WSD)"),
|
||||
@ -170,4 +171,6 @@ AVInputFormat ff_wsd_demuxer = {
|
||||
.extensions = "wsd",
|
||||
.flags = AVFMT_GENERIC_INDEX | AVFMT_NO_BYTE_SEEK,
|
||||
.raw_codec_id = AV_CODEC_ID_DSD_MSBF,
|
||||
.priv_data_size = sizeof(FFRawDemuxerContext),
|
||||
.priv_class = &wsd_demuxer_class,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user