summaryrefslogtreecommitdiff
path: root/libavformat/format.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-29 20:57:42 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-29 20:57:42 +0200
commit80a3a6611fe5866163b2e64da7c492fff7874a03 (patch)
treefb0d5f2036e844076f7d726ccbdaaefdd382fb7c /libavformat/format.c
parent31e0b5d3cb40acd960b6f6c711557a82dc2d6c5f (diff)
parent3a19405d574a467c68b48e4b824c76617fd59de0 (diff)
Merge commit '3a19405d574a467c68b48e4b824c76617fd59de0'
* commit '3a19405d574a467c68b48e4b824c76617fd59de0': avformat: Use the mime type information in input probe Conflicts: libavformat/format.c libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/format.c')
-rw-r--r--libavformat/format.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/libavformat/format.c b/libavformat/format.c
index 4b3d55a2e3..f29bb8027a 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -20,6 +20,7 @@
*/
#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
#include "avio_internal.h"
#include "avformat.h"
@@ -213,6 +214,10 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
if (av_match_ext(lpd.filename, fmt1->extensions))
score = AVPROBE_SCORE_EXTENSION;
}
+#ifdef FF_API_PROBE_MIME
+ if (av_match_name(lpd.mime_type, fmt1->mime_type))
+ score = FFMAX(score, AVPROBE_SCORE_EXTENSION);
+#endif
if (score > score_max) {
score_max = score;
fmt = fmt1;
@@ -264,12 +269,19 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
if (offset >= max_probe_size)
return AVERROR(EINVAL);
+#ifdef FF_API_PROBE_MIME
+ if (pb->av_class)
+ av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &pd.mime_type);
+#endif
+
+#if !FF_API_PROBE_MIME
if (!*fmt && pb->av_class && av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type) >= 0 && mime_type) {
if (!av_strcasecmp(mime_type, "audio/aacp")) {
*fmt = av_find_input_format("aac");
}
av_freep(&mime_type);
}
+#endif
for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt;
probe_size = FFMIN(probe_size << 1,
@@ -278,14 +290,13 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
/* Read probe data. */
if ((ret = av_reallocp(&buf, probe_size + AVPROBE_PADDING_SIZE)) < 0)
- return ret;
+ goto fail;
if ((ret = avio_read(pb, buf + buf_offset,
probe_size - buf_offset)) < 0) {
/* Fail if error was not end of file, otherwise, lower score. */
- if (ret != AVERROR_EOF) {
- av_free(buf);
- return ret;
- }
+ if (ret != AVERROR_EOF)
+ goto fail;
+
score = 0;
ret = 0; /* error was end of file, nothing read */
}
@@ -317,14 +328,17 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
}
}
- if (!*fmt) {
- av_free(buf);
- return AVERROR_INVALIDDATA;
- }
+ if (!*fmt)
+ ret = AVERROR_INVALIDDATA;
+fail:
/* Rewind. Reuse probe buffer to avoid seeking. */
- ret = ffio_rewind_with_probe_data(pb, &buf, buf_offset);
+ if (ret >= 0)
+ ret = ffio_rewind_with_probe_data(pb, &buf, buf_offset);
+#ifdef FF_API_PROBE_MIME
+ av_free(pd.mime_type);
+#endif
return ret < 0 ? ret : score;
}