[FFmpeg-devel] [PATCH] ffmpeg: fail on experimental encoders if -strict > experimental
Janne Grunau
janne-ffmpeg
Wed May 26 20:03:15 CEST 2010
On Wed, May 26, 2010 at 06:56:52PM +0200, Michael Niedermayer wrote:
> On Wed, May 26, 2010 at 09:31:55AM +0200, Janne Grunau wrote:
> > On Wed, May 26, 2010 at 02:08:00AM +0200, Michael Niedermayer wrote:
> > > On Wed, May 26, 2010 at 12:48:00AM +0200, Janne Grunau wrote:
> > > > @@ -3133,9 +3139,9 @@ static void opt_input_file(const char *filename)
> > > >
> > > > set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM);
> > > >
> > > > - ic->video_codec_id = find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0);
> > > > - ic->audio_codec_id = find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0);
> > > > - ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0);
> > > > + ic->video_codec_id = find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0, 0);
> > > > + ic->audio_codec_id = find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0, 0);
> > > > + ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0, 0);
> > >
> > > 0 is not ideal, it would be nice to be able to use this for decoders as well
> >
> > Agreed, there is unfortunately no AVCodecContext. Another hint that I'm
>
> avcodec_opts doesnt work?
missed that, it works. new patch attached
Janne
-------------- next part --------------
commit ef854fc5ded795aebb0e02bbc0c67e44d4023987
Author: Janne Grunau <janne at grunau.be>
Date: Mon May 24 23:15:19 2010 +0200
ffmpeg: fail if encoder is experimental and -strict > experimental
diff --git a/ffmpeg.c b/ffmpeg.c
index 63f0e6b..4c1e1b2 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3068,7 +3068,7 @@ static int opt_input_ts_offset(const char *opt, const char *arg)
return 0;
}
-static enum CodecID find_codec_or_die(const char *name, int type, int encoder)
+static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict)
{
const char *codec_string = encoder ? "encoder" : "decoder";
AVCodec *codec;
@@ -3086,6 +3086,13 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder)
fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name);
av_exit(1);
}
+ if(codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
+ strict > FF_COMPLIANCE_EXPERIMENTAL) {
+ fprintf(stderr, "%s \"%s\" is experimental and might produce bad "
+ "results.\nAdd \"-strict experimental\" if you want to use it.\n",
+ codec_string, codec->name);
+ av_exit(1);
+ }
return codec->id;
}
@@ -3133,9 +3140,15 @@ static void opt_input_file(const char *filename)
set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM);
- ic->video_codec_id = find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0);
- ic->audio_codec_id = find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0);
- ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0);
+ ic->video_codec_id =
+ find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0,
+ avcodec_opts[AVMEDIA_TYPE_VIDEO ]->strict_std_compliance);
+ ic->audio_codec_id =
+ find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0,
+ avcodec_opts[AVMEDIA_TYPE_AUDIO ]->strict_std_compliance);
+ ic->subtitle_codec_id=
+ find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0,
+ avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance);
ic->flags |= AVFMT_FLAG_NONBLOCK;
if(pgmyuv_compatibility_hack)
@@ -3364,7 +3377,8 @@ static void new_video_stream(AVFormatContext *oc)
AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1};
if (video_codec_name) {
- codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1);
+ codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1,
+ video_enc->strict_std_compliance);
codec = avcodec_find_encoder_by_name(video_codec_name);
output_codecs[nb_ocodecs] = codec;
} else {
@@ -3495,7 +3509,8 @@ static void new_audio_stream(AVFormatContext *oc)
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
if (audio_codec_name) {
- codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1);
+ codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
+ audio_enc->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
output_codecs[nb_ocodecs] = codec;
} else {
@@ -3555,7 +3570,8 @@ static void new_subtitle_stream(AVFormatContext *oc)
st->stream_copy = 1;
} else {
set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
- subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1);
+ subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1,
+ subtitle_enc->strict_std_compliance);
output_codecs[nb_ocodecs] = avcodec_find_encoder_by_name(subtitle_codec_name);
}
nb_ocodecs++;
More information about the ffmpeg-devel
mailing list