Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 25 May 2011 04:32:23 +0000 (06:32 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 25 May 2011 04:32:45 +0000 (06:32 +0200)
* qatar/master: (22 commits)
  configure: enable memalign_hack automatically when needed
  swscale: unbreak the build on non-x86 systems.
  swscale: remove if(bitexact) branch from functions.
  swscale: remove if(canMMX2BeUsed) conditional.
  swscale: remove swScale_{c,MMX,MMX2} duplication.
  swscale: use emms_c().
  Move emms_c() from libavcodec to libavutil.
  tiff: set palette in the context when specified in TIFF_PAL tag
  rtsp: use strtoul to parse rtptime and seq values.
  pgssubdec: fix incorrect colors.
  dvdsubdec: fix incorrect colors.
  ape: Allow demuxing of files with metadata tags.
  swscale: remove dead macro WRITEBGR24OLD.
  swscale: remove AMD3DNOW "optimizations".
  swscale: remove duplicate code in ppc/ subdirectory.
  swscale: remove duplicated x86/ functions.
  swscale: force --enable-runtime-cpudetect and remove SWS_CPU_CAPS_*.
  vsrc_buffer.h: add file doxy
  vsrc_buffer: tweak error message in init()
  msmpeg4: reindent.
  ...

Merged-by: Michael Niedermayer <michaelni@gmx.at>
40 files changed:
1  2 
configure
doc/encoders.texi
libavcodec/Makefile
libavcodec/ac3.h
libavcodec/ac3dec.h
libavcodec/ac3dec_data.c
libavcodec/ac3dec_data.h
libavcodec/ac3enc.c
libavcodec/ac3enc_fixed.c
libavcodec/ac3enc_float.c
libavcodec/ac3tab.c
libavcodec/ac3tab.h
libavcodec/allcodecs.c
libavcodec/dsputil.h
libavcodec/mpegvideo_enc.c
libavcodec/msmpeg4.c
libavcodec/msmpeg4.h
libavcodec/tiff.c
libavfilter/vf_mp.c
libavfilter/vsrc_buffer.h
libavformat/ape.c
libavutil/internal.h
libswscale/bfin/swscale_bfin.c
libswscale/colorspace-test.c
libswscale/options.c
libswscale/ppc/swscale_template.c
libswscale/ppc/yuv2rgb_altivec.c
libswscale/rgb2rgb.c
libswscale/rgb2rgb.h
libswscale/rgb2rgb_template.c
libswscale/swscale.c
libswscale/swscale.h
libswscale/swscale_internal.h
libswscale/swscale_template.c
libswscale/utils.c
libswscale/x86/rgb2rgb.c
libswscale/x86/swscale_template.c
libswscale/x86/yuv2rgb_mmx.c
libswscale/x86/yuv2rgb_template.c
libswscale/yuv2rgb.c

diff --cc configure
Simple merge
@@@ -369,67 -365,47 +369,113 @@@ is highly recommended that it be left a
  
  @end table
  
 +@c man end AUDIO ENCODERS
 +
 +@chapter Video Encoders
 +@c man begin VIDEO ENCODERS
 +
 +A description of some of the currently available video encoders
 +follows.
 +
 +@section libx264
 +
 +H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 format supported through
 +libx264.
 +
 +Requires the presence of the libx64 headers and library during
 +configuration. You need to explicitely configure the build with
 +@code{--enable-libx264}.
 +
 +@subsection Options
 +
 +@table @option
 +
 +@item preset @var{preset_name}
 +Set the encoding preset.
 +
 +@item tune @var{tune_name}
 +Tune the encoding params.
 +Deprecated in favor of @var{x264_opts}
 +
 +@item fastfirstpass @var{bool}
 +Use fast settings when encoding first pass, default value is 1.
 +Deprecated in favor of @var{x264_opts}.
 +
 +@item profile @var{profile_name}
 +Set profile restrictions.
 +Deprecated in favor of @var{x264_opts}.
 +
 +@item level @var{level}
 +Specify level (as defined by Annex A).
 +Deprecated in favor of @var{x264_opts}.
 +
 +@item passlogfile @var{filename}
 +Specify filename for 2 pass stats.
 +Deprecated in favor of @var{x264_opts}.
 +
 +@item wpredp @var{wpred_type}
 +Specify Weighted prediction for P-frames.
 +Deprecated in favor of @var{x264_opts}.
 +
 +@item x264opts @var{options}
 +Allow to set any x264 option, see x264 manual for a list.
 +
 +@var{options} is a list of @var{key}=@var{value} couples separated by
 +":".
 +@end table
 +
 +For example to specify libx264 encoding options with @file{ffmpeg}:
 +@example
 +ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
 +@end example
 +
 +For more information about libx264 and the supported options see:
 +@url{http://www.videolan.org/developers/x264.html}
 +
 +@c man end VIDEO ENCODERS
++
+ @subheading Floating-Point-Only AC-3 Encoding Options
+ These options are only valid for the floating-point encoder and do not exist
+ for the fixed-point encoder due to the corresponding features not being
+ implemented in fixed-point.
+ @table @option
+ @item -channel_coupling @var{boolean}
+ Enables/Disables use of channel coupling, which is an optional AC-3 feature
+ that increases quality by combining high frequency information from multiple
+ channels into a single channel. The per-channel high frequency information is
+ sent with less accuracy in both the frequency and time domains. This allows
+ more bits to be used for lower frequencies while preserving enough information
+ to reconstruct the high frequencies. This option is enabled by default for the
+ floating-point encoder and should generally be left as enabled except for
+ testing purposes or to increase encoding speed.
+ @table @option
+ @item -1
+ @itemx auto
+ Selected by Encoder (default)
+ @item 0
+ @itemx off
+ Disable Channel Coupling
+ @item 1
+ @itemx on
+ Enable Channel Coupling
+ @end table
+ @item -cpl_start_band @var{number}
+ Coupling Start Band. Sets the channel coupling start band, from 1 to 15. If a
+ value higher than the bandwidth is used, it will be reduced to 1 less than the
+ coupling end band. If @var{auto} is used, the start band will be determined by
+ the encoder based on the bit rate, sample rate, and channel layout. This option
+ has no effect if channel coupling is disabled.
+ @table @option
+ @item -1
+ @itemx auto
+ Selected by Encoder (default)
+ @end table
+ @end table
+ @c man end ENCODERS
++
Simple merge
@@@ -130,46 -129,8 +131,48 @@@ typedef enum 
      EAC3_FRAME_TYPE_RESERVED
  } EAC3FrameType;
  
-     int stereo_rematrixing;    
 +/**
 + * Encoding Options used by AVOption.
 + */
 +typedef struct AC3EncOptions {
 +    /* AC-3 metadata options*/
 +    int dialogue_level;
 +    int bitstream_mode;
 +    float center_mix_level;
 +    float surround_mix_level;
 +    int dolby_surround_mode;
 +    int audio_production_info;
 +    int mixing_level;
 +    int room_type;
 +    int copyright;
 +    int original;
 +    int extended_bsi_1;
 +    int preferred_stereo_downmix;
 +    float ltrt_center_mix_level;
 +    float ltrt_surround_mix_level;
 +    float loro_center_mix_level;
 +    float loro_surround_mix_level;
 +    int extended_bsi_2;
 +    int dolby_surround_ex_mode;
 +    int dolby_headphone_mode;
 +    int ad_converter_type;
 +
 +    /* other encoding options */
 +    int allow_per_frame_metadata;
++    int stereo_rematrixing;
++    int channel_coupling;
++    int cpl_start;    
 +} AC3EncOptions;
 +
 +
  void ff_ac3_common_init(void);
  
 +extern const int64_t ff_ac3_channel_layouts[];
 +extern const AVOption ff_ac3_options[];
 +
 +extern AVCodec ff_ac3_float_encoder;
 +extern AVCodec ff_ac3_fixed_encoder;
 +
  /**
   * Calculate the log power-spectral density of the input signal.
   * This gives a rough estimate of signal power in the frequency domain by using
Simple merge
Simple merge
Simple merge
@@@ -70,6 -70,39 +70,7 @@@ typedef struct AC3MDCTContext 
      FFTContext fft;                     ///< FFT context for MDCT calculation
  } AC3MDCTContext;
  
 -/**
 - * Encoding Options used by AVOption.
 - */
 -typedef struct AC3EncOptions {
 -    /* AC-3 metadata options*/
 -    int dialogue_level;
 -    int bitstream_mode;
 -    float center_mix_level;
 -    float surround_mix_level;
 -    int dolby_surround_mode;
 -    int audio_production_info;
 -    int mixing_level;
 -    int room_type;
 -    int copyright;
 -    int original;
 -    int extended_bsi_1;
 -    int preferred_stereo_downmix;
 -    float ltrt_center_mix_level;
 -    float ltrt_surround_mix_level;
 -    float loro_center_mix_level;
 -    float loro_surround_mix_level;
 -    int extended_bsi_2;
 -    int dolby_surround_ex_mode;
 -    int dolby_headphone_mode;
 -    int ad_converter_type;
 -
 -    /* other encoding options */
 -    int allow_per_frame_metadata;
 -    int stereo_rematrixing;
 -    int channel_coupling;
 -    int cpl_start;
 -} AC3EncOptions;
  /**
   * Data for a single audio block.
   */
@@@ -237,9 -289,14 +258,15 @@@ const AVOption ff_ac3_options[] = 
      {"hdcd",     "HDCD",               0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
  /* Other Encoding Options */
  {"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 1, AC3ENC_PARAM},
+ #if CONFIG_AC3ENC_FLOAT
+ {"channel_coupling",   "Channel Coupling",   OFFSET(channel_coupling),   FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 1, AC3ENC_PARAM, "channel_coupling"},
+     {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = -1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"},
+ {"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 15, AC3ENC_PARAM, "cpl_start_band"},
+     {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = -1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
+ #endif
  {NULL}
  };
 +#endif
  
  #if CONFIG_AC3ENC_FLOAT
  static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name,
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -154,9 -147,7 +154,9 @@@ void avcodec_register_all(void
      REGISTER_DECODER (MPEGVIDEO, mpegvideo);
      REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau);
      REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau);
-     REGISTER_ENCDEC  (MSMPEG4V1, msmpeg4v1);
 +    REGISTER_DECODER (MPEG2_CRYSTALHD, mpeg2_crystalhd);
 +    REGISTER_DECODER (MSMPEG4_CRYSTALHD, msmpeg4_crystalhd);
+     REGISTER_DECODER (MSMPEG4V1, msmpeg4v1);
      REGISTER_ENCDEC  (MSMPEG4V2, msmpeg4v2);
      REGISTER_ENCDEC  (MSMPEG4V3, msmpeg4v3);
      REGISTER_DECODER (MSRLE, msrle);
@@@ -652,23 -647,8 +645,10 @@@ void ff_intrax8dsp_init(DSPContext* c, 
  void ff_mlp_init(DSPContext* c, AVCodecContext *avctx);
  void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx);
  
- #if HAVE_MMX
- #undef emms_c
 +
- static inline void emms(void)
- {
-     __asm__ volatile ("emms;":::"memory");
- }
- #define emms_c() \
- {\
-     if(av_get_cpu_flags() & AV_CPU_FLAG_MMX)\
-         emms();\
- }
+ #if ARCH_ARM
  
- #elif ARCH_ARM
 +
  #if HAVE_NEON
  #   define STRIDE_ALIGN 16
  #endif
Simple merge
Simple merge
Simple merge
Simple merge
index 866dbb1,0000000..7dd8a64
mode 100644,000000..100644
--- /dev/null
@@@ -1,917 -1,0 +1,912 @@@
- //exact copy from vf_scale.c
 +/*
 + * Copyright (c) 2011 Michael Niedermayer
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 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 General Public License for more details.
 + *
 + * You should have received a copy of the GNU 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
 + *
 + * Parts of this file have been stolen from mplayer
 + */
 +
 +/**
 + * @file
 + */
 +
 +#include "avfilter.h"
 +#include "libavutil/avassert.h"
 +#include "libavutil/pixdesc.h"
 +#include "libavutil/intreadwrite.h"
 +#include "libavutil/imgutils.h"
 +
 +#include "libmpcodecs/vf.h"
 +#include "libmpcodecs/img_format.h"
 +#include "libmpcodecs/cpudetect.h"
 +#include "libmpcodecs/vd_ffmpeg.h"
 +#include "libmpcodecs/vf_scale.h"
 +#include "libmpcodecs/libvo/fastmemcpy.h"
 +
 +#include "libswscale/swscale.h"
 +
 +
 +//FIXME maybe link the orig in
 +static const struct {
 +    int fmt;
 +    enum PixelFormat pix_fmt;
 +} conversion_map[] = {
 +    {IMGFMT_ARGB, PIX_FMT_ARGB},
 +    {IMGFMT_BGRA, PIX_FMT_BGRA},
 +    {IMGFMT_BGR24, PIX_FMT_BGR24},
 +    {IMGFMT_BGR16BE, PIX_FMT_RGB565BE},
 +    {IMGFMT_BGR16LE, PIX_FMT_RGB565LE},
 +    {IMGFMT_BGR15BE, PIX_FMT_RGB555BE},
 +    {IMGFMT_BGR15LE, PIX_FMT_RGB555LE},
 +    {IMGFMT_BGR12BE, PIX_FMT_RGB444BE},
 +    {IMGFMT_BGR12LE, PIX_FMT_RGB444LE},
 +    {IMGFMT_BGR8,  PIX_FMT_RGB8},
 +    {IMGFMT_BGR4,  PIX_FMT_RGB4},
 +    {IMGFMT_BGR1,  PIX_FMT_MONOBLACK},
 +    {IMGFMT_RGB1,  PIX_FMT_MONOBLACK},
 +    {IMGFMT_RG4B,  PIX_FMT_BGR4_BYTE},
 +    {IMGFMT_BG4B,  PIX_FMT_RGB4_BYTE},
 +    {IMGFMT_RGB48LE, PIX_FMT_RGB48LE},
 +    {IMGFMT_RGB48BE, PIX_FMT_RGB48BE},
 +    {IMGFMT_ABGR, PIX_FMT_ABGR},
 +    {IMGFMT_RGBA, PIX_FMT_RGBA},
 +    {IMGFMT_RGB24, PIX_FMT_RGB24},
 +    {IMGFMT_RGB16BE, PIX_FMT_BGR565BE},
 +    {IMGFMT_RGB16LE, PIX_FMT_BGR565LE},
 +    {IMGFMT_RGB15BE, PIX_FMT_BGR555BE},
 +    {IMGFMT_RGB15LE, PIX_FMT_BGR555LE},
 +    {IMGFMT_RGB12BE, PIX_FMT_BGR444BE},
 +    {IMGFMT_RGB12LE, PIX_FMT_BGR444LE},
 +    {IMGFMT_RGB8,  PIX_FMT_BGR8},
 +    {IMGFMT_RGB4,  PIX_FMT_BGR4},
 +    {IMGFMT_BGR8,  PIX_FMT_PAL8},
 +    {IMGFMT_YUY2,  PIX_FMT_YUYV422},
 +    {IMGFMT_UYVY,  PIX_FMT_UYVY422},
 +    {IMGFMT_NV12,  PIX_FMT_NV12},
 +    {IMGFMT_NV21,  PIX_FMT_NV21},
 +    {IMGFMT_Y800,  PIX_FMT_GRAY8},
 +    {IMGFMT_Y8,    PIX_FMT_GRAY8},
 +    {IMGFMT_YVU9,  PIX_FMT_YUV410P},
 +    {IMGFMT_IF09,  PIX_FMT_YUV410P},
 +    {IMGFMT_YV12,  PIX_FMT_YUV420P},
 +    {IMGFMT_I420,  PIX_FMT_YUV420P},
 +    {IMGFMT_IYUV,  PIX_FMT_YUV420P},
 +    {IMGFMT_411P,  PIX_FMT_YUV411P},
 +    {IMGFMT_422P,  PIX_FMT_YUV422P},
 +    {IMGFMT_444P,  PIX_FMT_YUV444P},
 +    {IMGFMT_440P,  PIX_FMT_YUV440P},
 +
 +    {IMGFMT_420A,  PIX_FMT_YUVA420P},
 +
 +    {IMGFMT_420P16_LE,  PIX_FMT_YUV420P16LE},
 +    {IMGFMT_420P16_BE,  PIX_FMT_YUV420P16BE},
 +    {IMGFMT_422P16_LE,  PIX_FMT_YUV422P16LE},
 +    {IMGFMT_422P16_BE,  PIX_FMT_YUV422P16BE},
 +    {IMGFMT_444P16_LE,  PIX_FMT_YUV444P16LE},
 +    {IMGFMT_444P16_BE,  PIX_FMT_YUV444P16BE},
 +
 +    // YUVJ are YUV formats that use the full Y range and not just
 +    // 16 - 235 (see colorspaces.txt).
 +    // Currently they are all treated the same way.
 +    {IMGFMT_YV12,  PIX_FMT_YUVJ420P},
 +    {IMGFMT_422P,  PIX_FMT_YUVJ422P},
 +    {IMGFMT_444P,  PIX_FMT_YUVJ444P},
 +    {IMGFMT_440P,  PIX_FMT_YUVJ440P},
 +
 +    {IMGFMT_XVMC_MOCO_MPEG2, PIX_FMT_XVMC_MPEG2_MC},
 +    {IMGFMT_XVMC_IDCT_MPEG2, PIX_FMT_XVMC_MPEG2_IDCT},
 +    {IMGFMT_VDPAU_MPEG1,     PIX_FMT_VDPAU_MPEG1},
 +    {IMGFMT_VDPAU_MPEG2,     PIX_FMT_VDPAU_MPEG2},
 +    {IMGFMT_VDPAU_H264,      PIX_FMT_VDPAU_H264},
 +    {IMGFMT_VDPAU_WMV3,      PIX_FMT_VDPAU_WMV3},
 +    {IMGFMT_VDPAU_VC1,       PIX_FMT_VDPAU_VC1},
 +    {IMGFMT_VDPAU_MPEG4,     PIX_FMT_VDPAU_MPEG4},
 +    {0, PIX_FMT_NONE}
 +};
 +
 +//copied from vf.c
 +extern const vf_info_t vf_info_vo;
 +extern const vf_info_t vf_info_rectangle;
 +extern const vf_info_t vf_info_bmovl;
 +extern const vf_info_t vf_info_crop;
 +extern const vf_info_t vf_info_expand;
 +extern const vf_info_t vf_info_pp;
 +extern const vf_info_t vf_info_scale;
 +extern const vf_info_t vf_info_format;
 +extern const vf_info_t vf_info_noformat;
 +extern const vf_info_t vf_info_flip;
 +extern const vf_info_t vf_info_rotate;
 +extern const vf_info_t vf_info_mirror;
 +extern const vf_info_t vf_info_palette;
 +extern const vf_info_t vf_info_lavc;
 +extern const vf_info_t vf_info_zrmjpeg;
 +extern const vf_info_t vf_info_dvbscale;
 +extern const vf_info_t vf_info_cropdetect;
 +extern const vf_info_t vf_info_test;
 +extern const vf_info_t vf_info_noise;
 +extern const vf_info_t vf_info_yvu9;
 +extern const vf_info_t vf_info_lavcdeint;
 +extern const vf_info_t vf_info_eq;
 +extern const vf_info_t vf_info_eq2;
 +extern const vf_info_t vf_info_gradfun;
 +extern const vf_info_t vf_info_halfpack;
 +extern const vf_info_t vf_info_dint;
 +extern const vf_info_t vf_info_1bpp;
 +extern const vf_info_t vf_info_2xsai;
 +extern const vf_info_t vf_info_unsharp;
 +extern const vf_info_t vf_info_swapuv;
 +extern const vf_info_t vf_info_il;
 +extern const vf_info_t vf_info_fil;
 +extern const vf_info_t vf_info_boxblur;
 +extern const vf_info_t vf_info_sab;
 +extern const vf_info_t vf_info_smartblur;
 +extern const vf_info_t vf_info_perspective;
 +extern const vf_info_t vf_info_down3dright;
 +extern const vf_info_t vf_info_field;
 +extern const vf_info_t vf_info_denoise3d;
 +extern const vf_info_t vf_info_hqdn3d;
 +extern const vf_info_t vf_info_detc;
 +extern const vf_info_t vf_info_telecine;
 +extern const vf_info_t vf_info_tinterlace;
 +extern const vf_info_t vf_info_tfields;
 +extern const vf_info_t vf_info_ivtc;
 +extern const vf_info_t vf_info_ilpack;
 +extern const vf_info_t vf_info_dsize;
 +extern const vf_info_t vf_info_decimate;
 +extern const vf_info_t vf_info_softpulldown;
 +extern const vf_info_t vf_info_pullup;
 +extern const vf_info_t vf_info_filmdint;
 +extern const vf_info_t vf_info_framestep;
 +extern const vf_info_t vf_info_tile;
 +extern const vf_info_t vf_info_delogo;
 +extern const vf_info_t vf_info_remove_logo;
 +extern const vf_info_t vf_info_hue;
 +extern const vf_info_t vf_info_spp;
 +extern const vf_info_t vf_info_uspp;
 +extern const vf_info_t vf_info_fspp;
 +extern const vf_info_t vf_info_pp7;
 +extern const vf_info_t vf_info_yuvcsp;
 +extern const vf_info_t vf_info_kerndeint;
 +extern const vf_info_t vf_info_rgbtest;
 +extern const vf_info_t vf_info_qp;
 +extern const vf_info_t vf_info_phase;
 +extern const vf_info_t vf_info_divtc;
 +extern const vf_info_t vf_info_harddup;
 +extern const vf_info_t vf_info_softskip;
 +extern const vf_info_t vf_info_screenshot;
 +extern const vf_info_t vf_info_ass;
 +extern const vf_info_t vf_info_mcdeint;
 +extern const vf_info_t vf_info_yadif;
 +extern const vf_info_t vf_info_blackframe;
 +extern const vf_info_t vf_info_geq;
 +extern const vf_info_t vf_info_ow;
 +extern const vf_info_t vf_info_fixpts;
 +extern const vf_info_t vf_info_stereo3d;
 +
 +
 +static const vf_info_t* const filters[]={
 +    &vf_info_2xsai,
 +    &vf_info_blackframe,
 +    &vf_info_boxblur,
 +    &vf_info_cropdetect,
 +    &vf_info_decimate,
 +    &vf_info_delogo,
 +    &vf_info_denoise3d,
 +    &vf_info_detc,
 +    &vf_info_dint,
 +    &vf_info_divtc,
 +    &vf_info_down3dright,
 +    &vf_info_dsize,
 +    &vf_info_eq2,
 +    &vf_info_eq,
 +    &vf_info_field,
 +    &vf_info_fil,
 +//    &vf_info_filmdint, cmmx.h vd.h ‘opt_screen_size_x’
 +    &vf_info_fixpts,
 +    &vf_info_framestep,
 +    &vf_info_fspp,
 +    &vf_info_geq,
 +    &vf_info_gradfun,
 +    &vf_info_harddup,
 +    &vf_info_hqdn3d,
 +    &vf_info_hue,
 +    &vf_info_il,
 +    &vf_info_ilpack,
 +    &vf_info_ivtc,
 +    &vf_info_kerndeint,
 +    &vf_info_mcdeint,
 +    &vf_info_mirror,
 +    &vf_info_noise,
 +    &vf_info_ow,
 +    &vf_info_palette,
 +    &vf_info_perspective,
 +    &vf_info_phase,
 +    &vf_info_pp7,
 +    &vf_info_pullup,
 +    &vf_info_qp,
 +    &vf_info_rectangle,
 +    &vf_info_remove_logo,
 +    &vf_info_rgbtest,
 +    &vf_info_rotate,
 +    &vf_info_sab,
 +    &vf_info_screenshot,
 +    &vf_info_smartblur,
 +    &vf_info_softpulldown,
 +    &vf_info_softskip,
 +    &vf_info_spp,
 +    &vf_info_swapuv,
 +    &vf_info_telecine,
 +    &vf_info_test,
 +    &vf_info_tile,
 +    &vf_info_tinterlace,
 +    &vf_info_unsharp,
 +    &vf_info_uspp,
 +    &vf_info_yuvcsp,
 +    &vf_info_yvu9,
 +
 +    NULL
 +};
 +
 +/*
 +Unsupported filters
 +1bpp
 +ass
 +bmovl
 +crop
 +dvbscale
 +flip
 +expand
 +format
 +halfpack
 +lavc
 +lavcdeint
 +noformat
 +pp
 +scale
 +stereo3d
 +tfields
 +vo
 +yadif
 +zrmjpeg
 +*/
 +
 +CpuCaps gCpuCaps; //FIXME initialize this so optims work
 +
 +
-     return
-           (gCpuCaps.hasMMX   ? SWS_CPU_CAPS_MMX   : 0)
-         | (gCpuCaps.hasMMX2  ? SWS_CPU_CAPS_MMX2  : 0)
-         | (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0)
-         | (gCpuCaps.hasAltiVec ? SWS_CPU_CAPS_ALTIVEC : 0);
 +int get_sws_cpuflags(void){
-         return sws_getContext(srcW, srcH, sfmt, dstW, dstH, dfmt, flags | get_sws_cpuflags(), srcFilterParam, dstFilterParam, NULL);
++    return 0;
 +}
 +
 +static void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam)
 +{
 +        static int firstTime=1;
 +        *flags=0;
 +
 +#if ARCH_X86
 +        if(gCpuCaps.hasMMX)
 +                __asm__ volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions)
 +#endif
 +        if(firstTime)
 +        {
 +                firstTime=0;
 +                *flags= SWS_PRINT_INFO;
 +        }
 +        else if( mp_msg_test(MSGT_VFILTER,MSGL_DBG2) ) *flags= SWS_PRINT_INFO;
 +
 +        switch(SWS_BILINEAR)
 +        {
 +                case 0: *flags|= SWS_FAST_BILINEAR; break;
 +                case 1: *flags|= SWS_BILINEAR; break;
 +                case 2: *flags|= SWS_BICUBIC; break;
 +                case 3: *flags|= SWS_X; break;
 +                case 4: *flags|= SWS_POINT; break;
 +                case 5: *flags|= SWS_AREA; break;
 +                case 6: *flags|= SWS_BICUBLIN; break;
 +                case 7: *flags|= SWS_GAUSS; break;
 +                case 8: *flags|= SWS_SINC; break;
 +                case 9: *flags|= SWS_LANCZOS; break;
 +                case 10:*flags|= SWS_SPLINE; break;
 +                default:*flags|= SWS_BILINEAR; break;
 +        }
 +
 +        *srcFilterParam= NULL;
 +        *dstFilterParam= NULL;
 +}
 +
 +//exact copy from vf_scale.c
 +// will use sws_flags & src_filter (from cmd line)
 +struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat)
 +{
 +        int flags, i;
 +        SwsFilter *dstFilterParam, *srcFilterParam;
 +        enum PixelFormat dfmt, sfmt;
 +
 +        for(i=0; conversion_map[i].fmt && dstFormat != conversion_map[i].fmt; i++);
 +        dfmt= conversion_map[i].pix_fmt;
 +        for(i=0; conversion_map[i].fmt && srcFormat != conversion_map[i].fmt; i++);
 +        sfmt= conversion_map[i].pix_fmt;
 +
 +        if (srcFormat == IMGFMT_RGB8 || srcFormat == IMGFMT_BGR8) sfmt = PIX_FMT_PAL8;
 +        sws_getFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam);
 +
++        return sws_getContext(srcW, srcH, sfmt, dstW, dstH, dfmt, flags , srcFilterParam, dstFilterParam, NULL);
 +}
 +
 +typedef struct {
 +    vf_instance_t vf;
 +    vf_instance_t next_vf;
 +    AVFilterContext *avfctx;
 +    int frame_returned;
 +} MPContext;
 +
 +void mp_msg(int mod, int lev, const char *format, ... ){
 +    va_list va;
 +    va_start(va, format);
 +    //FIXME convert lev/mod
 +    av_vlog(NULL, AV_LOG_DEBUG, format, va);
 +    va_end(va);
 +}
 +
 +int mp_msg_test(int mod, int lev){
 +    return 123;
 +}
 +
 +void init_avcodec(void)
 +{
 +    //we maybe should init but its kinda 1. unneeded 2. a bit inpolite from here
 +}
 +
 +//Exact copy of vf.c
 +void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src){
 +    dst->pict_type= src->pict_type;
 +    dst->fields = src->fields;
 +    dst->qscale_type= src->qscale_type;
 +    if(dst->width == src->width && dst->height == src->height){
 +        dst->qstride= src->qstride;
 +        dst->qscale= src->qscale;
 +    }
 +}
 +
 +//Exact copy of vf.c
 +void vf_next_draw_slice(struct vf_instance *vf,unsigned char** src, int * stride,int w, int h, int x, int y){
 +    if (vf->next->draw_slice) {
 +        vf->next->draw_slice(vf->next,src,stride,w,h,x,y);
 +        return;
 +    }
 +    if (!vf->dmpi) {
 +        mp_msg(MSGT_VFILTER,MSGL_ERR,"draw_slice: dmpi not stored by vf_%s\n", vf->info->name);
 +        return;
 +    }
 +    if (!(vf->dmpi->flags & MP_IMGFLAG_PLANAR)) {
 +        memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+vf->dmpi->bpp/8*x,
 +            src[0], vf->dmpi->bpp/8*w, h, vf->dmpi->stride[0], stride[0]);
 +        return;
 +    }
 +    memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+x, src[0],
 +        w, h, vf->dmpi->stride[0], stride[0]);
 +    memcpy_pic(vf->dmpi->planes[1]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]+(x>>vf->dmpi->chroma_x_shift),
 +        src[1], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[1], stride[1]);
 +    memcpy_pic(vf->dmpi->planes[2]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]+(x>>vf->dmpi->chroma_x_shift),
 +        src[2], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[2], stride[2]);
 +}
 +
 +//Exact copy of vf.c
 +void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){
 +    int y;
 +    if(mpi->flags&MP_IMGFLAG_PLANAR){
 +        y0&=~1;h+=h&1;
 +        if(x0==0 && w==mpi->width){
 +            // full width clear:
 +            memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h);
 +            memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift));
 +            memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift));
 +        } else
 +        for(y=y0;y<y0+h;y+=2){
 +            memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w);
 +            memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w);
 +            memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
 +            memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
 +        }
 +        return;
 +    }
 +    // packed:
 +    for(y=y0;y<y0+h;y++){
 +        unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0;
 +        if(mpi->flags&MP_IMGFLAG_YUV){
 +            unsigned int* p=(unsigned int*) dst;
 +            int size=(mpi->bpp>>3)*w/4;
 +            int i;
 +#if HAVE_BIGENDIAN
 +#define CLEAR_PACKEDYUV_PATTERN 0x00800080
 +#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000
 +#else
 +#define CLEAR_PACKEDYUV_PATTERN 0x80008000
 +#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080
 +#endif
 +            if(mpi->flags&MP_IMGFLAG_SWAPPED){
 +                for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;
 +                for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;
 +            } else {
 +                for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN;
 +                for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN;
 +            }
 +        } else
 +            memset(dst,0,(mpi->bpp>>3)*w);
 +    }
 +}
 +
 +int vf_next_query_format(struct vf_instance *vf, unsigned int fmt){
 +    return 1;
 +}
 +
 +//used by delogo
 +unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred){
 +    return preferred;
 +}
 +
 +mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){
 +    MPContext *m= ((uint8_t*)vf) - offsetof(MPContext, next_vf);
 +  mp_image_t* mpi=NULL;
 +  int w2;
 +  int number = mp_imgtype >> 16;
 +
 +  av_assert0(vf->next == NULL); // all existing filters call this just on next
 +
 +  //vf_dint needs these as it calls vf_get_image() before configuring the output
 +  if(vf->w==0 && w>0) vf->w=w;
 +  if(vf->h==0 && h>0) vf->h=h;
 +
 +  av_assert0(w == -1 || w >= vf->w);
 +  av_assert0(h == -1 || h >= vf->h);
 +  av_assert0(vf->w > 0);
 +  av_assert0(vf->h > 0);
 +
 +  av_log(m->avfctx, AV_LOG_DEBUG, "get_image: %d:%d, vf: %d:%d\n", w,h,vf->w,vf->h);
 +
 +  if (w == -1) w = vf->w;
 +  if (h == -1) h = vf->h;
 +
 +  w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w;
 +
 +  // Note: we should call libvo first to check if it supports direct rendering
 +  // and if not, then fallback to software buffers:
 +  switch(mp_imgtype & 0xff){
 +  case MP_IMGTYPE_EXPORT:
 +    if(!vf->imgctx.export_images[0]) vf->imgctx.export_images[0]=new_mp_image(w2,h);
 +    mpi=vf->imgctx.export_images[0];
 +    break;
 +  case MP_IMGTYPE_STATIC:
 +    if(!vf->imgctx.static_images[0]) vf->imgctx.static_images[0]=new_mp_image(w2,h);
 +    mpi=vf->imgctx.static_images[0];
 +    break;
 +  case MP_IMGTYPE_TEMP:
 +    if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);
 +    mpi=vf->imgctx.temp_images[0];
 +    break;
 +  case MP_IMGTYPE_IPB:
 +    if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame:
 +      if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);
 +      mpi=vf->imgctx.temp_images[0];
 +      break;
 +    }
 +  case MP_IMGTYPE_IP:
 +    if(!vf->imgctx.static_images[vf->imgctx.static_idx]) vf->imgctx.static_images[vf->imgctx.static_idx]=new_mp_image(w2,h);
 +    mpi=vf->imgctx.static_images[vf->imgctx.static_idx];
 +    vf->imgctx.static_idx^=1;
 +    break;
 +  case MP_IMGTYPE_NUMBERED:
 +    if (number == -1) {
 +      int i;
 +      for (i = 0; i < NUM_NUMBERED_MPI; i++)
 +        if (!vf->imgctx.numbered_images[i] || !vf->imgctx.numbered_images[i]->usage_count)
 +          break;
 +      number = i;
 +    }
 +    if (number < 0 || number >= NUM_NUMBERED_MPI) return NULL;
 +    if (!vf->imgctx.numbered_images[number]) vf->imgctx.numbered_images[number] = new_mp_image(w2,h);
 +    mpi = vf->imgctx.numbered_images[number];
 +    mpi->number = number;
 +    break;
 +  }
 +  if(mpi){
 +    mpi->type=mp_imgtype;
 +    mpi->w=vf->w; mpi->h=vf->h;
 +    // keep buffer allocation status & color flags only:
 +//    mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
 +    mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;
 +    // accept restrictions, draw_slice and palette flags only:
 +    mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE);
 +    if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
 +    if(mpi->width!=w2 || mpi->height!=h){
 +//      printf("vf.c: MPI parameters changed!  %dx%d -> %dx%d   \n", mpi->width,mpi->height,w2,h);
 +        if(mpi->flags&MP_IMGFLAG_ALLOCATED){
 +            if(mpi->width<w2 || mpi->height<h){
 +                // need to re-allocate buffer memory:
 +                av_free(mpi->planes[0]);
 +                mpi->flags&=~MP_IMGFLAG_ALLOCATED;
 +                mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");
 +            }
 +//      } else {
 +        } {
 +            mpi->width=w2; mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;
 +            mpi->height=h; mpi->chroma_height=(h + (1<<mpi->chroma_y_shift) - 1)>>mpi->chroma_y_shift;
 +        }
 +    }
 +    if(!mpi->bpp) mp_image_setfmt(mpi,outfmt);
 +    if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){
 +
 +        av_assert0(!vf->get_image);
 +        // check libvo first!
 +        if(vf->get_image) vf->get_image(vf,mpi);
 +
 +        if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
 +          // non-direct and not yet allocated image. allocate it!
 +          if (!mpi->bpp) { // no way we can allocate this
 +              mp_msg(MSGT_DECVIDEO, MSGL_FATAL,
 +                     "vf_get_image: Tried to allocate a format that can not be allocated!\n");
 +              return NULL;
 +          }
 +
 +          // check if codec prefer aligned stride:
 +          if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){
 +              int align=(mpi->flags&MP_IMGFLAG_PLANAR &&
 +                         mpi->flags&MP_IMGFLAG_YUV) ?
 +                         (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME
 +              w2=((w+align)&(~align));
 +              if(mpi->width!=w2){
 +#if 0
 +                  // we have to change width... check if we CAN co it:
 +                  int flags=vf->query_format(vf,outfmt); // should not fail
 +                  if(!(flags&3)) mp_msg(MSGT_DECVIDEO,MSGL_WARN,"??? vf_get_image{vf->query_format(outfmt)} failed!\n");
 +//                printf("query -> 0x%X    \n",flags);
 +                  if(flags&VFCAP_ACCEPT_STRIDE){
 +#endif
 +                      mpi->width=w2;
 +                      mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;
 +//                  }
 +              }
 +          }
 +
 +          mp_image_alloc_planes(mpi);
 +//        printf("clearing img!\n");
 +          vf_mpi_clear(mpi,0,0,mpi->width,mpi->height);
 +        }
 +    }
 +    av_assert0(!vf->start_slice);
 +    if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)
 +        if(vf->start_slice) vf->start_slice(vf,mpi);
 +    if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){
 +            mp_msg(MSGT_DECVIDEO,MSGL_V,"*** [%s] %s%s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n",
 +                  "NULL"/*vf->info->name*/,
 +                  (mpi->type==MP_IMGTYPE_EXPORT)?"Exporting":
 +                  ((mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating"),
 +                  (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)?" (slices)":"",
 +                  mpi->width,mpi->height,mpi->bpp,
 +                  (mpi->flags&MP_IMGFLAG_YUV)?"YUV":((mpi->flags&MP_IMGFLAG_SWAPPED)?"BGR":"RGB"),
 +                  (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed",
 +                  mpi->bpp*mpi->width*mpi->height/8);
 +            mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %p,%p,%p strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n",
 +                mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2],
 +                mpi->stride[0], mpi->stride[1], mpi->stride[2],
 +                mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift);
 +            mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED;
 +    }
 +
 +  mpi->qscale = NULL;
 +  }
 +  mpi->usage_count++;
 +//    printf("\rVF_MPI: %p %p %p %d %d %d    \n",
 +//      mpi->planes[0],mpi->planes[1],mpi->planes[2],
 +//      mpi->stride[0],mpi->stride[1],mpi->stride[2]);
 +  return mpi;
 +}
 +
 +
 +int vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts){
 +    MPContext *m= (void*)vf;
 +    AVFilterLink *outlink     = m->avfctx->outputs[0];
 +    AVFilterBuffer    *pic    = av_mallocz(sizeof(AVFilterBuffer));
 +    AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef));
 +    int i;
 +
 +    av_assert0(vf->next);
 +
 +    av_log(m->avfctx, AV_LOG_DEBUG, "vf_next_put_image\n");
 +
 +    if (!pic || !picref)
 +        goto fail;
 +
 +    picref->buf = pic;
 +    picref->buf->please_use_av_free= av_free;
 +    if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps))))
 +        goto fail;
 +
 +    pic->w = picref->video->w = mpi->w;
 +    pic->h = picref->video->h = mpi->h;
 +
 +    /* make sure the buffer gets read permission or it's useless for output */
 +    picref->perms = AV_PERM_READ | AV_PERM_REUSE2;
 +//    av_assert0(mpi->flags&MP_IMGFLAG_READABLE);
 +    if(!(mpi->flags&MP_IMGFLAG_PRESERVE))
 +        picref->perms |= AV_PERM_WRITE;
 +
 +    pic->refcount = 1;
 +    picref->type = AVMEDIA_TYPE_VIDEO;
 +
 +    for(i=0; conversion_map[i].fmt && mpi->imgfmt != conversion_map[i].fmt; i++);
 +    pic->format = picref->format = conversion_map[i].pix_fmt;
 +
 +    memcpy(pic->data,        mpi->planes,   FFMIN(sizeof(pic->data)    , sizeof(mpi->planes)));
 +    memcpy(pic->linesize,    mpi->stride,   FFMIN(sizeof(pic->linesize), sizeof(mpi->stride)));
 +    memcpy(picref->data,     pic->data,     sizeof(picref->data));
 +    memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
 +
 +    if(pts != MP_NOPTS_VALUE)
 +        picref->pts= pts * av_q2d(outlink->time_base);
 +
 +    avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
 +    avfilter_draw_slice(outlink, 0, picref->video->h, 1);
 +    avfilter_end_frame(outlink);
 +    avfilter_unref_buffer(picref);
 +    m->frame_returned++;
 +
 +    return 1;
 +fail:
 +    if (picref && picref->video)
 +        av_free(picref->video);
 +    av_free(picref);
 +    av_free(pic);
 +    return 0;
 +}
 +
 +int vf_next_config(struct vf_instance *vf,
 +        int width, int height, int d_width, int d_height,
 +        unsigned int voflags, unsigned int outfmt){
 +
 +    av_assert0(width>0 && height>0);
 +    vf->next->w = width; vf->next->h = height;
 +
 +    return 1;
 +#if 0
 +    int flags=vf->next->query_format(vf->next,outfmt);
 +    if(!flags){
 +        // hmm. colorspace mismatch!!!
 +        //this is fatal for us ATM
 +        return 0;
 +    }
 +    mp_msg(MSGT_VFILTER,MSGL_V,"REQ: flags=0x%X  req=0x%X  \n",flags,vf->default_reqs);
 +    miss=vf->default_reqs - (flags&vf->default_reqs);
 +    if(miss&VFCAP_ACCEPT_STRIDE){
 +        // vf requires stride support but vf->next doesn't support it!
 +        // let's insert the 'expand' filter, it does the job for us:
 +        vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL);
 +        if(!vf2) return 0; // shouldn't happen!
 +        vf->next=vf2;
 +    }
 +    vf->next->w = width; vf->next->h = height;
 +#endif
 +    return 1;
 +}
 +
 +int vf_next_control(struct vf_instance *vf, int request, void* data){
 +    MPContext *m= (void*)vf;
 +    av_log(m->avfctx, AV_LOG_DEBUG, "Received control %d\n", request);
 +    return 0;
 +}
 +
 +static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt){
 +    MPContext *m= (void*)vf;
 +    int i;
 +    av_log(m->avfctx, AV_LOG_DEBUG, "query %X\n", fmt);
 +
 +    for(i=0; conversion_map[i].fmt; i++){
 +        if(fmt==conversion_map[i].fmt)
 +            return 1; //we suport all
 +    }
 +    return 0;
 +}
 +
 +
 +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 +{
 +    MPContext *m = ctx->priv;
 +    char name[256];
 +    int i;
 +
 +    av_log(ctx, AV_LOG_WARNING,
 +"This is a unholy filter, it will be purified by the ffmpeg exorcist team\n"
 +"which will change its syntax from dark -vf mp to light -vf.\n"
 +"Thou shalst not make spells or scripts that depend on it\n");
 +
 +    m->avfctx= ctx;
 +
 +    if(!args || 1!=sscanf(args, "%255[^:=]", name)){
 +        av_log(ctx, AV_LOG_ERROR, "Invalid parameter.\n");
 +        return AVERROR(EINVAL);
 +    }
 +    args+= strlen(name)+1;
 +
 +    for(i=0; ;i++){
 +        if(!filters[i] || !strcmp(name, filters[i]->name))
 +            break;
 +    }
 +
 +    if(!filters[i]){
 +        av_log(ctx, AV_LOG_ERROR, "Unknown filter %s\n", name);
 +        return AVERROR(EINVAL);
 +    }
 +
 +    memset(&m->vf,0,sizeof(m->vf));
 +    m->vf.info= filters[i];
 +
 +    m->vf.next        = &m->next_vf;
 +    m->vf.put_image   = vf_next_put_image;
 +    m->vf.config      = vf_next_config;
 +    m->vf.query_format= vf_default_query_format;
 +    m->vf.control     = vf_next_control;
 +    m->vf.default_caps=VFCAP_ACCEPT_STRIDE;
 +    m->vf.default_reqs=0;
 +    if(m->vf.info->opts)
 +        av_log(ctx, AV_LOG_ERROR, "opts / m_struct_set is unsupported\n");
 +#if 0
 +    if(vf->info->opts) { // vf_vo get some special argument
 +      const m_struct_t* st = vf->info->opts;
 +      void* vf_priv = m_struct_alloc(st);
 +      int n;
 +      for(n = 0 ; args && args[2*n] ; n++)
 +        m_struct_set(st,vf_priv,args[2*n],args[2*n+1]);
 +      vf->priv = vf_priv;
 +      args = NULL;
 +    } else // Otherwise we should have the '_oldargs_'
 +      if(args && !strcmp(args[0],"_oldargs_"))
 +        args = (char**)args[1];
 +      else
 +        args = NULL;
 +#endif
 +    if(m->vf.info->vf_open(&m->vf, args)<=0){
 +        av_log(ctx, AV_LOG_ERROR, "vf_open() of %s with arg=%s failed\n", name, args);
 +        return -1;
 +    }
 +
 +    return 0;
 +}
 +
 +static int query_formats(AVFilterContext *ctx)
 +{
 +    AVFilterFormats *avfmts=NULL;
 +    MPContext *m = ctx->priv;
 +    int i;
 +
 +    for(i=0; conversion_map[i].fmt; i++){
 +        av_log(ctx, AV_LOG_DEBUG, "query: %X\n", conversion_map[i].fmt);
 +        if(m->vf.query_format(&m->vf, conversion_map[i].fmt)){
 +            av_log(ctx, AV_LOG_DEBUG, "supported,adding\n");
 +            avfilter_add_format(&avfmts, conversion_map[i].pix_fmt);
 +        }
 +    }
 +
 +    //We assume all allowed input formats are also allowed output formats
 +    avfilter_set_common_formats(ctx, avfmts);
 +    return 0;
 +}
 +
 +static int config_inprops(AVFilterLink *inlink)
 +{
 +    MPContext *m = inlink->dst->priv;
 +    int i;
 +    for(i=0; conversion_map[i].fmt && conversion_map[i].pix_fmt != inlink->format; i++);
 +
 +    av_assert0(conversion_map[i].fmt && inlink->w && inlink->h);
 +
 +    m->vf.fmt.have_configured = 1;
 +    m->vf.fmt.orig_height     = inlink->h;
 +    m->vf.fmt.orig_width      = inlink->w;
 +    m->vf.fmt.orig_fmt        = conversion_map[i].fmt;
 +
 +    if(m->vf.config(&m->vf, inlink->w, inlink->h, inlink->w, inlink->h, 0, conversion_map[i].fmt)<=0)
 +        return -1;
 +
 +    return 0;
 +}
 +
 +static int config_outprops(AVFilterLink *outlink)
 +{
 +    MPContext *m = outlink->src->priv;
 +
 +    outlink->w = m->next_vf.w;
 +    outlink->h = m->next_vf.h;
 +
 +    return 0;
 +}
 +
 +static int request_frame(AVFilterLink *outlink)
 +{
 +    MPContext *m = outlink->src->priv;
 +    int ret;
 +
 +    av_log(m->avfctx, AV_LOG_DEBUG, "mp request_frame\n");
 +
 +    for(m->frame_returned=0; !m->frame_returned;){
 +        ret=avfilter_request_frame(outlink->src->inputs[0]);
 +        if(ret<0)
 +            break;
 +    }
 +
 +    av_log(m->avfctx, AV_LOG_DEBUG, "mp request_frame ret=%d\n", ret);
 +    return ret;
 +}
 +
 +static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
 +{
 +}
 +
 +static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 +{
 +}
 +
 +static void end_frame(AVFilterLink *inlink)
 +{
 +    MPContext *m = inlink->dst->priv;
 +    AVFilterBufferRef *inpic  = inlink->cur_buf;
 +    int i;
 +    double pts= MP_NOPTS_VALUE;
 +    mp_image_t* mpi = new_mp_image(inpic->video->w, inpic->video->h);
 +
 +    if(inpic->pts != AV_NOPTS_VALUE)
 +        pts= inpic->pts / av_q2d(inlink->time_base);
 +
 +    for(i=0; conversion_map[i].fmt && conversion_map[i].pix_fmt != inlink->format; i++);
 +    mp_image_setfmt(mpi,conversion_map[i].fmt);
 +
 +    memcpy(mpi->planes, inpic->data,     FFMIN(sizeof(inpic->data)    , sizeof(mpi->planes)));
 +    memcpy(mpi->stride, inpic->linesize, FFMIN(sizeof(inpic->linesize), sizeof(mpi->stride)));
 +
 +    //FIXME pass interleced & tff flags around
 +
 +    // mpi->flags|=MP_IMGFLAG_ALLOCATED; ?
 +    mpi->flags |= MP_IMGFLAG_READABLE;
 +    if(!(inpic->perms & AV_PERM_WRITE))
 +        mpi->flags |= MP_IMGFLAG_PRESERVE;
 +    if(m->vf.put_image(&m->vf, mpi, pts) == 0){
 +        av_log(m->avfctx, AV_LOG_DEBUG, "put_image() says skip\n");
 +    }
 +    free_mp_image(mpi);
 +
 +//    avfilter_unref_buffer(inpic);
 +}
 +
 +AVFilter avfilter_vf_mp = {
 +    .name      = "mp",
 +    .description = NULL_IF_CONFIG_SMALL("libmpcodecs wrapper."),
 +    .init = init,
 +    .priv_size = sizeof(MPContext),
 +    .query_formats = query_formats,
 +
 +    .inputs    = (AVFilterPad[]) {{ .name            = "default",
 +                                    .type            = AVMEDIA_TYPE_VIDEO,
 +                                    .start_frame     = start_frame,
 +                                    .draw_slice      = null_draw_slice,
 +                                    .end_frame       = end_frame,
 +                                    .config_props    = config_inprops,
 +                                    .min_perms       = AV_PERM_READ, },
 +                                  { .name = NULL}},
 +    .outputs   = (AVFilterPad[]) {{ .name            = "default",
 +                                    .type            = AVMEDIA_TYPE_VIDEO,
 +                                    .request_frame   = request_frame,
 +                                    .config_props    = config_outprops, },
 +                                  { .name = NULL}},
 +};
   * memory buffer source API for video
   */
  
 -#include "libavcodec/avcodec.h" /* AVFrame */
++
  #include "avfilter.h"
  
 -int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
 -                             int64_t pts, AVRational pixel_aspect);
 +/**
 + * Add video buffer data in picref to buffer_src.
 + *
 + * @param buffer_src pointer to a buffer source context
 + * @return >= 0 in case of success, a negative AVERROR code in case of
 + * failure
 + */
 +int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_src, AVFilterBufferRef *picref);
  
  #endif /* AVFILTER_VSRC_BUFFER_H */
Simple merge
@@@ -37,6 -37,6 +37,7 @@@
  #include "config.h"
  #include "attributes.h"
  #include "timer.h"
++#include "cpu.h"
  
  #ifndef attribute_align_arg
  #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
  #   define ONLY_IF_THREADS_ENABLED(x) NULL
  #endif
  
 -    __asm__ volatile ("emms" ::: "memory");
+ #if HAVE_MMX
+ /**
+  * Empty mmx state.
+  * this must be called between any dsp function and float/double code.
+  * for example sin(); dsp->idct_put(); emms_c(); cos()
+  */
+ static av_always_inline void emms_c(void)
+ {
++    if(av_get_cpu_flags() & AV_CPU_FLAG_MMX)
++        __asm__ volatile ("emms" ::: "memory");
+ }
+ #else /* HAVE_MMX */
+ #define emms_c()
+ #endif /* HAVE_MMX */
  #endif /* AVUTIL_INTERNAL_H */
Simple merge
Simple merge
Simple merge
@@@ -109,661 -54,8 +54,9 @@@ static inline void RENAME(yuv2packedX)(
                         chrFilter, chrSrc, chrFilterSize,
                         alpSrc, dest, dstW, dstY);
  }
+ #endif
  
- /**
-  * vertical bilinear scale YV12 to RGB
-  */
- static inline void RENAME(yuv2packed2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *uvbuf0, const uint16_t *uvbuf1,
-                           const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
- {
-     int  yalpha1=4095- yalpha;
-     int uvalpha1=4095-uvalpha;
-     int i;
-     YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C(void,0), YSCALE_YUV_2_GRAY16_2_C, YSCALE_YUV_2_MONO2_C)
- }
- /**
-  * YV12 to RGB without scaling or interpolating
-  */
- static inline void RENAME(yuv2packed1)(SwsContext *c, const uint16_t *buf0, const uint16_t *uvbuf0, const uint16_t *uvbuf1,
-                           const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y)
- {
-     const int yalpha1=0;
-     int i;
-     const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
-     const int yalpha= 4096; //FIXME ...
-     if (flags&SWS_FULL_CHR_H_INT) {
-         c->yuv2packed2(c, buf0, buf0, uvbuf0, uvbuf1, abuf0, abuf0, dest, dstW, 0, uvalpha, y);
-         return;
-     }
-     if (uvalpha < 2048) {
-         YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C(void,0), YSCALE_YUV_2_GRAY16_1_C, YSCALE_YUV_2_MONO2_C)
-     } else {
-         YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C(void,0), YSCALE_YUV_2_GRAY16_1_C, YSCALE_YUV_2_MONO2_C)
-     }
- }
- //FIXME yuy2* can read up to 7 samples too much
- static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++)
-         dst[i]= src[2*i];
- }
- static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         dstU[i]= src1[4*i + 1];
-         dstV[i]= src1[4*i + 3];
-     }
-     assert(src1 == src2);
- }
- static inline void RENAME(LEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         dstU[i]= src1[2*i + 1];
-         dstV[i]= src2[2*i + 1];
-     }
- }
- /* This is almost identical to the previous, end exists only because
-  * yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses. */
- static inline void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++)
-         dst[i]= src[2*i+1];
- }
- static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         dstU[i]= src1[4*i + 0];
-         dstV[i]= src1[4*i + 2];
-     }
-     assert(src1 == src2);
- }
- static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         dstU[i]= src1[2*i];
-         dstV[i]= src2[2*i];
-     }
- }
- static inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2,
-                                     const uint8_t *src, long width)
- {
-     int i;
-     for (i = 0; i < width; i++) {
-         dst1[i] = src[2*i+0];
-         dst2[i] = src[2*i+1];
-     }
- }
- static inline void RENAME(nv12ToUV)(uint8_t *dstU, uint8_t *dstV,
-                                     const uint8_t *src1, const uint8_t *src2,
-                                     long width, uint32_t *unused)
- {
-     RENAME(nvXXtoUV)(dstU, dstV, src1, width);
- }
- static inline void RENAME(nv21ToUV)(uint8_t *dstU, uint8_t *dstV,
-                                     const uint8_t *src1, const uint8_t *src2,
-                                     long width, uint32_t *unused)
- {
-     RENAME(nvXXtoUV)(dstV, dstU, src1, width);
- }
- static inline void RENAME(bgr24ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         int b= src[i*3+0];
-         int g= src[i*3+1];
-         int r= src[i*3+2];
-         dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
-     }
- }
- static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         int b= src1[3*i + 0];
-         int g= src1[3*i + 1];
-         int r= src1[3*i + 2];
-         dstU[i]= (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT;
-         dstV[i]= (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT;
-     }
-     assert(src1 == src2);
- }
- static inline void RENAME(bgr24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         int b= src1[6*i + 0] + src1[6*i + 3];
-         int g= src1[6*i + 1] + src1[6*i + 4];
-         int r= src1[6*i + 2] + src1[6*i + 5];
-         dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);
-         dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);
-     }
-     assert(src1 == src2);
- }
- static inline void RENAME(rgb24ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
- {
-     int i;
-     for (i=0; i<width; i++) {
-         int r= src[i*3+0];
-         int g= src[i*3+1];
-         int b= src[i*3+2];
-         dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
-     }
- }
- static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     assert(src1==src2);
-     for (i=0; i<width; i++) {
-         int r= src1[3*i + 0];
-         int g= src1[3*i + 1];
-         int b= src1[3*i + 2];
-         dstU[i]= (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT;
-         dstV[i]= (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT;
-     }
- }
- static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
- {
-     int i;
-     assert(src1==src2);
-     for (i=0; i<width; i++) {
-         int r= src1[6*i + 0] + src1[6*i + 3];
-         int g= src1[6*i + 1] + src1[6*i + 4];
-         int b= src1[6*i + 2] + src1[6*i + 5];
-         dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);
-         dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);
-     }
- }
- // bilinear / bicubic scaling
- static inline void RENAME(hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW, int xInc,
-                                   const int16_t *filter, const int16_t *filterPos, long filterSize)
- {
- #if COMPILE_TEMPLATE_ALTIVEC
-     hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
- #else
-     int i;
-     for (i=0; i<dstW; i++) {
-         int j;
-         int srcPos= filterPos[i];
-         int val=0;
-         //printf("filterPos: %d\n", filterPos[i]);
-         for (j=0; j<filterSize; j++) {
-             //printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]);
-             val += ((int)src[srcPos + j])*filter[filterSize*i + j];
-         }
-         //filter += hFilterSize;
-         dst[i] = FFMIN(val>>7, (1<<15)-1); // the cubic equation does overflow ...
-         //dst[i] = val>>7;
-     }
- #endif /* COMPILE_TEMPLATE_ALTIVEC */
- }
- //FIXME all pal and rgb srcFormats could do this convertion as well
- //FIXME all scalers more complex than bilinear could do half of this transform
- static void RENAME(chrRangeToJpeg)(uint16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++) {
-         dst[i     ] = (FFMIN(dst[i     ],30775)*4663 - 9289992)>>12; //-264
-         dst[i+VOFW] = (FFMIN(dst[i+VOFW],30775)*4663 - 9289992)>>12; //-264
-     }
- }
- static void RENAME(chrRangeFromJpeg)(uint16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++) {
-         dst[i     ] = (dst[i     ]*1799 + 4081085)>>11; //1469
-         dst[i+VOFW] = (dst[i+VOFW]*1799 + 4081085)>>11; //1469
-     }
- }
- static void RENAME(lumRangeToJpeg)(uint16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++)
-         dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14;
- }
- static void RENAME(lumRangeFromJpeg)(uint16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++)
-         dst[i] = (dst[i]*14071 + 33561947)>>14;
- }
- static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
-                                         long dstWidth, const uint8_t *src, int srcW,
-                                         int xInc)
- {
-     int i;
-     unsigned int xpos=0;
-     for (i=0;i<dstWidth;i++) {
-         register unsigned int xx=xpos>>16;
-         register unsigned int xalpha=(xpos&0xFFFF)>>9;
-         dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
-         xpos+=xInc;
-     }
- }
-       // *** horizontal scale Y line to temp buffer
- static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc,
-                                    const int16_t *hLumFilter,
-                                    const int16_t *hLumFilterPos, int hLumFilterSize,
-                                    uint8_t *formatConvBuffer,
-                                    uint32_t *pal, int isAlpha)
- {
-     void (*toYV12)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
-     void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
-     src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
-     if (toYV12) {
-         toYV12(formatConvBuffer, src, srcW, pal);
-         src= formatConvBuffer;
-     }
-     if (c->hScale16) {
-         c->hScale16(dst, dstWidth, (uint16_t*)src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize, av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1);
-     } else if (!c->hyscale_fast) {
-         c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
-     } else { // fast bilinear upscale / crap downscale
-         c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
-     }
-     if (convertRange)
-         convertRange(dst, dstWidth);
- }
- static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
-                                         long dstWidth, const uint8_t *src1,
-                                         const uint8_t *src2, int srcW, int xInc)
- {
-     int i;
-     unsigned int xpos=0;
-     for (i=0;i<dstWidth;i++) {
-         register unsigned int xx=xpos>>16;
-         register unsigned int xalpha=(xpos&0xFFFF)>>9;
-         dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
-         dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
-         /* slower
-         dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
-         dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
-         */
-         xpos+=xInc;
-     }
- }
- inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
-                                    int srcW, int xInc, const int16_t *hChrFilter,
-                                    const int16_t *hChrFilterPos, int hChrFilterSize,
-                                    uint8_t *formatConvBuffer,
-                                    uint32_t *pal)
- {
-     src1 += c->chrSrcOffset;
-     src2 += c->chrSrcOffset;
-     if (c->chrToYV12) {
-         c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
-         src1= formatConvBuffer;
-         src2= formatConvBuffer+VOFW;
-     }
-     if (c->hScale16) {
-         c->hScale16(dst     , dstWidth, (uint16_t*)src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1);
-         c->hScale16(dst+VOFW, dstWidth, (uint16_t*)src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1);
-     } else if (!c->hcscale_fast) {
-         c->hScale(dst     , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
-         c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
-     } else { // fast bilinear upscale / crap downscale
-         c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
-     }
-     if (c->chrConvertRange)
-         c->chrConvertRange(dst, dstWidth);
- }
- #define DEBUG_SWSCALE_BUFFERS 0
- #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__)
- static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
-                            int srcSliceH, uint8_t* dst[], int dstStride[])
- {
-     /* load a few things into local vars to make the code more readable? and faster */
-     const int srcW= c->srcW;
-     const int dstW= c->dstW;
-     const int dstH= c->dstH;
-     const int chrDstW= c->chrDstW;
-     const int chrSrcW= c->chrSrcW;
-     const int lumXInc= c->lumXInc;
-     const int chrXInc= c->chrXInc;
-     const enum PixelFormat dstFormat= c->dstFormat;
-     const int flags= c->flags;
-     int16_t *vLumFilterPos= c->vLumFilterPos;
-     int16_t *vChrFilterPos= c->vChrFilterPos;
-     int16_t *hLumFilterPos= c->hLumFilterPos;
-     int16_t *hChrFilterPos= c->hChrFilterPos;
-     int16_t *vLumFilter= c->vLumFilter;
-     int16_t *vChrFilter= c->vChrFilter;
-     int16_t *hLumFilter= c->hLumFilter;
-     int16_t *hChrFilter= c->hChrFilter;
-     int32_t *lumMmxFilter= c->lumMmxFilter;
-     int32_t *chrMmxFilter= c->chrMmxFilter;
-     int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
-     const int vLumFilterSize= c->vLumFilterSize;
-     const int vChrFilterSize= c->vChrFilterSize;
-     const int hLumFilterSize= c->hLumFilterSize;
-     const int hChrFilterSize= c->hChrFilterSize;
-     int16_t **lumPixBuf= c->lumPixBuf;
-     int16_t **chrPixBuf= c->chrPixBuf;
-     int16_t **alpPixBuf= c->alpPixBuf;
-     const int vLumBufSize= c->vLumBufSize;
-     const int vChrBufSize= c->vChrBufSize;
-     uint8_t *formatConvBuffer= c->formatConvBuffer;
-     const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
-     const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
-     int lastDstY;
-     uint32_t *pal=c->pal_yuv;
-     /* vars which will change and which we need to store back in the context */
-     int dstY= c->dstY;
-     int lumBufIndex= c->lumBufIndex;
-     int chrBufIndex= c->chrBufIndex;
-     int lastInLumBuf= c->lastInLumBuf;
-     int lastInChrBuf= c->lastInChrBuf;
-     if (isPacked(c->srcFormat)) {
-         src[0]=
-         src[1]=
-         src[2]=
-         src[3]= src[0];
-         srcStride[0]=
-         srcStride[1]=
-         srcStride[2]=
-         srcStride[3]= srcStride[0];
-     }
-     srcStride[1]<<= c->vChrDrop;
-     srcStride[2]<<= c->vChrDrop;
-     DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
-                   src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
-                   dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
-     DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
-                    srcSliceY,    srcSliceH,    dstY,    dstH);
-     DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
-                    vLumFilterSize,    vLumBufSize,    vChrFilterSize,    vChrBufSize);
-     if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {
-         static int warnedAlready=0; //FIXME move this into the context perhaps
-         if (flags & SWS_PRINT_INFO && !warnedAlready) {
-             av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
-                    "         ->cannot do aligned memory accesses anymore\n");
-             warnedAlready=1;
-         }
-     }
-     /* Note the user might start scaling the picture in the middle so this
-        will not get executed. This is not really intended but works
-        currently, so people might do it. */
-     if (srcSliceY ==0) {
-         lumBufIndex=-1;
-         chrBufIndex=-1;
-         dstY=0;
-         lastInLumBuf= -1;
-         lastInChrBuf= -1;
-     }
-     lastDstY= dstY;
-     for (;dstY < dstH; dstY++) {
-         unsigned char *dest =dst[0]+dstStride[0]*dstY;
-         const int chrDstY= dstY>>c->chrDstVSubSample;
-         unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
-         unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
-         unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;
-         const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
-         const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];
-         const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
-         int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
-         int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed as input
-         int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
-         int enough_lines;
-         //handle holes (FAST_BILINEAR & weird filters)
-         if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
-         if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
-         assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
-         assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
-         DEBUG_BUFFERS("dstY: %d\n", dstY);
-         DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
-                          firstLumSrcY,    lastLumSrcY,    lastInLumBuf);
-         DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
-                          firstChrSrcY,    lastChrSrcY,    lastInChrBuf);
-         // Do we have enough lines in this slice to output the dstY line
-         enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
-         if (!enough_lines) {
-             lastLumSrcY = srcSliceY + srcSliceH - 1;
-             lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
-             DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
-                                             lastLumSrcY, lastChrSrcY);
-         }
-         //Do horizontal scaling
-         while(lastInLumBuf < lastLumSrcY) {
-             const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
-             const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
-             lumBufIndex++;
-             assert(lumBufIndex < 2*vLumBufSize);
-             assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
-             assert(lastInLumBuf + 1 - srcSliceY >= 0);
-             RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
-                             hLumFilter, hLumFilterPos, hLumFilterSize,
-                             formatConvBuffer,
-                             pal, 0);
-             if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
-                 RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc,
-                                 hLumFilter, hLumFilterPos, hLumFilterSize,
-                                 formatConvBuffer,
-                                 pal, 1);
-             lastInLumBuf++;
-             DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
-                                lumBufIndex,    lastInLumBuf);
-         }
-         while(lastInChrBuf < lastChrSrcY) {
-             const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
-             const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
-             chrBufIndex++;
-             assert(chrBufIndex < 2*vChrBufSize);
-             assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
-             assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
-             //FIXME replace parameters through context struct (some at least)
-             if (c->needs_hcscale)
-                 RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
-                                 hChrFilter, hChrFilterPos, hChrFilterSize,
-                                 formatConvBuffer,
-                                 pal);
-             lastInChrBuf++;
-             DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
-                                chrBufIndex,    lastInChrBuf);
-         }
-         //wrap buf index around to stay inside the ring buffer
-         if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;
-         if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;
-         if (!enough_lines)
-             break; //we can't output a dstY line so let's try with the next slice
-         if (dstY < dstH-2) {
-             const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
-             const int16_t **chrSrcPtr= (const int16_t **) chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
-             const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
-             if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
-                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
-                 if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
-                 c->yuv2nv12X(c,
-                              vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                              vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                              dest, uDest, dstW, chrDstW, dstFormat);
-             } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
-                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
-                 if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
-                 if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
-                     yuv2yuvX16inC(
-                                   vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                                   vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                   alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
-                                   dstFormat);
-                 } else if (vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
-                     const int16_t *lumBuf = lumSrcPtr[0];
-                     const int16_t *chrBuf= chrSrcPtr[0];
-                     const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
-                     c->yuv2yuv1(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW);
-                 } else { //General YV12
-                     c->yuv2yuvX(c,
-                                 vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                                 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                 alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
-                 }
-             } else {
-                 assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
-                 assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
-                 if (vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB
-                     int chrAlpha= vChrFilter[2*dstY+1];
-                     if(flags & SWS_FULL_CHR_H_INT) {
-                         yuv2rgbXinC_full(c, //FIXME write a packed1_full function
-                                          vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
-                                          vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                          alpSrcPtr, dest, dstW, dstY);
-                     } else {
-                         c->yuv2packed1(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
-                                        alpPixBuf ? *alpSrcPtr : NULL,
-                                        dest, dstW, chrAlpha, dstFormat, flags, dstY);
-                     }
-                 } else if (vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB
-                     int lumAlpha= vLumFilter[2*dstY+1];
-                     int chrAlpha= vChrFilter[2*dstY+1];
-                     lumMmxFilter[2]=
-                     lumMmxFilter[3]= vLumFilter[2*dstY   ]*0x10001;
-                     chrMmxFilter[2]=
-                     chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
-                     if(flags & SWS_FULL_CHR_H_INT) {
-                         yuv2rgbXinC_full(c, //FIXME write a packed2_full function
-                                          vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
-                                          vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                          alpSrcPtr, dest, dstW, dstY);
-                     } else {
-                         c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
-                                        alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
-                                        dest, dstW, lumAlpha, chrAlpha, dstY);
-                     }
-                 } else { //general RGB
-                     if(flags & SWS_FULL_CHR_H_INT) {
-                         yuv2rgbXinC_full(c,
-                                          vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
-                                          vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                          alpSrcPtr, dest, dstW, dstY);
-                     } else {
-                         c->yuv2packedX(c,
-                                        vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
-                                        vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                        alpSrcPtr, dest, dstW, dstY);
-                     }
-                 }
-             }
-         } else { // hmm looks like we can't use MMX here without overwriting this array's tail
-             const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
-             const int16_t **chrSrcPtr= (const int16_t **)chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
-             const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
-             if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
-                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
-                 if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
-                 yuv2nv12XinC(
-                              vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                              vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                              dest, uDest, dstW, chrDstW, dstFormat);
-             } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12
-                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
-                 if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
-                 if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
-                     yuv2yuvX16inC(
-                                   vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                                   vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                   alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
-                                   dstFormat);
-                 } else {
-                     yuv2yuvXinC(
-                                 vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
-                                 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                 alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
-                 }
-             } else {
-                 assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
-                 assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
-                 if(flags & SWS_FULL_CHR_H_INT) {
-                     yuv2rgbXinC_full(c,
-                                      vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
-                                      vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                      alpSrcPtr, dest, dstW, dstY);
-                 } else {
-                     yuv2packedXinC(c,
-                                    vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
-                                    vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                                    alpSrcPtr, dest, dstW, dstY);
-                 }
-             }
-         }
-     }
-     if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
-         fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
-     /* store changed local vars back in the context */
-     c->dstY= dstY;
-     c->lumBufIndex= lumBufIndex;
-     c->chrBufIndex= chrBufIndex;
-     c->lastInLumBuf= lastInLumBuf;
-     c->lastInChrBuf= lastInChrBuf;
-     return dstY - lastDstY;
- }
 +
  static void RENAME(sws_init_swScale)(SwsContext *c)
  {
      enum PixelFormat srcFormat = c->srcFormat;
Simple merge
@@@ -116,42 -116,13 +116,41 @@@ void (*yuyvtoyuv422)(uint8_t *ydst, uin
   32-bit C version, and and&add trick by Michael Niedermayer
  */
  
- void sws_rgb2rgb_init(int flags)
+ void sws_rgb2rgb_init(void)
  {
      rgb2rgb_init_c();
- #if HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX
-     rgb2rgb_init_x86(flags);
- #endif /* HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX */
+     if (HAVE_MMX)
+         rgb2rgb_init_x86();
  }
  
 +#if LIBSWSCALE_VERSION_MAJOR < 1
 +void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
 +{
 +    sws_convertPalette8ToPacked32(src, dst, num_pixels, palette);
 +}
 +
 +void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
 +{
 +    sws_convertPalette8ToPacked24(src, dst, num_pixels, palette);
 +}
 +
 +/**
 + * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette.
 + */
 +void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
 +{
 +    long i;
 +    for (i=0; i<num_pixels; i++)
 +        ((uint16_t *)dst)[i] = ((const uint16_t *)palette)[src[i]];
 +}
 +void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
 +{
 +    long i;
 +    for (i=0; i<num_pixels; i++)
 +        ((uint16_t *)dst)[i] = av_bswap16(((const uint16_t *)palette)[src[i]]);
 +}
 +#endif
 +
  void rgb32to24(const uint8_t *src, uint8_t *dst, long src_size)
  {
      long i;
Simple merge
Simple merge
@@@ -60,9 -60,9 +60,10 @@@ untested special converter
  #include "swscale.h"
  #include "swscale_internal.h"
  #include "rgb2rgb.h"
 +#include "libavutil/avassert.h"
  #include "libavutil/intreadwrite.h"
  #include "libavutil/x86_cpu.h"
+ #include "libavutil/cpu.h"
  #include "libavutil/avutil.h"
  #include "libavutil/mathematics.h"
  #include "libavutil/bswap.h"
Simple merge
Simple merge
@@@ -363,180 -364,9 +363,38 @@@ static inline void hScale_c(int16_t *ds
      }
  }
  
- static inline void RENAME(hScale16)(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc,
++static inline void hScale16_c(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc,
 +                                    const int16_t *filter, const int16_t *filterPos, long filterSize, int shift)
 +{
 +    int i, j;
- #if COMPILE_TEMPLATE_MMX
-     assert(filterSize % 4 == 0 && filterSize>0);
-     if (filterSize==4 && shift<15) { // Always true for upscaling, sometimes for down, too.
-         x86_reg counter= -2*dstW;
-         filter-= counter*2;
-         filterPos-= counter/2;
-         dst-= counter/2;
-         __asm__ volatile(
-             "movd                   %5, %%mm7       \n\t"
- #if defined(PIC)
-             "push            %%"REG_b"              \n\t"
- #endif
-             "push           %%"REG_BP"              \n\t" // we use 7 regs here ...
-             "mov             %%"REG_a", %%"REG_BP"  \n\t"
-             ".p2align                4              \n\t"
-             "1:                                     \n\t"
-             "movzwl   (%2, %%"REG_BP"), %%eax       \n\t"
-             "movzwl  2(%2, %%"REG_BP"), %%ebx       \n\t"
-             "movq  (%1, %%"REG_BP", 4), %%mm1       \n\t"
-             "movq 8(%1, %%"REG_BP", 4), %%mm3       \n\t"
-             "movq      (%3, %%"REG_a", 2), %%mm0    \n\t"
-             "movq      (%3, %%"REG_b", 2), %%mm2    \n\t"
-             "pmaddwd             %%mm1, %%mm0       \n\t"
-             "pmaddwd             %%mm2, %%mm3       \n\t"
-             "movq                %%mm0, %%mm4       \n\t"
-             "punpckldq           %%mm3, %%mm0       \n\t"
-             "punpckhdq           %%mm3, %%mm4       \n\t"
-             "paddd               %%mm4, %%mm0       \n\t"
-             "psrad               %%mm7, %%mm0       \n\t"
-             "packssdw            %%mm0, %%mm0       \n\t"
-             "movd                %%mm0, (%4, %%"REG_BP")    \n\t"
-             "add                    $4, %%"REG_BP"  \n\t"
-             " jnc                   1b              \n\t"
-             "pop            %%"REG_BP"              \n\t"
- #if defined(PIC)
-             "pop             %%"REG_b"              \n\t"
- #endif
-             : "+a" (counter)
-             : "c" (filter), "d" (filterPos), "S" (src), "D" (dst), "m"(shift)
- #if !defined(PIC)
-             : "%"REG_b
- #endif
-         );
-     } else if (filterSize==8 && shift<15) {
-         x86_reg counter= -2*dstW;
-         filter-= counter*4;
-         filterPos-= counter/2;
-         dst-= counter/2;
-         __asm__ volatile(
-             "movd                   %5, %%mm7       \n\t"
- #if defined(PIC)
-             "push            %%"REG_b"              \n\t"
- #endif
-             "push            %%"REG_BP"             \n\t" // we use 7 regs here ...
-             "mov              %%"REG_a", %%"REG_BP" \n\t"
-             ".p2align                 4             \n\t"
-             "1:                                     \n\t"
-             "movzwl    (%2, %%"REG_BP"), %%eax      \n\t"
-             "movzwl   2(%2, %%"REG_BP"), %%ebx      \n\t"
-             "movq   (%1, %%"REG_BP", 8), %%mm1      \n\t"
-             "movq 16(%1, %%"REG_BP", 8), %%mm3      \n\t"
-             "movq       (%3, %%"REG_a", 2), %%mm0   \n\t"
-             "movq       (%3, %%"REG_b", 2), %%mm2   \n\t"
-             "pmaddwd              %%mm1, %%mm0      \n\t"
-             "pmaddwd              %%mm2, %%mm3      \n\t"
-             "movq  8(%1, %%"REG_BP", 8), %%mm1      \n\t"
-             "movq 24(%1, %%"REG_BP", 8), %%mm5      \n\t"
-             "movq      8(%3, %%"REG_a", 2), %%mm4   \n\t"
-             "movq      8(%3, %%"REG_b", 2), %%mm2   \n\t"
-             "pmaddwd              %%mm1, %%mm4      \n\t"
-             "pmaddwd              %%mm2, %%mm5      \n\t"
-             "paddd                %%mm4, %%mm0      \n\t"
-             "paddd                %%mm5, %%mm3      \n\t"
-             "movq                 %%mm0, %%mm4      \n\t"
-             "punpckldq            %%mm3, %%mm0      \n\t"
-             "punpckhdq            %%mm3, %%mm4      \n\t"
-             "paddd                %%mm4, %%mm0      \n\t"
-             "psrad                %%mm7, %%mm0      \n\t"
-             "packssdw             %%mm0, %%mm0      \n\t"
-             "movd                 %%mm0, (%4, %%"REG_BP")   \n\t"
-             "add                     $4, %%"REG_BP" \n\t"
-             " jnc                    1b             \n\t"
-             "pop             %%"REG_BP"             \n\t"
- #if defined(PIC)
-             "pop             %%"REG_b"              \n\t"
- #endif
-             : "+a" (counter)
-             : "c" (filter), "d" (filterPos), "S" (src), "D" (dst), "m"(shift)
- #if !defined(PIC)
-             : "%"REG_b
- #endif
-         );
-     } else if (shift<15){
-         const uint16_t *offset = src+filterSize;
-         x86_reg counter= -2*dstW;
-         //filter-= counter*filterSize/2;
-         filterPos-= counter/2;
-         dst-= counter/2;
-         __asm__ volatile(
-             "movd                   %7, %%mm7       \n\t"
-             ".p2align                  4            \n\t"
-             "1:                                     \n\t"
-             "mov                      %2, %%"REG_c" \n\t"
-             "movzwl      (%%"REG_c", %0), %%eax     \n\t"
-             "movzwl     2(%%"REG_c", %0), %%edx     \n\t"
-             "mov                      %5, %%"REG_c" \n\t"
-             "pxor                  %%mm4, %%mm4     \n\t"
-             "pxor                  %%mm5, %%mm5     \n\t"
-             "2:                                     \n\t"
-             "movq                   (%1), %%mm1     \n\t"
-             "movq               (%1, %6), %%mm3     \n\t"
-             "movq (%%"REG_c", %%"REG_a", 2), %%mm0     \n\t"
-             "movq (%%"REG_c", %%"REG_d", 2), %%mm2     \n\t"
-             "pmaddwd               %%mm1, %%mm0     \n\t"
-             "pmaddwd               %%mm2, %%mm3     \n\t"
-             "paddd                 %%mm3, %%mm5     \n\t"
-             "paddd                 %%mm0, %%mm4     \n\t"
-             "add                      $8, %1        \n\t"
-             "add                      $8, %%"REG_c" \n\t"
-             "cmp                      %4, %%"REG_c" \n\t"
-             " jb                      2b            \n\t"
-             "add                      %6, %1        \n\t"
-             "movq                  %%mm4, %%mm0     \n\t"
-             "punpckldq             %%mm5, %%mm4     \n\t"
-             "punpckhdq             %%mm5, %%mm0     \n\t"
-             "paddd                 %%mm0, %%mm4     \n\t"
-             "psrad                 %%mm7, %%mm4     \n\t"
-             "packssdw              %%mm4, %%mm4     \n\t"
-             "mov                      %3, %%"REG_a" \n\t"
-             "movd                  %%mm4, (%%"REG_a", %0)   \n\t"
-             "add                      $4, %0        \n\t"
-             " jnc                     1b            \n\t"
-             : "+r" (counter), "+r" (filter)
-             : "m" (filterPos), "m" (dst), "m"(offset),
-             "m" (src), "r" ((x86_reg)filterSize*2), "m"(shift)
-             : "%"REG_a, "%"REG_c, "%"REG_d
-         );
-     } else
- #endif
++
 +    for (i=0; i<dstW; i++) {
 +        int srcPos= filterPos[i];
 +        int val=0;
 +        for (j=0; j<filterSize; j++) {
 +            val += ((int)src[srcPos + j])*filter[filterSize*i + j];
 +        }
 +        dst[i] = FFMIN(val>>shift, (1<<15)-1); // the cubic equation does overflow ...
 +    }
 +}
 +
- static inline void RENAME(hScale16X)(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc,
++static inline void hScale16X_c(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc,
 +                                    const int16_t *filter, const int16_t *filterPos, long filterSize, int shift)
 +{
 +    int i, j;
 +    for (i=0; i<dstW; i++) {
 +        int srcPos= filterPos[i];
 +        int val=0;
 +        for (j=0; j<filterSize; j++) {
 +            val += ((int)av_bswap16(src[srcPos + j]))*filter[filterSize*i + j];
 +        }
 +        dst[i] = FFMIN(val>>shift, (1<<15)-1); // the cubic equation does overflow ...
 +    }
 +}
 +
  //FIXME all pal and rgb srcFormats could do this convertion as well
  //FIXME all scalers more complex than bilinear could do half of this transform
 -static void chrRangeToJpeg_c(uint16_t *dst, int width)
 +static void chrRangeToJpeg_c(int16_t *dst, int width)
  {
      int i;
      for (i = 0; i < width; i++) {
@@@ -995,20 -834,16 +867,20 @@@ static void sws_init_swScale_c(SwsConte
          case PIX_FMT_PAL8     :
          case PIX_FMT_BGR4_BYTE:
          case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV; break;
 -        case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break;
 -        case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break;
 -        case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break;
 -        case PIX_FMT_YUV420P10LE: c->chrToYV12 = LE10ToUV_c; break;
 +        case PIX_FMT_GRAY16BE :
 +        case PIX_FMT_YUV420P9BE:
 +        case PIX_FMT_YUV422P10BE:
 +        case PIX_FMT_YUV420P10BE:
          case PIX_FMT_YUV420P16BE:
          case PIX_FMT_YUV422P16BE:
-         case PIX_FMT_YUV444P16BE: c->hScale16= HAVE_BIGENDIAN ? RENAME(hScale16) : RENAME(hScale16X); break;
 -        case PIX_FMT_YUV444P16BE: c->chrToYV12 = BEToUV_c; break;
++        case PIX_FMT_YUV444P16BE: c->hScale16= HAVE_BIGENDIAN ? hScale16_c : hScale16X_c; break;
 +        case PIX_FMT_GRAY16LE :
 +        case PIX_FMT_YUV420P9LE:
 +        case PIX_FMT_YUV422P10LE:
 +        case PIX_FMT_YUV420P10LE:
          case PIX_FMT_YUV420P16LE:
          case PIX_FMT_YUV422P16LE:
-         case PIX_FMT_YUV444P16LE: c->hScale16= HAVE_BIGENDIAN ? RENAME(hScale16X) : RENAME(hScale16); break;
 -        case PIX_FMT_YUV444P16LE: c->chrToYV12 = LEToUV_c; break;
++        case PIX_FMT_YUV444P16LE: c->hScale16= HAVE_BIGENDIAN ? hScale16X_c : hScale16_c; break;
      }
      if (c->chrSrcHSubSample) {
          switch(srcFormat) {
Simple merge
Simple merge
@@@ -937,10 -857,8 +857,8 @@@ static inline void RENAME(yuv2yuvX)(Sws
  static inline void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, const int16_t *chrSrc, const int16_t *alpSrc,
                                      uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, long dstW, long chrDstW)
  {
-     int i;
-     if(!(c->flags & SWS_BITEXACT)) {
          long p= 4;
 -        const uint8_t *src[4]= {alpSrc + dstW, lumSrc + dstW, chrSrc + chrDstW, chrSrc + VOFW + chrDstW};
 +        const int16_t *src[4]= {alpSrc + dstW, lumSrc + dstW, chrSrc + chrDstW, chrSrc + VOFW + chrDstW};
          uint8_t *dst[4]= {aDest, dest, uDest, vDest};
          x86_reg counter[4]= {dstW, dstW, chrDstW, chrDstW};
  
@@@ -2061,45 -1904,7 +1904,164 @@@ static inline void RENAME(hScale)(int16
      }
  }
  
- //FIXME all pal and rgb srcFormats could do this convertion as well
- //FIXME all scalers more complex than bilinear could do half of this transform
- static void RENAME(chrRangeToJpeg)(int16_t *dst, int width)
++static inline void RENAME(hScale16)(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc,
++                                    const int16_t *filter, const int16_t *filterPos, long filterSize, int shift)
 +{
-     int i;
-     for (i = 0; i < width; i++) {
-         dst[i     ] = (FFMIN(dst[i     ],30775)*4663 - 9289992)>>12; //-264
-         dst[i+VOFW] = (FFMIN(dst[i+VOFW],30775)*4663 - 9289992)>>12; //-264
-     }
- }
- static void RENAME(chrRangeFromJpeg)(int16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++) {
-         dst[i     ] = (dst[i     ]*1799 + 4081085)>>11; //1469
-         dst[i+VOFW] = (dst[i+VOFW]*1799 + 4081085)>>11; //1469
++    int i, j;
++
++    assert(filterSize % 4 == 0 && filterSize>0);
++    if (filterSize==4 && shift<15) { // Always true for upscaling, sometimes for down, too.
++        x86_reg counter= -2*dstW;
++        filter-= counter*2;
++        filterPos-= counter/2;
++        dst-= counter/2;
++        __asm__ volatile(
++            "movd                   %5, %%mm7       \n\t"
++#if defined(PIC)
++            "push            %%"REG_b"              \n\t"
++#endif
++            "push           %%"REG_BP"              \n\t" // we use 7 regs here ...
++            "mov             %%"REG_a", %%"REG_BP"  \n\t"
++            ".p2align                4              \n\t"
++            "1:                                     \n\t"
++            "movzwl   (%2, %%"REG_BP"), %%eax       \n\t"
++            "movzwl  2(%2, %%"REG_BP"), %%ebx       \n\t"
++            "movq  (%1, %%"REG_BP", 4), %%mm1       \n\t"
++            "movq 8(%1, %%"REG_BP", 4), %%mm3       \n\t"
++            "movq      (%3, %%"REG_a", 2), %%mm0    \n\t"
++            "movq      (%3, %%"REG_b", 2), %%mm2    \n\t"
++            "pmaddwd             %%mm1, %%mm0       \n\t"
++            "pmaddwd             %%mm2, %%mm3       \n\t"
++            "movq                %%mm0, %%mm4       \n\t"
++            "punpckldq           %%mm3, %%mm0       \n\t"
++            "punpckhdq           %%mm3, %%mm4       \n\t"
++            "paddd               %%mm4, %%mm0       \n\t"
++            "psrad               %%mm7, %%mm0       \n\t"
++            "packssdw            %%mm0, %%mm0       \n\t"
++            "movd                %%mm0, (%4, %%"REG_BP")    \n\t"
++            "add                    $4, %%"REG_BP"  \n\t"
++            " jnc                   1b              \n\t"
++
++            "pop            %%"REG_BP"              \n\t"
++#if defined(PIC)
++            "pop             %%"REG_b"              \n\t"
++#endif
++            : "+a" (counter)
++            : "c" (filter), "d" (filterPos), "S" (src), "D" (dst), "m"(shift)
++#if !defined(PIC)
++            : "%"REG_b
++#endif
++        );
++    } else if (filterSize==8 && shift<15) {
++        x86_reg counter= -2*dstW;
++        filter-= counter*4;
++        filterPos-= counter/2;
++        dst-= counter/2;
++        __asm__ volatile(
++            "movd                   %5, %%mm7       \n\t"
++#if defined(PIC)
++            "push            %%"REG_b"              \n\t"
++#endif
++            "push            %%"REG_BP"             \n\t" // we use 7 regs here ...
++            "mov              %%"REG_a", %%"REG_BP" \n\t"
++            ".p2align                 4             \n\t"
++            "1:                                     \n\t"
++            "movzwl    (%2, %%"REG_BP"), %%eax      \n\t"
++            "movzwl   2(%2, %%"REG_BP"), %%ebx      \n\t"
++            "movq   (%1, %%"REG_BP", 8), %%mm1      \n\t"
++            "movq 16(%1, %%"REG_BP", 8), %%mm3      \n\t"
++            "movq       (%3, %%"REG_a", 2), %%mm0   \n\t"
++            "movq       (%3, %%"REG_b", 2), %%mm2   \n\t"
++            "pmaddwd              %%mm1, %%mm0      \n\t"
++            "pmaddwd              %%mm2, %%mm3      \n\t"
++
++            "movq  8(%1, %%"REG_BP", 8), %%mm1      \n\t"
++            "movq 24(%1, %%"REG_BP", 8), %%mm5      \n\t"
++            "movq      8(%3, %%"REG_a", 2), %%mm4   \n\t"
++            "movq      8(%3, %%"REG_b", 2), %%mm2   \n\t"
++            "pmaddwd              %%mm1, %%mm4      \n\t"
++            "pmaddwd              %%mm2, %%mm5      \n\t"
++            "paddd                %%mm4, %%mm0      \n\t"
++            "paddd                %%mm5, %%mm3      \n\t"
++            "movq                 %%mm0, %%mm4      \n\t"
++            "punpckldq            %%mm3, %%mm0      \n\t"
++            "punpckhdq            %%mm3, %%mm4      \n\t"
++            "paddd                %%mm4, %%mm0      \n\t"
++            "psrad                %%mm7, %%mm0      \n\t"
++            "packssdw             %%mm0, %%mm0      \n\t"
++            "movd                 %%mm0, (%4, %%"REG_BP")   \n\t"
++            "add                     $4, %%"REG_BP" \n\t"
++            " jnc                    1b             \n\t"
++
++            "pop             %%"REG_BP"             \n\t"
++#if defined(PIC)
++            "pop             %%"REG_b"              \n\t"
++#endif
++            : "+a" (counter)
++            : "c" (filter), "d" (filterPos), "S" (src), "D" (dst), "m"(shift)
++#if !defined(PIC)
++            : "%"REG_b
++#endif
++        );
++    } else if (shift<15){
++        const uint16_t *offset = src+filterSize;
++        x86_reg counter= -2*dstW;
++        //filter-= counter*filterSize/2;
++        filterPos-= counter/2;
++        dst-= counter/2;
++        __asm__ volatile(
++            "movd                   %7, %%mm7       \n\t"
++            ".p2align                  4            \n\t"
++            "1:                                     \n\t"
++            "mov                      %2, %%"REG_c" \n\t"
++            "movzwl      (%%"REG_c", %0), %%eax     \n\t"
++            "movzwl     2(%%"REG_c", %0), %%edx     \n\t"
++            "mov                      %5, %%"REG_c" \n\t"
++            "pxor                  %%mm4, %%mm4     \n\t"
++            "pxor                  %%mm5, %%mm5     \n\t"
++            "2:                                     \n\t"
++            "movq                   (%1), %%mm1     \n\t"
++            "movq               (%1, %6), %%mm3     \n\t"
++            "movq (%%"REG_c", %%"REG_a", 2), %%mm0     \n\t"
++            "movq (%%"REG_c", %%"REG_d", 2), %%mm2     \n\t"
++            "pmaddwd               %%mm1, %%mm0     \n\t"
++            "pmaddwd               %%mm2, %%mm3     \n\t"
++            "paddd                 %%mm3, %%mm5     \n\t"
++            "paddd                 %%mm0, %%mm4     \n\t"
++            "add                      $8, %1        \n\t"
++            "add                      $8, %%"REG_c" \n\t"
++            "cmp                      %4, %%"REG_c" \n\t"
++            " jb                      2b            \n\t"
++            "add                      %6, %1        \n\t"
++            "movq                  %%mm4, %%mm0     \n\t"
++            "punpckldq             %%mm5, %%mm4     \n\t"
++            "punpckhdq             %%mm5, %%mm0     \n\t"
++            "paddd                 %%mm0, %%mm4     \n\t"
++            "psrad                 %%mm7, %%mm4     \n\t"
++            "packssdw              %%mm4, %%mm4     \n\t"
++            "mov                      %3, %%"REG_a" \n\t"
++            "movd                  %%mm4, (%%"REG_a", %0)   \n\t"
++            "add                      $4, %0        \n\t"
++            " jnc                     1b            \n\t"
++
++            : "+r" (counter), "+r" (filter)
++            : "m" (filterPos), "m" (dst), "m"(offset),
++            "m" (src), "r" ((x86_reg)filterSize*2), "m"(shift)
++            : "%"REG_a, "%"REG_c, "%"REG_d
++        );
++    } else
++    for (i=0; i<dstW; i++) {
++        int srcPos= filterPos[i];
++        int val=0;
++        for (j=0; j<filterSize; j++) {
++            val += ((int)src[srcPos + j])*filter[filterSize*i + j];
++        }
++        dst[i] = FFMIN(val>>shift, (1<<15)-1); // the cubic equation does overflow ...
 +    }
 +}
- static void RENAME(lumRangeToJpeg)(int16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++)
-         dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14;
- }
- static void RENAME(lumRangeFromJpeg)(int16_t *dst, int width)
- {
-     int i;
-     for (i = 0; i < width; i++)
-         dst[i] = (dst[i]*14071 + 33561947)>>14;
- }
 +
- #define FAST_BILINEAR_X86 \
-     "subl    %%edi, %%esi    \n\t" /*  src[xx+1] - src[xx] */                   \
-     "imull   %%ecx, %%esi    \n\t" /* (src[xx+1] - src[xx])*xalpha */           \
-     "shll      $16, %%edi    \n\t"                                              \
-     "addl    %%edi, %%esi    \n\t" /* src[xx+1]*xalpha + src[xx]*(1-xalpha) */  \
-     "mov        %1, %%"REG_D"\n\t"                                              \
-     "shrl       $9, %%esi    \n\t"                                              \
 +
+ #if COMPILE_TEMPLATE_MMX2
  static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
                                          long dstWidth, const uint8_t *src, int srcW,
                                          int xInc)
@@@ -2759,30 -2147,27 +2304,27 @@@ static void RENAME(sws_init_swScale)(Sw
          c->hyscale_fast = RENAME(hyscale_fast);
          c->hcscale_fast = RENAME(hcscale_fast);
      } else {
+ #endif /* COMPILE_TEMPLATE_MMX2 */
          c->hyscale_fast = NULL;
          c->hcscale_fast = NULL;
+ #if COMPILE_TEMPLATE_MMX2
      }
+ #endif /* COMPILE_TEMPLATE_MMX2 */
  
--    switch(srcFormat) {
++     switch(srcFormat) {
          case PIX_FMT_YUYV422  : c->chrToYV12 = RENAME(yuy2ToUV); break;
          case PIX_FMT_UYVY422  : c->chrToYV12 = RENAME(uyvyToUV); break;
          case PIX_FMT_NV12     : c->chrToYV12 = RENAME(nv12ToUV); break;
          case PIX_FMT_NV21     : c->chrToYV12 = RENAME(nv21ToUV); break;
--        case PIX_FMT_YUV420P16BE:
--        case PIX_FMT_YUV422P16BE:
--        case PIX_FMT_YUV444P16BE: c->chrToYV12 = RENAME(BEToUV); break;
++        case PIX_FMT_GRAY16LE :
++        case PIX_FMT_YUV420P9LE:
++        case PIX_FMT_YUV422P10LE:
++        case PIX_FMT_YUV420P10LE:
          case PIX_FMT_YUV420P16LE:
          case PIX_FMT_YUV422P16LE:
--        case PIX_FMT_YUV444P16LE: c->chrToYV12 = RENAME(LEToUV); break;
--        default: break;
--    }
-     if (c->chrSrcHSubSample) {
-         switch(srcFormat) {
-         case PIX_FMT_BGR24  : c->chrToYV12 = RENAME(bgr24ToUV_half); break;
-         case PIX_FMT_RGB24  : c->chrToYV12 = RENAME(rgb24ToUV_half); break;
-         default: break;
-         }
-     } else {
++        case PIX_FMT_YUV444P16LE: c->hScale16= RENAME(hScale16); break;
++    }   
+     if (!c->chrSrcHSubSample) {
          switch(srcFormat) {
          case PIX_FMT_BGR24  : c->chrToYV12 = RENAME(bgr24ToUV); break;
          case PIX_FMT_RGB24  : c->chrToYV12 = RENAME(rgb24ToUV); break;
  
      switch (srcFormat) {
      case PIX_FMT_YUYV422  :
--    case PIX_FMT_YUV420P16BE:
--    case PIX_FMT_YUV422P16BE:
--    case PIX_FMT_YUV444P16BE:
      case PIX_FMT_Y400A    :
--    case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break;
++                            c->lumToYV12 = RENAME(yuy2ToY); break;
      case PIX_FMT_UYVY422  :
--    case PIX_FMT_YUV420P16LE:
--    case PIX_FMT_YUV422P16LE:
--    case PIX_FMT_YUV444P16LE:
--    case PIX_FMT_GRAY16LE : c->lumToYV12 = RENAME(uyvyToY); break;
++                            c->lumToYV12 = RENAME(uyvyToY); break;
      case PIX_FMT_BGR24    : c->lumToYV12 = RENAME(bgr24ToY); break;
      case PIX_FMT_RGB24    : c->lumToYV12 = RENAME(rgb24ToY); break;
      default: break;
Simple merge
Simple merge
Simple merge