Commit e3a91c51 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'c3e15f7b'

* commit 'c3e15f7b':
  rtpdec: Don't pass a non-AVClass pointer as log context
  rtsp: Update a comment to the current filename scheme
  avcodec: handle AVERROR_EXPERIMENTAL
  avutil: Add AVERROR_EXPERIMENTAL
  avcodec: prefer decoders without CODEC_CAP_EXPERIMENTAL

Conflicts:
	doc/APIchanges
	ffmpeg.c
	libavcodec/utils.c
	libavformat/rtpdec.c
	libavutil/error.c
	libavutil/error.h
	libavutil/version.h
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents c3778df2 c3e15f7b
...@@ -104,6 +104,9 @@ API changes, most recent first: ...@@ -104,6 +104,9 @@ API changes, most recent first:
2012-03-26 - a67d9cf - lavfi 2.66.100 2012-03-26 - a67d9cf - lavfi 2.66.100
Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
2012-10-18 - xxxxxxx - lavu 51.45.0 - error.h
Add AVERROR_EXPERIMENTAL
2012-10-12 - xxxxxxx - lavu 51.44.0 - pixdesc.h 2012-10-12 - xxxxxxx - lavu 51.44.0 - pixdesc.h
Add functions for accessing pixel format descriptors. Add functions for accessing pixel format descriptors.
Accessing the av_pix_fmt_descriptors array directly is now Accessing the av_pix_fmt_descriptors array directly is now
......
...@@ -467,21 +467,18 @@ void assert_avoptions(AVDictionary *m) ...@@ -467,21 +467,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"; const char *codec_string = encoder ? "encoder" : "decoder";
AVCodec *codec; AVCodec *codec;
if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL && av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad "
c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { "results.\nAdd '-strict experimental' if you want to use it.\n",
av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad " codec_string, c->name);
"results.\nAdd '-strict experimental' if you want to use it.\n", codec = encoder ? avcodec_find_encoder(c->id) : avcodec_find_decoder(c->id);
codec_string, c->codec->name); if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL))
codec = encoder ? avcodec_find_encoder(c->codec->id) : avcodec_find_decoder(c->codec->id); av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n",
if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) codec_string, codec->name);
av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n", exit(1);
codec_string, codec->name);
exit(1);
}
} }
static void update_benchmark(const char *fmt, ...) static void update_benchmark(const char *fmt, ...)
...@@ -1859,6 +1856,7 @@ static void print_sdp(void) ...@@ -1859,6 +1856,7 @@ static void print_sdp(void)
static int init_input_stream(int ist_index, char *error, int error_len) static int init_input_stream(int ist_index, char *error, int error_len)
{ {
int ret;
InputStream *ist = input_streams[ist_index]; InputStream *ist = input_streams[ist_index];
if (ist->decoding_needed) { if (ist->decoding_needed) {
...@@ -1878,12 +1876,13 @@ static int init_input_stream(int ist_index, char *error, int error_len) ...@@ -1878,12 +1876,13 @@ static int init_input_stream(int ist_index, char *error, int error_len)
if (!av_dict_get(ist->opts, "threads", NULL, 0)) if (!av_dict_get(ist->opts, "threads", NULL, 0))
av_dict_set(&ist->opts, "threads", "auto", 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", snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d",
ist->file_index, ist->st->index); ist->file_index, ist->st->index);
return AVERROR(EINVAL); return ret;
} }
assert_codec_experimental(ist->st->codec, 0);
assert_avoptions(ist->opts); assert_avoptions(ist->opts);
} }
...@@ -2267,17 +2266,17 @@ static int transcode_init(void) ...@@ -2267,17 +2266,17 @@ static int transcode_init(void)
} }
if (!av_dict_get(ost->opts, "threads", NULL, 0)) if (!av_dict_get(ost->opts, "threads", NULL, 0))
av_dict_set(&ost->opts, "threads", "auto", 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", 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); ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format; goto dump_format;
} }
if (ost->enc->type == AVMEDIA_TYPE_AUDIO && if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
!(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE))
av_buffersink_set_frame_size(ost->filter->filter, av_buffersink_set_frame_size(ost->filter->filter,
ost->st->codec->frame_size); ost->st->codec->frame_size);
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts); assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) 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." av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
......
...@@ -886,15 +886,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code ...@@ -886,15 +886,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
goto free_and_end; goto free_and_end;
if (codec->capabilities & CODEC_CAP_EXPERIMENTAL)
if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_ERROR,
"Codec %s is experimental but experimental codecs are not enabled, try -strict %d\n",
codec->name, FF_COMPLIANCE_EXPERIMENTAL);
ret = -1;
goto free_and_end;
}
//We only call avcodec_set_dimensions() for non h264 codecs so as not to overwrite previously setup dimensions //We only call avcodec_set_dimensions() for non h264 codecs so as not to overwrite previously setup dimensions
if (!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == AV_CODEC_ID_H264)){ if (!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == AV_CODEC_ID_H264)){
...@@ -937,6 +928,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code ...@@ -937,6 +928,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
avctx->frame_number = 0; avctx->frame_number = 0;
avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id); avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id);
if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_ERROR,
"Codec %s is experimental but experimental codecs are not enabled, try -strict %d\n",
codec->name, FF_COMPLIANCE_EXPERIMENTAL);
ret = AVERROR_EXPERIMENTAL;
goto free_and_end;
}
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
(!avctx->time_base.num || !avctx->time_base.den)) { (!avctx->time_base.num || !avctx->time_base.den)) {
avctx->time_base.num = 1; avctx->time_base.num = 1;
...@@ -1961,13 +1961,14 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) ...@@ -1961,13 +1961,14 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
} }
} }
AVCodec *avcodec_find_encoder(enum AVCodecID id) static AVCodec *find_encdec(enum AVCodecID id, int encoder)
{ {
AVCodec *p, *experimental = NULL; AVCodec *p, *experimental = NULL;
p = first_avcodec; p = first_avcodec;
id= remap_deprecated_codec_id(id); id= remap_deprecated_codec_id(id);
while (p) { 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) { if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {
experimental = p; experimental = p;
} else } else
...@@ -1978,6 +1979,11 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id) ...@@ -1978,6 +1979,11 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id)
return experimental; return experimental;
} }
AVCodec *avcodec_find_encoder(enum AVCodecID id)
{
return find_encdec(id, 1);
}
AVCodec *avcodec_find_encoder_by_name(const char *name) AVCodec *avcodec_find_encoder_by_name(const char *name)
{ {
AVCodec *p; AVCodec *p;
...@@ -1994,19 +2000,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name) ...@@ -1994,19 +2000,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name)
AVCodec *avcodec_find_decoder(enum AVCodecID id) AVCodec *avcodec_find_decoder(enum AVCodecID id)
{ {
AVCodec *p, *experimental=NULL; return find_encdec(id, 0);
p = first_avcodec;
id= remap_deprecated_codec_id(id);
while (p) {
if (av_codec_is_decoder(p) && p->id == id) {
if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {
experimental = p;
} else
return p;
}
p = p->next;
}
return experimental;
} }
AVCodec *avcodec_find_decoder_by_name(const char *name) AVCodec *avcodec_find_decoder_by_name(const char *name)
......
...@@ -788,7 +788,7 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, ...@@ -788,7 +788,7 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
int value_size = strlen(p) + 1; int value_size = strlen(p) + 1;
if (!(value = av_malloc(value_size))) { if (!(value = av_malloc(value_size))) {
av_log(stream, AV_LOG_ERROR, "Failed to allocate data for FMTP.\n"); av_log(NULL, AV_LOG_ERROR, "Failed to allocate data for FMTP.\n");
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
......
...@@ -424,7 +424,7 @@ typedef struct RTSPStream { ...@@ -424,7 +424,7 @@ typedef struct RTSPStream {
int sdp_payload_type; /**< payload type */ 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 */ /** handler structure */
RTPDynamicProtocolHandler *dynamic_handler; RTPDynamicProtocolHandler *dynamic_handler;
......
...@@ -47,6 +47,7 @@ static const struct error_entry error_entries[] = { ...@@ -47,6 +47,7 @@ static const struct error_entry error_entries[] = {
{ ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" }, { ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
{ ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" }, { ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
{ ERROR_TAG(UNKNOWN), "Unknown error occurred" }, { ERROR_TAG(UNKNOWN), "Unknown error occurred" },
{ ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
}; };
int av_strerror(int errnum, char *errbuf, size_t errbuf_size) int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
......
...@@ -61,14 +61,15 @@ ...@@ -61,14 +61,15 @@
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found #define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome #define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found #define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
/** /**
* This is semantically identical to AVERROR_BUG * This is semantically identical to AVERROR_BUG
* it has been introduced in Libav after our AVERROR_BUG and with a modified value. * it has been introduced in Libav after our AVERROR_BUG and with a modified value.
*/ */
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ') #define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library #define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< 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.
#define AV_ERROR_MAX_STRING_SIZE 64 #define AV_ERROR_MAX_STRING_SIZE 64
......
...@@ -75,8 +75,8 @@ ...@@ -75,8 +75,8 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 51 #define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 76 #define LIBAVUTIL_VERSION_MINOR 77
#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \ LIBAVUTIL_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment