OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 18 Jun 2011 02:40:18 +0000 (04:40 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 18 Jun 2011 03:10:38 +0000 (05:10 +0200)
* qatar/master:
  lavc: add opt_find to AVCodecContext class.
  h264: Complexify frame num gap shortening code
  intreadwrite.h: fix AV_RL32/AV_RB32 signedness.
  Fix decoding of mpegts streams with h264 video that does *NOT* have b frames
  Add minor bumps and APIChanges entries for lavf private options.
  ffmpeg: deprecate -vc and -tvstd
  ffmpeg: use new avformat_open_* API.
  ffserver: use new avformat_open_* API.
  ffprobe: use new avformat_open_* API.
  ffplay: use new avformat_open_* API.
  cmdutils: add opt_default2().
  dict: add AV_DICT_APPEND flag.
  lavf: add avformat_write_header() as a replacement for av_write_header().
  Deprecate av_open_input_* and remove their uses.
  lavf: add avformat_open_input() as a replacement for av_open_input_*
  AVOptions: add av_opt_find() as a replacement for av_find_opt.
  AVOptions: add av_opt_set_dict() mapping a dictionary struct to a context.
  ffmpeg: don't abuse a global for passing frame size from input to output
  ffmpeg: don't abuse a global for passing pixel format from input to output
  ffmpeg: initialise encoders earlier.

Conflicts:
cmdutils.c
doc/APIchanges
ffmpeg.c
ffplay.c
ffprobe.c
libavcodec/h264.c
libavformat/avformat.h
libavformat/utils.c
libavformat/version.h
libavutil/avutil.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
26 files changed:
1  2 
cmdutils.c
cmdutils.h
doc/APIchanges
ffmpeg.c
ffprobe.c
ffserver.c
libavcodec/h264.c
libavcodec/options.c
libavfilter/vsrc_movie.c
libavformat/applehttp.c
libavformat/avformat.h
libavformat/avidec.c
libavformat/options.c
libavformat/rdt.c
libavformat/rtpdec_asf.c
libavformat/rtpenc_chain.c
libavformat/sapdec.c
libavformat/utils.c
libavformat/version.h
libavutil/avutil.h
libavutil/dict.c
libavutil/dict.h
libavutil/intreadwrite.h
libavutil/log.h
libavutil/opt.c
libavutil/opt.h

diff --cc cmdutils.c
@@@ -295,34 -340,9 +338,34 @@@ int opt_default(const char *opt, const 
      int ret= 0;
      const AVOption *o= NULL;
      int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
 +    AVCodec *p = NULL;
 +    AVOutputFormat *oformat = NULL;
 +    AVInputFormat *iformat = NULL;
 +
 +    while ((p = av_codec_next(p))) {
 +        const AVClass *c = p->priv_class;
 +        if (c && av_find_opt(&c, opt, NULL, 0, 0))
 +            break;
 +    }
 +    if (p)
 +        goto out;
 +    while ((oformat = av_oformat_next(oformat))) {
 +        const AVClass *c = oformat->priv_class;
 +        if (c && av_find_opt(&c, opt, NULL, 0, 0))
 +            break;
 +    }
 +    if (oformat)
 +        goto out;
 +    while ((iformat = av_iformat_next(iformat))) {
 +        const AVClass *c = iformat->priv_class;
 +        if (c && av_find_opt(&c, opt, NULL, 0, 0))
 +            break;
 +    }
 +    if (iformat)
 +        goto out;
  
      for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){
-         const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
+         const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0);
          if(o2)
              ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
      }
          exit(1);
      }
      if (!o) {
++//<<<<<<< HEAD
 +        fprintf(stderr, "Unrecognized option '%s'\n", opt);
 +        exit(1);
++/*||||||| merged common ancestors
++        AVCodec *p = NULL;
++        AVOutputFormat *oformat = NULL;
++        while ((p=av_codec_next(p))){
++            const AVClass *c = p->priv_class;
++            if(c && av_find_opt(&c, opt, NULL, 0, 0))
++                break;
++        }
++        if (!p) {
++            while ((oformat = av_oformat_next(oformat))) {
++                const AVClass *c = oformat->priv_class;
++                if (c && av_find_opt(&c, opt, NULL, 0, 0))
++                    break;
++            }
++        }
++        if(!p && !oformat){
++            fprintf(stderr, "Unrecognized option '%s'\n", opt);
++            exit(1);
++        }
++=======
+         AVCodec *p = NULL;
+         AVOutputFormat *oformat = NULL;
+         while ((p=av_codec_next(p))){
+             const AVClass *c = p->priv_class;
+             if(c && av_opt_find(&c, opt, NULL, 0, 0))
+                 break;
+         }
+         if (!p) {
+             while ((oformat = av_oformat_next(oformat))) {
+                 const AVClass *c = oformat->priv_class;
+                 if (c && av_opt_find(&c, opt, NULL, 0, 0))
+                     break;
+             }
+         }
++>>>>>>> qatar/master*/
      }
  
 + out:
+     if ((ret = opt_default2(opt, arg)) < 0)
+         return ret;
  //    av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL));
  
 -    //FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this
      opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1));
 -    opt_values[opt_name_count]= o ? NULL : av_strdup(arg);
 +    opt_values[opt_name_count] = av_strdup(arg);
      opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
 -    opt_names[opt_name_count++]= o ? o->name : av_strdup(opt);
 +    opt_names[opt_name_count++] = av_strdup(opt);
  
      if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug))
          av_log_set_level(AV_LOG_DEBUG);
diff --cc cmdutils.h
Simple merge
diff --cc doc/APIchanges
@@@ -13,16 -13,16 +13,26 @@@ libavutil:   2011-04-1
  
  API changes, most recent first:
  
 +2011-06-12 - xxxxxxx - lavfi 2.18.0 - avcodec.h
 +  Add avfilter_get_video_buffer_ref_from_frame() function in
 +  libavfilter/avcodec.h.
 +
 +2011-06-12 - xxxxxxx - lavfi 2.17.0 - avfiltergraph.h
 +  Add avfilter_inout_alloc() and avfilter_inout_free() functions.
 +
 +2011-06-12 - xxxxxxx - lavfi 2.16.0 - avfilter_graph_parse()
 +  Change avfilter_graph_parse() signature.
 +
+ 2011-06-xx - xxxxxxx - lavf 53.2.0 - avformat.h
+   Add avformat_open_input and avformat_write_header().
+   Deprecate av_open_input_stream, av_open_input_file,
+   AVFormatParameters and av_write_header.
+ 2011-06-xx - xxxxxxx - lavu 51.7.0 - opt.h
+   Add av_opt_set_dict() and av_opt_find().
+   Deprecate av_find_opt().
+   Add AV_DICT_APPEND flag.
  2011-06-xx - xxxxxxx - lavu 51.6.0 - opt.h
    Add av_opt_flag_is_set().
  
diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -2295,8 -2210,32 +2301,12 @@@ static int transcode(AVFormatContext **
                                        codec->height  != icodec->height ||
                                        codec->pix_fmt != icodec->pix_fmt;
                  if (ost->video_resample) {
 -#if !CONFIG_AVFILTER
 -                    avcodec_get_frame_defaults(&ost->pict_tmp);
 -                    if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
 -                                         codec->width, codec->height)) {
 -                        fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
 -                        ffmpeg_exit(1);
 -                    }
 -                    ost->img_resample_ctx = sws_getContext(
 -                        icodec->width,
 -                        icodec->height,
 -                            icodec->pix_fmt,
 -                            codec->width,
 -                            codec->height,
 -                            codec->pix_fmt,
 -                            ost->sws_flags, NULL, NULL, NULL);
 -                    if (ost->img_resample_ctx == NULL) {
 -                        fprintf(stderr, "Cannot get resampling context\n");
 -                        ffmpeg_exit(1);
 -                    }
 -#endif
 -                    codec->bits_per_raw_sample= 0;
 +                    codec->bits_per_raw_sample= frame_bits_per_raw_sample;
                  }
+                 if (!codec->width || !codec->height) {
+                     codec->width  = icodec->width;
+                     codec->height = icodec->height;
+                 }
                  ost->resample_height = icodec->height;
                  ost->resample_width  = icodec->width;
                  ost->resample_pix_fmt= icodec->pix_fmt;
@@@ -3394,12 -3314,7 +3402,9 @@@ static int opt_input_file(const char *o
              break;
          case AVMEDIA_TYPE_VIDEO:
              input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(video_codec_name);
 +            if(!input_codecs[nb_input_codecs-1])
 +                input_codecs[nb_input_codecs-1] = avcodec_find_decoder(dec->codec_id);
              set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, input_codecs[nb_input_codecs-1]);
-             frame_height = dec->height;
-             frame_width  = dec->width;
-             frame_pix_fmt = dec->pix_fmt;
              rfps      = ic->streams[i]->r_frame_rate.num;
              rfps_base = ic->streams[i]->r_frame_rate.den;
              if (dec->lowres) {
      input_files[nb_input_files - 1].ctx        = ic;
      input_files[nb_input_files - 1].ist_index  = nb_input_streams - ic->nb_streams;
  
-     video_channel = 0;
 +    top_field_first = -1;
++    video_channel = 0;
      frame_rate    = (AVRational){0, 0};
+     frame_pix_fmt = PIX_FMT_NONE;
+     frame_height = 0;
+     frame_width  = 0;
      audio_sample_rate = 0;
      audio_channels    = 0;
  
@@@ -3575,11 -3488,8 +3581,9 @@@ static void new_video_stream(AVFormatCo
          video_enc->width = frame_width;
          video_enc->height = frame_height;
          video_enc->pix_fmt = frame_pix_fmt;
 +        video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;
          st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
  
-         choose_pixel_fmt(st, codec);
          if (intra_only)
              video_enc->gop_size = 0;
          if (video_qscale || same_quality) {
@@@ -3981,10 -3896,11 +3985,12 @@@ static int opt_output_file(const char *
      oc->preload= (int)(mux_preload*AV_TIME_BASE);
      oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
      oc->loop_output = loop_output;
 -    oc->flags |= AVFMT_FLAG_NONBLOCK;
 +
 +    set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
  
      frame_rate    = (AVRational){0, 0};
+     frame_width   = 0;
+     frame_height  = 0;
      audio_sample_rate = 0;
      audio_channels    = 0;
  
diff --cc ffprobe.c
Simple merge
diff --cc ffserver.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -751,10 -730,8 +751,12 @@@ typedef struct AVFormatContext 
  #if FF_API_FLAG_RTP_HINT
  #define AVFMT_FLAG_RTP_HINT     0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead
  #endif
- #define AVFMT_FLAG_MP4A_LATM    0x0080 ///< Enable RTP MP4A-LATM payload
+ #define AVFMT_FLAG_CUSTOM_IO    0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
++#define AVFMT_FLAG_MP4A_LATM    0x8000 ///< Enable RTP MP4A-LATM payload
 +#define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
 +#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
 +#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Dont merge side data but keep it seperate.
      int loop_input;
  
      /**
@@@ -1078,9 -1044,29 +1084,31 @@@ attribute_deprecated int av_open_input_
                         AVInputFormat *fmt,
                         int buf_size,
                         AVFormatParameters *ap);
+ #endif
+ /**
+  * Open an input stream and read the header. The codecs are not opened.
+  * The stream must be closed with av_close_input_file().
+  *
+  * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
+  *           May be a pointer to NULL, in which case an AVFormatContext is allocated by this
+  *           function and written into ps.
+  *           Note that a user-supplied AVFormatContext will be freed on failure.
+  * @param filename Name of the stream to open.
+  * @param fmt If non-NULL, this parameter forces a specific input format.
+  *            Otherwise the format is autodetected.
+  * @param options  A dictionary filled with AVFormatContext and demuxer-private options.
+  *                 On return this parameter will be destroyed and replaced with a dict containing
+  *                 options that were not found. May be NULL.
+  *
+  * @return 0 on success, a negative AVERROR on failure.
+  *
+  * @note If you want to use custom IO, preallocate the format context and set its pb field.
+  */
+ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
  
 +int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap);
 +
  /**
   * Allocate an AVFormatContext.
   * avformat_free_context() can be used to free the context and everything
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #include "avio_internal.h"
  #include "internal.h"
  #include "libavcodec/internal.h"
 +#include "libavcodec/raw.h"
  #include "libavutil/opt.h"
  #include "libavutil/dict.h"
+ #include "libavutil/pixdesc.h"
  #include "metadata.h"
  #include "id3v2.h"
  #include "libavutil/avstring.h"
@@@ -417,80 -456,16 +461,32 @@@ int av_open_input_stream(AVFormatContex
          err = AVERROR(ENOMEM);
          goto fail;
      }
-     ic->iformat = fmt;
      ic->pb = pb;
-     ic->duration = AV_NOPTS_VALUE;
-     ic->start_time = AV_NOPTS_VALUE;
-     av_strlcpy(ic->filename, filename, sizeof(ic->filename));
  
-     /* allocate private data */
-     if (fmt->priv_data_size > 0) {
-         ic->priv_data = av_mallocz(fmt->priv_data_size);
-         if (!ic->priv_data) {
-             err = AVERROR(ENOMEM);
-             goto fail;
-         }
-         if (fmt->priv_class) {
-             *(const AVClass**)ic->priv_data= fmt->priv_class;
-             av_opt_set_defaults(ic->priv_data);
-         }
-     } else {
-         ic->priv_data = NULL;
-     }
+     err = avformat_open_input(ic_ptr, filename, fmt, &opts);
  
-     // e.g. AVFMT_NOFILE formats will not have a AVIOContext
-     if (ic->pb)
-         ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC);
-     if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && ic->iformat->read_header) {
-         err = ic->iformat->read_header(ic, ap);
-         if (err < 0)
-             goto fail;
-     }
-     if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && pb && !ic->data_offset)
-         ic->data_offset = avio_tell(ic->pb);
-     ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
-     *ic_ptr = ic;
-     return 0;
-  fail:
-     if (ic) {
-         int i;
-         av_freep(&ic->priv_data);
-         for(i=0;i<ic->nb_streams;i++) {
-             AVStream *st = ic->streams[i];
-             if (st) {
-                 av_free(st->priv_data);
-                 av_free(st->codec->extradata);
-                 av_free(st->codec);
-                 av_free(st->info);
-             }
-             av_free(st);
-         }
-     }
-     av_free(ic);
-     *ic_ptr = NULL;
+ fail:
+     av_dict_free(&opts);
      return err;
  }
+ #endif
  
 +int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap){
 +    int err;
 +
 +    if (ic->iformat->read_header) {
 +        err = ic->iformat->read_header(ic, ap);
 +        if (err < 0)
 +            return err;
 +    }
 +
 +    if (ic->pb && !ic->data_offset)
 +        ic->data_offset = avio_tell(ic->pb);
 +
 +    return 0;
 +}
 +
 +
  /** size of probe buffer, for guessing file type from file contents */
  #define PROBE_BUF_MIN 2048
  #define PROBE_BUF_MAX (1<<20)
@@@ -568,62 -544,117 +565,117 @@@ int av_open_input_file(AVFormatContext 
                         AVFormatParameters *ap)
  {
      int err;
-     AVProbeData probe_data, *pd = &probe_data;
-     AVIOContext *pb = NULL;
-     void *logctx= ap && ap->prealloced_context ? *ic_ptr : NULL;
+     AVDictionary *opts = convert_format_parameters(ap);
  
-     pd->filename = "";
-     if (filename)
-         pd->filename = filename;
-     pd->buf = NULL;
-     pd->buf_size = 0;
+     if (!ap->prealloced_context)
+         *ic_ptr = NULL;
+     err = avformat_open_input(ic_ptr, filename, fmt, &opts);
  
-     if (!fmt) {
-         /* guess format if no file can be opened */
-         fmt = av_probe_input_format(pd, 0);
+     av_dict_free(&opts);
+     return err;
+ }
+ #endif
+ /* open input file and probe the format if necessary */
+ static int init_input(AVFormatContext *s, const char *filename)
+ {
+     int ret;
+     AVProbeData pd = {filename, NULL, 0};
+     if (s->pb) {
+         s->flags |= AVFMT_FLAG_CUSTOM_IO;
+         if (!s->iformat)
+             return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0);
+         else if (s->iformat->flags & AVFMT_NOFILE)
+             return AVERROR(EINVAL);
+         return 0;
      }
  
-     /* Do not open file if the format does not need it. XXX: specific
-        hack needed to handle RTSP/TCP */
-     if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
-         /* if no file needed do not try to open one */
-         if ((err=avio_open(&pb, filename, AVIO_FLAG_READ)) < 0) {
+     if ( (s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
+         (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0))))
+         return 0;
+     if ((ret = avio_open(&s->pb, filename, AVIO_FLAG_READ)) < 0)
+        return ret;
+     if (s->iformat)
+         return 0;
+     return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0);
+ }
+ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
+ {
+     AVFormatContext *s = *ps;
+     int ret = 0;
+     AVFormatParameters ap = { 0 };
+     AVDictionary *tmp = NULL;
+     if (!s && !(s = avformat_alloc_context()))
+         return AVERROR(ENOMEM);
+     if (fmt)
+         s->iformat = fmt;
+     if (options)
+         av_dict_copy(&tmp, *options, 0);
+     if ((ret = av_opt_set_dict(s, &tmp)) < 0)
+         goto fail;
+     if ((ret = init_input(s, filename)) < 0)
+         goto fail;
+     /* check filename in case an image number is expected */
+     if (s->iformat->flags & AVFMT_NEEDNUMBER) {
+         if (!av_filename_number_test(filename)) {
+             ret = AVERROR(EINVAL);
              goto fail;
          }
-         if (buf_size > 0) {
-             ffio_set_buf_size(pb, buf_size);
-         }
-         if (!fmt && (err = av_probe_input_buffer(pb, &fmt, filename, logctx, 0, logctx ? (*ic_ptr)->probesize : 0)) < 0) {
+     }
+     s->duration = s->start_time = AV_NOPTS_VALUE;
+     av_strlcpy(s->filename, filename, sizeof(s->filename));
+     /* allocate private data */
+     if (s->iformat->priv_data_size > 0) {
+         if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) {
+             ret = AVERROR(ENOMEM);
              goto fail;
          }
+         if (s->iformat->priv_class) {
+             *(const AVClass**)s->priv_data = s->iformat->priv_class;
+             av_opt_set_defaults(s->priv_data);
+             if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0)
+                 goto fail;
+         }
      }
  
-     /* if still no format found, error */
-     if (!fmt) {
-         err = AVERROR_INVALIDDATA;
-         goto fail;
-     }
+     /* e.g. AVFMT_NOFILE formats will not have a AVIOContext */
+     if (s->pb)
+         ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);
  
-     /* check filename in case an image number is expected */
-     if (fmt->flags & AVFMT_NEEDNUMBER) {
-         if (!av_filename_number_test(filename)) {
-             err = AVERROR(EINVAL);
 -    if (s->iformat->read_header)
++    if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
+         if ((ret = s->iformat->read_header(s, &ap)) < 0)
              goto fail;
-         }
 -    if (s->pb && !s->data_offset)
++    if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->data_offset)
+         s->data_offset = avio_tell(s->pb);
+     s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
+     if (options) {
+         av_dict_free(options);
+         *options = tmp;
      }
-     err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);
-     if (err)
-         goto fail;
+     *ps = s;
      return 0;
-  fail:
-     av_freep(&pd->buf);
-     if (pb)
-         avio_close(pb);
-     if (ap && ap->prealloced_context)
-         av_free(*ic_ptr);
-     *ic_ptr = NULL;
-     return err;
  
+ fail:
+     av_dict_free(&tmp);
+     if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO))
+         avio_close(s->pb);
+     avformat_free_context(s);
+     *ps = NULL;
+     return ret;
  }
  
  /*******************************************************/
@@@ -2722,8 -2733,11 +2775,9 @@@ AVChapter *ff_new_chapter(AVFormatConte
  /************************************************************/
  /* output media file */
  
+ #if FF_API_FORMAT_PARAMETERS
  int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
  {
 -    int ret;
 -
      if (s->oformat->priv_data_size > 0) {
          s->priv_data = av_mallocz(s->oformat->priv_data_size);
          if (!s->priv_data)
      } else
          s->priv_data = NULL;
  
 -    if (s->oformat->set_parameters) {
 -        ret = s->oformat->set_parameters(s, ap);
 -        if (ret < 0)
 -            return ret;
 +    return 0;
 +}
++#endif
 +
 +int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat,
 +                                   const char *format, const char *filename)
 +{
 +    AVFormatContext *s = avformat_alloc_context();
 +    int ret = 0;
 +
 +    *avctx = NULL;
 +    if (!s)
 +        goto nomem;
 +
 +    if (!oformat) {
 +        if (format) {
 +            oformat = av_guess_format(format, NULL, NULL);
 +            if (!oformat) {
 +                av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
 +                ret = AVERROR(EINVAL);
 +                goto error;
 +            }
 +        } else {
 +            oformat = av_guess_format(NULL, filename, NULL);
 +            if (!oformat) {
 +                ret = AVERROR(EINVAL);
 +                av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
 +                       filename);
 +                goto error;
 +            }
 +        }
      }
 +
 +    s->oformat = oformat;
 +    if (s->oformat->priv_data_size > 0) {
 +        s->priv_data = av_mallocz(s->oformat->priv_data_size);
 +        if (!s->priv_data)
 +            goto nomem;
 +        if (s->oformat->priv_class) {
 +            *(const AVClass**)s->priv_data= s->oformat->priv_class;
 +            av_opt_set_defaults(s->priv_data);
 +        }
 +    } else
 +        s->priv_data = NULL;
 +
 +    if (filename)
 +        av_strlcpy(s->filename, filename, sizeof(s->filename));
 +    *avctx = s;
      return 0;
 +nomem:
 +    av_log(s, AV_LOG_ERROR, "Out of memory\n");
 +    ret = AVERROR(ENOMEM);
 +error:
 +    avformat_free_context(s);
 +    return ret;
 +}
 +
 +#if FF_API_ALLOC_OUTPUT_CONTEXT
 +AVFormatContext *avformat_alloc_output_context(const char *format,
 +                                               AVOutputFormat *oformat, const char *filename)
 +{
 +    AVFormatContext *avctx;
 +    int ret = avformat_alloc_output_context2(&avctx, oformat, format, filename);
 +    return ret < 0 ? NULL : avctx;
  }
  #endif
  
@@@ -24,8 -24,8 +24,8 @@@
  #include "libavutil/avutil.h"
  
  #define LIBAVFORMAT_VERSION_MAJOR 53
- #define LIBAVFORMAT_VERSION_MINOR  3
- #define LIBAVFORMAT_VERSION_MICRO  1
 -#define LIBAVFORMAT_VERSION_MINOR  2
++#define LIBAVFORMAT_VERSION_MINOR  4
+ #define LIBAVFORMAT_VERSION_MICRO  0
  
  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                 LIBAVFORMAT_VERSION_MINOR, \
@@@ -40,7 -40,7 +40,7 @@@
  #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
  
  #define LIBAVUTIL_VERSION_MAJOR 51
- #define LIBAVUTIL_VERSION_MINOR  8
 -#define LIBAVUTIL_VERSION_MINOR  7
++#define LIBAVUTIL_VERSION_MINOR  9
  #define LIBAVUTIL_VERSION_MICRO  0
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
Simple merge
Simple merge
Simple merge
diff --cc libavutil/log.h
Simple merge
diff --cc libavutil/opt.c
@@@ -259,9 -263,9 +262,9 @@@ const char *av_get_string(void *obj, co
  
  static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum)
  {
-     const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
+     const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
      void *dst;
 -    if (!o || o->offset<=0)
 +    if (!o || (o->offset<=0 && o->type != FF_OPT_TYPE_CONST))
          goto error;
  
      dst= ((uint8_t*)obj) + o->offset;
diff --cc libavutil/opt.h
Simple merge