Merge commit 'c3e15f7b39aac2012f09ee4ca86d2bc674ffdbd4'

* commit 'c3e15f7b39aac2012f09ee4ca86d2bc674ffdbd4':
  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: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-10-22 14:39:12 +02:00
commit e3a91c51f7
8 changed files with 45 additions and 47 deletions

View File

@ -104,6 +104,9 @@ API changes, most recent first:
2012-03-26 - a67d9cf - lavfi 2.66.100
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
Add functions for accessing pixel format descriptors.
Accessing the av_pix_fmt_descriptors array directly is now

View File

@ -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";
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);
}
static void update_benchmark(const char *fmt, ...)
@ -1859,6 +1856,7 @@ static void print_sdp(void)
static int init_input_stream(int ist_index, char *error, int error_len)
{
int ret;
InputStream *ist = input_streams[ist_index];
if (ist->decoding_needed) {
@ -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))
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);
}
@ -2267,17 +2266,17 @@ 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;
}
if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
!(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE))
av_buffersink_set_frame_size(ost->filter->filter,
ost->st->codec->frame_size);
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."

View File

@ -886,15 +886,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
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
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
avctx->frame_number = 0;
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 &&
(!avctx->time_base.num || !avctx->time_base.den)) {
avctx->time_base.num = 1;
@ -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;
p = first_avcodec;
id= remap_deprecated_codec_id(id);
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
@ -1978,6 +1979,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;
@ -1994,19 +2000,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name)
AVCodec *avcodec_find_decoder(enum AVCodecID id)
{
AVCodec *p, *experimental=NULL;
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;
return find_encdec(id, 0);
}
AVCodec *avcodec_find_decoder_by_name(const char *name)

View File

@ -788,7 +788,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.\n");
av_log(NULL, AV_LOG_ERROR, "Failed to allocate data for FMTP.\n");
return AVERROR(ENOMEM);
}

View File

@ -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;

View File

@ -47,6 +47,7 @@ static const struct error_entry error_entries[] = {
{ ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
{ ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
{ ERROR_TAG(UNKNOWN), "Unknown error occurred" },
{ ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
};
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)

View File

@ -61,14 +61,15 @@
#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_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
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
*/
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
#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

View File

@ -75,8 +75,8 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 76
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_MINOR 77
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \