From 58f8463947e56dc448baeeabd7875ea90bdb4a98 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Apr 2011 00:52:04 +0200 Subject: [PATCH 01/15] error: add error code AVERROR_OPTION_NOT_FOUND, and use it in opt.c The new error code is better than AVERROR(ENOENT), which has a completely different semantics ("No such file or directory"). Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- libavutil/error.c | 1 + libavutil/error.h | 1 + libavutil/opt.c | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/error.c b/libavutil/error.c index 978e5431e9..3c3f03fe9b 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -33,6 +33,7 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found"; break; case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found"; break; case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found"; break; + case AVERROR_OPTION_NOT_FOUND: errstr = "Option not found"; break; case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found"; break; case AVERROR_FILTER_NOT_FOUND: errstr = "Filter not found"; break; case AVERROR_BSF_NOT_FOUND: errstr = "Bitstream filter not found"; break; diff --git a/libavutil/error.h b/libavutil/error.h index 33332b18c4..23e0b01789 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -48,6 +48,7 @@ #define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found #define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found #define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found +#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found #define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found #define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found #define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< Bitstream filter not found diff --git a/libavutil/opt.c b/libavutil/opt.c index 30efb52ddd..f08ed8f068 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -57,7 +57,7 @@ static int av_set_number2(void *obj, const char *name, double num, int den, int6 if (o_out) *o_out= o; if (!o || o->offset<=0) - return AVERROR(ENOENT); + return AVERROR_OPTION_NOT_FOUND; if (o->max*den < num*intnum || o->min*den > num*intnum) { av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name); @@ -119,7 +119,7 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons if (o_out) *o_out = o; if (!o) - return AVERROR(ENOENT); + return AVERROR_OPTION_NOT_FOUND; if (!val || o->offset<=0) return AVERROR(EINVAL); @@ -490,7 +490,7 @@ static int parse_key_value_pair(void *ctx, const char **buf, av_log(ctx, AV_LOG_DEBUG, "Setting value '%s' for key '%s'\n", val, key); ret = av_set_string3(ctx, key, val, 1, NULL); - if (ret == AVERROR(ENOENT)) + if (ret == AVERROR_OPTION_NOT_FOUND) av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key); av_free(key); From 79157f400bec7fdb6385befa63fdafc727378143 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Apr 2011 00:29:30 +0200 Subject: [PATCH 02/15] error: remove AVERROR_NUMEXPECTED AVERROR_NUMEXPECTED is used only in the image muxer and demuxer, and has a too much specific meaning, which is better explained through a log message. Thus it can be replaced by AVERROR(EINVAL). This breaks API. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- ffmpeg.c | 2 +- libavformat/utils.c | 2 +- libavutil/error.c | 1 - libavutil/error.h | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 6e620bf55e..886d5da7de 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3722,7 +3722,7 @@ static void opt_output_file(const char *filename) /* check filename in case of an image number is expected */ if (oc->oformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(oc->filename)) { - print_error(oc->filename, AVERROR_NUMEXPECTED); + print_error(oc->filename, AVERROR(EINVAL)); ffmpeg_exit(1); } } diff --git a/libavformat/utils.c b/libavformat/utils.c index 19498b96a4..88e9a49e87 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -581,7 +581,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, /* check filename in case an image number is expected */ if (fmt->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(filename)) { - err = AVERROR_NUMEXPECTED; + err = AVERROR(EINVAL); goto fail; } } diff --git a/libavutil/error.c b/libavutil/error.c index 3c3f03fe9b..252007a6c9 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -27,7 +27,6 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) switch (errnum) { case AVERROR_EOF: errstr = "End of file"; break; case AVERROR_INVALIDDATA: errstr = "Invalid data found when processing input"; break; - case AVERROR_NUMEXPECTED: errstr = "Number syntax expected in filename"; break; case AVERROR_PATCHWELCOME: errstr = "Not yet implemented in Libav, patches welcome"; break; case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found"; break; case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found"; break; diff --git a/libavutil/error.h b/libavutil/error.h index 23e0b01789..62e75e136d 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -42,7 +42,6 @@ #define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome #define AVERROR_INVALIDDATA (-MKTAG('I','N','D','A')) ///< Invalid data found when processing input -#define AVERROR_NUMEXPECTED (-MKTAG('N','U','E','X')) ///< Number syntax expected in filename #define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found #define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found From a975dbc86b97a421e51ac7075b8df869915745a2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 20 Apr 2011 07:14:50 +0200 Subject: [PATCH 03/15] error: change AVERROR_EOF value The current value is masking the POSIX error code EPIPE, which has a different semantics. This breaks API. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- libavutil/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/error.h b/libavutil/error.h index 62e75e136d..a422f8555c 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -37,7 +37,7 @@ #define AVUNERROR(e) (e) #endif -#define AVERROR_EOF AVERROR(EPIPE) ///< End of file +#define AVERROR_EOF (-MKTAG('E','O','F',' ')) ///< End of file #define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome From 095290f9a4230698f64c56b5ee9d89c046f6dd5b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 20 Apr 2011 17:09:45 +0200 Subject: [PATCH 04/15] lavc: provide the opt.h header until the next bump AVOptions were moved to libavutil only recently. --- libavcodec/Makefile | 2 +- libavcodec/opt.h | 16 ++++++++++++++++ libavcodec/version.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 libavcodec/opt.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f05244ed95..784226f7af 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak NAME = avcodec FFLIBS = avutil -HEADERS = avcodec.h avfft.h dxva2.h vaapi.h vdpau.h version.h xvmc.h +HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h version.h xvmc.h OBJS = allcodecs.o \ audioconvert.o \ diff --git a/libavcodec/opt.h b/libavcodec/opt.h new file mode 100644 index 0000000000..e754bb93d8 --- /dev/null +++ b/libavcodec/opt.h @@ -0,0 +1,16 @@ +/** + * @file + * This header is provided for compatibility only and will be removed + * on next major bump + */ + +#ifndef AVCODEC_OPT_H +#define AVCODEC_OPT_H + +#include "libavcodec/version.h" + +#if FF_API_OPT_H +#include "libavutil/opt.h" +#endif + +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 3146f765ee..92f9e58ffa 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -62,5 +62,8 @@ #ifndef FF_API_REQUEST_CHANNELS #define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_OPT_H +#define FF_API_OPT_H (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 65af48b55930abe5ac9130be3ff4d9c287a7f010 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 20 Apr 2011 17:21:39 +0200 Subject: [PATCH 05/15] lavc: provide deprecated avcodec_thread_init until next major version It was deprecated only recently. --- libavcodec/avcodec.h | 8 ++++++++ libavcodec/utils.c | 8 ++++++++ libavcodec/version.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 40d3b2245b..7727ad08bf 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3577,6 +3577,14 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); +#if FF_API_THREAD_INIT +/** + * @deprecated Set s->thread_count before calling avcodec_open() instead of calling this. + */ +attribute_deprecated +int avcodec_thread_init(AVCodecContext *s, int thread_count); +#endif + int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); //FIXME func typedef diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0190e6652c..744e0ada87 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1220,3 +1220,11 @@ void ff_thread_await_progress(AVFrame *f, int progress, int field) } #endif + +#if FF_API_THREAD_INIT +int avcodec_thread_init(AVCodecContext *s, int thread_count) +{ + s->thread_count = thread_count; + return ff_thread_init(s); +} +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 92f9e58ffa..b9c219d260 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -65,5 +65,8 @@ #ifndef FF_API_OPT_H #define FF_API_OPT_H (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_THREAD_INIT +#define FF_API_THREAD_INIT (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 32a128522ad392d2bca67165fda1d2fe30262189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 21 Apr 2011 13:49:21 +0300 Subject: [PATCH 06/15] libavdevice: Define _XOPEN_SOURCE for usleep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hopefully fixes build failures on Dragonfly BSD. Signed-off-by: Martin Storsjö --- libavdevice/bktr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 3e705a0247..ab70a1b2b7 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -26,6 +26,7 @@ #define _BSD_SOURCE 1 #define _NETBSD_SOURCE +#define _XOPEN_SOURCE 600 #include "libavformat/avformat.h" #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H From 23d3931a6a8a37bb7e86bd6cb4709eb46031bfe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 21 Apr 2011 13:02:38 +0200 Subject: [PATCH 07/15] Provide a fallback version of the libm function trunc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes compilation on DOS. Signed-off-by: Martin Storsjö --- configure | 2 ++ libavutil/libm.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/configure b/configure index 32c3544fb3..dd44ba4739 100755 --- a/configure +++ b/configure @@ -1119,6 +1119,7 @@ HAVE_LIST=" sys_videoio_h ten_operands threads + trunc truncf vfp_args VirtualAlloc @@ -2852,6 +2853,7 @@ check_mathfunc lrint check_mathfunc lrintf check_mathfunc round check_mathfunc roundf +check_mathfunc trunc check_mathfunc truncf # these are off by default, so fail if requested and not available diff --git a/libavutil/libm.h b/libavutil/libm.h index 704bcf9554..783f3cdfab 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -86,6 +86,13 @@ static av_always_inline av_const float roundf(float x) } #endif /* HAVE_ROUNDF */ +#if !HAVE_TRUNC +static av_always_inline av_const double trunc(double x) +{ + return (x > 0) ? floor(x) : ceil(x); +} +#endif /* HAVE_TRUNC */ + #if !HAVE_TRUNCF static av_always_inline av_const float truncf(float x) { From cac275791994be44b7a6d11a3878646e78ab5653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 23:04:31 +0300 Subject: [PATCH 08/15] doc: Add some initial docs on the applehttp demuxer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/demuxers.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index bbdde9c92d..4168fc10c6 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -64,4 +64,13 @@ Note that the pattern must not necessarily contain "%d" or ffmpeg -f image2 -i img.jpeg img.png @end example +@section applehttp + +Apple HTTP Live Streaming demuxer. + +This demuxer presents all AVStreams from all variant streams. +The id field is set to the bitrate variant index number. By setting +the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay), +the caller can decide which variant streams to actually receive. + @c man end INPUT DEVICES From fe8e039460064ad765c37736dadd123478c5ff1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 10:10:10 +0300 Subject: [PATCH 09/15] applehttp: Expose the stream bitrate via metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps callers to intelligently switch between bitrate variants. Signed-off-by: Martin Storsjö --- doc/demuxers.texi | 2 ++ libavformat/applehttp.c | 3 +++ libavformat/avformat.h | 1 + libavformat/version.h | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 4168fc10c6..98f9fdeff8 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -72,5 +72,7 @@ This demuxer presents all AVStreams from all variant streams. The id field is set to the bitrate variant index number. By setting the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay), the caller can decide which variant streams to actually receive. +The total bitrate of the variant that the stream belongs to is +available in a metadata key named "variant_bitrate". @c man end INPUT DEVICES diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index df4494a785..90b86a8733 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -367,6 +367,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) for (i = 0; i < c->n_variants; i++) { struct variant *v = c->variants[i]; AVInputFormat *in_fmt = NULL; + char bitrate_str[20]; if (v->n_segments == 0) continue; @@ -393,6 +394,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) if (ret < 0) goto fail; v->stream_offset = stream_offset; + snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth); /* Create new AVStreams for each stream in this variant */ for (j = 0; j < v->ctx->nb_streams; j++) { AVStream *st = av_new_stream(s, i); @@ -401,6 +403,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; } avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); + av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str, 0); } stream_offset += v->ctx->nb_streams; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2567aabd5a..732756222e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -104,6 +104,7 @@ struct AVFormatContext; * service_provider -- name of the service provider in broadcasting. * title -- name of the work. * track -- number of this work in the set, can be in form current/total. + * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of */ #define AV_METADATA_MATCH_CASE 1 diff --git a/libavformat/version.h b/libavformat/version.h index 01730183b2..04c5d73f50 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -25,7 +25,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MINOR 0 -#define LIBAVFORMAT_VERSION_MICRO 0 +#define LIBAVFORMAT_VERSION_MICRO 1 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From ab1adff73f4852d99f9c65ef5a5ceca3e2accbe8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 21 Apr 2011 15:56:55 +0200 Subject: [PATCH 10/15] The stabilization period after version bumps should be one month, not one week. --- doc/APIchanges | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a9faaf927c..24ba7b143b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -1,5 +1,6 @@ -Never assume the API of libav* to be stable unless at least 1 week has passed since -the last major version increase. +Never assume the API of libav* to be stable unless at least 1 month has passed +since the last major version increase. + The last version increases were: libavcodec: 2011-04-18 libavdevice: 2011-04-18 From 8d67218bd73744c367450d8b8ecc5a6e6c42bd11 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 13:36:12 +0200 Subject: [PATCH 11/15] error: sort, pack, and align error code and string definitions Signed-off-by: Diego Biurrun --- libavutil/error.c | 24 ++++++++++++------------ libavutil/error.h | 26 +++++++++++--------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/libavutil/error.c b/libavutil/error.c index 252007a6c9..ddcc038650 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -25,19 +25,19 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) const char *errstr = NULL; switch (errnum) { - case AVERROR_EOF: errstr = "End of file"; break; - case AVERROR_INVALIDDATA: errstr = "Invalid data found when processing input"; break; + case AVERROR_BSF_NOT_FOUND: errstr = "Bitstream filter not found" ; break; + case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found" ; break; + case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found" ; break; + case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found" ; break; + case AVERROR_EOF: errstr = "End of file" ; break; + case AVERROR_EXIT: errstr = "Immediate exit requested" ; break; + case AVERROR_FILTER_NOT_FOUND: errstr = "Filter not found" ; break; + case AVERROR_INVALIDDATA: errstr = "Invalid data found when processing input" ; break; + case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found" ; break; + case AVERROR_OPTION_NOT_FOUND: errstr = "Option not found" ; break; case AVERROR_PATCHWELCOME: errstr = "Not yet implemented in Libav, patches welcome"; break; - case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found"; break; - case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found"; break; - case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found"; break; - case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found"; break; - case AVERROR_OPTION_NOT_FOUND: errstr = "Option not found"; break; - case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found"; break; - case AVERROR_FILTER_NOT_FOUND: errstr = "Filter not found"; break; - case AVERROR_BSF_NOT_FOUND: errstr = "Bitstream filter not found"; break; - case AVERROR_STREAM_NOT_FOUND: errstr = "Stream not found"; break; - case AVERROR_EXIT: errstr = "Immediate exit requested"; break; + case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found" ; break; + case AVERROR_STREAM_NOT_FOUND: errstr = "Stream not found" ; break; } if (errstr) { diff --git a/libavutil/error.h b/libavutil/error.h index a422f8555c..ba12d2bfae 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -37,24 +37,20 @@ #define AVUNERROR(e) (e) #endif -#define AVERROR_EOF (-MKTAG('E','O','F',' ')) ///< End of file - -#define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome - -#define AVERROR_INVALIDDATA (-MKTAG('I','N','D','A')) ///< Invalid data found when processing input - -#define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found -#define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found -#define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found -#define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found -#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found -#define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found -#define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found #define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< Bitstream filter not found +#define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found +#define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found +#define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found +#define AVERROR_EOF (-MKTAG( 'E','O','F',' ')) ///< End of file +#define AVERROR_EXIT (-MKTAG( 'E','X','I','T')) ///< Immediate exit was requested; the called function should not be restarted +#define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found +#define AVERROR_INVALIDDATA (-MKTAG( 'I','N','D','A')) ///< Invalid data found when processing input +#define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found +#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found +#define AVERROR_PATCHWELCOME (-MKTAG( 'P','A','W','E')) ///< Not yet implemented in Libav, patches welcome +#define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found #define AVERROR_STREAM_NOT_FOUND (-MKTAG(0xF8,'S','T','R')) ///< Stream not found -#define AVERROR_EXIT (-MKTAG('E','X','I','T')) ///< Immediate exit was requested; the called function should not be restarted - /** * Put a description of the AVERROR code errnum in errbuf. * In case of failure the global variable errno is set to indicate the From 70fb031ce27ce200026de2ea77ec038e2c2e141f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 21 Apr 2011 19:38:49 +0200 Subject: [PATCH 12/15] Use av_log_ask_for_sample() where appropriate. --- libavcodec/cook.c | 12 ++++++------ libavcodec/truemotion1.c | 4 ++-- libavcodec/tta.c | 5 +++-- libavcodec/v210x.c | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 7717c4bbc6..0e792affca 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1136,7 +1136,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) switch (q->subpacket[s].cookversion) { case MONO: if (q->nb_channels != 1) { - av_log(avctx,AV_LOG_ERROR,"Container channels != 1, report sample!\n"); + av_log_ask_for_sample(avctx, "Container channels != 1.!\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"MONO\n"); @@ -1150,7 +1150,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) break; case JOINT_STEREO: if (q->nb_channels != 2) { - av_log(avctx,AV_LOG_ERROR,"Container channels != 2, report sample!\n"); + av_log_ask_for_sample(avctx, "Container channels != 2.\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n"); @@ -1188,7 +1188,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) break; default: - av_log(avctx,AV_LOG_ERROR,"Unknown Cook version, report sample!\n"); + av_log_ask_for_sample(avctx, "Unknown Cook version.\n"); return -1; break; } @@ -1205,7 +1205,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Try to catch some obviously faulty streams, othervise it might be exploitable */ if (q->subpacket[s].total_subbands > 53) { - av_log(avctx,AV_LOG_ERROR,"total_subbands > 53, report sample!\n"); + av_log_ask_for_sample(avctx, "total_subbands > 53\n"); return -1; } @@ -1215,7 +1215,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) } if (q->subpacket[s].subbands > 50) { - av_log(avctx,AV_LOG_ERROR,"subbands > 50, report sample!\n"); + av_log_ask_for_sample(avctx, "subbands > 50\n"); return -1; } q->subpacket[s].gains1.now = q->subpacket[s].gain_1; @@ -1226,7 +1226,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->num_subpackets++; s++; if (s > MAX_SUBPACKETS) { - av_log(avctx,AV_LOG_ERROR,"Too many subpackets > 5, report file!\n"); + av_log_ask_for_sample(avctx, "Too many subpackets > 5\n"); return -1; } } diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index afa9cf22fe..97330d1bb4 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -353,7 +353,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) s->flags = FLAG_KEYFRAME; if (s->flags & FLAG_SPRITE) { - av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n"); + av_log_ask_for_sample(s->avctx, "SPRITE frame found.\n"); /* FIXME header.width, height, xoffset and yoffset aren't initialized */ #if 0 s->w = header.width; @@ -370,7 +370,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) if ((s->w < 213) && (s->h >= 176)) { s->flags |= FLAG_INTERPOLATED; - av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n"); + av_log_ask_for_sample(s->avctx, "INTERPOLATION selected.\n"); } } } diff --git a/libavcodec/tta.c b/libavcodec/tta.c index fbfc59e60a..57f5818d7b 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -247,7 +247,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) if (s->is_float) { avctx->sample_fmt = AV_SAMPLE_FMT_FLT; - av_log(s->avctx, AV_LOG_ERROR, "Unsupported sample format. Please contact the developers.\n"); + av_log_ask_for_sample(s->avctx, "Unsupported sample format.\n"); return -1; } else switch(s->bps) { @@ -256,7 +256,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) // case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S24; break; case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break; default: - av_log(s->avctx, AV_LOG_ERROR, "Invalid/unsupported sample format. Please contact the developers.\n"); + av_log_ask_for_sample(s->avctx, + "Invalid/unsupported sample format.\n"); return -1; } diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c index 3d8bdcf780..511548f366 100644 --- a/libavcodec/v210x.c +++ b/libavcodec/v210x.c @@ -52,7 +52,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac } if(avpkt->size > avctx->width * avctx->height * 8 / 3){ - av_log(avctx, AV_LOG_ERROR, "Probably padded data, need sample!\n"); + av_log_ask_for_sample(avctx, "Probably padded data\n"); } pic->reference= 0; From 3283f274fdbef16d13df06661cec601e1bc01aab Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 20 Apr 2011 13:12:38 -0400 Subject: [PATCH 13/15] FATE: allow forcing thread-type when doing threaded fate runs. Signed-off-by: Ronald S. Bultje --- Makefile | 2 +- tests/fate-run.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f8e68d6c49..0849443f1d 100644 --- a/Makefile +++ b/Makefile @@ -285,7 +285,7 @@ fate: $(FATE) $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF)) @echo "TEST $(@:fate-%=%)" - $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' + $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)' fate-list: @printf '%s\n' $(sort $(FATE)) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 3a6b46b786..366145d22f 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -16,6 +16,7 @@ cmp=${6:-diff} ref=${7:-"${base}/ref/fate/${test}"} fuzz=$8 threads=${9:-1} +thread_type=${10:-3} outdir="tests/data/fate" outfile="${outdir}/${test}" @@ -49,7 +50,7 @@ run(){ } ffmpeg(){ - run ffmpeg -v 0 -threads $threads "$@" + run ffmpeg -v 0 -threads $threads -thread_type $thread_type "$@" } framecrc(){ @@ -78,7 +79,7 @@ regtest(){ cleanfiles="$cleanfiles $outfile $errfile" outfile=tests/data/regression/$2/$t errfile=tests/data/$t.$2.err - ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" + ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" } codectest(){ From 94f7451a3a5ad61cd49da0aa9f08cefe75482007 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 20 Apr 2011 14:14:42 -0400 Subject: [PATCH 14/15] Introduce slice threads flag. Signed-off-by: Ronald S. Bultje --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 4 ++++ libavcodec/dnxhdenc.c | 1 + libavcodec/dv.c | 3 ++- libavcodec/ffv1.c | 3 ++- libavcodec/h264.c | 3 ++- libavcodec/mpeg12.c | 4 ++-- libavcodec/mpeg12enc.c | 4 ++-- libavcodec/mpeg4videoenc.c | 2 +- libavcodec/mpegvideo_enc.c | 1 + libavcodec/pthread.c | 3 ++- libavcodec/version.h | 2 +- 12 files changed, 23 insertions(+), 10 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 24ba7b143b..482b3a8c04 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-04-21 - XXXXXX - lavc 53.1.0 - avcodec.h + Add CODEC_CAP_SLICE_THREADS for codecs supporting sliced threading. + 2011-04-15 - lavc 52.120.0 - avcodec.h AVPacket structure got additional members for passing side information: 4de339e introduce side information for AVPacket diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7727ad08bf..d1377ca0f8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -676,6 +676,10 @@ typedef struct RcOverride{ * Codec supports frame-level multithreading. */ #define CODEC_CAP_FRAME_THREADS 0x1000 +/** + * Codec supports slice-based (or partition-based) multithreading. + */ +#define CODEC_CAP_SLICE_THREADS 0x2000 //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 958f9d4081..bd5f2282ae 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -869,6 +869,7 @@ AVCodec ff_dnxhd_encoder = { dnxhd_encode_init, dnxhd_encode_picture, dnxhd_encode_end, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), .priv_class = &class, diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 0b87d28e8b..5c5e7fefb1 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -1297,6 +1297,7 @@ AVCodec ff_dvvideo_encoder = { sizeof(DVVideoContext), dvvideo_init_encoder, dvvideo_encode_frame, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), }; @@ -1312,7 +1313,7 @@ AVCodec ff_dvvideo_decoder = { NULL, dvvideo_close, dvvideo_decode_frame, - CODEC_CAP_DR1, + CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, NULL, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 8b46091462..bf89fae8c5 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -1795,7 +1795,7 @@ AVCodec ff_ffv1_decoder = { NULL, common_end, decode_frame, - CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, + CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/ | CODEC_CAP_SLICE_THREADS, NULL, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }; @@ -1809,6 +1809,7 @@ AVCodec ff_ffv1_encoder = { encode_init, encode_frame, common_end, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }; diff --git a/libavcodec/h264.c b/libavcodec/h264.c index dbf71a761e..cd7dccc172 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3426,7 +3426,8 @@ AVCodec ff_h264_decoder = { NULL, ff_h264_decode_end, decode_frame, - /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY, + /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY | + CODEC_CAP_SLICE_THREADS, .flush= flush_dpb, .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .profiles = NULL_IF_CONFIG_SMALL(profiles), diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 3e9f74a696..0676f18157 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2523,7 +2523,7 @@ AVCodec ff_mpeg2video_decoder = { NULL, mpeg_decode_end, mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), @@ -2540,7 +2540,7 @@ AVCodec ff_mpegvideo_decoder = { NULL, mpeg_decode_end, mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 206e7d6bc4..5e9b2ba3b1 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -940,7 +940,7 @@ AVCodec ff_mpeg1video_encoder = { MPV_encode_end, .supported_framerates= ff_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, - .capabilities= CODEC_CAP_DELAY, + .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), }; @@ -954,6 +954,6 @@ AVCodec ff_mpeg2video_encoder = { MPV_encode_end, .supported_framerates= ff_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, - .capabilities= CODEC_CAP_DELAY, + .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), }; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 134894c112..33ecc0ae46 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1347,6 +1347,6 @@ AVCodec ff_mpeg4_encoder = { MPV_encode_picture, MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, - .capabilities= CODEC_CAP_DELAY, + .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 7f9892351b..c08098506a 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3800,6 +3800,7 @@ AVCodec ff_h263p_encoder = { MPV_encode_init, MPV_encode_picture, MPV_encode_end, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"), }; diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index ba6e395d75..0311dcd7e9 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -877,7 +877,8 @@ static void validate_thread_parameters(AVCodecContext *avctx) avctx->active_thread_type = 0; } else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) { avctx->active_thread_type = FF_THREAD_FRAME; - } else if (avctx->thread_type & FF_THREAD_SLICE) { + } else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS && + avctx->thread_type & FF_THREAD_SLICE) { avctx->active_thread_type = FF_THREAD_SLICE; } } diff --git a/libavcodec/version.h b/libavcodec/version.h index b9c219d260..487e7a5136 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 0 +#define LIBAVCODEC_VERSION_MINOR 1 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From b4a53314f115a47567b77004e02dd317e0e29ad9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 21 Apr 2011 19:50:19 -0400 Subject: [PATCH 15/15] APIChanges: document git revision for CODEC_CAP_SLICE_THREADS addition. --- doc/APIchanges | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 482b3a8c04..5c7b6775c4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,7 +13,7 @@ libavutil: 2011-04-18 API changes, most recent first: -2011-04-21 - XXXXXX - lavc 53.1.0 - avcodec.h +2011-04-21 - 94f7451 - lavc 53.1.0 - avcodec.h Add CODEC_CAP_SLICE_THREADS for codecs supporting sliced threading. 2011-04-15 - lavc 52.120.0 - avcodec.h