]> git.sesse.net Git - ffmpeg/commitdiff
Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 10 Apr 2012 20:06:53 +0000 (22:06 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 10 Apr 2012 20:53:25 +0000 (22:53 +0200)
* qatar/master: (22 commits)
  rv40dsp x86: use only one register, for both increment and loop counter
  rv40dsp: implement prescaled versions for biweight.
  avconv: use default channel layouts when they are unknown
  avconv: parse channel layout string
  nutdec: K&R formatting cosmetics
  vda: Signal 4 byte NAL headers to the decoder regardless of what's in the extradata
  mem: Consistently return NULL for av_malloc(0)
  vf_overlay: implement poll_frame()
  vf_scale: support named constants for sws flags.
  lavc doxy: add all installed headers to doxy groups.
  lavc doxy: add avfft to the main lavc group.
  lavc doxy: add remaining avcodec.h functions to a misc doxygen group.
  lavc doxy: add AVPicture functions to a doxy group.
  lavc doxy: add resampling functions to a doxy group.
  lavc doxy: replace \ with /
  lavc doxy: add encoding functions to a doxy group.
  lavc doxy: add decoding functions to a doxy group.
  lavc doxy: fix formatting of AV_PKT_DATA_{PARAM_CHANGE,H263_MB_INFO}
  lavc doxy: add AVPacket-related stuff to a separate doxy group.
  lavc doxy: add core functions/definitions to a doxy group.
  ...

Conflicts:
ffmpeg.c
libavcodec/avcodec.h
libavcodec/vda.c
libavcodec/x86/rv40dsp.asm
libavfilter/vf_scale.c
libavformat/nutdec.c
libavutil/mem.c
tests/ref/acodec/pcm_s24daud

Merged-by: Michael Niedermayer <michaelni@gmx.at>
21 files changed:
1  2 
ffmpeg.c
libavcodec/avcodec.h
libavcodec/avfft.h
libavcodec/dxva2.h
libavcodec/ppc/gmc_altivec.c
libavcodec/ppc/int_altivec.c
libavcodec/rv34.c
libavcodec/rv34.h
libavcodec/rv40dsp.c
libavcodec/vaapi.h
libavcodec/vda.c
libavcodec/vda.h
libavcodec/vdpau.h
libavcodec/version.h
libavcodec/x86/rv40dsp.asm
libavcodec/xvmc.h
libavfilter/vf_overlay.c
libavfilter/vf_scale.c
libavformat/nutdec.c
tests/ref/acodec/pcm_s24daud
tests/ref/lavf/caf

diff --cc ffmpeg.c
index 0a2375d38ac831736d0fe44c2e029d67907c85cf,2cefe5d5497c3645e2e4ec999124a2cd05793df1..66f96ccebde78ea9c8f8b30aaa6deb45f01c92e1
+++ b/ffmpeg.c
@@@ -1279,24 -1145,21 +1279,24 @@@ static void do_audio_out(AVFormatContex
                  av_log(NULL, AV_LOG_VERBOSE, "compensating audio timestamp drift:%f compensation:%d in:%d\n",
                         delta, comp, enc->sample_rate);
  //                fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2));
 -                av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate);
 +                swr_set_compensation(ost->swr, comp, enc->sample_rate);
              }
          }
-     } else
+     } else if (audio_sync_method == 0)
 -        ost->sync_opts = lrintf(get_sync_ipts(ost, ist->last_dts) * enc->sample_rate) -
 +        ost->sync_opts = lrintf(get_sync_ipts(ost, ist->pts) * enc->sample_rate) -
                                  av_fifo_size(ost->fifo) / (enc->channels * osize); // FIXME wrong
  
 -    if (ost->audio_resample) {
 +    if (ost->audio_resample || ost->audio_channels_mapped) {
          buftmp = audio_buf;
 -        size_out = audio_resample(ost->resample,
 -                                  (short *)buftmp, (short *)buf,
 -                                  size / (dec->channels * isize));
 +        size_out = swr_convert(ost->swr, (      uint8_t*[]){buftmp}, allocated_audio_buf_size / (enc->channels * osize),
 +                                         buf, size / (dec->channels * isize));
 +        if (size_out < 0) {
 +            av_log(NULL, AV_LOG_FATAL, "swr_convert failed\n");
 +            exit_program(1);
 +        }
          size_out = size_out * enc->channels * osize;
      } else {
 -        buftmp = buf;
 +        buftmp = buf[0];
          size_out = size;
      }
  
@@@ -2331,7 -2193,8 +2376,9 @@@ static void get_default_channel_layouts
  static int init_input_stream(int ist_index, OutputStream *output_streams, int nb_output_streams,
                               char *error, int error_len)
  {
 -    int i;
      InputStream *ist = &input_streams[ist_index];
++    int i;
++
      if (ist->decoding_needed) {
          AVCodec *codec = ist->dec;
          if (!codec) {
          }
          assert_codec_experimental(ist->st->codec, 0);
          assert_avoptions(ist->opts);
+         if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+             for (i = 0; i < nb_output_streams; i++) {
+                 OutputStream *ost = &output_streams[i];
+                 if (ost->source_index == ist_index) {
+                     if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout)
+                         get_default_channel_layouts(ost, ist);
+                     break;
+                 }
+             }
+         }
      }
  
 -    ist->last_dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
 +    ist->dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
 +    ist->next_pts = AV_NOPTS_VALUE;
      ist->next_dts = AV_NOPTS_VALUE;
 -    init_pts_correction(&ist->pts_ctx);
      ist->is_start = 1;
  
      return 0;
@@@ -5047,10 -4553,10 +5140,11 @@@ static const OptionDef options[] = 
      { "ac", HAS_ARG | OPT_AUDIO | OPT_INT | OPT_SPEC, {.off = OFFSET(audio_channels)}, "set number of audio channels", "channels" },
      { "an", OPT_BOOL | OPT_AUDIO | OPT_OFFSET, {.off = OFFSET(audio_disable)}, "disable audio" },
      { "acodec", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" },
 -    { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
 +    { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_old2new}, "force audio tag/fourcc", "fourcc/tag" },
      { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
      { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING, {.off = OFFSET(sample_fmts)}, "set sample format", "format" },
 +    { "rmvol", HAS_ARG | OPT_AUDIO | OPT_FLOAT | OPT_SPEC, {.off = OFFSET(rematrix_volume)}, "rematrix volume (as factor)", "volume" },
+     { "channel_layout", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_channel_layout}, "set channel layout", "layout" },
  
      /* subtitle options */
      { "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off = OFFSET(subtitle_disable)}, "disable subtitle" },
index 56fc15cad1ff7f467fc47253c52d0ff001a7b207,92a5d0a173d33df6dc8b8209fa9cc8e80de05dc2..d905a019e0fe5135f88cf87218a8b5dbe5b785cd
@@@ -444,9 -432,10 +453,10 @@@ enum CodecID 
   * Note: If the first 23 bits of the additional bytes are not 0, then damaged
   * MPEG bitstreams could cause overread and segfault.
   */
 -#define FF_INPUT_BUFFER_PADDING_SIZE 8
 +#define FF_INPUT_BUFFER_PADDING_SIZE 16
  
  /**
+  * @ingroup lavc_encoding
   * minimum encoding buffer size
   * Used to avoid some checks during header writing.
   */
@@@ -3111,544 -3079,293 +3152,374 @@@ typedef struct AVSubtitle 
      int64_t pts;    ///< Same as packet pts, in AV_TIME_BASE
  } AVSubtitle;
  
- /* packet functions */
  /**
-  * @deprecated use NULL instead
+  * If c is NULL, returns the first registered codec,
+  * if c is non-NULL, returns the next registered codec after c,
+  * or NULL if c is the last one.
   */
attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
AVCodec *av_codec_next(AVCodec *c);
  
  /**
-  * Default packet destructor.
+  * Return the LIBAVCODEC_VERSION_INT constant.
   */
void av_destruct_packet(AVPacket *pkt);
unsigned avcodec_version(void);
  
  /**
-  * Initialize optional fields of a packet with default values.
-  *
-  * @param pkt packet
+  * Return the libavcodec build-time configuration.
   */
void av_init_packet(AVPacket *pkt);
const char *avcodec_configuration(void);
  
  /**
-  * Allocate the payload of a packet and initialize its fields with
-  * default values.
-  *
-  * @param pkt packet
-  * @param size wanted payload size
-  * @return 0 if OK, AVERROR_xxx otherwise
+  * Return the libavcodec license.
   */
int av_new_packet(AVPacket *pkt, int size);
const char *avcodec_license(void);
  
  /**
-  * Reduce packet size, correctly zeroing padding
+  * Register the codec codec and initialize libavcodec.
   *
-  * @param pkt packet
-  * @param size new size
+  * @warning either this function or avcodec_register_all() must be called
+  * before any other libavcodec functions.
+  *
+  * @see avcodec_register_all()
   */
- void av_shrink_packet(AVPacket *pkt, int size);
+ void avcodec_register(AVCodec *codec);
  
  /**
-  * Increase packet size, correctly zeroing padding
+  * Register all the codecs, parsers and bitstream filters which were enabled at
+  * configuration time. If you do not call this function you can select exactly
+  * which formats you want to support, by using the individual registration
+  * functions.
   *
-  * @param pkt packet
-  * @param grow_by number of bytes by which to increase the size of the packet
+  * @see avcodec_register
+  * @see av_register_codec_parser
+  * @see av_register_bitstream_filter
   */
int av_grow_packet(AVPacket *pkt, int grow_by);
void avcodec_register_all(void);
  
- /**
-  * @warning This is a hack - the packet memory allocation stuff is broken. The
-  * packet is allocated if it was not really allocated.
-  */
- int av_dup_packet(AVPacket *pkt);
 +
++#if FF_API_ALLOC_CONTEXT
 +/**
-  * Free a packet.
++ * Allocate an AVCodecContext and set its fields to default values.  The
++ * resulting struct can be deallocated by simply calling av_free().
 + *
-  * @param pkt packet to free
++ * @return An AVCodecContext filled with default values or NULL on failure.
++ * @see avcodec_get_context_defaults
++ *
++ * @deprecated use avcodec_alloc_context3()
 + */
- void av_free_packet(AVPacket *pkt);
++attribute_deprecated
++AVCodecContext *avcodec_alloc_context(void);
++
++/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
++ *  we WILL change its arguments and name a few times! */
++attribute_deprecated
++AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
 +
 +/**
-  * Allocate new information of a packet.
++ * Set the fields of the given AVCodecContext to default values.
 + *
-  * @param pkt packet
-  * @param type side information type
-  * @param size side information size
-  * @return pointer to fresh allocated data or NULL otherwise
++ * @param s The AVCodecContext of which the fields should be set to default values.
++ * @deprecated use avcodec_get_context_defaults3
 + */
- uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                                  int size);
++attribute_deprecated
++void avcodec_get_context_defaults(AVCodecContext *s);
++
++/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
++ *  we WILL change its arguments and name a few times! */
++attribute_deprecated
++void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
++#endif
 +
  /**
-  * Shrink the already allocated side data buffer
+  * Allocate an AVCodecContext and set its fields to default values.  The
+  * resulting struct can be deallocated by calling avcodec_close() on it followed
+  * by av_free().
   *
-  * @param pkt packet
-  * @param type side information type
-  * @param size new side information size
-  * @return 0 on success, < 0 on failure
+  * @param codec if non-NULL, allocate private data and initialize defaults
+  *              for the given codec. It is illegal to then call avcodec_open2()
+  *              with a different codec.
+  *              If NULL, then the codec-specific defaults won't be initialized,
+  *              which may result in suboptimal default settings (this is
+  *              important mainly for encoders, e.g. libx264).
+  *
+  * @return An AVCodecContext filled with default values or NULL on failure.
+  * @see avcodec_get_context_defaults
   */
- int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                                int size);
+ AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
  
  /**
-  * Get side information from packet.
+  * Set the fields of the given AVCodecContext to default values corresponding
+  * to the given codec (defaults may be codec-dependent).
   *
-  * @param pkt packet
-  * @param type desired side information type
-  * @param size pointer for side information size to store (optional)
-  * @return pointer to data if present or NULL otherwise
+  * Do not call this function if a non-NULL codec has been passed
+  * to avcodec_alloc_context3() that allocated this AVCodecContext.
+  * If codec is non-NULL, it is illegal to call avcodec_open2() with a
+  * different codec on this AVCodecContext.
   */
- uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                                  int *size);
- int av_packet_merge_side_data(AVPacket *pkt);
- int av_packet_split_side_data(AVPacket *pkt);
- /* resample.c */
- struct ReSampleContext;
- struct AVResampleContext;
- typedef struct ReSampleContext ReSampleContext;
+ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
  
  /**
-  *  Initialize audio resampling context.
+  * Get the AVClass for AVCodecContext. It can be used in combination with
+  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
   *
-  * @param output_channels  number of output channels
-  * @param input_channels   number of input channels
-  * @param output_rate      output sample rate
-  * @param input_rate       input sample rate
-  * @param sample_fmt_out   requested output sample format
-  * @param sample_fmt_in    input sample format
-  * @param filter_length    length of each FIR filter in the filterbank relative to the cutoff frequency
-  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
-  * @param linear           if 1 then the used FIR filter will be linearly interpolated
-                            between the 2 closest, if 0 the closest will be used
-  * @param cutoff           cutoff frequency, 1.0 corresponds to half the output sampling rate
-  * @return allocated ReSampleContext, NULL if error occurred
+  * @see av_opt_find().
   */
- ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
-                                         int output_rate, int input_rate,
-                                         enum AVSampleFormat sample_fmt_out,
-                                         enum AVSampleFormat sample_fmt_in,
-                                         int filter_length, int log2_phase_count,
-                                         int linear, double cutoff);
- int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
+ const AVClass *avcodec_get_class(void);
  
-  * Free resample context.
 +/**
-  * @param s a non-NULL pointer to a resample context previously
-  *          created with av_audio_resample_init()
++ * Get the AVClass for AVFrame. It can be used in combination with
++ * AV_OPT_SEARCH_FAKE_OBJ for examining options.
 + *
- void audio_resample_close(ReSampleContext *s);
++ * @see av_opt_find().
 + */
++const AVClass *avcodec_get_frame_class(void);
 +
  /**
-  * Initialize an audio resampler.
-  * Note, if either rate is not an integer then simply scale both rates up so they are.
-  * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
-  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
-  * @param linear If 1 then the used FIR filter will be linearly interpolated
-                  between the 2 closest, if 0 the closest will be used
-  * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
+  * Copy the settings of the source AVCodecContext into the destination
+  * AVCodecContext. The resulting destination codec context will be
+  * unopened, i.e. you are required to call avcodec_open2() before you
+  * can use this AVCodecContext to decode/encode video/audio data.
+  *
+  * @param dest target codec context, should be initialized with
+  *             avcodec_alloc_context3(), but otherwise uninitialized
+  * @param src source codec context
+  * @return AVERROR() on error (e.g. memory allocation error), 0 on success
   */
struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
  
  /**
-  * Resample an array of samples using a previously configured context.
-  * @param src an array of unconsumed samples
-  * @param consumed the number of samples of src which have been consumed are returned here
-  * @param src_size the number of unconsumed samples available
-  * @param dst_size the amount of space in samples available in dst
-  * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
-  * @return the number of samples written in dst or -1 if an error occurred
+  * Allocate an AVFrame and set its fields to default values.  The resulting
+  * struct can be deallocated by simply calling av_free().
+  *
+  * @return An AVFrame filled with default values or NULL on failure.
+  * @see avcodec_get_frame_defaults
   */
- int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
+ AVFrame *avcodec_alloc_frame(void);
  
  /**
-  * Compensate samplerate/timestamp drift. The compensation is done by changing
-  * the resampler parameters, so no audible clicks or similar distortions occur
-  * @param compensation_distance distance in output samples over which the compensation should be performed
-  * @param sample_delta number of output samples which should be output less
-  *
-  * example: av_resample_compensate(c, 10, 500)
-  * here instead of 510 samples only 500 samples would be output
+  * Set the fields of the given AVFrame to default values.
   *
-  * note, due to rounding the actual compensation might be slightly different,
-  * especially if the compensation_distance is large and the in_rate used during init is small
+  * @param pic The AVFrame of which the fields should be set to default values.
   */
- void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
- void av_resample_close(struct AVResampleContext *c);
+ void avcodec_get_frame_defaults(AVFrame *pic);
  
-  * Allocate memory for a picture.  Call avpicture_free() to free it.
++#if FF_API_AVCODEC_OPEN
 +/**
-  * @see avpicture_fill()
++ * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
++ * function the context has to be allocated.
 + *
-  * @param picture the picture to be filled in
-  * @param pix_fmt the format of the picture
-  * @param width the width of the picture
-  * @param height the height of the picture
-  * @return zero if successful, a negative value if not
-  */
- int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
- /**
-  * Free a picture previously allocated by avpicture_alloc().
-  * The data buffer used by the AVPicture is freed, but the AVPicture structure
-  * itself is not.
++ * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
++ * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
++ * retrieving a codec.
 + *
-  * @param picture the AVPicture to be freed
++ * @warning This function is not thread safe!
 + *
- void avpicture_free(AVPicture *picture);
++ * @code
++ * avcodec_register_all();
++ * codec = avcodec_find_decoder(CODEC_ID_H264);
++ * if (!codec)
++ *     exit(1);
++ *
++ * context = avcodec_alloc_context3(codec);
++ *
++ * if (avcodec_open(context, codec) < 0)
++ *     exit(1);
++ * @endcode
++ *
++ * @param avctx The context which will be set up to use the given codec.
++ * @param codec The codec to use within the context.
++ * @return zero on success, a negative value on error
++ * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
++ *
++ * @deprecated use avcodec_open2
 + */
++attribute_deprecated
++int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
++#endif
 +
  /**
-  * Fill in the AVPicture fields.
-  * The fields of the given AVPicture are filled in by using the 'ptr' address
-  * which points to the image data buffer. Depending on the specified picture
-  * format, one or multiple image data pointers and line sizes will be set.
-  * If a planar format is specified, several pointers will be set pointing to
-  * the different picture planes and the line sizes of the different planes
-  * will be stored in the lines_sizes array.
-  * Call with ptr == NULL to get the required size for the ptr buffer.
+  * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
+  * function the context has to be allocated with avcodec_alloc_context3().
   *
-  * To allocate the buffer and fill in the AVPicture fields in one call,
-  * use avpicture_alloc().
+  * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
+  * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
+  * retrieving a codec.
   *
-  * @param picture AVPicture whose fields are to be filled in
-  * @param ptr Buffer which will contain or contains the actual image data
-  * @param pix_fmt The format in which the picture data is stored.
-  * @param width the width of the image in pixels
-  * @param height the height of the image in pixels
-  * @return size of the image data in bytes
+  * @warning This function is not thread safe!
+  *
+  * @code
+  * avcodec_register_all();
+  * av_dict_set(&opts, "b", "2.5M", 0);
+  * codec = avcodec_find_decoder(CODEC_ID_H264);
+  * if (!codec)
+  *     exit(1);
+  *
+  * context = avcodec_alloc_context3(codec);
+  *
+  * if (avcodec_open2(context, codec, opts) < 0)
+  *     exit(1);
+  * @endcode
+  *
+  * @param avctx The context to initialize.
+  * @param codec The codec to open this context for. If a non-NULL codec has been
+  *              previously passed to avcodec_alloc_context3() or
+  *              avcodec_get_context_defaults3() for this context, then this
+  *              parameter MUST be either NULL or equal to the previously passed
+  *              codec.
+  * @param options A dictionary filled with AVCodecContext and codec-private options.
+  *                On return this object will be filled with options that were not found.
+  *
+  * @return zero on success, a negative value on error
+  * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
+  *      av_dict_set(), av_opt_find().
   */
- int avpicture_fill(AVPicture *picture, uint8_t *ptr,
-                    enum PixelFormat pix_fmt, int width, int height);
+ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
  
  /**
-  * Copy pixel data from an AVPicture into a buffer.
-  * The data is stored compactly, without any gaps for alignment or padding
-  * which may be applied by avpicture_fill().
-  *
-  * @see avpicture_get_size()
+  * Close a given AVCodecContext and free all the data associated with it
+  * (but not the AVCodecContext itself).
   *
-  * @param[in] src AVPicture containing image data
-  * @param[in] pix_fmt The format in which the picture data is stored.
-  * @param[in] width the width of the image in pixels.
-  * @param[in] height the height of the image in pixels.
-  * @param[out] dest A buffer into which picture data will be copied.
-  * @param[in] dest_size The size of 'dest'.
-  * @return The number of bytes written to dest, or a negative value (error code) on error.
+  * Calling this function on an AVCodecContext that hasn't been opened will free
+  * the codec-specific data allocated in avcodec_alloc_context3() /
+  * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
+  * do nothing.
   */
- int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
-                      unsigned char *dest, int dest_size);
+ int avcodec_close(AVCodecContext *avctx);
  
  /**
-  * Calculate the size in bytes that a picture of the given width and height
-  * would occupy if stored in the given picture format.
-  * Note that this returns the size of a compact representation as generated
-  * by avpicture_layout(), which can be smaller than the size required for e.g.
-  * avpicture_fill().
+  * Free all allocated data in the given subtitle struct.
   *
-  * @param pix_fmt the given picture format
-  * @param width the width of the image
-  * @param height the height of the image
-  * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
+  * @param sub AVSubtitle to free.
   */
- int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
- void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
+ void avsubtitle_free(AVSubtitle *sub);
  
  /**
-  * Get the name of a codec.
-  * @return  a static string identifying the codec; never NULL
+  * @}
   */
- const char *avcodec_get_name(enum CodecID id);
- void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  
  /**
-  * Return a value representing the fourCC code associated to the
-  * pixel format pix_fmt, or 0 if no associated fourCC code can be
-  * found.
+  * @addtogroup lavc_packet
+  * @{
   */
- unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
  
  /**
-  * Put a string representing the codec tag codec_tag in buf.
-  *
-  * @param buf_size size in bytes of buf
-  * @return the length of the string that would have been generated if
-  * enough space had been available, excluding the trailing null
+  * @deprecated use NULL instead
   */
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
  
- #define FF_LOSS_RESOLUTION  0x0001 /**< loss due to resolution change */
- #define FF_LOSS_DEPTH       0x0002 /**< loss due to color depth change */
- #define FF_LOSS_COLORSPACE  0x0004 /**< loss due to color space conversion */
- #define FF_LOSS_ALPHA       0x0008 /**< loss of alpha bits */
- #define FF_LOSS_COLORQUANT  0x0010 /**< loss due to color quantization */
- #define FF_LOSS_CHROMA      0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
+ /**
+  * Default packet destructor.
+  */
+ void av_destruct_packet(AVPacket *pkt);
  
  /**
-  * Compute what kind of losses will occur when converting from one specific
-  * pixel format to another.
-  * When converting from one pixel format to another, information loss may occur.
-  * For example, when converting from RGB24 to GRAY, the color information will
-  * be lost. Similarly, other losses occur when converting from some formats to
-  * other formats. These losses can involve loss of chroma, but also loss of
-  * resolution, loss of color depth, loss due to the color space conversion, loss
-  * of the alpha bits or loss due to color quantization.
-  * avcodec_get_fix_fmt_loss() informs you about the various types of losses
-  * which will occur when converting from one pixel format to another.
+  * Initialize optional fields of a packet with default values.
   *
-  * @param[in] dst_pix_fmt destination pixel format
-  * @param[in] src_pix_fmt source pixel format
-  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
-  * @return Combination of flags informing you what kind of losses will occur
-  * (maximum loss for an invalid dst_pix_fmt).
+  * @param pkt packet
   */
- int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
-                              int has_alpha);
+ void av_init_packet(AVPacket *pkt);
  
  /**
-  * Find the best pixel format to convert to given a certain source pixel
-  * format.  When converting from one pixel format to another, information loss
-  * may occur.  For example, when converting from RGB24 to GRAY, the color
-  * information will be lost. Similarly, other losses occur when converting from
-  * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
-  * the given pixel formats should be used to suffer the least amount of loss.
-  * The pixel formats from which it chooses one, are determined by the
-  * pix_fmt_mask parameter.
-  *
-  * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
-  *
-  * @code
-  * src_pix_fmt = PIX_FMT_YUV420P;
-  * pix_fmt_mask = (1 << PIX_FMT_YUV422P) | (1 << PIX_FMT_RGB24);
-  * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
-  * @endcode
+  * Allocate the payload of a packet and initialize its fields with
+  * default values.
   *
-  * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
-  * @param[in] src_pix_fmt source pixel format
-  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
-  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
-  * @return The best pixel format to convert to or -1 if none was found.
+  * @param pkt packet
+  * @param size wanted payload size
+  * @return 0 if OK, AVERROR_xxx otherwise
   */
- enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
-                               int has_alpha, int *loss_ptr);
+ int av_new_packet(AVPacket *pkt, int size);
  
  /**
-  * Find the best pixel format to convert to given a certain source pixel
-  * format and a selection of two destination pixel formats. When converting from
-  * one pixel format to another, information loss may occur.  For example, when converting
-  * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
-  * converting from some formats to other formats. avcodec_find_best_pix_fmt2() selects which of
-  * the given pixel formats should be used to suffer the least amount of loss.
-  *
-  * If one of the destination formats is PIX_FMT_NONE the other pixel format (if valid) will be
-  * returned.
-  *
-  * @code
-  * src_pix_fmt = PIX_FMT_YUV420P;
-  * dst_pix_fmt1= PIX_FMT_RGB24;
-  * dst_pix_fmt2= PIX_FMT_GRAY8;
-  * dst_pix_fmt3= PIX_FMT_RGB8;
-  * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
-  * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
-  * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
-  * @endcode
+  * Reduce packet size, correctly zeroing padding
   *
-  * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
-  * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
-  * @param[in] src_pix_fmt Source pixel format
-  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
-  * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
-  *                               NULL or value of zero means we care about all losses. Out: the loss
-  *                               that occurs when converting from src to selected dst pixel format.
-  * @return The best pixel format to convert to or -1 if none was found.
+  * @param pkt packet
+  * @param size new size
   */
- enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
-                                             enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
- /* deinterlace a picture */
- /* deinterlace - if not supported return -1 */
- int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
-                           enum PixelFormat pix_fmt, int width, int height);
- /* external high level API */
+ void av_shrink_packet(AVPacket *pkt, int size);
  
  /**
-  * If c is NULL, returns the first registered codec,
-  * if c is non-NULL, returns the next registered codec after c,
-  * or NULL if c is the last one.
+  * Increase packet size, correctly zeroing padding
+  *
+  * @param pkt packet
+  * @param grow_by number of bytes by which to increase the size of the packet
   */
AVCodec *av_codec_next(AVCodec *c);
int av_grow_packet(AVPacket *pkt, int grow_by);
  
  /**
-  * Return the LIBAVCODEC_VERSION_INT constant.
+  * @warning This is a hack - the packet memory allocation stuff is broken. The
+  * packet is allocated if it was not really allocated.
   */
unsigned avcodec_version(void);
int av_dup_packet(AVPacket *pkt);
  
  /**
-  * Return the libavcodec build-time configuration.
-  */
- const char *avcodec_configuration(void);
- /**
-  * Return the libavcodec license.
-  */
- const char *avcodec_license(void);
- /**
-  * Register the codec codec and initialize libavcodec.
-  *
-  * @warning either this function or avcodec_register_all() must be called
-  * before any other libavcodec functions.
-  *
-  * @see avcodec_register_all()
-  */
- void avcodec_register(AVCodec *codec);
- /**
-  * Find a registered encoder with a matching codec ID.
-  *
-  * @param id CodecID of the requested encoder
-  * @return An encoder if one was found, NULL otherwise.
-  */
- AVCodec *avcodec_find_encoder(enum CodecID id);
- /**
-  * Find a registered encoder with the specified name.
-  *
-  * @param name name of the requested encoder
-  * @return An encoder if one was found, NULL otherwise.
-  */
- AVCodec *avcodec_find_encoder_by_name(const char *name);
- /**
-  * Find a registered decoder with a matching codec ID.
+  * Free a packet.
   *
-  * @param id CodecID of the requested decoder
-  * @return A decoder if one was found, NULL otherwise.
+  * @param pkt packet to free
   */
AVCodec *avcodec_find_decoder(enum CodecID id);
void av_free_packet(AVPacket *pkt);
  
  /**
-  * Find a registered decoder with the specified name.
+  * Allocate new information of a packet.
   *
-  * @param name name of the requested decoder
-  * @return A decoder if one was found, NULL otherwise.
+  * @param pkt packet
+  * @param type side information type
+  * @param size side information size
+  * @return pointer to fresh allocated data or NULL otherwise
   */
- AVCodec *avcodec_find_decoder_by_name(const char *name);
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
+ uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
                                 int size);
  
  /**
-  * Return a name for the specified profile, if available.
+  * Shrink the already allocated side data buffer
   *
-  * @param codec the codec that is searched for the given profile
-  * @param profile the profile value for which a name is requested
-  * @return A name for the profile if found, NULL otherwise.
+  * @param pkt packet
+  * @param type side information type
+  * @param size new side information size
+  * @return 0 on success, < 0 on failure
   */
- const char *av_get_profile_name(const AVCodec *codec, int profile);
+ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
+                                int size);
  
- #if FF_API_ALLOC_CONTEXT
  /**
-  * Set the fields of the given AVCodecContext to default values.
+  * Get side information from packet.
   *
-  * @param s The AVCodecContext of which the fields should be set to default values.
-  * @deprecated use avcodec_get_context_defaults3
+  * @param pkt packet
+  * @param type desired side information type
+  * @param size pointer for side information size to store (optional)
+  * @return pointer to data if present or NULL otherwise
   */
- attribute_deprecated
- void avcodec_get_context_defaults(AVCodecContext *s);
- /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
-  *  we WILL change its arguments and name a few times! */
- attribute_deprecated
- void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
- #endif
+ uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
+                                  int *size);
  
- /**
-  * Set the fields of the given AVCodecContext to default values corresponding
-  * to the given codec (defaults may be codec-dependent).
-  *
-  * Do not call this function if a non-NULL codec has been passed
-  * to avcodec_alloc_context3() that allocated this AVCodecContext.
-  * If codec is non-NULL, it is illegal to call avcodec_open2() with a
-  * different codec on this AVCodecContext.
-  */
- int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
++int av_packet_merge_side_data(AVPacket *pkt);
 +
- #if FF_API_ALLOC_CONTEXT
- /**
-  * Allocate an AVCodecContext and set its fields to default values.  The
-  * resulting struct can be deallocated by simply calling av_free().
-  *
-  * @return An AVCodecContext filled with default values or NULL on failure.
-  * @see avcodec_get_context_defaults
-  *
-  * @deprecated use avcodec_alloc_context3()
-  */
- attribute_deprecated
- AVCodecContext *avcodec_alloc_context(void);
++int av_packet_split_side_data(AVPacket *pkt);
 +
- /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
-  *  we WILL change its arguments and name a few times! */
- attribute_deprecated
- AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
- #endif
 +
  /**
-  * Allocate an AVCodecContext and set its fields to default values.  The
-  * resulting struct can be deallocated by calling avcodec_close() on it followed
-  * by av_free().
-  *
-  * @param codec if non-NULL, allocate private data and initialize defaults
-  *              for the given codec. It is illegal to then call avcodec_open2()
-  *              with a different codec.
-  *              If NULL, then the codec-specific defaults won't be initialized,
-  *              which may result in suboptimal default settings (this is
-  *              important mainly for encoders, e.g. libx264).
-  *
-  * @return An AVCodecContext filled with default values or NULL on failure.
-  * @see avcodec_get_context_defaults
+  * @}
   */
- AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
  
  /**
-  * Copy the settings of the source AVCodecContext into the destination
-  * AVCodecContext. The resulting destination codec context will be
-  * unopened, i.e. you are required to call avcodec_open2() before you
-  * can use this AVCodecContext to decode/encode video/audio data.
-  *
-  * @param dest target codec context, should be initialized with
-  *             avcodec_alloc_context3(), but otherwise uninitialized
-  * @param src source codec context
-  * @return AVERROR() on error (e.g. memory allocation error), 0 on success
+  * @addtogroup lavc_decoding
+  * @{
   */
- int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
  
  /**
-  * Set the fields of the given AVFrame to default values.
+  * Find a registered decoder with a matching codec ID.
   *
-  * @param pic The AVFrame of which the fields should be set to default values.
+  * @param id CodecID of the requested decoder
+  * @return A decoder if one was found, NULL otherwise.
   */
void avcodec_get_frame_defaults(AVFrame *pic);
AVCodec *avcodec_find_decoder(enum CodecID id);
  
  /**
-  * Allocate an AVFrame and set its fields to default values.  The resulting
-  * struct can be deallocated by simply calling av_free().
+  * Find a registered decoder with the specified name.
   *
-  * @return An AVFrame filled with default values or NULL on failure.
-  * @see avcodec_get_frame_defaults
+  * @param name name of the requested decoder
+  * @return A decoder if one was found, NULL otherwise.
   */
- AVFrame *avcodec_alloc_frame(void);
+ AVCodec *avcodec_find_decoder_by_name(const char *name);
  
  int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
@@@ -4085,28 -3924,335 +4078,371 @@@ int avcodec_encode_video2(AVCodecContex
  int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
                              const AVSubtitle *sub);
  
  /**
-  * Close a given AVCodecContext and free all the data associated with it
-  * (but not the AVCodecContext itself).
+  * @}
+  */
+ /**
+  * @defgroup lavc_resample Audio resampling
+  * @ingroup libavc
   *
-  * Calling this function on an AVCodecContext that hasn't been opened will free
-  * the codec-specific data allocated in avcodec_alloc_context3() /
-  * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
-  * do nothing.
+  * @{
   */
- int avcodec_close(AVCodecContext *avctx);
+ struct ReSampleContext;
+ struct AVResampleContext;
+ typedef struct ReSampleContext ReSampleContext;
  
  /**
-  * Register all the codecs, parsers and bitstream filters which were enabled at
-  * configuration time. If you do not call this function you can select exactly
-  * which formats you want to support, by using the individual registration
-  * functions.
+  *  Initialize audio resampling context.
+  *
+  * @param output_channels  number of output channels
+  * @param input_channels   number of input channels
+  * @param output_rate      output sample rate
+  * @param input_rate       input sample rate
+  * @param sample_fmt_out   requested output sample format
+  * @param sample_fmt_in    input sample format
+  * @param filter_length    length of each FIR filter in the filterbank relative to the cutoff frequency
+  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
+  * @param linear           if 1 then the used FIR filter will be linearly interpolated
+                            between the 2 closest, if 0 the closest will be used
+  * @param cutoff           cutoff frequency, 1.0 corresponds to half the output sampling rate
+  * @return allocated ReSampleContext, NULL if error occurred
+  */
+ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
+                                         int output_rate, int input_rate,
+                                         enum AVSampleFormat sample_fmt_out,
+                                         enum AVSampleFormat sample_fmt_in,
+                                         int filter_length, int log2_phase_count,
+                                         int linear, double cutoff);
+ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
+ /**
+  * Free resample context.
+  *
+  * @param s a non-NULL pointer to a resample context previously
+  *          created with av_audio_resample_init()
+  */
+ void audio_resample_close(ReSampleContext *s);
+ /**
+  * Initialize an audio resampler.
+  * Note, if either rate is not an integer then simply scale both rates up so they are.
+  * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
+  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
+  * @param linear If 1 then the used FIR filter will be linearly interpolated
+                  between the 2 closest, if 0 the closest will be used
+  * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
+  */
+ struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
+ /**
+  * Resample an array of samples using a previously configured context.
+  * @param src an array of unconsumed samples
+  * @param consumed the number of samples of src which have been consumed are returned here
+  * @param src_size the number of unconsumed samples available
+  * @param dst_size the amount of space in samples available in dst
+  * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
+  * @return the number of samples written in dst or -1 if an error occurred
+  */
+ int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
+ /**
+  * Compensate samplerate/timestamp drift. The compensation is done by changing
+  * the resampler parameters, so no audible clicks or similar distortions occur
+  * @param compensation_distance distance in output samples over which the compensation should be performed
+  * @param sample_delta number of output samples which should be output less
+  *
+  * example: av_resample_compensate(c, 10, 500)
+  * here instead of 510 samples only 500 samples would be output
+  *
+  * note, due to rounding the actual compensation might be slightly different,
+  * especially if the compensation_distance is large and the in_rate used during init is small
+  */
+ void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
+ void av_resample_close(struct AVResampleContext *c);
+ /**
+  * @}
+  */
+ /**
+  * @addtogroup lavc_picture
+  * @{
+  */
+ /**
+  * Allocate memory for a picture.  Call avpicture_free() to free it.
+  *
+  * @see avpicture_fill()
+  *
+  * @param picture the picture to be filled in
+  * @param pix_fmt the format of the picture
+  * @param width the width of the picture
+  * @param height the height of the picture
+  * @return zero if successful, a negative value if not
+  */
+ int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
+ /**
+  * Free a picture previously allocated by avpicture_alloc().
+  * The data buffer used by the AVPicture is freed, but the AVPicture structure
+  * itself is not.
+  *
+  * @param picture the AVPicture to be freed
+  */
+ void avpicture_free(AVPicture *picture);
+ /**
+  * Fill in the AVPicture fields.
+  * The fields of the given AVPicture are filled in by using the 'ptr' address
+  * which points to the image data buffer. Depending on the specified picture
+  * format, one or multiple image data pointers and line sizes will be set.
+  * If a planar format is specified, several pointers will be set pointing to
+  * the different picture planes and the line sizes of the different planes
+  * will be stored in the lines_sizes array.
+  * Call with ptr == NULL to get the required size for the ptr buffer.
+  *
+  * To allocate the buffer and fill in the AVPicture fields in one call,
+  * use avpicture_alloc().
+  *
+  * @param picture AVPicture whose fields are to be filled in
+  * @param ptr Buffer which will contain or contains the actual image data
+  * @param pix_fmt The format in which the picture data is stored.
+  * @param width the width of the image in pixels
+  * @param height the height of the image in pixels
+  * @return size of the image data in bytes
+  */
+ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
+                    enum PixelFormat pix_fmt, int width, int height);
+ /**
+  * Copy pixel data from an AVPicture into a buffer.
+  * The data is stored compactly, without any gaps for alignment or padding
+  * which may be applied by avpicture_fill().
+  *
+  * @see avpicture_get_size()
+  *
+  * @param[in] src AVPicture containing image data
+  * @param[in] pix_fmt The format in which the picture data is stored.
+  * @param[in] width the width of the image in pixels.
+  * @param[in] height the height of the image in pixels.
+  * @param[out] dest A buffer into which picture data will be copied.
+  * @param[in] dest_size The size of 'dest'.
+  * @return The number of bytes written to dest, or a negative value (error code) on error.
+  */
+ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
+                      unsigned char *dest, int dest_size);
+ /**
+  * Calculate the size in bytes that a picture of the given width and height
+  * would occupy if stored in the given picture format.
+  * Note that this returns the size of a compact representation as generated
+  * by avpicture_layout(), which can be smaller than the size required for e.g.
+  * avpicture_fill().
+  *
+  * @param pix_fmt the given picture format
+  * @param width the width of the image
+  * @param height the height of the image
+  * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
+  */
+ int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
+ /**
+  *  deinterlace - if not supported return -1
+  */
+ int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
+                           enum PixelFormat pix_fmt, int width, int height);
+ /**
+  * Copy image src to dst. Wraps av_picture_data_copy() above.
+  */
+ void av_picture_copy(AVPicture *dst, const AVPicture *src,
+                      enum PixelFormat pix_fmt, int width, int height);
+ /**
+  * Crop image top and left side.
+  */
+ int av_picture_crop(AVPicture *dst, const AVPicture *src,
+                     enum PixelFormat pix_fmt, int top_band, int left_band);
+ /**
+  * Pad image.
+  */
+ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
+             int padtop, int padbottom, int padleft, int padright, int *color);
+ /**
+  * @}
+  */
+ /**
+  * @defgroup lavc_misc Utility functions
+  * @ingroup libavc
+  *
+  * Miscellaneous utility functions related to both encoding and decoding
+  * (or neither).
+  * @{
+  */
+ /**
+  * @defgroup lavc_misc_pixfmt Pixel formats
+  *
+  * Functions for working with pixel formats.
+  * @{
+  */
+ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
+ /**
+  * Return a value representing the fourCC code associated to the
+  * pixel format pix_fmt, or 0 if no associated fourCC code can be
+  * found.
+  */
+ unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
+ #define FF_LOSS_RESOLUTION  0x0001 /**< loss due to resolution change */
+ #define FF_LOSS_DEPTH       0x0002 /**< loss due to color depth change */
+ #define FF_LOSS_COLORSPACE  0x0004 /**< loss due to color space conversion */
+ #define FF_LOSS_ALPHA       0x0008 /**< loss of alpha bits */
+ #define FF_LOSS_COLORQUANT  0x0010 /**< loss due to color quantization */
+ #define FF_LOSS_CHROMA      0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
+ /**
+  * Compute what kind of losses will occur when converting from one specific
+  * pixel format to another.
+  * When converting from one pixel format to another, information loss may occur.
+  * For example, when converting from RGB24 to GRAY, the color information will
+  * be lost. Similarly, other losses occur when converting from some formats to
+  * other formats. These losses can involve loss of chroma, but also loss of
+  * resolution, loss of color depth, loss due to the color space conversion, loss
+  * of the alpha bits or loss due to color quantization.
+  * avcodec_get_fix_fmt_loss() informs you about the various types of losses
+  * which will occur when converting from one pixel format to another.
+  *
+  * @param[in] dst_pix_fmt destination pixel format
+  * @param[in] src_pix_fmt source pixel format
+  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
 - * @return Combination of flags informing you what kind of losses will occur.
++ * @return Combination of flags informing you what kind of losses will occur
++ * (maximum loss for an invalid dst_pix_fmt).
+  */
+ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
+                              int has_alpha);
+ /**
+  * Find the best pixel format to convert to given a certain source pixel
+  * format.  When converting from one pixel format to another, information loss
+  * may occur.  For example, when converting from RGB24 to GRAY, the color
+  * information will be lost. Similarly, other losses occur when converting from
+  * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
+  * the given pixel formats should be used to suffer the least amount of loss.
+  * The pixel formats from which it chooses one, are determined by the
+  * pix_fmt_mask parameter.
+  *
++ * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
++ *
+  * @code
+  * src_pix_fmt = PIX_FMT_YUV420P;
 - * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
++ * pix_fmt_mask = (1 << PIX_FMT_YUV422P) | (1 << PIX_FMT_RGB24);
+  * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
+  * @endcode
+  *
+  * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
+  * @param[in] src_pix_fmt source pixel format
+  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
+  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
+  * @return The best pixel format to convert to or -1 if none was found.
+  */
+ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
+                               int has_alpha, int *loss_ptr);
++/**
++ * Find the best pixel format to convert to given a certain source pixel
++ * format and a selection of two destination pixel formats. When converting from
++ * one pixel format to another, information loss may occur.  For example, when converting
++ * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
++ * converting from some formats to other formats. avcodec_find_best_pix_fmt2() selects which of
++ * the given pixel formats should be used to suffer the least amount of loss.
++ *
++ * If one of the destination formats is PIX_FMT_NONE the other pixel format (if valid) will be
++ * returned.
++ *
++ * @code
++ * src_pix_fmt = PIX_FMT_YUV420P;
++ * dst_pix_fmt1= PIX_FMT_RGB24;
++ * dst_pix_fmt2= PIX_FMT_GRAY8;
++ * dst_pix_fmt3= PIX_FMT_RGB8;
++ * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
++ * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
++ * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
++ * @endcode
++ *
++ * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
++ * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
++ * @param[in] src_pix_fmt Source pixel format
++ * @param[in] has_alpha Whether the source pixel format alpha channel is used.
++ * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
++ *                               NULL or value of zero means we care about all losses. Out: the loss
++ *                               that occurs when converting from src to selected dst pixel format.
++ * @return The best pixel format to convert to or -1 if none was found.
++ */
++enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
++                                            enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
++
+ enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
+ /**
+  * @}
+  */
+ void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
+ /**
+  * Put a string representing the codec tag codec_tag in buf.
+  *
+  * @param buf_size size in bytes of buf
+  * @return the length of the string that would have been generated if
+  * enough space had been available, excluding the trailing null
+  */
+ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
+ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
+ /**
+  * Return a name for the specified profile, if available.
+  *
+  * @param codec the codec that is searched for the given profile
+  * @param profile the profile value for which a name is requested
+  * @return A name for the profile if found, NULL otherwise.
+  */
+ const char *av_get_profile_name(const AVCodec *codec, int profile);
+ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
+ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
+ //FIXME func typedef
+ /**
+  * Fill audio frame data and linesize.
+  * AVFrame extended_data channel pointers are allocated if necessary for
+  * planar audio.
   *
-  * @see avcodec_register
-  * @see av_register_codec_parser
-  * @see av_register_bitstream_filter
+  * @param frame       the AVFrame
+  *                    frame->nb_samples must be set prior to calling the
+  *                    function. This function fills in frame->data,
+  *                    frame->extended_data, frame->linesize[0].
+  * @param nb_channels channel count
+  * @param sample_fmt  sample format
+  * @param buf         buffer to use for frame data
+  * @param buf_size    size of buffer
+  * @param align       plane size sample alignment (0 = default)
+  * @return            0 on success, negative error code on failure
   */
- void avcodec_register_all(void);
+ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
+                              enum AVSampleFormat sample_fmt, const uint8_t *buf,
+                              int buf_size, int align);
  
  /**
   * Flush buffers, should be called when seeking or when switching to a different stream.
@@@ -4504,22 -4427,6 +4625,12 @@@ int av_lockmgr_register(int (*cb)(void 
   */
  enum AVMediaType avcodec_get_type(enum CodecID codec_id);
  
-  * Get the AVClass for AVCodecContext. It can be used in combination with
-  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
-  *
-  * @see av_opt_find().
-  */
- const AVClass *avcodec_get_class(void);
- /**
-  * Get the AVClass for AVFrame. It can be used in combination with
-  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
-  *
-  * @see av_opt_find().
 +/**
- const AVClass *avcodec_get_frame_class(void);
++ * Get the name of a codec.
++ * @return  a static string identifying the codec; never NULL
 + */
++const char *avcodec_get_name(enum CodecID id);
 +
  /**
   * @return a positive value if s is open (i.e. avcodec_open2() was called on it
   * with no corresponding avcodec_close()), 0 otherwise.
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index a2814d702456cf2ca7356dda71875b47661c7521,3c03dcd3e013e3f8b76d3e2b7120321b939175b8..e910ce133293fab8ae578b3c03c8485da209491a
@@@ -144,25 -140,36 +144,60 @@@ int ff_vda_create_decoder(struct vda_co
      CFMutableDictionaryRef io_surface_properties;
      CFNumberRef cv_pix_fmt;
  
 +    vda_ctx->bitstream = NULL;
 +    vda_ctx->ref_size = 0;
 +
      pthread_mutex_init(&vda_ctx->queue_mutex, NULL);
  
++<<<<<<< HEAD
 +    if (extradata[4]==0xFE) {
 +        // convert 3 byte NAL sizes to 4 byte
 +        extradata[4] = 0xFF;
 +    }
 +
++||||||| merged common ancestors
++=======
+     /* Each VCL NAL in the bistream sent to the decoder
+      * is preceeded by a 4 bytes length header.
+      * Change the avcC atom header if needed, to signal headers of 4 bytes. */
+     if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) {
+         uint8_t *rw_extradata;
+         if (!(rw_extradata = av_malloc(extradata_size)))
+             return AVERROR(ENOMEM);
+         memcpy(rw_extradata, extradata, extradata_size);
+         rw_extradata[4] |= 0x03;
+         avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size);
+         av_freep(&rw_extradata);
+     } else {
+         avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
+     }
++>>>>>>> qatar/master
      config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                              4,
                                              &kCFTypeDictionaryKeyCallBacks,
                                              &kCFTypeDictionaryValueCallBacks);
  
++<<<<<<< HEAD
 +    height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height);
 +    width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width);
 +    format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format);
 +    avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
++||||||| merged common ancestors
++    height   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height);
++    width    = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width);
++    format   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format);
++    avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
++=======
+     height   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height);
+     width    = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width);
+     format   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format);
++>>>>>>> qatar/master
  
      CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
      CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
Simple merge
Simple merge
index 6c631d804520f158b6c4bafa484ab87b61d4eaf9,c35fce40e3aecdecc8b3a04723fa06563967f518..2429eb5e64ca43c7efc95c32b8baec03ed1fb44f
  #ifndef AVCODEC_VERSION_H
  #define AVCODEC_VERSION_H
  
+ /**
+  * @file
+  * @ingroup libavc
+  * Libavcodec version macros.
+  */
  #define LIBAVCODEC_VERSION_MAJOR 54
 -#define LIBAVCODEC_VERSION_MINOR 11
 -#define LIBAVCODEC_VERSION_MICRO  1
 +#define LIBAVCODEC_VERSION_MINOR  14
 +#define LIBAVCODEC_VERSION_MICRO 101
  
  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                 LIBAVCODEC_VERSION_MINOR, \
index c13e9f03d9d9c2a9a45da49d3a5eb9469426dd0e,721d3df094fdf8302d56333766dcf8eb99663892..e8acfb25feecdfbee29a9662046ab4ec74a59f20
@@@ -147,51 -148,33 +148,33 @@@ cglobal rv40_weight_func_%1_%2, 6, 7, 
      mova       m1, [pw_16]
  %endif
      pxor       m0, m0
-     mov        r6, r3
-     or         r6, r4
-     ; The weights are FP0.14 notation of fractions depending on pts.
-     ; For timebases without rounding error (i.e. PAL), the fractions
-     ; can be simplified, and several operations can be avoided.
-     ; Therefore, we check here whether they are multiples of 2^9 for
-     ; those simplifications to occur.
-     and        r6, 0x1FF
      ; Set loop counter and increments
- %if mmsize == 8
-     mov        r6, %1
- %else
-     mov        r6, (%1 * %1) / mmsize
- %endif
+     mov        r6, r5
+     shl        r6, %3
+     add        r0, r6
+     add        r1, r6
+     add        r2, r6
+     neg        r6
  
-     ; Use result of test now
-     jz .loop_512
 -    movd       m2, r3
 -    movd       m3, r4
 +    movd       m2, r3d
 +    movd       m3, r4d
+ %ifidn %1,rnd
+ %define  RND   0
      SPLATW     m2, m2
-     SPLATW     m3, m3
- .loop:
-     MAIN_LOOP  %1, 0
-     jnz        .loop
-     REP_RET
-     ; Weights are multiple of 512, which allows some shortcuts
- .loop_512:
-     sar        r3, 9
-     sar        r4, 9
-     movd       m2, r3d
-     movd       m3, r4d
+ %else
+ %define  RND   1
  %if cpuflag(ssse3)
      punpcklbw  m3, m2
-     SPLATW     m3, m3
  %else
      SPLATW     m2, m2
-     SPLATW     m3, m3
  %endif
- .loop2:
-     MAIN_LOOP  %1, 1
-     jnz        .loop2
-     REP_RET
+ %endif
+     SPLATW     m3, m3
  
+ .loop:
+     MAIN_LOOP  %2, RND
+     jnz        .loop
+     REP_RET
  %endmacro
  
  INIT_MMX mmx
Simple merge
index 04cacad6358a18cf27184fa2ad3f03f52df15348,e8171e0069f610e69c72b1d5e48c0cfc91233ca8..8227d35755456e4bb5a9e8509ac8f805e2175060
@@@ -539,8 -386,9 +551,9 @@@ AVFilter avfilter_vf_overlay = 
                                      .min_perms       = AV_PERM_READ,
                                      .rej_perms       = AV_PERM_REUSE2, },
                                    { .name = NULL}},
 -    .outputs   = (AVFilterPad[]) {{ .name            = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
-                                     .config_props    = config_output, },
+                                     .config_props    = config_output,
+                                     .poll_frame      = poll_frame },
                                    { .name = NULL}},
  };
index 86be86f3c965073c0ca9cc1a9d4b0b90515c38b4,85095b78d7a3ab6c031ddcd23d3b48254518ecc0..810a6d3ef10337a1cd75d18bc45868767a6c2b63
  #include "libavutil/avstring.h"
  #include "libavutil/eval.h"
  #include "libavutil/mathematics.h"
+ #include "libavutil/opt.h"
  #include "libavutil/pixdesc.h"
 +#include "libavutil/imgutils.h"
 +#include "libavutil/avassert.h"
  #include "libswscale/swscale.h"
  
  static const char *const var_names[] = {
@@@ -92,11 -92,15 +93,19 @@@ static av_cold int init(AVFilterContex
      if (args) {
          sscanf(args, "%255[^:]:%255[^:]", scale->w_expr, scale->h_expr);
          p = strstr(args,"flags=");
-         if (p) scale->flags = strtoul(p+6, NULL, 0);
+         if (p) {
+             const AVClass *class = sws_get_class();
+             const AVOption    *o = av_opt_find(&class, "sws_flags", NULL, 0,
+                                                AV_OPT_SEARCH_FAKE_OBJ);
+             int ret = av_opt_eval_flags(&class, o, p + 6, &scale->flags);
+             if (ret < 0)
+                 return ret;
+         }
 +        if(strstr(args,"interl=1")){
 +            scale->interlaced=1;
 +        }else if(strstr(args,"interl=-1"))
 +            scale->interlaced=-1;
      }
  
      return 0;
index 99e036d4a4a4047c31e33176b704c3381e26d2bb,32db763a6771373514a0ceaed2f5c5c712543fe1..6d51950e11d18a26f37c92e800711eab43416b15
@@@ -113,17 -131,19 +131,19 @@@ static int get_packetheader(NUTContext 
      return size;
  }
  
- static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos){
-     uint64_t state=0;
-     if(pos >= 0)
-         avio_seek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we currently are
-     while(!url_feof(bc)){
-         state= (state<<8) | avio_r8(bc);
-         if((state>>56) != 'N')
+ static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos)
+ {
+     uint64_t state = 0;
+     if (pos >= 0)
+         /* Note, this may fail if the stream is not seekable, but that should
+          * not matter, as in this case we simply start where we currently are */
+         avio_seek(bc, pos, SEEK_SET);
 -    while (!bc->eof_reached) {
++    while (!url_feof(bc)) {
+         state = (state << 8) | avio_r8(bc);
+         if ((state >> 56) != 'N')
              continue;
-         switch(state){
+         switch (state) {
          case MAIN_STARTCODE:
          case STREAM_STARTCODE:
          case SYNCPOINT_STARTCODE:
@@@ -774,27 -827,27 +827,27 @@@ static int nut_read_packet(AVFormatCont
  {
      NUTContext *nut = s->priv_data;
      AVIOContext *bc = s->pb;
-     int i, frame_code=0, ret, skip;
+     int i, frame_code = 0, ret, skip;
      int64_t ts, back_ptr;
  
-     for(;;){
-         int64_t pos= avio_tell(bc);
-         uint64_t tmp= nut->next_startcode;
-         nut->next_startcode=0;
+     for (;;) {
+         int64_t pos  = avio_tell(bc);
+         uint64_t tmp = nut->next_startcode;
+         nut->next_startcode = 0;
  
-         if(tmp){
-             pos-=8;
-         }else{
+         if (tmp) {
+             pos -= 8;
+         } else {
              frame_code = avio_r8(bc);
-             if(url_feof(bc))
 -            if (bc->eof_reached)
++            if (url_feof(bc))
                  return -1;
-             if(frame_code == 'N'){
-                 tmp= frame_code;
-                 for(i=1; i<8; i++)
-                     tmp = (tmp<<8) + avio_r8(bc);
+             if (frame_code == 'N') {
+                 tmp = frame_code;
+                 for (i = 1; i < 8; i++)
+                     tmp = (tmp << 8) + avio_r8(bc);
              }
          }
-         switch(tmp){
+         switch (tmp) {
          case MAIN_STARTCODE:
          case STREAM_STARTCODE:
          case INDEX_STARTCODE:
index 62c44219082894e10c30d72c8b972fbda9031aae,fb7cad1d89689d8c194b54f9a2a32123c7b8aeea..e1f22964fcd931a2ae66080c53996c2e6326e31d
@@@ -1,4 -1,4 +1,4 @@@
 -8168a5c1343553ef027541830f2cb879 *./tests/data/acodec/pcm_s24daud.302
 +1b75d5198ae789ab3c48f7024e08f4a9 *./tests/data/acodec/pcm_s24daud.302
  10368730 ./tests/data/acodec/pcm_s24daud.302
- 4708f86529c594e29404603c64bb208c *./tests/data/pcm_s24daud.acodec.out.wav
 -7ce988d6c5b2bf0ebf0216ba15bc5cee *./tests/data/pcm_s24daud.acodec.out.wav
 -stddev: 9416.28 PSNR: 16.85 MAXDIFF:42744 bytes:  6911796/  1058400
++70ec0ba6bc151ddc7509c09804d95d3b *./tests/data/pcm_s24daud.acodec.out.wav
 +stddev: 8967.92 PSNR: 17.28 MAXDIFF:42548 bytes:  6911796/  1058400
index 2e38f864f453ccda9fba22c83c360a8d3e19b2ac,0000000000000000000000000000000000000000..972b27cc19cced21cfac3ccbe68c7b183c32b91e
mode 100644,000000..100644
--- /dev/null
@@@ -1,3 -1,0 +1,3 @@@
- df9ebf2812784a653d3337cf12c0c687 *./tests/data/lavf/lavf.caf
- 90180 ./tests/data/lavf/lavf.caf
++71e1abdfc59613fe05fca2939f02e02d *./tests/data/lavf/lavf.caf
++90204 ./tests/data/lavf/lavf.caf
 +./tests/data/lavf/lavf.caf CRC=0xf1ae5536