From a4aa20fbdbe8a092fa0a2707cd702531865d957f Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Thu, 18 Oct 2012 14:47:38 -0600 Subject: [PATCH 1/5] avcodec: prefer decoders without CODEC_CAP_EXPERIMENTAL Signed-off-by: Luca Barbato --- libavcodec/utils.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 836d95388d..cbe527e5b3 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1490,12 +1490,13 @@ av_cold int avcodec_close(AVCodecContext *avctx) return 0; } -AVCodec *avcodec_find_encoder(enum AVCodecID id) +static AVCodec *find_encdec(enum AVCodecID id, int encoder) { AVCodec *p, *experimental = NULL; p = first_avcodec; while (p) { - if (av_codec_is_encoder(p) && p->id == id) { + if ((encoder ? av_codec_is_encoder(p) : av_codec_is_decoder(p)) && + p->id == id) { if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { experimental = p; } else @@ -1506,6 +1507,11 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id) return experimental; } +AVCodec *avcodec_find_encoder(enum AVCodecID id) +{ + return find_encdec(id, 1); +} + AVCodec *avcodec_find_encoder_by_name(const char *name) { AVCodec *p; @@ -1522,14 +1528,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name) AVCodec *avcodec_find_decoder(enum AVCodecID id) { - AVCodec *p; - p = first_avcodec; - while (p) { - if (av_codec_is_decoder(p) && p->id == id) - return p; - p = p->next; - } - return NULL; + return find_encdec(id, 0); } AVCodec *avcodec_find_decoder_by_name(const char *name) From a893655bdaa726a82424367b6456d195be12ebbc Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Thu, 18 Oct 2012 22:59:04 -0600 Subject: [PATCH 2/5] avutil: Add AVERROR_EXPERIMENTAL Signed-off-by: Luca Barbato --- doc/APIchanges | 3 +++ libavutil/error.c | 1 + libavutil/error.h | 1 + libavutil/version.h | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0c9a455838..ed479df569 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2012-10-18 - xxxxxxx - lavu 51.45.0 - error.h + Add AVERROR_EXPERIMENTAL + 2012-10-12 - xxxxxxx - lavu 51.44.0 - pixdesc.h Add functions for accessing pixel format descriptors. Accessing the av_pix_fmt_descriptors array directly is now diff --git a/libavutil/error.c b/libavutil/error.c index c335cde13d..6803d2d4cd 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -41,6 +41,7 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) case AVERROR_STREAM_NOT_FOUND: errstr = "Stream not found" ; break; case AVERROR_BUG: errstr = "Bug detected, please report the issue" ; break; case AVERROR_UNKNOWN: errstr = "Unknown error occurred" ; break; + case AVERROR_EXPERIMENTAL: errstr = "Experimental feature" ; break; } if (errstr) { diff --git a/libavutil/error.h b/libavutil/error.h index 61d5fb9085..3dfd8807fe 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -60,6 +60,7 @@ #define AVERROR_STREAM_NOT_FOUND (-0x2dabac08) ///< Stream not found #define AVERROR_BUG (-0x5fb8aabe) ///< Bug detected, please report the issue #define AVERROR_UNKNOWN (-0x31b4b1ab) ///< Unknown error, typically from an external library +#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it. /** * Put a description of the AVERROR code errnum in errbuf. diff --git a/libavutil/version.h b/libavutil/version.h index 4cc2f7cf75..4de2a9446f 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -37,7 +37,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 44 +#define LIBAVUTIL_VERSION_MINOR 45 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From c854102da773fa898cc6dbc8ca474b1088ce5f12 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Thu, 18 Oct 2012 22:58:25 -0600 Subject: [PATCH 3/5] avcodec: handle AVERROR_EXPERIMENTAL Error out on init if a codec with CODEC_CAP_EXPERIMENTAL is requested and strict_std_compliance is not FF_COMPLIANCE_EXPERIMENTAL. Move the check from avconv to avcodec_open2() and return AVERROR_EXPERIMENTAL accordingly. Signed-off-by: Luca Barbato --- avconv.c | 36 +++++++++++++++++------------------- libavcodec/utils.c | 6 ++++++ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/avconv.c b/avconv.c index 4d9c7c0b7f..759e1c0ce8 100644 --- a/avconv.c +++ b/avconv.c @@ -229,21 +229,18 @@ void assert_avoptions(AVDictionary *m) } } -static void assert_codec_experimental(AVCodecContext *c, int encoder) +static void abort_codec_experimental(AVCodec *c, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; - if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL && - c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { - av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad " - "results.\nAdd '-strict experimental' if you want to use it.\n", - codec_string, c->codec->name); - codec = encoder ? avcodec_find_encoder(c->codec->id) : avcodec_find_decoder(c->codec->id); - if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) - av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n", - codec_string, codec->name); - exit(1); - } + av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad " + "results.\nAdd '-strict experimental' if you want to use it.\n", + codec_string, c->name); + codec = encoder ? avcodec_find_encoder(c->id) : avcodec_find_decoder(c->id); + if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) + av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n", + codec_string, codec->name); + exit(1); } /* @@ -1442,7 +1439,7 @@ static void print_sdp(void) static int init_input_stream(int ist_index, char *error, int error_len) { - int i; + int i, ret; InputStream *ist = input_streams[ist_index]; if (ist->decoding_needed) { AVCodec *codec = ist->dec; @@ -1470,12 +1467,13 @@ static int init_input_stream(int ist_index, char *error, int error_len) if (!av_dict_get(ist->opts, "threads", NULL, 0)) av_dict_set(&ist->opts, "threads", "auto", 0); - if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { + if ((ret = avcodec_open2(ist->st->codec, codec, &ist->opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 0); snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d", ist->file_index, ist->st->index); - return AVERROR(EINVAL); + return ret; } - assert_codec_experimental(ist->st->codec, 0); assert_avoptions(ist->opts); } @@ -1808,13 +1806,13 @@ static int transcode_init(void) } if (!av_dict_get(ost->opts, "threads", NULL, 0)) av_dict_set(&ost->opts, "threads", "auto", 0); - if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { + if ((ret = avcodec_open2(ost->st->codec, codec, &ost->opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 1); snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); - ret = AVERROR(EINVAL); goto dump_format; } - assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cbe527e5b3..5e22b9f6cf 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -778,6 +778,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } avctx->frame_number = 0; + if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL && + avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + ret = AVERROR_EXPERIMENTAL; + goto free_and_end; + } + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && (!avctx->time_base.num || !avctx->time_base.den)) { avctx->time_base.num = 1; From e0d5ac6ae3a83e6718a6731e391e168da187bce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sat, 20 Oct 2012 23:04:14 +0300 Subject: [PATCH 4/5] rtsp: Update a comment to the current filename scheme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtsp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 2812fcb393..043b67aa6f 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -424,7 +424,7 @@ typedef struct RTSPStream { int sdp_payload_type; /**< payload type */ //@} - /** The following are used for dynamic protocols (rtp_*.c/rdt.c) */ + /** The following are used for dynamic protocols (rtpdec_*.c/rdt.c) */ //@{ /** handler structure */ RTPDynamicProtocolHandler *dynamic_handler; From c3e15f7b39aac2012f09ee4ca86d2bc674ffdbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sat, 20 Oct 2012 23:29:15 +0300 Subject: [PATCH 5/5] rtpdec: Don't pass a non-AVClass pointer as log context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The log context is assumed to start with an AVClass pointer. Signed-off-by: Martin Storsjö --- libavformat/rtpdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index dac367dd86..9a1c4972ca 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -785,7 +785,7 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, int value_size = strlen(p) + 1; if (!(value = av_malloc(value_size))) { - av_log(stream, AV_LOG_ERROR, "Failed to allocate data for FMTP."); + av_log(NULL, AV_LOG_ERROR, "Failed to allocate data for FMTP."); return AVERROR(ENOMEM); }