22#include "config_components.h"
48 ext = strrchr(filename,
'.');
67 for (ext = uc.
query; *ext !=
'.' && ext > uc.
path; ext--)
72 if (uc.
query - ext >
sizeof(scratchpad))
80 const char *mime_type)
88#if CONFIG_IMAGE2_MUXER
89 if (!short_name && filename &&
109 if (score > score_max) {
118 const char *filename,
const char *mime_type,
130#if CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER
131 if (!strcmp(fmt->
name,
"image2") || !strcmp(fmt->
name,
"image2pipe")) {
158 int *score_ret,
int *undecided)
163 int score, score_max = 0;
168 ID3_ALMOST_GREATER_PROBE,
170 ID3_GREATER_MAX_PROBE,
174 lpd.
buf = (
unsigned char *) zerobuffer;
180 nodat = ID3_ALMOST_GREATER_PROBE;
184 nodat = ID3_GREATER_MAX_PROBE;
187 nodat = ID3_GREATER_PROBE;
200 if (score ==
AVERROR(EAGAIN)) {
211 score =
FFMAX(score, 1);
213 case ID3_GREATER_PROBE:
214 case ID3_ALMOST_GREATER_PROBE:
217 case ID3_GREATER_MAX_PROBE:
227 int old_score = score;
232 if (score > score_max) {
235 }
else if (score == score_max)
238 if (nodat == ID3_GREATER_PROBE)
240 *score_ret = score_max;
246 int is_opened,
int *score_ret)
252 int is_opened,
int *score_max)
257 if (score_ret > *score_max) {
258 *score_max = score_ret;
271 const char *filename,
void *logctx,
272 unsigned int offset,
unsigned int max_probe_size)
276 int ret = 0, probe_size, buf_offset = 0;
285 "Specified probe size value %u cannot be < %u\n", max_probe_size,
PROBE_BUF_MIN);
289 if (
offset >= max_probe_size)
293 uint8_t *mime_type_opt =
NULL;
296 pd.
mime_type = (
const char *)mime_type_opt;
303 for (probe_size =
PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt && !eof;
304 probe_size =
FFMIN(probe_size << 1,
305 FFMAX(max_probe_size, probe_size + 1))) {
312 probe_size - buf_offset)) < 0) {
330 int score_new, undecided = 0;
335 if (undecided && probe_size < max_probe_size && !eof) {
337 }
else if (score_new > score) {
346 "Format %s detected only with low score of %d, "
347 "misdetection possible!\n", (*fmt)->name, score);
350 "Format %s probed with size=%d and score=%d\n",
351 (*fmt)->name, probe_size, score);
353 FILE *
f = fopen(
"probestat.tmp",
"ab");
354 fprintf(
f,
"probe_size:%d format:%s score:%d filename:%s\n", probe_size, (*fmt)->name, score, filename);
370 return ret < 0 ?
ret : score;
374 const char *filename,
void *logctx,
375 unsigned int offset,
unsigned int max_probe_size)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
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.
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
static const FFInputFormat * ffifmt(const AVInputFormat *fmt)
AVCodecID
Identify the syntax and semantics of the bitstream.
const AVOutputFormat * av_muxer_iterate(void **opaque)
Iterate over all registered muxers.
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
const AVInputFormat * av_probe_input_format3(const AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)
Like av_probe_input_buffer2() but returns 0 on success.
int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
const AVInputFormat * av_probe_input_format(const AVProbeData *pd, int is_opened)
Guess the file format.
const AVInputFormat * av_probe_input_format2(const AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type)
Guess the codec ID based upon muxer and filename.
const AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
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.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
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 av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
int ff_id3v2_match(const uint8_t *buf, const char *magic)
Detect ID3v2 Header.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
enum AVCodecID ff_guess_image2_codec(const char *filename)
Memory handling functions.
const AVClass * av_class
A class for private options.
This structure contains the data a format has to probe a file.
const char * mime_type
mime_type, when known.
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.
const char * query
including initial '?
int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
Parse an URL to find the components.
unbuffered private I/O API
#define URL_COMPONENT_HAVE(uc, component)