Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 16 Aug 2012 14:12:45 +0000 (16:12 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 16 Aug 2012 14:20:30 +0000 (16:20 +0200)
* qatar/master:
  Fix even more missing includes after the common.h removal
  build: Factor out rangecoder dependencies to CONFIG_RANGECODER
  build: Factor out error resilience dependencies to CONFIG_ERROR_RESILIENCE
  x86: avcodec: Consistently name all init files
  Add more missing includes after removing the implicit common.h
  Add some more missing includes after removing the implicit common.h
  Don't include common.h from avutil.h
  rtmp: Automatically compute the hash for SWFVerification

Conflicts:
configure
doc/APIchanges
doc/examples/decoding_encoding.c
libavcodec/Makefile
libavcodec/assdec.c
libavcodec/audio_frame_queue.c
libavcodec/avpacket.c
libavcodec/dv_profile.c
libavcodec/dwt.c
libavcodec/libtheoraenc.c
libavcodec/rawdec.c
libavcodec/rv40dsp.c
libavcodec/tiff.c
libavcodec/tiffenc.c
libavcodec/v210dec.h
libavcodec/vc1dsp.c
libavcodec/x86/Makefile
libavfilter/asrc_anullsrc.c
libavfilter/avfilter.c
libavfilter/buffer.c
libavfilter/formats.c
libavfilter/vf_ass.c
libavfilter/vf_drawtext.c
libavfilter/vf_fade.c
libavfilter/vf_select.c
libavfilter/video.c
libavfilter/vsrc_testsrc.c
libavformat/version.h
libavutil/audioconvert.c
libavutil/error.h
libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
232 files changed:
1  2 
configure
doc/examples/decoding_encoding.c
doc/protocols.texi
libavcodec/8bps.c
libavcodec/8svx.c
libavcodec/Makefile
libavcodec/a64multienc.c
libavcodec/aac_ac3_parser.c
libavcodec/acelp_filters.c
libavcodec/acelp_pitch_delay.c
libavcodec/acelp_vectors.c
libavcodec/allcodecs.c
libavcodec/amr.h
libavcodec/amrwbdec.c
libavcodec/ansi.c
libavcodec/ass.c
libavcodec/assdec.c
libavcodec/assenc.c
libavcodec/atrac.c
libavcodec/audio_frame_queue.c
libavcodec/audioconvert.c
libavcodec/aura.c
libavcodec/avpacket.c
libavcodec/bitstream_filter.c
libavcodec/cavsdsp.c
libavcodec/celp_filters.c
libavcodec/celp_math.c
libavcodec/cinepak.c
libavcodec/codec_desc.c
libavcodec/cscd.c
libavcodec/cyuv.c
libavcodec/dct.c
libavcodec/dirac_parser.c
libavcodec/dnxhddata.c
libavcodec/dpxenc.c
libavcodec/dump_extradata_bsf.c
libavcodec/dv_profile.c
libavcodec/dvdsub_parser.c
libavcodec/dwt.c
libavcodec/dxa.c
libavcodec/eacmv.c
libavcodec/eaidct.c
libavcodec/elbg.c
libavcodec/faanidct.c
libavcodec/fmtconvert.c
libavcodec/g722enc.c
libavcodec/h264_mp4toannexb_bsf.c
libavcodec/h264dsp.c
libavcodec/h264idct_template.c
libavcodec/idcinvideo.c
libavcodec/iirfilter.c
libavcodec/imgconvert.c
libavcodec/intrax8dsp.c
libavcodec/jpegls.h
libavcodec/kgv1dec.c
libavcodec/lclenc.c
libavcodec/libfaac.c
libavcodec/libfdk-aacenc.c
libavcodec/libgsm.c
libavcodec/libilbc.c
libavcodec/libmp3lame.c
libavcodec/libopencore-amr.c
libavcodec/libspeexdec.c
libavcodec/libspeexenc.c
libavcodec/libtheoraenc.c
libavcodec/libvo-amrwbenc.c
libavcodec/libvpxdec.c
libavcodec/libvpxenc.c
libavcodec/libx264.c
libavcodec/lpc.c
libavcodec/lzw.c
libavcodec/mace.c
libavcodec/motion-test.c
libavcodec/movsub_bsf.c
libavcodec/mp3_header_compress_bsf.c
libavcodec/mp3_header_decompress_bsf.c
libavcodec/mpegaudio_parser.c
libavcodec/msvideo1.c
libavcodec/noise_bsf.c
libavcodec/nuv.c
libavcodec/options.c
libavcodec/options_table.h
libavcodec/parser.c
libavcodec/pnm.c
libavcodec/ppc/dsputil_ppc.c
libavcodec/ppc/fmtconvert_altivec.c
libavcodec/ppc/gmc_altivec.c
libavcodec/ppc/h264_altivec_template.c
libavcodec/ppc/vp8dsp_altivec.c
libavcodec/proresdsp.c
libavcodec/psymodel.c
libavcodec/pthread.c
libavcodec/ptx.c
libavcodec/qdrw.c
libavcodec/r210dec.c
libavcodec/ra144.c
libavcodec/ra288.h
libavcodec/raw.c
libavcodec/rawdec.c
libavcodec/rawenc.c
libavcodec/resample.c
libavcodec/resample2.c
libavcodec/rl2.c
libavcodec/rle.c
libavcodec/rpza.c
libavcodec/rtjpeg.h
libavcodec/rv40dsp.c
libavcodec/s302m.c
libavcodec/sinewin_tablegen.h
libavcodec/sipr.h
libavcodec/sipr16k.c
libavcodec/sparc/dsputil_vis.c
libavcodec/sparc/simple_idct_vis.c
libavcodec/srtdec.c
libavcodec/sunrast.c
libavcodec/targaenc.c
libavcodec/tiff.c
libavcodec/tiffenc.c
libavcodec/tmv.c
libavcodec/truemotion1.c
libavcodec/v210dec.c
libavcodec/v210x.c
libavcodec/v410dec.c
libavcodec/v410enc.c
libavcodec/vc1dsp.c
libavcodec/vcr1.c
libavcodec/vmdav.c
libavcodec/vmnc.c
libavcodec/vorbis_data.c
libavcodec/vp3dsp.c
libavcodec/vp56dsp.c
libavcodec/vp8dsp.c
libavcodec/ws-snd1.c
libavcodec/x86/Makefile
libavcodec/x86/idct_mmx_xvid.c
libavcodec/x86/idct_sse2_xvid.c
libavcodec/x86/lpc_mmx.c
libavcodec/x86/mlpdsp.c
libavcodec/x86/motion_est_mmx.c
libavcodec/x86/pngdsp_init.c
libavcodec/x86/proresdsp_init.c
libavcodec/x86/rv40dsp_init.c
libavcodec/x86/simple_idct_mmx.c
libavcodec/x86/vc1dsp_mmx.c
libavcodec/x86/vp8dsp_init.c
libavcodec/xbmenc.c
libavcodec/xl.c
libavcodec/zmbv.c
libavcodec/zmbvenc.c
libavdevice/avdevice.c
libavdevice/timefilter.c
libavfilter/af_aformat.c
libavfilter/af_amix.c
libavfilter/af_anull.c
libavfilter/af_asyncts.c
libavfilter/af_channelmap.c
libavfilter/af_channelsplit.c
libavfilter/af_join.c
libavfilter/allfilters.c
libavfilter/asink_anullsink.c
libavfilter/asrc_anullsrc.c
libavfilter/audio.c
libavfilter/avfilter.c
libavfilter/avfiltergraph.c
libavfilter/buffer.c
libavfilter/buffersink.c
libavfilter/buffersrc.c
libavfilter/drawutils.c
libavfilter/f_settb.c
libavfilter/fifo.c
libavfilter/formats.c
libavfilter/graphparser.c
libavfilter/split.c
libavfilter/vf_aspect.c
libavfilter/vf_blackframe.c
libavfilter/vf_boxblur.c
libavfilter/vf_copy.c
libavfilter/vf_crop.c
libavfilter/vf_cropdetect.c
libavfilter/vf_delogo.c
libavfilter/vf_drawbox.c
libavfilter/vf_drawtext.c
libavfilter/vf_fade.c
libavfilter/vf_fieldorder.c
libavfilter/vf_format.c
libavfilter/vf_fps.c
libavfilter/vf_gradfun.c
libavfilter/vf_hflip.c
libavfilter/vf_hqdn3d.c
libavfilter/vf_lut.c
libavfilter/vf_null.c
libavfilter/vf_overlay.c
libavfilter/vf_pad.c
libavfilter/vf_pixdesctest.c
libavfilter/vf_scale.c
libavfilter/vf_select.c
libavfilter/vf_setpts.c
libavfilter/vf_showinfo.c
libavfilter/vf_slicify.c
libavfilter/vf_transpose.c
libavfilter/vf_vflip.c
libavfilter/video.c
libavfilter/vsink_nullsink.c
libavfilter/vsrc_testsrc.c
libavfilter/x86/gradfun.c
libavfilter/x86/yadif.c
libavformat/network.c
libavformat/rtmpproto.c
libavformat/version.h
libavresample/utils.c
libavutil/audioconvert.c
libavutil/avstring.c
libavutil/dict.c
libavutil/error.c
libavutil/eval.c
libavutil/fifo.h
libavutil/file.c
libavutil/file.h
libavutil/imgutils.c
libavutil/log.c
libavutil/mem.h
libavutil/opt.c
libavutil/parseutils.c
libavutil/samplefmt.c
libavutil/samplefmt.h
libavutil/timer.h
libavutil/tree.c
libavutil/version.h
libswscale/colorspace-test.c
libswscale/swscale.h
libswscale/swscale_internal.h
tools/graph2dot.c

diff --cc configure
+++ b/configure
@@@ -1527,11 -1361,11 +1529,12 @@@ dnxhd_encoder_select="aandcttables mpeg
  dxa_decoder_select="zlib"
  eac3_decoder_select="ac3_decoder"
  eac3_encoder_select="mdct ac3dsp"
- eamad_decoder_select="aandcttables"
+ eamad_decoder_select="aandcttables error_resilience"
  eatgq_decoder_select="aandcttables"
- eatqi_decoder_select="aandcttables mpegvideo"
+ eatqi_decoder_select="aandcttables error_resilience mpegvideo"
 +exr_decoder_select="zlib"
- ffv1_decoder_select="golomb"
+ ffv1_decoder_select="golomb rangecoder"
+ ffv1_encoder_select="rangecoder"
  flac_decoder_select="golomb"
  flac_encoder_select="golomb lpc"
  flashsv_decoder_select="zlib"
@@@ -1548,8 -1381,7 +1551,8 @@@ h263_encoder_select="aandcttables error
  h263_vaapi_hwaccel_select="vaapi h263_decoder"
  h263i_decoder_select="h263_decoder"
  h263p_encoder_select="h263_encoder"
- h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
 +h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
+ h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  h264_dxva2_hwaccel_deps="dxva2api_h"
  h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  h264_vaapi_hwaccel_select="vaapi h264_decoder"
@@@ -1581,17 -1412,13 +1584,17 @@@ mpeg_vdpau_decoder_select="vdpau mpegvi
  mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  mpeg_xvmc_decoder_select="mpegvideo_decoder"
  mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
- mpeg1video_decoder_select="mpegvideo"
- mpeg1video_encoder_select="aandcttables mpegvideoenc"
 +mpeg1_vdpau_hwaccel_select="vdpau mpeg1video_decoder"
+ mpeg1video_decoder_select="error_resilience mpegvideo"
+ mpeg1video_encoder_select="aandcttables error_resilience mpegvideoenc"
 +mpeg2_crystalhd_decoder_select="crystalhd"
  mpeg2_dxva2_hwaccel_deps="dxva2api_h"
  mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
 +mpeg2_vdpau_hwaccel_select="vdpau mpeg2video_decoder"
  mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
- mpeg2video_decoder_select="mpegvideo"
- mpeg2video_encoder_select="aandcttables mpegvideoenc"
+ mpeg2video_decoder_select="error_resilience mpegvideo"
+ mpeg2video_encoder_select="aandcttables error_resilience mpegvideoenc"
 +mpeg4_crystalhd_decoder_select="crystalhd"
  mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  mpeg4_encoder_select="h263_encoder"
  mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
@@@ -1615,18 -1441,15 +1618,18 @@@ rv10_decoder_select="h263_decoder
  rv10_encoder_select="h263_encoder"
  rv20_decoder_select="h263_decoder"
  rv20_encoder_select="h263_encoder"
- rv30_decoder_select="golomb h264chroma h264pred h264qpel mpegvideo"
- rv40_decoder_select="golomb h264chroma h264pred h264qpel mpegvideo"
+ rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
+ rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  shorten_decoder_select="golomb"
  sipr_decoder_select="lsp"
- snow_decoder_select="dwt"
- snow_encoder_select="aandcttables dwt mpegvideoenc"
+ snow_decoder_select="dwt rangecoder"
+ snow_encoder_select="aandcttables dwt error_resilience mpegvideoenc rangecoder"
 +sonic_decoder_select="golomb"
 +sonic_encoder_select="golomb"
 +sonic_ls_encoder_select="golomb"
- svq1_decoder_select="mpegvideo"
- svq1_encoder_select="aandcttables mpegvideoenc"
- svq3_decoder_select="golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
+ svq1_decoder_select="error_resilience mpegvideo"
+ svq1_encoder_select="aandcttables error_resilience mpegvideoenc"
+ svq3_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  svq3_decoder_suggest="zlib"
  theora_decoder_select="vp3_decoder"
  tiff_decoder_suggest="zlib"
@@@ -1676,14 -1497,12 +1679,14 @@@ vda_deps="VideoDecodeAcceleration_VDADe
  vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  
  # parsers
- h264_parser_select="golomb h264dsp h264pred mpegvideo"
- mpeg4video_parser_select="mpegvideo"
- mpegvideo_parser_select="mpegvideo"
- vc1_parser_select="mpegvideo"
+ h264_parser_select="error_resilience golomb h264dsp h264pred mpegvideo"
+ mpeg4video_parser_select="error_resilience mpegvideo"
+ mpegvideo_parser_select="error_resilience mpegvideo"
+ vc1_parser_select="error_resilience mpegvideo"
  
  # external libraries
 +libaacplus_encoder_deps="libaacplus"
 +libcelt_decoder_deps="libcelt"
  libfaac_encoder_deps="libfaac"
  libfdk_aac_encoder_deps="libfdk_aac"
  libgsm_decoder_deps="libgsm"
index 919ee48,0000000..288432f
mode 100644,000000..100644
--- /dev/null
@@@ -1,600 -1,0 +1,601 @@@
 +/*
 + * Copyright (c) 2001 Fabrice Bellard
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a copy
 + * of this software and associated documentation files (the "Software"), to deal
 + * in the Software without restriction, including without limitation the rights
 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 + * copies of the Software, and to permit persons to whom the Software is
 + * furnished to do so, subject to the following conditions:
 + *
 + * The above copyright notice and this permission notice shall be included in
 + * all copies or substantial portions of the Software.
 + *
 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 + * THE SOFTWARE.
 + */
 +
 +/**
 + * @file
 + * libavcodec API use example.
 + *
 + * Note that libavcodec only handles codecs (mpeg, mpeg4, etc...),
 + * not file formats (avi, vob, mp4, mov, mkv, mxf, flv, mpegts, mpegps, etc...). See library 'libavformat' for the
 + * format handling
 + */
 +
 +#include <math.h>
 +
 +#include <libavutil/opt.h>
 +#include <libavcodec/avcodec.h>
 +#include <libavutil/audioconvert.h>
++#include <libavutil/common.h>
 +#include <libavutil/imgutils.h>
 +#include <libavutil/mathematics.h>
 +#include <libavutil/samplefmt.h>
 +
 +#define INBUF_SIZE 4096
 +#define AUDIO_INBUF_SIZE 20480
 +#define AUDIO_REFILL_THRESH 4096
 +
 +/* check that a given sample format is supported by the encoder */
 +static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt)
 +{
 +    const enum AVSampleFormat *p = codec->sample_fmts;
 +
 +    while (*p != AV_SAMPLE_FMT_NONE) {
 +        if (*p == sample_fmt)
 +            return 1;
 +        p++;
 +    }
 +    return 0;
 +}
 +
 +/* just pick the highest supported samplerate */
 +static int select_sample_rate(AVCodec *codec)
 +{
 +    const int *p;
 +    int best_samplerate = 0;
 +
 +    if (!codec->supported_samplerates)
 +        return 44100;
 +
 +    p = codec->supported_samplerates;
 +    while (*p) {
 +        best_samplerate = FFMAX(*p, best_samplerate);
 +        p++;
 +    }
 +    return best_samplerate;
 +}
 +
 +/* select layout with the highest channel count */
 +static int select_channel_layout(AVCodec *codec)
 +{
 +    const uint64_t *p;
 +    uint64_t best_ch_layout = 0;
 +    int best_nb_channells   = 0;
 +
 +    if (!codec->channel_layouts)
 +        return AV_CH_LAYOUT_STEREO;
 +
 +    p = codec->channel_layouts;
 +    while (*p) {
 +        int nb_channels = av_get_channel_layout_nb_channels(*p);
 +
 +        if (nb_channels > best_nb_channells) {
 +            best_ch_layout    = *p;
 +            best_nb_channells = nb_channels;
 +        }
 +        p++;
 +    }
 +    return best_ch_layout;
 +}
 +
 +/*
 + * Audio encoding example
 + */
 +static void audio_encode_example(const char *filename)
 +{
 +    AVCodec *codec;
 +    AVCodecContext *c= NULL;
 +    AVFrame *frame;
 +    AVPacket pkt;
 +    int i, j, k, ret, got_output;
 +    int buffer_size;
 +    FILE *f;
 +    uint16_t *samples;
 +    float t, tincr;
 +
 +    printf("Encode audio file %s\n", filename);
 +
 +    /* find the MP2 encoder */
 +    codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
 +    if (!codec) {
 +        fprintf(stderr, "codec not found\n");
 +        exit(1);
 +    }
 +
 +    c = avcodec_alloc_context3(codec);
 +
 +    /* put sample parameters */
 +    c->bit_rate = 64000;
 +
 +    /* check that the encoder supports s16 pcm input */
 +    c->sample_fmt = AV_SAMPLE_FMT_S16;
 +    if (!check_sample_fmt(codec, c->sample_fmt)) {
 +        fprintf(stderr, "encoder does not support %s",
 +                av_get_sample_fmt_name(c->sample_fmt));
 +        exit(1);
 +    }
 +
 +    /* select other audio parameters supported by the encoder */
 +    c->sample_rate    = select_sample_rate(codec);
 +    c->channel_layout = select_channel_layout(codec);
 +    c->channels       = av_get_channel_layout_nb_channels(c->channel_layout);
 +
 +    /* open it */
 +    if (avcodec_open2(c, codec, NULL) < 0) {
 +        fprintf(stderr, "could not open codec\n");
 +        exit(1);
 +    }
 +
 +    f = fopen(filename, "wb");
 +    if (!f) {
 +        fprintf(stderr, "could not open %s\n", filename);
 +        exit(1);
 +    }
 +
 +    /* frame containing input raw audio */
 +    frame = avcodec_alloc_frame();
 +    if (!frame) {
 +        fprintf(stderr, "could not allocate audio frame\n");
 +        exit(1);
 +    }
 +
 +    frame->nb_samples     = c->frame_size;
 +    frame->format         = c->sample_fmt;
 +    frame->channel_layout = c->channel_layout;
 +
 +    /* the codec gives us the frame size, in samples,
 +     * we calculate the size of the samples buffer in bytes */
 +    buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
 +                                             c->sample_fmt, 0);
 +    samples = av_malloc(buffer_size);
 +    if (!samples) {
 +        fprintf(stderr, "could not allocate %d bytes for samples buffer\n",
 +                buffer_size);
 +        exit(1);
 +    }
 +    /* setup the data pointers in the AVFrame */
 +    ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
 +                                   (const uint8_t*)samples, buffer_size, 0);
 +    if (ret < 0) {
 +        fprintf(stderr, "could not setup audio frame\n");
 +        exit(1);
 +    }
 +
 +    /* encode a single tone sound */
 +    t = 0;
 +    tincr = 2 * M_PI * 440.0 / c->sample_rate;
 +    for(i=0;i<200;i++) {
 +        av_init_packet(&pkt);
 +        pkt.data = NULL; // packet data will be allocated by the encoder
 +        pkt.size = 0;
 +
 +        for (j = 0; j < c->frame_size; j++) {
 +            samples[2*j] = (int)(sin(t) * 10000);
 +
 +            for (k = 1; k < c->channels; k++)
 +                samples[2*j + k] = samples[2*j];
 +            t += tincr;
 +        }
 +        /* encode the samples */
 +        ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
 +        if (ret < 0) {
 +            fprintf(stderr, "error encoding audio frame\n");
 +            exit(1);
 +        }
 +        if (got_output) {
 +            fwrite(pkt.data, 1, pkt.size, f);
 +            av_free_packet(&pkt);
 +        }
 +    }
 +    fclose(f);
 +
 +    av_freep(&samples);
 +    av_freep(&frame);
 +    avcodec_close(c);
 +    av_free(c);
 +}
 +
 +/*
 + * Audio decoding.
 + */
 +static void audio_decode_example(const char *outfilename, const char *filename)
 +{
 +    AVCodec *codec;
 +    AVCodecContext *c= NULL;
 +    int len;
 +    FILE *f, *outfile;
 +    uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
 +    AVPacket avpkt;
 +    AVFrame *decoded_frame = NULL;
 +
 +    av_init_packet(&avpkt);
 +
 +    printf("Decode audio file %s\n", filename);
 +
 +    /* find the mpeg audio decoder */
 +    codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
 +    if (!codec) {
 +        fprintf(stderr, "codec not found\n");
 +        exit(1);
 +    }
 +
 +    c = avcodec_alloc_context3(codec);
 +
 +    /* open it */
 +    if (avcodec_open2(c, codec, NULL) < 0) {
 +        fprintf(stderr, "could not open codec\n");
 +        exit(1);
 +    }
 +
 +    f = fopen(filename, "rb");
 +    if (!f) {
 +        fprintf(stderr, "could not open %s\n", filename);
 +        exit(1);
 +    }
 +    outfile = fopen(outfilename, "wb");
 +    if (!outfile) {
 +        av_free(c);
 +        exit(1);
 +    }
 +
 +    /* decode until eof */
 +    avpkt.data = inbuf;
 +    avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
 +
 +    while (avpkt.size > 0) {
 +        int got_frame = 0;
 +
 +        if (!decoded_frame) {
 +            if (!(decoded_frame = avcodec_alloc_frame())) {
 +                fprintf(stderr, "out of memory\n");
 +                exit(1);
 +            }
 +        } else
 +            avcodec_get_frame_defaults(decoded_frame);
 +
 +        len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
 +        if (len < 0) {
 +            fprintf(stderr, "Error while decoding\n");
 +            exit(1);
 +        }
 +        if (got_frame) {
 +            /* if a frame has been decoded, output it */
 +            int data_size = av_samples_get_buffer_size(NULL, c->channels,
 +                                                       decoded_frame->nb_samples,
 +                                                       c->sample_fmt, 1);
 +            fwrite(decoded_frame->data[0], 1, data_size, outfile);
 +        }
 +        avpkt.size -= len;
 +        avpkt.data += len;
 +        avpkt.dts =
 +        avpkt.pts = AV_NOPTS_VALUE;
 +        if (avpkt.size < AUDIO_REFILL_THRESH) {
 +            /* Refill the input buffer, to avoid trying to decode
 +             * incomplete frames. Instead of this, one could also use
 +             * a parser, or use a proper container format through
 +             * libavformat. */
 +            memmove(inbuf, avpkt.data, avpkt.size);
 +            avpkt.data = inbuf;
 +            len = fread(avpkt.data + avpkt.size, 1,
 +                        AUDIO_INBUF_SIZE - avpkt.size, f);
 +            if (len > 0)
 +                avpkt.size += len;
 +        }
 +    }
 +
 +    fclose(outfile);
 +    fclose(f);
 +
 +    avcodec_close(c);
 +    av_free(c);
 +    av_free(decoded_frame);
 +}
 +
 +/*
 + * Video encoding example
 + */
 +static void video_encode_example(const char *filename, int codec_id)
 +{
 +    AVCodec *codec;
 +    AVCodecContext *c= NULL;
 +    int i, ret, x, y, got_output;
 +    FILE *f;
 +    AVFrame *picture;
 +    AVPacket pkt;
 +    uint8_t endcode[] = { 0, 0, 1, 0xb7 };
 +
 +    printf("Encode video file %s\n", filename);
 +
 +    /* find the mpeg1 video encoder */
 +    codec = avcodec_find_encoder(codec_id);
 +    if (!codec) {
 +        fprintf(stderr, "codec not found\n");
 +        exit(1);
 +    }
 +
 +    c = avcodec_alloc_context3(codec);
 +    picture= avcodec_alloc_frame();
 +
 +    /* put sample parameters */
 +    c->bit_rate = 400000;
 +    /* resolution must be a multiple of two */
 +    c->width = 352;
 +    c->height = 288;
 +    /* frames per second */
 +    c->time_base= (AVRational){1,25};
 +    c->gop_size = 10; /* emit one intra frame every ten frames */
 +    c->max_b_frames=1;
 +    c->pix_fmt = PIX_FMT_YUV420P;
 +
 +    if(codec_id == AV_CODEC_ID_H264)
 +        av_opt_set(c->priv_data, "preset", "slow", 0);
 +
 +    /* open it */
 +    if (avcodec_open2(c, codec, NULL) < 0) {
 +        fprintf(stderr, "could not open codec\n");
 +        exit(1);
 +    }
 +
 +    f = fopen(filename, "wb");
 +    if (!f) {
 +        fprintf(stderr, "could not open %s\n", filename);
 +        exit(1);
 +    }
 +
 +    /* the image can be allocated by any means and av_image_alloc() is
 +     * just the most convenient way if av_malloc() is to be used */
 +    ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height,
 +                         c->pix_fmt, 32);
 +    if (ret < 0) {
 +        fprintf(stderr, "could not alloc raw picture buffer\n");
 +        exit(1);
 +    }
 +
 +    picture->format = c->pix_fmt;
 +    picture->width  = c->width;
 +    picture->height = c->height;
 +
 +    /* encode 1 second of video */
 +    for(i=0;i<25;i++) {
 +        av_init_packet(&pkt);
 +        pkt.data = NULL;    // packet data will be allocated by the encoder
 +        pkt.size = 0;
 +
 +        fflush(stdout);
 +        /* prepare a dummy image */
 +        /* Y */
 +        for(y=0;y<c->height;y++) {
 +            for(x=0;x<c->width;x++) {
 +                picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
 +            }
 +        }
 +
 +        /* Cb and Cr */
 +        for(y=0;y<c->height/2;y++) {
 +            for(x=0;x<c->width/2;x++) {
 +                picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
 +                picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
 +            }
 +        }
 +
 +        picture->pts = i;
 +
 +        /* encode the image */
 +        ret = avcodec_encode_video2(c, &pkt, picture, &got_output);
 +        if (ret < 0) {
 +            fprintf(stderr, "error encoding frame\n");
 +            exit(1);
 +        }
 +
 +        if (got_output) {
 +            printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
 +            fwrite(pkt.data, 1, pkt.size, f);
 +            av_free_packet(&pkt);
 +        }
 +    }
 +
 +    /* get the delayed frames */
 +    for (got_output = 1; got_output; i++) {
 +        fflush(stdout);
 +
 +        ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
 +        if (ret < 0) {
 +            fprintf(stderr, "error encoding frame\n");
 +            exit(1);
 +        }
 +
 +        if (got_output) {
 +            printf("write frame %3d (size=%5d)\n", i, pkt.size);
 +            fwrite(pkt.data, 1, pkt.size, f);
 +            av_free_packet(&pkt);
 +        }
 +    }
 +
 +    /* add sequence end code to have a real mpeg file */
 +    fwrite(endcode, 1, sizeof(endcode), f);
 +    fclose(f);
 +
 +    avcodec_close(c);
 +    av_free(c);
 +    av_freep(&picture->data[0]);
 +    av_free(picture);
 +    printf("\n");
 +}
 +
 +/*
 + * Video decoding example
 + */
 +
 +static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
 +                     char *filename)
 +{
 +    FILE *f;
 +    int i;
 +
 +    f=fopen(filename,"w");
 +    fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
 +    for(i=0;i<ysize;i++)
 +        fwrite(buf + i * wrap,1,xsize,f);
 +    fclose(f);
 +}
 +
 +static void video_decode_example(const char *outfilename, const char *filename)
 +{
 +    AVCodec *codec;
 +    AVCodecContext *c= NULL;
 +    int frame, got_picture, len;
 +    FILE *f;
 +    AVFrame *picture;
 +    uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
 +    char buf[1024];
 +    AVPacket avpkt;
 +
 +    av_init_packet(&avpkt);
 +
 +    /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
 +    memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
 +
 +    printf("Decode video file %s\n", filename);
 +
 +    /* find the mpeg1 video decoder */
 +    codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
 +    if (!codec) {
 +        fprintf(stderr, "codec not found\n");
 +        exit(1);
 +    }
 +
 +    c = avcodec_alloc_context3(codec);
 +    picture= avcodec_alloc_frame();
 +
 +    if(codec->capabilities&CODEC_CAP_TRUNCATED)
 +        c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
 +
 +    /* For some codecs, such as msmpeg4 and mpeg4, width and height
 +       MUST be initialized there because this information is not
 +       available in the bitstream. */
 +
 +    /* open it */
 +    if (avcodec_open2(c, codec, NULL) < 0) {
 +        fprintf(stderr, "could not open codec\n");
 +        exit(1);
 +    }
 +
 +    /* the codec gives us the frame size, in samples */
 +
 +    f = fopen(filename, "rb");
 +    if (!f) {
 +        fprintf(stderr, "could not open %s\n", filename);
 +        exit(1);
 +    }
 +
 +    frame = 0;
 +    for(;;) {
 +        avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
 +        if (avpkt.size == 0)
 +            break;
 +
 +        /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
 +           and this is the only method to use them because you cannot
 +           know the compressed data size before analysing it.
 +
 +           BUT some other codecs (msmpeg4, mpeg4) are inherently frame
 +           based, so you must call them with all the data for one
 +           frame exactly. You must also initialize 'width' and
 +           'height' before initializing them. */
 +
 +        /* NOTE2: some codecs allow the raw parameters (frame size,
 +           sample rate) to be changed at any frame. We handle this, so
 +           you should also take care of it */
 +
 +        /* here, we use a stream based decoder (mpeg1video), so we
 +           feed decoder and see if it could decode a frame */
 +        avpkt.data = inbuf;
 +        while (avpkt.size > 0) {
 +            len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
 +            if (len < 0) {
 +                fprintf(stderr, "Error while decoding frame %d\n", frame);
 +                exit(1);
 +            }
 +            if (got_picture) {
 +                printf("saving frame %3d\n", frame);
 +                fflush(stdout);
 +
 +                /* the picture is allocated by the decoder. no need to
 +                   free it */
 +                snprintf(buf, sizeof(buf), outfilename, frame);
 +                pgm_save(picture->data[0], picture->linesize[0],
 +                         c->width, c->height, buf);
 +                frame++;
 +            }
 +            avpkt.size -= len;
 +            avpkt.data += len;
 +        }
 +    }
 +
 +    /* some codecs, such as MPEG, transmit the I and P frame with a
 +       latency of one frame. You must do the following to have a
 +       chance to get the last frame of the video */
 +    avpkt.data = NULL;
 +    avpkt.size = 0;
 +    len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
 +    if (got_picture) {
 +        printf("saving last frame %3d\n", frame);
 +        fflush(stdout);
 +
 +        /* the picture is allocated by the decoder. no need to
 +           free it */
 +        snprintf(buf, sizeof(buf), outfilename, frame);
 +        pgm_save(picture->data[0], picture->linesize[0],
 +                 c->width, c->height, buf);
 +        frame++;
 +    }
 +
 +    fclose(f);
 +
 +    avcodec_close(c);
 +    av_free(c);
 +    av_free(picture);
 +    printf("\n");
 +}
 +
 +int main(int argc, char **argv)
 +{
 +    const char *filename;
 +
 +    /* register all the codecs */
 +    avcodec_register_all();
 +
 +    if (argc <= 1) {
 +        audio_encode_example("/tmp/test.mp2");
 +        audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
 +
 +        video_encode_example("/tmp/test.h264", AV_CODEC_ID_H264);
 +        video_encode_example("/tmp/test.mpg", AV_CODEC_ID_MPEG1VIDEO);
 +        filename = "/tmp/test.mpg";
 +    } else {
 +        filename = argv[1];
 +    }
 +
 +    //    audio_decode_example("/tmp/test.sw", filename);
 +    video_decode_example("/tmp/test%d.pgm", filename);
 +
 +    return 0;
 +}
Simple merge
Simple merge
   *
   * supports: fibonacci delta encoding
   *         : exponential encoding
 + *
 + * For more information about the 8SVX format:
 + * http://netghost.narod.ru/gff/vendspec/iff/iff.txt
 + * http://sox.sourceforge.net/AudioFormats-11.html
 + * http://aminet.net/package/mus/misc/wavepak
 + * http://amigan.1emu.net/reg/8SVX.txt
 + *
 + * Samples can be found here:
 + * http://aminet.net/mods/smpl/
   */
  
 +#include "libavutil/avassert.h"
  #include "avcodec.h"
+ #include "libavutil/common.h"
  
  /** decoder context */
  typedef struct EightSvxContext {
@@@ -36,11 -33,11 +36,12 @@@ OBJS = allcodecs.
  # parts needed for many different codecs
  OBJS-$(CONFIG_AANDCTTABLES)            += aandcttab.o
  OBJS-$(CONFIG_AC3DSP)                  += ac3dsp.o
 +OBJS-$(CONFIG_CRYSTALHD)               += crystalhd.o
  OBJS-$(CONFIG_ENCODERS)                += faandct.o jfdctfst.o jfdctint.o
  OBJS-$(CONFIG_DCT)                     += dct.o dct32_fixed.o dct32_float.o
 -OBJS-$(CONFIG_DWT)                     += dwt.o
 +OBJS-$(CONFIG_DWT)                     += dwt.o snow.o
  OBJS-$(CONFIG_DXVA2)                   += dxva2.o
+ OBJS-$(CONFIG_ERROR_RESILIENCE)        += error_resilience.o
  FFT-OBJS-$(CONFIG_HARDCODED_TABLES)    += cos_tables.o cos_fixed_tables.o
  OBJS-$(CONFIG_FFT)                     += avfft.o fft_fixed.o fft_float.o \
                                            $(FFT-OBJS-yes)
@@@ -173,18 -157,14 +175,18 @@@ OBJS-$(CONFIG_EIGHTBPS_DECODER)        
  OBJS-$(CONFIG_EIGHTSVX_EXP_DECODER)    += 8svx.o
  OBJS-$(CONFIG_EIGHTSVX_FIB_DECODER)    += 8svx.o
  OBJS-$(CONFIG_ESCAPE124_DECODER)       += escape124.o
- OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o rangecoder.o
- OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
 +OBJS-$(CONFIG_ESCAPE130_DECODER)       += escape130.o
 +OBJS-$(CONFIG_EXR_DECODER)             += exr.o
+ OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o
+ OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o
  OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o
  OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o
 +OBJS-$(CONFIG_FFWAVESYNTH_DECODER)     += ffwavesynth.o
  OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o flacdsp.o
 -OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o
 +OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o vorbis_data.o
  OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
  OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
 +OBJS-$(CONFIG_FLASHSV2_ENCODER)        += flashsv2enc.o
  OBJS-$(CONFIG_FLASHSV2_DECODER)        += flashsv.o
  OBJS-$(CONFIG_FLIC_DECODER)            += flicvideo.o
  OBJS-$(CONFIG_FOURXM_DECODER)          += 4xm.o
@@@ -198,15 -176,14 +200,14 @@@ OBJS-$(CONFIG_GIF_DECODER)             
  OBJS-$(CONFIG_GIF_ENCODER)             += gif.o lzwenc.o
  OBJS-$(CONFIG_GSM_DECODER)             += gsmdec.o gsmdec_data.o msgsmdec.o
  OBJS-$(CONFIG_GSM_MS_DECODER)          += gsmdec.o gsmdec_data.o msgsmdec.o
- OBJS-$(CONFIG_H261_DECODER)            += h261dec.o h261.o h261data.o error_resilience.o
 -OBJS-$(CONFIG_H261_DECODER)            += h261dec.o h261.o
 -OBJS-$(CONFIG_H261_ENCODER)            += h261enc.o h261.o
++OBJS-$(CONFIG_H261_DECODER)            += h261dec.o h261.o h261data.o
 +OBJS-$(CONFIG_H261_ENCODER)            += h261enc.o h261.o h261data.o
  OBJS-$(CONFIG_H263_DECODER)            += h263dec.o h263.o ituh263dec.o        \
                                            mpeg4video.o mpeg4videodec.o flvdec.o\
-                                           intelh263dec.o  error_resilience.o
+                                           intelh263dec.o
  OBJS-$(CONFIG_H263_VAAPI_HWACCEL)      += vaapi_mpeg4.o
  OBJS-$(CONFIG_H263_ENCODER)            += mpeg4videoenc.o mpeg4video.o  \
-                                           h263.o ituh263enc.o flvenc.o  \
-                                           error_resilience.o
+                                           h263.o ituh263enc.o flvenc.o
  OBJS-$(CONFIG_H264_DECODER)            += h264.o                               \
                                            h264_loopfilter.o h264_direct.o      \
                                            cabac.o h264_sei.o h264_ps.o         \
@@@ -243,9 -215,7 +243,8 @@@ OBJS-$(CONFIG_LJPEG_ENCODER)           
  OBJS-$(CONFIG_LOCO_DECODER)            += loco.o
  OBJS-$(CONFIG_MACE3_DECODER)           += mace.o
  OBJS-$(CONFIG_MACE6_DECODER)           += mace.o
- OBJS-$(CONFIG_MDEC_DECODER)            += mdec.o mpeg12.o mpeg12data.o \
-                                           error_resilience.o
+ OBJS-$(CONFIG_MDEC_DECODER)            += mdec.o mpeg12.o mpeg12data.o
 +OBJS-$(CONFIG_MICRODVD_DECODER)        += microdvddec.o ass.o
  OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o
  OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o mjpeg.o
  OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o mjpeg.o
@@@ -285,21 -253,13 +284,17 @@@ OBJS-$(CONFIG_MPC7_DECODER)            
  OBJS-$(CONFIG_MPC8_DECODER)            += mpc8.o mpc.o mpegaudiodec.o      \
                                            mpegaudiodecheader.o mpegaudio.o \
                                            mpegaudiodata.o
 +OBJS-$(CONFIG_MPEGVIDEO_DECODER)       += mpeg12.o mpeg12data.o \
 +                                          mpegvideo.o error_resilience.o
  OBJS-$(CONFIG_MPEG_XVMC_DECODER)       += mpegvideo_xvmc.o
- OBJS-$(CONFIG_MPEG1VIDEO_DECODER)      += mpeg12.o mpeg12data.o \
-                                           error_resilience.o
+ OBJS-$(CONFIG_MPEG1VIDEO_DECODER)      += mpeg12.o mpeg12data.o
 -OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
 +OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o          \
-                                           timecode.o                  \
-                                           error_resilience.o
++                                          timecode.o
  OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)     += dxva2_mpeg2.o
  OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)     += vaapi_mpeg2.o
- OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12.o mpeg12data.o \
-                                           error_resilience.o
+ OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12.o mpeg12data.o
 -OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
 +OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o          \
-                                           timecode.o                  \
-                                           error_resilience.o
++                                          timecode.o
  OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL)     += vaapi_mpeg4.o
  OBJS-$(CONFIG_MSMPEG4V1_DECODER)       += msmpeg4.o msmpeg4data.o
  OBJS-$(CONFIG_MSMPEG4V2_DECODER)       += msmpeg4.o msmpeg4data.o h263dec.o \
@@@ -380,13 -331,9 +375,11 @@@ OBJS-$(CONFIG_RV10_DECODER)            
  OBJS-$(CONFIG_RV10_ENCODER)            += rv10enc.o
  OBJS-$(CONFIG_RV20_DECODER)            += rv10.o
  OBJS-$(CONFIG_RV20_ENCODER)            += rv20enc.o
- OBJS-$(CONFIG_RV30_DECODER)            += rv30.o rv34.o rv30dsp.o rv34dsp.o \
-                                           error_resilience.o
- OBJS-$(CONFIG_RV40_DECODER)            += rv40.o rv34.o rv34dsp.o rv40dsp.o \
-                                           error_resilience.o
+ OBJS-$(CONFIG_RV30_DECODER)            += rv30.o rv34.o rv30dsp.o rv34dsp.o
+ OBJS-$(CONFIG_RV40_DECODER)            += rv40.o rv34.o rv34dsp.o rv40dsp.o
 +OBJS-$(CONFIG_SAMI_DECODER)            += samidec.o ass.o
  OBJS-$(CONFIG_S302M_DECODER)           += s302m.o
 +OBJS-$(CONFIG_SANM_DECODER)            += sanm.o
  OBJS-$(CONFIG_SGI_DECODER)             += sgidec.o
  OBJS-$(CONFIG_SGI_ENCODER)             += sgienc.o rle.o
  OBJS-$(CONFIG_SHORTEN_DECODER)         += shorten.o
@@@ -397,27 -344,17 +390,24 @@@ OBJS-$(CONFIG_SIPR_DECODER)            
  OBJS-$(CONFIG_SMACKAUD_DECODER)        += smacker.o
  OBJS-$(CONFIG_SMACKER_DECODER)         += smacker.o
  OBJS-$(CONFIG_SMC_DECODER)             += smc.o
- OBJS-$(CONFIG_SNOW_DECODER)            += snowdec.o snow.o rangecoder.o
- OBJS-$(CONFIG_SNOW_ENCODER)            += snowenc.o snow.o rangecoder.o    \
-                                           h263.o ituh263enc.o          \
-                                           error_resilience.o
+ OBJS-$(CONFIG_SNOW_DECODER)            += snowdec.o snow.o
+ OBJS-$(CONFIG_SNOW_ENCODER)            += snowenc.o snow.o              \
+                                           h263.o ituh263enc.o
  OBJS-$(CONFIG_SOL_DPCM_DECODER)        += dpcm.o
 +OBJS-$(CONFIG_SONIC_DECODER)           += sonic.o
 +OBJS-$(CONFIG_SONIC_ENCODER)           += sonic.o
 +OBJS-$(CONFIG_SONIC_LS_ENCODER)        += sonic.o
  OBJS-$(CONFIG_SP5X_DECODER)            += sp5xdec.o mjpegdec.o mjpeg.o
  OBJS-$(CONFIG_SRT_DECODER)             += srtdec.o ass.o
 +OBJS-$(CONFIG_SRT_ENCODER)             += srtenc.o ass_split.o
 +OBJS-$(CONFIG_SUBRIP_DECODER)          += srtdec.o ass.o
 +OBJS-$(CONFIG_SUBRIP_ENCODER)          += srtenc.o ass_split.o
 +OBJS-$(CONFIG_SUBVIEWER_DECODER)       += subviewerdec.o ass.o
  OBJS-$(CONFIG_SUNRAST_DECODER)         += sunrast.o
  OBJS-$(CONFIG_SUNRAST_ENCODER)         += sunrastenc.o
- OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o h263.o \
-                                           error_resilience.o
+ OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o h263.o
  OBJS-$(CONFIG_SVQ1_ENCODER)            += svq1enc.o svq1.o    \
-                                           h263.o ituh263enc.o \
-                                           error_resilience.o
+                                           h263.o ituh263enc.o
  OBJS-$(CONFIG_SVQ3_DECODER)            += h264.o svq3.o                       \
                                            h264_loopfilter.o h264_direct.o     \
                                            h264_sei.o h264_ps.o h264_refs.o    \
@@@ -721,10 -628,8 +709,9 @@@ OBJS-$(CONFIG_AAC_LATM_PARSER)         
  OBJS-$(CONFIG_MJPEG_PARSER)            += mjpeg_parser.o
  OBJS-$(CONFIG_MLP_PARSER)              += mlp_parser.o mlp.o
  OBJS-$(CONFIG_MPEG4VIDEO_PARSER)       += mpeg4video_parser.o h263.o \
-                                           error_resilience.o \
                                            mpeg4videodec.o mpeg4video.o \
                                            ituh263dec.o h263dec.o
 +OBJS-$(CONFIG_PNG_PARSER)              += png_parser.o
  OBJS-$(CONFIG_MPEGAUDIO_PARSER)        += mpegaudio_parser.o \
                                            mpegaudiodecheader.o mpegaudiodata.o
  OBJS-$(CONFIG_MPEGVIDEO_PARSER)        += mpegvideo_parser.o    \
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #include "avcodec.h"
  #include "ass.h"
  #include "libavutil/avstring.h"
+ #include "libavutil/common.h"
  
 -/**
 - * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
 - *
 - * @param avctx pointer to the AVCodecContext
 - * @param font name of the default font face to use
 - * @param font_size default font size to use
 - * @param color default text color to use (ABGR)
 - * @param back_color default background color to use (ABGR)
 - * @param bold 1 for bold text, 0 for normal text
 - * @param italic 1 for italic text, 0 for normal text
 - * @param underline 1 for underline text, 0 for normal text
 - * @param alignment position of the text (left, center, top...), defined after
 - *                  the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top)
 - * @return >= 0 on success otherwise an error code <0
 - */
 -static int ff_ass_subtitle_header(AVCodecContext *avctx,
 -                                  const char *font, int font_size,
 -                                  int color, int back_color,
 -                                  int bold, int italic, int underline,
 -                                  int alignment)
 +int ff_ass_subtitle_header(AVCodecContext *avctx,
 +                           const char *font, int font_size,
 +                           int color, int back_color,
 +                           int bold, int italic, int underline,
 +                           int alignment)
  {
 -    char header[512];
 -
 -    snprintf(header, sizeof(header),
 +    avctx->subtitle_header = av_asprintf(
               "[Script Info]\r\n"
               "ScriptType: v4.00+\r\n"
               "\r\n"
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include <string.h>
  #include "avcodec.h"
  #include "ass.h"
 +#include "ass_split.h"
+ #include "libavutil/internal.h"
+ #include "libavutil/mem.h"
  
  static av_cold int ass_decode_init(AVCodecContext *avctx)
  {
Simple merge
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 -#include "libavutil/mathematics.h"
 -#include "internal.h"
+ #include "libavutil/common.h"
  #include "audio_frame_queue.h"
 +#include "internal.h"
 +#include "libavutil/avassert.h"
  
  void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
  {
Simple merge
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
- #include "internal.h"
+ #include <string.h>
  #include "libavutil/avassert.h"
- #include "bytestream.h"
+ #include "libavutil/mem.h"
  #include "avcodec.h"
++#include "bytestream.h"
++#include "internal.h"
  
  void av_destruct_packet_nofree(AVPacket *pkt)
  {
Simple merge
Simple merge
Simple merge
  
  #include <inttypes.h>
  #include <limits.h>
 -#include <assert.h>
  
 +#include "libavutil/avassert.h"
  #include "avcodec.h"
 +#include "mathops.h"
  #include "celp_math.h"
+ #include "libavutil/common.h"
  
 +#ifdef G729_BITEXACT
 +/**
 + * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
 + */
 +static const int16_t base_cos[64] =
 +{
 +  32767,  32729,  32610,  32413,  32138,  31786,  31357,  30853,
 +  30274,  29622,  28899,  28106,  27246,  26320,  25330,  24279,
 +  23170,  22006,  20788,  19520,  18205,  16846,  15447,  14010,
 +  12540,  11039,   9512,   7962,   6393,   4808,   3212,   1608,
 +      0,  -1608,  -3212,  -4808,  -6393,  -7962,  -9512, -11039,
 + -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006,
 + -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622,
 + -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729
 +};
 +
 +/**
 + * Slope used to compute cos(x)
 + *
 + * cos(ind*64+offset) = base_cos[ind]+offset*slope_cos[ind]
 + * values multiplied by 1<<19
 + */
 +static const int16_t slope_cos[64] =
 +{
 +   -632,  -1893,  -3150,  -4399,  -5638,  -6863,  -8072,  -9261,
 + -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744,
 + -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526,
 + -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726,
 + -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009,
 + -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637,
 + -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428,
 +  -9261,  -8072,  -6863,  -5638,  -4399,  -3150,  -1893,   -632
 +};
 +
 +/**
 + * Table used to compute exp2(x)
 + *
 + * tab_exp2[i] = (1<<14) * exp2(i/32) = 2^(i/32) i=0..32
 + */
 +static const uint16_t tab_exp2[33] =
 +{
 +  16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911,
 +  20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726,
 +  25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706,
 +  31379, 32066, 32767
 +};
 +
 +int16_t ff_cos(uint16_t arg)
 +{
 +    uint8_t offset= arg;
 +    uint8_t ind = arg >> 8;
 +
 +    av_assert2(arg < 0x4000);
 +
 +    return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000);
 +}
 +
 +int ff_exp2(uint16_t power)
 +{
 +    uint16_t frac_x0;
 +    uint16_t frac_dx;
 +    int result;
 +
 +    av_assert2(power <= 0x7fff);
 +
 +    frac_x0 = power >> 10;
 +    frac_dx = (power & 0x03ff) << 5;
 +
 +    result = tab_exp2[frac_x0] << 15;
 +    result += frac_dx * (tab_exp2[frac_x0+1] - tab_exp2[frac_x0]);
 +
 +    return result >> 10;
 +}
 +
 +#else // G729_BITEXACT
 +
  /**
   * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
   */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  
  #include "avcodec.h"
  #include "dnxhddata.h"
+ #include "libavutil/common.h"
  
 +/* The quantization tables below are in zigzag order! */
 +
  static const uint8_t dnxhd_1235_luma_weight[] = {
 -     0, 32, 32, 32, 33, 35, 38, 39,
 -    32, 33, 32, 33, 36, 36, 39, 42,
 -    32, 32, 33, 36, 35, 37, 41, 43,
 -    31, 33, 34, 36, 36, 40, 42, 48,
 -    32, 34, 36, 37, 39, 42, 46, 51,
 -    36, 37, 37, 39, 41, 46, 51, 55,
 -    37, 39, 41, 41, 47, 50, 55, 56,
 -    41, 42, 41, 44, 50, 53, 60, 60
 +     0, 32, 32, 32, 33, 32, 32, 32,
 +    32, 31, 32, 33, 33, 33, 33, 35,
 +    36, 36, 34, 34, 36, 37, 37, 36,
 +    36, 35, 36, 38, 39, 39, 37, 36,
 +    37, 37, 39, 41, 42, 41, 39, 39,
 +    40, 41, 42, 43, 42, 42, 41, 41,
 +    41, 44, 47, 46, 46, 48, 51, 51,
 +    50, 50, 53, 55, 55, 56, 60, 60,
  };
  
  static const uint8_t dnxhd_1235_chroma_weight[] = {
Simple merge
Simple merge
@@@ -18,7 -18,7 +18,8 @@@
  
  #include <stdint.h>
  
+ #include "libavutil/common.h"
 +#include "libavutil/intreadwrite.h"
  #include "libavutil/log.h"
  #include "libavutil/pixdesc.h"
  #include "avcodec.h"
Simple merge
   */
  
  #include "libavutil/attributes.h"
 +#include "libavutil/avassert.h"
+ #include "libavutil/common.h"
  #include "dsputil.h"
  #include "dwt.h"
 +#include "libavcodec/x86/dwt.h"
  
  int ff_slice_buffer_init(slice_buffer *buf, int line_count,
                           int max_allocated_lines, int line_width,
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
   */
  
  #include <stdint.h>
 +#include "libavutil/avassert.h"
  #include "avcodec.h"
  #include "h264dsp.h"
+ #include "libavutil/common.h"
  
  #define BIT_DEPTH 8
  #include "h264dsp_template.c"
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #include <stdio.h>
  #include <stdlib.h>
  
 +#include "libavutil/avassert.h"
  #include "avcodec.h"
 +#include "internal.h"
  #include "lcl.h"
+ #include "libavutil/internal.h"
+ #include "libavutil/mem.h"
  
  #include <zlib.h>
  
Simple merge
Simple merge
  #include "avcodec.h"
  #include "internal.h"
  #include "gsm.h"
+ #include "libavutil/common.h"
  
 +static av_cold int libgsm_encode_close(AVCodecContext *avctx) {
 +#if FF_API_OLD_ENCODE_AUDIO
 +    av_freep(&avctx->coded_frame);
 +#endif
 +    gsm_destroy(avctx->priv_data);
 +    avctx->priv_data = NULL;
 +    return 0;
 +}
 +
  static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
      if (avctx->channels > 1) {
          av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -30,7 -30,8 +30,8 @@@
   * and o_ prefixes on variables which are libogg types.
   */
  
 -/* Libav includes */
 +/* FFmpeg includes */
+ #include "libavutil/common.h"
  #include "libavutil/intreadwrite.h"
  #include "libavutil/log.h"
  #include "libavutil/base64.h"
Simple merge
Simple merge
@@@ -30,8 -30,8 +30,9 @@@
  
  #include "avcodec.h"
  #include "internal.h"
 +#include "libavutil/avassert.h"
  #include "libavutil/base64.h"
+ #include "libavutil/common.h"
  #include "libavutil/mathematics.h"
  #include "libavutil/opt.h"
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  
  #include <stdio.h>
  #include <stdlib.h>
 +#include <limits.h>
  
  #include "libavutil/bswap.h"
+ #include "libavutil/common.h"
  #include "libavutil/lzo.h"
  #include "libavutil/imgutils.h"
  #include "avcodec.h"
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #include "avcodec.h"
  #include "imgconvert.h"
  #include "raw.h"
 +#include "libavutil/avassert.h"
+ #include "libavutil/common.h"
  #include "libavutil/intreadwrite.h"
  #include "libavutil/imgutils.h"
 +#include "libavutil/opt.h"
  
  typedef struct RawVideoContext {
 +    AVClass *av_class;
      uint32_t palette[AVPALETTE_COUNT];
      unsigned char * buffer;  /* block of memory for holding one frame */
      int             length;  /* number of bytes in buffer */
Simple merge
Simple merge
   * @author Michael Niedermayer <michaelni@gmx.at>
   */
  
 +#include "libavutil/avassert.h"
  #include "avcodec.h"
  #include "dsputil.h"
+ #include "libavutil/common.h"
  
  #ifndef CONFIG_RESAMPLE_HP
  #define FILTER_SHIFT 15
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -27,7 -27,7 +27,8 @@@
  #include "avcodec.h"
  #include "dsputil.h"
  #include "rv34dsp.h"
 +#include "libavutil/avassert.h"
+ #include "libavutil/common.h"
  
  #define RV40_LOWPASS(OPNAME, OP) \
  static av_unused void OPNAME ## rv40_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -25,7 -26,7 +25,8 @@@
   */
  
  #include "avcodec.h"
 +#include "bytestream.h"
+ #include "config.h"
  #if CONFIG_ZLIB
  #include <zlib.h>
  #endif
@@@ -34,8 -33,7 +34,8 @@@
  #if CONFIG_ZLIB
  #include <zlib.h>
  #endif
- #include "libavutil/opt.h"
  #include "bytestream.h"
++#include "internal.h"
  #include "tiff.h"
  #include "rle.h"
  #include "lzw.h"
Simple merge
Simple merge
   */
  
  #include "avcodec.h"
 +#include "v210dec.h"
  #include "libavutil/bswap.h"
+ #include "libavutil/internal.h"
+ #include "libavutil/mem.h"
  
 +#define READ_PIXELS(a, b, c)         \
 +    do {                             \
 +        val  = av_le2ne32(*src++);   \
 +        *a++ =  val & 0x3FF;         \
 +        *b++ = (val >> 10) & 0x3FF;  \
 +        *c++ = (val >> 20) & 0x3FF;  \
 +    } while (0)
 +
 +static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)
 +{
 +    uint32_t val;
 +    int i;
 +
 +    for( i = 0; i < width-5; i += 6 ){
 +        READ_PIXELS(u, y, v);
 +        READ_PIXELS(y, u, y);
 +        READ_PIXELS(v, y, u);
 +        READ_PIXELS(y, v, y);
 +    }
 +}
 +
  static av_cold int decode_init(AVCodecContext *avctx)
  {
 +    V210DecContext *s = avctx->priv_data;
 +
      if (avctx->width & 1) {
          av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n");
          return -1;
Simple merge
Simple merge
Simple merge
@@@ -26,7 -26,8 +26,9 @@@
   */
  
  #include "vc1dsp.h"
 +#include "libavutil/avassert.h"
+ #include "libavutil/common.h"
  
  /** Apply overlap transform to horizontal edge
  */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -25,9 -23,8 +25,9 @@@ MMX-OBJS-$(CONFIG_H264DSP)             
  MMX-OBJS-$(CONFIG_H264PRED)            += x86/h264_intrapred_init.o
  MMX-OBJS-$(CONFIG_LPC)                 += x86/lpc_mmx.o
  MMX-OBJS-$(CONFIG_MPEGAUDIODSP)        += x86/mpegaudiodec_mmx.o
- MMX-OBJS-$(CONFIG_PNG_DECODER)         += x86/pngdsp-init.o
- MMX-OBJS-$(CONFIG_PRORES_DECODER)      += x86/proresdsp-init.o
- MMX-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp-init.o
+ MMX-OBJS-$(CONFIG_PNG_DECODER)         += x86/pngdsp_init.o
+ MMX-OBJS-$(CONFIG_PRORES_DECODER)      += x86/proresdsp_init.o
++MMX-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp_init.o
  MMX-OBJS-$(CONFIG_RV30_DECODER)        += x86/rv34dsp_init.o
  MMX-OBJS-$(CONFIG_RV40_DECODER)        += x86/rv34dsp_init.o            \
                                            x86/rv40dsp_init.o
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0000000,aa21847..7a12730
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,51 +1,51 @@@
 - * This file is part of Libav.
+ /*
+  * x86 PNG optimizations.
+  * Copyright (c) 2008 Loren Merrit <lorenm@u.washington.edu>
+  *
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #include "libavutil/common.h"
+ #include "libavutil/cpu.h"
+ #include "libavcodec/pngdsp.h"
+ void ff_add_png_paeth_prediction_mmx2 (uint8_t *dst, uint8_t *src,
+                                        uint8_t *top, int w, int bpp);
+ void ff_add_png_paeth_prediction_ssse3(uint8_t *dst, uint8_t *src,
+                                        uint8_t *top, int w, int bpp);
+ void ff_add_bytes_l2_mmx (uint8_t *dst, uint8_t *src1,
+                           uint8_t *src2, int w);
+ void ff_add_bytes_l2_sse2(uint8_t *dst, uint8_t *src1,
+                           uint8_t *src2, int w);
+ void ff_pngdsp_init_x86(PNGDSPContext *dsp)
+ {
+ #if HAVE_YASM
+     int flags = av_get_cpu_flags();
+ #if ARCH_X86_32
+     if (flags & AV_CPU_FLAG_MMX)
+         dsp->add_bytes_l2         = ff_add_bytes_l2_mmx;
+ #endif
+     if (flags & AV_CPU_FLAG_MMXEXT)
+         dsp->add_paeth_prediction = ff_add_png_paeth_prediction_mmx2;
+     if (flags & AV_CPU_FLAG_SSE2)
+         dsp->add_bytes_l2         = ff_add_bytes_l2_sse2;
+     if (flags & AV_CPU_FLAG_SSSE3)
+         dsp->add_paeth_prediction = ff_add_png_paeth_prediction_ssse3;
+ #endif
+ }
index 0000000,f202f9f..a99a938
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,54 +1,57 @@@
 - * This file is part of Libav.
+ /*
+  * Apple ProRes compatible decoder
+  *
+  * Copyright (c) 2010-2011 Maxim Poliakovski
+  *
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
 -void ff_proresdsp_x86_init(ProresDSPContext *dsp)
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #include "libavcodec/proresdsp.h"
+ void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
+                                 DCTELEM *block, const int16_t *qmat);
+ void ff_prores_idct_put_10_sse4(uint16_t *dst, int linesize,
+                                 DCTELEM *block, const int16_t *qmat);
+ void ff_prores_idct_put_10_avx (uint16_t *dst, int linesize,
+                                 DCTELEM *block, const int16_t *qmat);
++void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx)
+ {
+ #if ARCH_X86_64 && HAVE_YASM
+     int flags = av_get_cpu_flags();
++    if(avctx->flags & CODEC_FLAG_BITEXACT)
++        return;
++
+     if (flags & AV_CPU_FLAG_SSE2) {
+         dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+         dsp->idct_put = ff_prores_idct_put_10_sse2;
+     }
+     if (flags & AV_CPU_FLAG_SSE4) {
+         dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+         dsp->idct_put = ff_prores_idct_put_10_sse4;
+     }
+ #if HAVE_AVX
+     if (flags & AV_CPU_FLAG_AVX) {
+         dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+         dsp->idct_put = ff_prores_idct_put_10_avx;
+     }
+ #endif /* HAVE_AVX */
+ #endif /* ARCH_X86_64 && HAVE_YASM */
+ }
Simple merge
Simple merge
Simple merge
index 0000000,04cfecc..a7e351a
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,450 +1,450 @@@
 - * This file is part of Libav.
+ /*
+  * VP8 DSP functions x86-optimized
+  * Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com>
+  * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com>
+  *
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #include "libavutil/cpu.h"
+ #include "libavutil/mem.h"
+ #include "libavutil/x86/asm.h"
+ #include "libavcodec/vp8dsp.h"
+ #if HAVE_YASM
+ /*
+  * MC functions
+  */
+ extern void ff_put_vp8_epel4_h4_mmx2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_h6_mmx2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_v4_mmx2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_v6_mmx2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_h4_sse2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_h6_sse2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_v4_sse2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_v6_sse2  (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel4_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                        uint8_t *src, ptrdiff_t srcstride,
+                                        int height, int mx, int my);
+ extern void ff_put_vp8_bilinear4_h_mmx2  (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear8_h_sse2  (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear4_h_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear4_v_mmx2  (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear8_v_sse2  (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear4_v_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, ptrdiff_t dststride,
+                                           uint8_t *src, ptrdiff_t srcstride,
+                                           int height, int mx, int my);
+ extern void ff_put_vp8_pixels8_mmx (uint8_t *dst, ptrdiff_t dststride,
+                                     uint8_t *src, ptrdiff_t srcstride,
+                                     int height, int mx, int my);
+ extern void ff_put_vp8_pixels16_mmx(uint8_t *dst, ptrdiff_t dststride,
+                                     uint8_t *src, ptrdiff_t srcstride,
+                                     int height, int mx, int my);
+ extern void ff_put_vp8_pixels16_sse(uint8_t *dst, ptrdiff_t dststride,
+                                     uint8_t *src, ptrdiff_t srcstride,
+                                     int height, int mx, int my);
+ #define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \
+ static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \
+     uint8_t *dst,  ptrdiff_t dststride, uint8_t *src, \
+     ptrdiff_t srcstride, int height, int mx, int my) \
+ { \
+     ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
+         dst,     dststride, src,     srcstride, height, mx, my); \
+     ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
+         dst + 8, dststride, src + 8, srcstride, height, mx, my); \
+ }
+ #define TAP_W8(OPT, FILTERTYPE, TAPTYPE) \
+ static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
+     uint8_t *dst,  ptrdiff_t dststride, uint8_t *src, \
+     ptrdiff_t srcstride, int height, int mx, int my) \
+ { \
+     ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
+         dst,     dststride, src,     srcstride, height, mx, my); \
+     ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
+         dst + 4, dststride, src + 4, srcstride, height, mx, my); \
+ }
+ #if ARCH_X86_32
+ TAP_W8 (mmx2,  epel, h4)
+ TAP_W8 (mmx2,  epel, h6)
+ TAP_W16(mmx2,  epel, h6)
+ TAP_W8 (mmx2,  epel, v4)
+ TAP_W8 (mmx2,  epel, v6)
+ TAP_W16(mmx2,  epel, v6)
+ TAP_W8 (mmx2,  bilinear, h)
+ TAP_W16(mmx2,  bilinear, h)
+ TAP_W8 (mmx2,  bilinear, v)
+ TAP_W16(mmx2,  bilinear, v)
+ #endif
+ TAP_W16(sse2,  epel, h6)
+ TAP_W16(sse2,  epel, v6)
+ TAP_W16(sse2,  bilinear, h)
+ TAP_W16(sse2,  bilinear, v)
+ TAP_W16(ssse3, epel, h6)
+ TAP_W16(ssse3, epel, v6)
+ TAP_W16(ssse3, bilinear, h)
+ TAP_W16(ssse3, bilinear, v)
+ #define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \
+ static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \
+     uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
+     ptrdiff_t srcstride, int height, int mx, int my) \
+ { \
+     DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \
+     uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \
+     src -= srcstride * (TAPNUMY / 2 - 1); \
+     ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## _ ## OPT( \
+         tmp, SIZE,      src,    srcstride, height + TAPNUMY - 1, mx, my); \
+     ff_put_vp8_epel ## SIZE ## _v ## TAPNUMY ## _ ## OPT( \
+         dst, dststride, tmpptr, SIZE,      height,               mx, my); \
+ }
+ #if ARCH_X86_32
+ #define HVTAPMMX(x, y) \
+ HVTAP(mmx2, 8, x, y,  4,  8) \
+ HVTAP(mmx2, 8, x, y,  8, 16)
+ HVTAP(mmx2, 8, 6, 6, 16, 16)
+ #else
+ #define HVTAPMMX(x, y) \
+ HVTAP(mmx2, 8, x, y,  4,  8)
+ #endif
+ HVTAPMMX(4, 4)
+ HVTAPMMX(4, 6)
+ HVTAPMMX(6, 4)
+ HVTAPMMX(6, 6)
+ #define HVTAPSSE2(x, y, w) \
+ HVTAP(sse2,  16, x, y, w, 16) \
+ HVTAP(ssse3, 16, x, y, w, 16)
+ HVTAPSSE2(4, 4, 8)
+ HVTAPSSE2(4, 6, 8)
+ HVTAPSSE2(6, 4, 8)
+ HVTAPSSE2(6, 6, 8)
+ HVTAPSSE2(6, 6, 16)
+ HVTAP(ssse3, 16, 4, 4, 4, 8)
+ HVTAP(ssse3, 16, 4, 6, 4, 8)
+ HVTAP(ssse3, 16, 6, 4, 4, 8)
+ HVTAP(ssse3, 16, 6, 6, 4, 8)
+ #define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \
+ static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \
+     uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
+     ptrdiff_t srcstride, int height, int mx, int my) \
+ { \
+     DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + 2)]; \
+     ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT( \
+         tmp, SIZE,      src, srcstride, height + 1, mx, my); \
+     ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT( \
+         dst, dststride, tmp, SIZE,      height,     mx, my); \
+ }
+ HVBILIN(mmx2,  8,  4,  8)
+ #if ARCH_X86_32
+ HVBILIN(mmx2,  8,  8, 16)
+ HVBILIN(mmx2,  8, 16, 16)
+ #endif
+ HVBILIN(sse2,  8,  8, 16)
+ HVBILIN(sse2,  8, 16, 16)
+ HVBILIN(ssse3, 8,  4,  8)
+ HVBILIN(ssse3, 8,  8, 16)
+ HVBILIN(ssse3, 8, 16, 16)
+ extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, DCTELEM block[16],
+                                    ptrdiff_t stride);
+ extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, DCTELEM block[16],
+                                     ptrdiff_t stride);
+ extern void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, DCTELEM block[4][16],
+                                       ptrdiff_t stride);
+ extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, DCTELEM block[4][16],
+                                       ptrdiff_t stride);
+ extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, DCTELEM block[2][16],
+                                       ptrdiff_t stride);
+ extern void ff_vp8_luma_dc_wht_mmx(DCTELEM block[4][4][16], DCTELEM dc[16]);
+ extern void ff_vp8_luma_dc_wht_sse(DCTELEM block[4][4][16], DCTELEM dc[16]);
+ extern void ff_vp8_idct_add_mmx(uint8_t *dst, DCTELEM block[16],
+                                 ptrdiff_t stride);
+ extern void ff_vp8_idct_add_sse(uint8_t *dst, DCTELEM block[16],
+                                 ptrdiff_t stride);
+ #define DECLARE_LOOP_FILTER(NAME)\
+ extern void ff_vp8_v_loop_filter_simple_ ## NAME(uint8_t *dst, \
+                                                  ptrdiff_t stride, \
+                                                  int flim);\
+ extern void ff_vp8_h_loop_filter_simple_ ## NAME(uint8_t *dst, \
+                                                  ptrdiff_t stride, \
+                                                  int flim);\
+ extern void ff_vp8_v_loop_filter16y_inner_ ## NAME (uint8_t *dst, \
+                                                      ptrdiff_t stride,\
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_h_loop_filter16y_inner_ ## NAME (uint8_t *dst, \
+                                                     ptrdiff_t stride,\
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_v_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, \
+                                                     uint8_t *dstV,\
+                                                     ptrdiff_t s, \
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_h_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, \
+                                                     uint8_t *dstV,\
+                                                     ptrdiff_t s, \
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_v_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, \
+                                                     ptrdiff_t stride,\
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_h_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, \
+                                                     ptrdiff_t stride,\
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_v_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \
+                                                     uint8_t *dstV,\
+                                                     ptrdiff_t s, \
+                                                     int e, int i, int hvt);\
+ extern void ff_vp8_h_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \
+                                                     uint8_t *dstV,\
+                                                     ptrdiff_t s, \
+                                                     int e, int i, int hvt);
+ DECLARE_LOOP_FILTER(mmx)
+ DECLARE_LOOP_FILTER(mmx2)
+ DECLARE_LOOP_FILTER(sse2)
+ DECLARE_LOOP_FILTER(ssse3)
+ DECLARE_LOOP_FILTER(sse4)
+ #endif
+ #define VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) \
+     c->put_vp8_epel_pixels_tab[IDX][0][2] = ff_put_vp8_epel ## SIZE ## _h6_ ## OPT; \
+     c->put_vp8_epel_pixels_tab[IDX][2][0] = ff_put_vp8_epel ## SIZE ## _v6_ ## OPT; \
+     c->put_vp8_epel_pixels_tab[IDX][2][2] = ff_put_vp8_epel ## SIZE ## _h6v6_ ## OPT
+ #define VP8_MC_FUNC(IDX, SIZE, OPT) \
+     c->put_vp8_epel_pixels_tab[IDX][0][1] = ff_put_vp8_epel ## SIZE ## _h4_ ## OPT; \
+     c->put_vp8_epel_pixels_tab[IDX][1][0] = ff_put_vp8_epel ## SIZE ## _v4_ ## OPT; \
+     c->put_vp8_epel_pixels_tab[IDX][1][1] = ff_put_vp8_epel ## SIZE ## _h4v4_ ## OPT; \
+     c->put_vp8_epel_pixels_tab[IDX][1][2] = ff_put_vp8_epel ## SIZE ## _h6v4_ ## OPT; \
+     c->put_vp8_epel_pixels_tab[IDX][2][1] = ff_put_vp8_epel ## SIZE ## _h4v6_ ## OPT; \
+     VP8_LUMA_MC_FUNC(IDX, SIZE, OPT)
+ #define VP8_BILINEAR_MC_FUNC(IDX, SIZE, OPT) \
+     c->put_vp8_bilinear_pixels_tab[IDX][0][1] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][0][2] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][1][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][1][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][1][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][2][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][2][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
+     c->put_vp8_bilinear_pixels_tab[IDX][2][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT
+ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
+ {
+ #if HAVE_YASM
+     int mm_flags = av_get_cpu_flags();
+     if (mm_flags & AV_CPU_FLAG_MMX) {
+         c->vp8_idct_dc_add    = ff_vp8_idct_dc_add_mmx;
+         c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;
+ #if ARCH_X86_32
+         c->vp8_idct_dc_add4y  = ff_vp8_idct_dc_add4y_mmx;
+         c->vp8_idct_add       = ff_vp8_idct_add_mmx;
+         c->vp8_luma_dc_wht    = ff_vp8_luma_dc_wht_mmx;
+         c->put_vp8_epel_pixels_tab[0][0][0]     =
+         c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;
+ #endif
+         c->put_vp8_epel_pixels_tab[1][0][0]     =
+         c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;
+ #if ARCH_X86_32
+         c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx;
+         c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx;
+         c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx;
+         c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx;
+         c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx;
+         c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx;
+         c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_mmx;
+         c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_mmx;
+         c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_mmx;
+         c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_mmx;
+ #endif
+     }
+     /* note that 4-tap width=16 functions are missing because w=16
+      * is only used for luma, and luma is always a copy or sixtap. */
+     if (mm_flags & AV_CPU_FLAG_MMXEXT) {
+         VP8_MC_FUNC(2, 4, mmx2);
+         VP8_BILINEAR_MC_FUNC(2, 4, mmx2);
+ #if ARCH_X86_32
+         VP8_LUMA_MC_FUNC(0, 16, mmx2);
+         VP8_MC_FUNC(1, 8, mmx2);
+         VP8_BILINEAR_MC_FUNC(0, 16, mmx2);
+         VP8_BILINEAR_MC_FUNC(1, 8, mmx2);
+         c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx2;
+         c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx2;
+         c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx2;
+         c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx2;
+         c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx2;
+         c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx2;
+         c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_mmx2;
+         c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_mmx2;
+         c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_mmx2;
+         c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_mmx2;
+ #endif
+     }
+     if (mm_flags & AV_CPU_FLAG_SSE) {
+         c->vp8_idct_add                         = ff_vp8_idct_add_sse;
+         c->vp8_luma_dc_wht                      = ff_vp8_luma_dc_wht_sse;
+         c->put_vp8_epel_pixels_tab[0][0][0]     =
+         c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;
+     }
+     if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
+         VP8_LUMA_MC_FUNC(0, 16, sse2);
+         VP8_MC_FUNC(1, 8, sse2);
+         VP8_BILINEAR_MC_FUNC(0, 16, sse2);
+         VP8_BILINEAR_MC_FUNC(1, 8, sse2);
+         c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2;
+ #if ARCH_X86_64 || HAVE_ALIGNED_STACK
+         c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2;
+         c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_sse2;
+         c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_sse2;
+         c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_sse2;
+ #endif
+     }
+     if (mm_flags & AV_CPU_FLAG_SSE2) {
+         c->vp8_idct_dc_add4y          = ff_vp8_idct_dc_add4y_sse2;
+         c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;
+ #if ARCH_X86_64 || HAVE_ALIGNED_STACK
+         c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2;
+         c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2;
+         c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_sse2;
+         c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_sse2;
+ #endif
+     }
+     if (mm_flags & AV_CPU_FLAG_SSSE3) {
+         VP8_LUMA_MC_FUNC(0, 16, ssse3);
+         VP8_MC_FUNC(1, 8, ssse3);
+         VP8_MC_FUNC(2, 4, ssse3);
+         VP8_BILINEAR_MC_FUNC(0, 16, ssse3);
+         VP8_BILINEAR_MC_FUNC(1, 8, ssse3);
+         VP8_BILINEAR_MC_FUNC(2, 4, ssse3);
+         c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_ssse3;
+         c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_ssse3;
+ #if ARCH_X86_64 || HAVE_ALIGNED_STACK
+         c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_ssse3;
+         c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_ssse3;
+         c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_ssse3;
+         c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_ssse3;
+         c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_ssse3;
+         c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_ssse3;
+         c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_ssse3;
+         c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_ssse3;
+ #endif
+     }
+     if (mm_flags & AV_CPU_FLAG_SSE4) {
+         c->vp8_idct_dc_add                  = ff_vp8_idct_dc_add_sse4;
+         c->vp8_h_loop_filter_simple   = ff_vp8_h_loop_filter_simple_sse4;
+ #if ARCH_X86_64 || HAVE_ALIGNED_STACK
+         c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_sse4;
+         c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_sse4;
+ #endif
+     }
+ #endif
+ }
Simple merge
diff --cc libavcodec/xl.c
Simple merge
Simple merge
Simple merge
@@@ -16,8 -16,8 +16,9 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#include "libavutil/avassert.h"
  #include "avdevice.h"
+ #include "config.h"
  
  unsigned avdevice_version(void)
  {
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
   * null audio source
   */
  
- #include "internal.h"
- #include "libavutil/audioconvert.h"
- #include "libavutil/opt.h"
+ #include <inttypes.h>
+ #include <stdio.h>
  
 +#include "audio.h"
  #include "avfilter.h"
  #include "internal.h"
 +
+ #include "libavutil/audioconvert.h"
+ #include "libavutil/internal.h"
++#include "libavutil/opt.h"
  typedef struct {
 +    const AVClass *class;
 +    char   *channel_layout_str;
      uint64_t channel_layout;
 -    int64_t sample_rate;
 +    char   *sample_rate_str;
 +    int     sample_rate;
 +    int nb_samples;             ///< number of samples per requested frame
 +    int64_t pts;
  } ANullContext;
  
 +#define OFFSET(x) offsetof(ANullContext, x)
 +
 +static const AVOption anullsrc_options[]= {
 +    { "channel_layout", "set channel_layout", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0 },
 +    { "cl",             "set channel_layout", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0 },
 +    { "sample_rate",    "set sample rate",    OFFSET(sample_rate_str)   , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0 },
 +    { "r",              "set sample rate",    OFFSET(sample_rate_str)   , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0 },
 +    { "nb_samples",     "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX },
 +    { "n",              "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX },
 +    { NULL },
 +};
 +
 +AVFILTER_DEFINE_CLASS(anullsrc);
 +
  static int init(AVFilterContext *ctx, const char *args)
  {
 -    ANullContext *priv = ctx->priv;
 -    char channel_layout_str[128] = "";
 +    ANullContext *null = ctx->priv;
 +    int ret;
  
 -    priv->sample_rate = 44100;
 -    priv->channel_layout = AV_CH_LAYOUT_STEREO;
 +    null->class = &anullsrc_class;
 +    av_opt_set_defaults(null);
  
 -    if (args)
 -        sscanf(args, "%"PRId64":%s", &priv->sample_rate, channel_layout_str);
 +    if ((ret = (av_set_options_string(null, args, "=", ":"))) < 0)
 +        return ret;
  
 -    if (priv->sample_rate < 0) {
 -        av_log(ctx, AV_LOG_ERROR, "Invalid negative sample rate: %"PRId64"\n", priv->sample_rate);
 -        return AVERROR(EINVAL);
 -    }
 +    if ((ret = ff_parse_sample_rate(&null->sample_rate,
 +                                     null->sample_rate_str, ctx)) < 0)
 +        return ret;
  
 -    if (*channel_layout_str)
 -        if (!(priv->channel_layout = av_get_channel_layout(channel_layout_str))
 -            && sscanf(channel_layout_str, "%"PRId64, &priv->channel_layout) != 1) {
 -            av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for channel layout\n",
 -                   channel_layout_str);
 -            return AVERROR(EINVAL);
 -        }
 +    if ((ret = ff_parse_channel_layout(&null->channel_layout,
 +                                        null->channel_layout_str, ctx)) < 0)
 +        return ret;
  
      return 0;
  }
@@@ -19,8 -16,8 +19,9 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#include "libavutil/avassert.h"
  #include "libavutil/audioconvert.h"
+ #include "libavutil/common.h"
  
  #include "audio.h"
  #include "avfilter.h"
@@@ -19,6 -19,9 +19,7 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 -/* #define DEBUG */
 -
+ #include "libavutil/common.h"
  #include "libavutil/pixdesc.h"
  #include "libavutil/rational.h"
  #include "libavutil/audioconvert.h"
Simple merge
@@@ -21,8 -17,7 +21,9 @@@
   */
  
  #include "libavutil/audioconvert.h"
 +#include "libavutil/avassert.h"
+ #include "libavutil/common.h"
 +#include "libavutil/imgutils.h"
  #include "libavcodec/avcodec.h"
  
  #include "avfilter.h"
Simple merge
  #include "formats.h"
  #include "internal.h"
  #include "video.h"
 +#include "avcodec.h"
  
  #include "libavutil/audioconvert.h"
+ #include "libavutil/common.h"
  #include "libavutil/fifo.h"
  #include "libavutil/imgutils.h"
  #include "libavutil/opt.h"
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include <string.h>
  #include "libavutil/avutil.h"
  #include "libavutil/colorspace.h"
+ #include "libavutil/mem.h"
  #include "libavutil/pixdesc.h"
  #include "drawutils.h"
 +#include "formats.h"
  
  enum { RED = 0, GREEN, BLUE, ALPHA };
  
index 3430e70,0000000..e6c16aa
mode 100644,000000..100644
--- /dev/null
@@@ -1,182 -1,0 +1,186 @@@
 +/*
 + * Copyright (c) 2010 Stefano Sabatini
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +/**
 + * @file
 + * Set timebase for the output link.
 + */
 +
++#include <inttypes.h>
++#include <stdio.h>
++
 +#include "libavutil/avstring.h"
 +#include "libavutil/eval.h"
++#include "libavutil/internal.h"
 +#include "libavutil/mathematics.h"
 +#include "libavutil/rational.h"
 +#include "avfilter.h"
 +#include "internal.h"
 +#include "audio.h"
 +#include "video.h"
 +
 +static const char *const var_names[] = {
 +    "AVTB",   /* default timebase 1/AV_TIME_BASE */
 +    "intb",   /* input timebase */
 +    "sr",     /* sample rate */
 +    NULL
 +};
 +
 +enum var_name {
 +    VAR_AVTB,
 +    VAR_INTB,
 +    VAR_SR,
 +    VAR_VARS_NB
 +};
 +
 +typedef struct {
 +    char tb_expr[256];
 +    double var_values[VAR_VARS_NB];
 +} SetTBContext;
 +
 +static av_cold int init(AVFilterContext *ctx, const char *args)
 +{
 +    SetTBContext *settb = ctx->priv;
 +    av_strlcpy(settb->tb_expr, "intb", sizeof(settb->tb_expr));
 +
 +    if (args)
 +        sscanf(args, "%255[^:]", settb->tb_expr);
 +
 +    return 0;
 +}
 +
 +static int config_output_props(AVFilterLink *outlink)
 +{
 +    AVFilterContext *ctx = outlink->src;
 +    SetTBContext *settb = ctx->priv;
 +    AVFilterLink *inlink = ctx->inputs[0];
 +    AVRational time_base;
 +    int ret;
 +    double res;
 +
 +    settb->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q);
 +    settb->var_values[VAR_INTB] = av_q2d(inlink->time_base);
 +    settb->var_values[VAR_SR]   = inlink->sample_rate;
 +
 +    outlink->w = inlink->w;
 +    outlink->h = inlink->h;
 +
 +    if ((ret = av_expr_parse_and_eval(&res, settb->tb_expr, var_names, settb->var_values,
 +                                      NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0) {
 +        av_log(ctx, AV_LOG_ERROR, "Invalid expression '%s' for timebase.\n", settb->tb_expr);
 +        return ret;
 +    }
 +    time_base = av_d2q(res, INT_MAX);
 +    if (time_base.num <= 0 || time_base.den <= 0) {
 +        av_log(ctx, AV_LOG_ERROR,
 +               "Invalid non-positive values for the timebase num:%d or den:%d.\n",
 +               time_base.num, time_base.den);
 +        return AVERROR(EINVAL);
 +    }
 +
 +    outlink->time_base = time_base;
 +    av_log(outlink->src, AV_LOG_VERBOSE, "tb:%d/%d -> tb:%d/%d\n",
 +           inlink ->time_base.num, inlink ->time_base.den,
 +           outlink->time_base.num, outlink->time_base.den);
 +
 +    return 0;
 +}
 +
 +static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
 +{
 +    AVFilterContext *ctx = inlink->dst;
 +    AVFilterLink *outlink = ctx->outputs[0];
 +
 +    if (av_cmp_q(inlink->time_base, outlink->time_base)) {
 +        int64_t orig_pts = picref->pts;
 +        picref->pts = av_rescale_q(picref->pts, inlink->time_base, outlink->time_base);
 +        av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
 +               inlink ->time_base.num, inlink ->time_base.den, orig_pts,
 +               outlink->time_base.num, outlink->time_base.den, picref->pts);
 +    }
 +    inlink->cur_buf = NULL;
 +
 +    return ff_start_frame(outlink, picref);
 +}
 +
 +static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
 +{
 +    AVFilterContext *ctx = inlink->dst;
 +    AVFilterLink *outlink = ctx->outputs[0];
 +
 +    if (av_cmp_q(inlink->time_base, outlink->time_base)) {
 +        int64_t orig_pts = samplesref->pts;
 +        samplesref->pts = av_rescale_q(samplesref->pts, inlink->time_base, outlink->time_base);
 +        av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
 +               inlink ->time_base.num, inlink ->time_base.den, orig_pts,
 +               outlink->time_base.num, outlink->time_base.den, samplesref->pts);
 +    }
 +
 +    return ff_filter_samples(outlink, samplesref);
 +}
 +
 +#if CONFIG_SETTB_FILTER
 +AVFilter avfilter_vf_settb = {
 +    .name      = "settb",
 +    .description = NULL_IF_CONFIG_SMALL("Set timebase for the video output link."),
 +    .init      = init,
 +
 +    .priv_size = sizeof(SetTBContext),
 +
 +    .inputs    = (const AVFilterPad[]) {
 +        { .name             = "default",
 +          .type             = AVMEDIA_TYPE_VIDEO,
 +          .get_video_buffer = ff_null_get_video_buffer,
 +          .start_frame      = start_frame,
 +          .end_frame        = ff_null_end_frame },
 +        { .name = NULL }
 +    },
 +    .outputs   = (const AVFilterPad[]) {
 +        { .name            = "default",
 +          .type            = AVMEDIA_TYPE_VIDEO,
 +          .config_props    = config_output_props, },
 +        { .name = NULL}
 +    },
 +};
 +#endif
 +
 +#if CONFIG_ASETTB_FILTER
 +AVFilter avfilter_af_asettb = {
 +    .name      = "asettb",
 +    .description = NULL_IF_CONFIG_SMALL("Set timebase for the audio output link."),
 +    .init      = init,
 +
 +    .priv_size = sizeof(SetTBContext),
 +
 +    .inputs    = (const AVFilterPad[]) {
 +        { .name             = "default",
 +          .type             = AVMEDIA_TYPE_AUDIO,
 +          .get_audio_buffer = ff_null_get_audio_buffer,
 +          .filter_samples   = filter_samples, },
 +        { .name = NULL }
 +    },
 +    .outputs   = (const AVFilterPad[]) {
 +        { .name            = "default",
 +          .type            = AVMEDIA_TYPE_AUDIO,
 +          .config_props    = config_output_props, },
 +        { .name = NULL}
 +    },
 +};
 +#endif
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include "libavutil/common.h"
 +#include "libavutil/eval.h"
  #include "libavutil/pixdesc.h"
 +#include "libavutil/parseutils.h"
 +#include "libavutil/audioconvert.h"
  #include "avfilter.h"
  #include "internal.h"
  #include "formats.h"
Simple merge
Simple merge
@@@ -23,8 -23,8 +23,9 @@@
   * aspect ratio modification video filters
   */
  
+ #include "libavutil/common.h"
  #include "libavutil/mathematics.h"
 +#include "libavutil/parseutils.h"
  #include "avfilter.h"
  #include "internal.h"
  #include "video.h"
   * Ported from MPlayer libmpcodecs/vf_blackframe.c.
   */
  
+ #include <stdio.h>
+ #include <inttypes.h>
+ #include "libavutil/internal.h"
  #include "avfilter.h"
 +#include "internal.h"
  #include "formats.h"
  #include "internal.h"
  #include "video.h"
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -29,8 -29,8 +29,9 @@@
  #include <sys/time.h>
  #include <time.h>
  
 -#include "libavutil/colorspace.h"
 +#include "config.h"
 +#include "libavutil/avstring.h"
+ #include "libavutil/common.h"
  #include "libavutil/file.h"
  #include "libavutil/eval.h"
  #include "libavutil/opt.h"
   * based heavily on vf_negate.c by Bobby Bingham
   */
  
 +#include "libavutil/avstring.h"
+ #include "libavutil/common.h"
 +#include "libavutil/eval.h"
 +#include "libavutil/opt.h"
  #include "libavutil/pixdesc.h"
  #include "avfilter.h"
 +#include "drawutils.h"
 +#include "internal.h"
  #include "formats.h"
  #include "internal.h"
  #include "video.h"
Simple merge
   * format and noformat video filters
   */
  
+ #include <string.h>
+ #include "libavutil/internal.h"
+ #include "libavutil/mem.h"
  #include "libavutil/pixdesc.h"
  #include "avfilter.h"
 +#include "internal.h"
  #include "formats.h"
  #include "internal.h"
  #include "video.h"
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -24,7 -24,9 +24,8 @@@
   * value, and apply it to input video.
   */
  
+ #include "libavutil/common.h"
  #include "libavutil/eval.h"
 -#include "libavutil/mathematics.h"
  #include "libavutil/opt.h"
  #include "libavutil/pixdesc.h"
  #include "avfilter.h"
Simple merge
   * overlay one video on top of another
   */
  
 +/* #define DEBUG */
 +
  #include "avfilter.h"
  #include "formats.h"
+ #include "libavutil/common.h"
  #include "libavutil/eval.h"
  #include "libavutil/avstring.h"
 +#include "libavutil/opt.h"
  #include "libavutil/pixdesc.h"
  #include "libavutil/imgutils.h"
  #include "libavutil/mathematics.h"
Simple merge
Simple merge
Simple merge
  
  #include "libavutil/eval.h"
  #include "libavutil/fifo.h"
 -#include "libavutil/mathematics.h"
 +#include "libavcodec/dsputil.h"
+ #include "libavutil/internal.h"
  #include "avfilter.h"
 +#include "formats.h"
  #include "internal.h"
  #include "video.h"
  
Simple merge
@@@ -24,8 -24,8 +24,9 @@@
  
  #include "libavutil/adler32.h"
  #include "libavutil/imgutils.h"
+ #include "libavutil/internal.h"
  #include "libavutil/pixdesc.h"
 +#include "libavutil/timestamp.h"
  #include "avfilter.h"
  #include "internal.h"
  #include "video.h"
Simple merge
Simple merge
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include <string.h>
+ #include <stdio.h>
 +#include "libavutil/avassert.h"
  #include "libavutil/imgutils.h"
+ #include "libavutil/mem.h"
  
  #include "avfilter.h"
  #include "internal.h"
Simple merge
@@@ -35,8 -32,9 +35,9 @@@
  
  #include <float.h>
  
 -#include "libavutil/mathematics.h"
+ #include "libavutil/common.h"
  #include "libavutil/opt.h"
 +#include "libavutil/imgutils.h"
  #include "libavutil/intreadwrite.h"
  #include "libavutil/parseutils.h"
  #include "avfilter.h"
Simple merge
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#include "libavutil/avutil.h"
  #include "network.h"
  #include "libavcodec/internal.h"
+ #include "libavutil/mem.h"
  
  #define THREADS (HAVE_PTHREADS || (defined(WIN32) && !defined(__MINGW32CE__)))
  
Simple merge
@@@ -30,8 -30,8 +30,8 @@@
  #include "libavutil/avutil.h"
  
  #define LIBAVFORMAT_VERSION_MAJOR 54
 -#define LIBAVFORMAT_VERSION_MINOR 13
 -#define LIBAVFORMAT_VERSION_MICRO  4
 +#define LIBAVFORMAT_VERSION_MINOR 24
- #define LIBAVFORMAT_VERSION_MICRO 100
++#define LIBAVFORMAT_VERSION_MICRO 101
  
  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                 LIBAVFORMAT_VERSION_MINOR, \
@@@ -18,8 -18,9 +18,9 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include "libavutil/common.h"
  #include "libavutil/dict.h"
 -#include "libavutil/error.h"
 +// #include "libavutil/error.h"
  #include "libavutil/log.h"
  #include "libavutil/mem.h"
  #include "libavutil/opt.h"
  #include "avstring.h"
  #include "avutil.h"
  #include "audioconvert.h"
 +#include "bprint.h"
+ #include "common.h"
  
 -static const char * const channel_names[] = {
 -    [0]  = "FL",        /* front left */
 -    [1]  = "FR",        /* front right */
 -    [2]  = "FC",        /* front center */
 -    [3]  = "LFE",       /* low frequency */
 -    [4]  = "BL",        /* back left */
 -    [5]  = "BR",        /* back right */
 -    [6]  = "FLC",       /* front left-of-center  */
 -    [7]  = "FRC",       /* front right-of-center */
 -    [8]  = "BC",        /* back-center */
 -    [9]  = "SL",        /* side left */
 -    [10] = "SR",        /* side right */
 -    [11] = "TC",        /* top center */
 -    [12] = "TFL",       /* top front left */
 -    [13] = "TFC",       /* top front center */
 -    [14] = "TFR",       /* top front right */
 -    [15] = "TBL",       /* top back left */
 -    [16] = "TBC",       /* top back center */
 -    [17] = "TBR",       /* top back right */
 -    [29] = "DL",        /* downmix left */
 -    [30] = "DR",        /* downmix right */
 -    [31] = "WL",        /* wide left */
 -    [32] = "WR",        /* wide right */
 -    [33] = "SDL",       /* surround direct left */
 -    [34] = "SDR",       /* surround direct right */
 +struct channel_name {
 +    const char *name;
 +    const char *description;
 +};
 +
 +static const struct channel_name channel_names[] = {
 +     [0] = { "FL",        "front left"            },
 +     [1] = { "FR",        "front right"           },
 +     [2] = { "FC",        "front center"          },
 +     [3] = { "LFE",       "low frequency"         },
 +     [4] = { "BL",        "back left"             },
 +     [5] = { "BR",        "back right"            },
 +     [6] = { "FLC",       "front left-of-center"  },
 +     [7] = { "FRC",       "front right-of-center" },
 +     [8] = { "BC",        "back center"           },
 +     [9] = { "SL",        "side left"             },
 +    [10] = { "SR",        "side right"            },
 +    [11] = { "TC",        "top center"            },
 +    [12] = { "TFL",       "top front left"        },
 +    [13] = { "TFC",       "top front center"      },
 +    [14] = { "TFR",       "top front right"       },
 +    [15] = { "TBL",       "top back left"         },
 +    [16] = { "TBC",       "top back center"       },
 +    [17] = { "TBR",       "top back right"        },
 +    [29] = { "DL",        "downmix left"          },
 +    [30] = { "DR",        "downmix right"         },
 +    [31] = { "WL",        "wide left"             },
 +    [32] = { "WR",        "wide right"            },
 +    [33] = { "SDL",       "surround direct left"  },
 +    [34] = { "SDR",       "surround direct right" },
  };
  
  static const char *get_channel_name(int channel_id)
Simple merge
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#undef _GNU_SOURCE
  #include "avutil.h"
  #include "avstring.h"
+ #include "common.h"
  
 +struct error_entry {
 +    int num;
 +    const char *tag;
 +    const char *str;
 +};
 +
 +#define ERROR_TAG(tag) AVERROR_##tag, #tag
 +struct error_entry error_entries[] = {
 +    { ERROR_TAG(BSF_NOT_FOUND),      "Bitstream filter not found"                     },
 +    { ERROR_TAG(BUG),                "Internal bug, should not have happened"         },
 +    { ERROR_TAG(BUG2),               "Internal bug, should not have happened"         },
 +    { ERROR_TAG(BUFFER_TOO_SMALL),   "Buffer too small"                               },
 +    { ERROR_TAG(DECODER_NOT_FOUND),  "Decoder not found"                              },
 +    { ERROR_TAG(DEMUXER_NOT_FOUND),  "Demuxer not found"                              },
 +    { ERROR_TAG(ENCODER_NOT_FOUND),  "Encoder not found"                              },
 +    { ERROR_TAG(EOF),                "End of file"                                    },
 +    { ERROR_TAG(EXIT),               "Immediate exit requested"                       },
 +    { ERROR_TAG(EXTERNAL),           "Generic error in an external library"           },
 +    { ERROR_TAG(FILTER_NOT_FOUND),   "Filter not found"                               },
 +    { ERROR_TAG(INVALIDDATA),        "Invalid data found when processing input"       },
 +    { ERROR_TAG(MUXER_NOT_FOUND),    "Muxer not found"                                },
 +    { ERROR_TAG(OPTION_NOT_FOUND),   "Option not found"                               },
 +    { ERROR_TAG(PATCHWELCOME),       "Not yet implemented in FFmpeg, patches welcome" },
 +    { ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found"                             },
 +    { ERROR_TAG(STREAM_NOT_FOUND),   "Stream not found"                               },
 +    { ERROR_TAG(UNKNOWN),            "Unknown error occurred"                         },
 +};
 +
  int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
  {
 -    int ret = 0;
 -    const char *errstr = NULL;
 -
 -    switch (errnum) {
 -    case AVERROR_BSF_NOT_FOUND:     errstr = "Bitstream filter not found"                   ; break;
 -    case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found"                            ; break;
 -    case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found"                            ; break;
 -    case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found"                            ; break;
 -    case AVERROR_EOF:               errstr = "End of file"                                  ; break;
 -    case AVERROR_EXIT:              errstr = "Immediate exit requested"                     ; break;
 -    case AVERROR_FILTER_NOT_FOUND:  errstr = "Filter not found"                             ; break;
 -    case AVERROR_INVALIDDATA:       errstr = "Invalid data found when processing input"     ; break;
 -    case AVERROR_MUXER_NOT_FOUND:   errstr = "Muxer not found"                              ; break;
 -    case AVERROR_OPTION_NOT_FOUND:  errstr = "Option not found"                             ; break;
 -    case AVERROR_PATCHWELCOME:      errstr = "Not yet implemented in Libav, patches welcome"; break;
 -    case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found"                           ; break;
 -    case AVERROR_STREAM_NOT_FOUND:  errstr = "Stream not found"                             ; break;
 -    case AVERROR_BUG:               errstr = "Bug detected, please report the issue"        ; break;
 -    case AVERROR_UNKNOWN:           errstr = "Unknown error occurred"                       ; break;
 -    }
 +    int ret = 0, i;
 +    struct error_entry *entry = NULL;
  
 -    if (errstr) {
 -        av_strlcpy(errbuf, errstr, errbuf_size);
 +    for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
 +        if (errnum == error_entries[i].num) {
 +            entry = &error_entries[i];
 +            break;
 +        }
 +    }
 +    if (entry) {
 +        av_strlcpy(errbuf, entry->str, errbuf_size);
      } else {
  #if HAVE_STRERROR_R
 -        ret = strerror_r(AVUNERROR(errnum), errbuf, errbuf_size);
 +        ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
  #else
          ret = -1;
  #endif
@@@ -26,8 -26,8 +26,9 @@@
   * see http://joe.hotchkiss.com/programming/eval/eval.html
   */
  
 +#include <float.h>
  #include "avutil.h"
+ #include "common.h"
  #include "eval.h"
  #include "log.h"
  #include "mathematics.h"
Simple merge
Simple merge
Simple merge
   * misc image utilities
   */
  
+ #include "common.h"
  #include "imgutils.h"
  #include "internal.h"
 +#include "intreadwrite.h"
  #include "log.h"
  #include "pixdesc.h"
  
diff --cc libavutil/log.c
  #include <unistd.h>
  #endif
  #include <stdlib.h>
 -#include "avstring.h"
  #include "avutil.h"
+ #include "common.h"
  #include "log.h"
  
 +#define LINE_SZ 1024
 +
  static int av_log_level = AV_LOG_INFO;
  static int flags;
  
diff --cc libavutil/mem.h
  #ifndef AVUTIL_MEM_H
  #define AVUTIL_MEM_H
  
+ #include <limits.h>
  #include "attributes.h"
 +#include "error.h"
  #include "avutil.h"
  
  /**
diff --cc libavutil/opt.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -39,8 -37,8 +39,8 @@@
   */
  
  #define LIBAVUTIL_VERSION_MAJOR 51
- #define LIBAVUTIL_VERSION_MINOR 69
 -#define LIBAVUTIL_VERSION_MINOR 39
 -#define LIBAVUTIL_VERSION_MICRO  0
++#define LIBAVUTIL_VERSION_MINOR 70
 +#define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \
Simple merge
Simple merge
Simple merge
Simple merge