40 #define GLOB_NOMAGIC 0
66 *width_ptr =
sizes[i][0];
67 *height_ptr =
sizes[i][1];
81 while (p = strchr(p,
'%')) {
86 if (span = strspn(p,
"*?[]{}"))
106 const char *path,
int start_index,
int start_index_range)
109 int range, last_index, range1, first_index;
112 for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
123 if (first_index == start_index + start_index_range)
127 last_index = first_index;
136 last_index + range1) < 0)
142 if (range >= (1 << 30))
150 *pfirst_index = first_index;
151 *plast_index = last_index;
180 int first_index = 1, last_index = 1;
211 #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
212 av_log(s1,
AV_LOG_ERROR,
"POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n");
231 char *p = s->
path, *q, *dup;
236 "use pattern_type 'glob' instead\n");
241 if ((p - s->
path) >= (
sizeof(s->
path) - 2))
243 if (*q ==
'%' && strspn(q + 1,
"%*?[]{}"))
245 else if (strspn(q,
"\\*?[]{}"))
252 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC,
NULL, &s->globstate);
257 last_index = s->globstate.gl_pathc - 1;
265 "Could find no file with path '%s' and index in the range %d-%d\n",
272 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC,
NULL, &s->globstate);
277 last_index = s->globstate.gl_pathc - 1;
281 "Pattern type 'glob' was selected but globbing "
282 "is not supported by this libavformat build\n");
287 "Unknown value '%d' for pattern_type option\n", s->
pattern_type);
296 st->
duration = last_index - first_index + 1;
310 const char *str = strrchr(s->
path,
'.');
314 int probe_buffer_size = 2048;
322 probe_buffer_size =
avio_read(s1->
pb, probe_buffer, probe_buffer_size);
323 if (probe_buffer_size < 0) {
325 return probe_buffer_size;
329 pd.
buf = probe_buffer;
366 char filename_bytes[1024];
367 char *filename = filename_bytes;
369 int size[3] = { 0 }, ret[3] = { 0 };
384 filename = s->globstate.gl_pathv[s->
img_number];
392 for (i = 0; i < 3; i++) {
405 filename[strlen(filename) - 1] =
'U' + i;
418 memset(header + ret, 0,
sizeof(header) - ret);
452 struct stat img_stat;
453 if (stat(filename, &img_stat))
455 pkt->
pts = (int64_t)img_stat.st_mtime;
456 #
if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
458 pkt->
pts = 1000000000*pkt->
pts + img_stat.st_mtim.tv_nsec;
469 for (i = 0; i < 3; i++) {
485 if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
489 }
else if (ret[1] < 0) {
491 }
else if (ret[2] < 0)
507 globfree(&s->globstate);
533 #define OFFSET(x) offsetof(VideoDemuxData, x)
534 #define DEC AV_OPT_FLAG_DECODING_PARAM
546 {
"start_number",
"set first number in the sequence",
OFFSET(start_number),
AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX,
DEC },
547 {
"start_number_range",
"set range for looking at the first sequence number",
OFFSET(start_number_range),
AV_OPT_TYPE_INT, {.i64 = 5}, 1, INT_MAX,
DEC },
550 {
"ts_from_file",
"set frame timestamp from file's one",
OFFSET(ts_from_file),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2,
DEC,
"ts_type" },
557 #if CONFIG_IMAGE2_DEMUXER
558 static const AVClass img2_class = {
574 .priv_class = &img2_class,
577 #if CONFIG_IMAGE2PIPE_DEMUXER
578 static const AVClass img2pipe_class = {
585 .
name =
"image2pipe",
590 .priv_class = &img2pipe_class,
603 if (ihsize < 12 || ihsize > 255)
616 if (
AV_RB64(b) == 0x444453207c000000
633 if (w <= 0 || h <= 0)
654 if (
AV_RB64(b) == 0x0000000c6a502020 ||
663 int i,
state = 0xD8, exif_size = 0;
671 exif_size =
AV_RB16(b + 2) + 2;
674 for (i = 0; i + exif_size < p->
buf_size - 2; i++) {
704 if ( (c >= 0x02 && c <= 0xBF)
729 && (
AV_RB64(b + 520) & 0xFFFFFFFFFFFF) == 0x001102ff0c00
733 if ( (
AV_RB64(b + 8) & 0xFFFFFFFFFFFF) == 0x001102ff0c00
753 if (
AV_RB64(b) == 0x89504e470d0a1a0a)
764 (b[3] & ~3) == 0 && b[3] &&
783 if (
AV_RB32(b) == 0x49492a00 ||
793 if (
AV_RB32(b) == 0x52494646 &&
799 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
800 static const AVClass imgname ## _class = {\
801 .class_name = AV_STRINGIFY(imgname) " demuxer",\
802 .item_name = av_default_item_name,\
803 .option = ff_img_options,\
804 .version = LIBAVUTIL_VERSION_INT,\
806 AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
807 .name = AV_STRINGIFY(imgname) "_pipe",\
808 .long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\
809 .priv_data_size = sizeof(VideoDemuxData),\
810 .read_probe = imgname ## _probe,\
811 .read_header = ff_img_read_header,\
812 .read_packet = ff_img_read_packet,\
813 .priv_class = & imgname ## _class,\
814 .flags = AVFMT_GENERIC_INDEX, \
815 .raw_codec_id = codecid,\
static enum AVPixelFormat pix_fmt
int height
Set by a private option.
static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
int64_t avio_size(AVIOContext *s)
Get the filesize.
void av_free_packet(AVPacket *pkt)
Free a packet.
static int bmp_probe(AVProbeData *p)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static int qdraw_probe(AVProbeData *p)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **buf, int buf_size)
Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file...
static int j2k_probe(AVProbeData *p)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static int img_read_close(struct AVFormatContext *s1)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVInputFormat * av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
int ctx_flags
Flags signalling stream properties.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static int png_probe(AVProbeData *p)
char * pixel_format
Set by a private option.
#define IMAGEAUTO_DEMUXER(imgname, codecid)
int avio_check(const char *url, int flags)
Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int dds_probe(AVProbeData *p)
int pattern_type
PatternType.
static int pictor_probe(AVProbeData *p)
enum AVStreamParseType need_parsing
int ff_img_read_header(AVFormatContext *s1)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
AVStream ** streams
A list of all streams in the file.
int flags
Flags modifying the (de)muxer behaviour.
static int img_read_probe(AVProbeData *p)
#define AVERROR_EOF
End of file.
static int webp_probe(AVProbeData *p)
static av_cold int read_close(AVFormatContext *ctx)
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
const AVOption ff_img_options[]
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static const uint8_t header[24]
enum AVCodecID video_codec_id
Forced video codec_id.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int exr_probe(AVProbeData *p)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int is_glob(const char *path)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
static const int sizes[][2]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int flags
A combination of AV_PKT_FLAG values.
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
char filename[1024]
input or output filename
static int jpeg_probe(AVProbeData *p)
enum AVCodecID audio_codec_id
Forced audio codec_id.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int width
picture width / height.
static int sgi_probe(AVProbeData *p)
#define FF_ARRAY_ELEMS(a)
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in 'buf' the path with 'd' replaced by a number.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate the string s.
AVIOContext * pb
I/O context.
int split_planes
use independent file for each Y, U, V plane
main external API structure.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Describe the class of an AVClass context structure.
static int infer_size(int *width_ptr, int *height_ptr, int size)
offset must point to AVRational
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
offset must point to two consecutive integers
This structure contains the data a format has to probe a file.
static int sunrast_probe(AVProbeData *p)
int64_t duration
Decoding: duration of the stream, in stream time base.
static int dpx_probe(AVProbeData *p)
static int tiff_probe(AVProbeData *p)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int find_image_range(int *pfirst_index, int *plast_index, const char *path, int start_index, int start_index_range)
Get index range of image files matched by path.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
struct AVInputFormat * iformat
The input container format.
enum AVCodecID ff_guess_image2_codec(const char *filename)
AVRational framerate
Set by a private option.
struct AVCodecParserContext * parser
void * priv_data
Format private data.
static int jpegls_probe(AVProbeData *p)
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPixelFormat
Pixel format.
This structure stores compressed data.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
AVInputFormat * av_iformat_next(const AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...