From dba5b06ead6bbec8fd1207d778240188182c8361 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 6 Jul 2012 22:21:09 +0200 Subject: flacdec: don't create an attached picture stream until we have all information. This way we don't end with an invalid stream if parsing the picture fails. --- libavformat/flacdec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index f481c10cfa..0be60a4b7e 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -38,10 +38,6 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) int type, width, height; int len, ret = 0; - st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); - pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) return AVERROR(ENOMEM); @@ -114,6 +110,12 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) goto fail; } + st = avformat_new_stream(s, NULL); + if (!st) { + ret = AVERROR(ENOMEM); + goto fail; + } + av_init_packet(&st->attached_pic); st->attached_pic.data = data; st->attached_pic.size = len; -- cgit v1.2.3 From b7d3a9a0153bc59cc43b753f0119f36da2b30b1a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 6 Jul 2012 22:30:17 +0200 Subject: flacdec: be less strict when parsing attached pictures. Only return an error if memory allocation fails or error recognition is set to explode. Otherwise just print an error message and continue reading the file. --- libavformat/flacdec.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 0be60a4b7e..abb36d9377 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -46,8 +46,11 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) type = avio_rb32(pb); if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) { av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type); - ret = AVERROR_INVALIDDATA; - goto fail; + if (s->error_recognition & AV_EF_EXPLODE) { + ret = AVERROR_INVALIDDATA; + goto fail; + } + type = 0; } /* picture mimetype */ @@ -56,7 +59,8 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) { av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached " "picture.\n"); - ret = AVERROR_INVALIDDATA; + if (s->error_recognition & AV_EF_EXPLODE) + ret = AVERROR_INVALIDDATA; goto fail; } mimetype[len] = 0; @@ -71,7 +75,8 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) if (id == CODEC_ID_NONE) { av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n", mimetype); - ret = AVERROR_INVALIDDATA; + if (s->error_recognition & AV_EF_EXPLODE) + ret = AVERROR_INVALIDDATA; goto fail; } @@ -84,7 +89,9 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) } if (avio_read(pb, desc, len) != len) { - ret = AVERROR(EIO); + av_log(s, AV_LOG_ERROR, "Error reading attached picture description.\n"); + if (s->error_recognition & AV_EF_EXPLODE) + ret = AVERROR(EIO); goto fail; } desc[len] = 0; @@ -98,7 +105,9 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) /* picture data */ len = avio_rb32(pb); if (len <= 0) { - ret = AVERROR_INVALIDDATA; + av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len); + if (s->error_recognition & AV_EF_EXPLODE) + ret = AVERROR_INVALIDDATA; goto fail; } if (!(data = av_malloc(len))) { @@ -106,7 +115,9 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) goto fail; } if (avio_read(pb, data, len) != len) { - ret = AVERROR(EIO); + av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n"); + if (s->error_recognition & AV_EF_EXPLODE) + ret = AVERROR(EIO); goto fail; } -- cgit v1.2.3 From 25b51b2c44f16f46d6bd5db4f3421ae57909924e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 6 Jul 2012 22:35:10 +0200 Subject: id3v2: add a mimetype for bmp pictures. --- libavformat/id3v2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 3891897bb3..9398f7d770 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -117,6 +117,7 @@ const CodecMime ff_id3v2_mime_tags[] = { {"image/jpg", CODEC_ID_MJPEG}, {"image/png" , CODEC_ID_PNG}, {"image/tiff", CODEC_ID_TIFF}, + {"image/bmp", CODEC_ID_BMP}, {"", CODEC_ID_NONE}, }; -- cgit v1.2.3 From 07b287020c9ada750251344c05b52f541be4d533 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 7 Jul 2012 13:30:11 -0700 Subject: x86/timer: implement an intrinsic-based version for rdtsc (AV_READ_TIME). --- configure | 3 +++ libavutil/x86/timer.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/configure b/configure index a08b3af79e..ec68648520 100755 --- a/configure +++ b/configure @@ -1121,6 +1121,7 @@ HAVE_LIST=" netinet_sctp_h poll_h posix_memalign + rdtsc round roundf sched_getaffinity @@ -2642,6 +2643,8 @@ check_cc < +#if HAVE_INLINE_ASM + #define AV_READ_TIME read_time static inline uint64_t read_time(void) @@ -32,4 +34,10 @@ static inline uint64_t read_time(void) return ((uint64_t)d << 32) + a; } +#elif HAVE_RDTSC + +#define AV_READ_TIME __rdtsc + +#endif /* HAVE_INLINE_ASM */ + #endif /* AVUTIL_X86_TIMER_H */ -- cgit v1.2.3 From 66a297975d19e0d9b8a5ff8a723dcd2116a506ce Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 7 Jul 2012 13:46:26 -0700 Subject: cmutils: include shellapi.h on Win32 (for CommandLineToArgvW). This is required for CommandLineToArgvW. Normally, shellapi.h is included implicitly by windows.h, but if we define WIN32_LEAN_AND_MEAN (or some of the other earlier headers have included windows.h with that option), windows.h doesn't include this one. Thus explicitly include the headers we really need, for clarity and compatibility. --- cmdutils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmdutils.c b/cmdutils.c index 6d13bd6b4d..11a5f03eec 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -162,6 +162,7 @@ static const OptionDef *find_option(const OptionDef *po, const char *name) #if defined(_WIN32) && !defined(__MINGW32CE__) #include +#include /* Will be leaked on exit */ static char** win32_argv_utf8 = NULL; static int win32_argc = 0; -- cgit v1.2.3