diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ff_audio_decoder.c xine-lib-1.1.8/src/libffmpeg/ff_audio_decoder.c
--- xine-lib-1.1.8.orig/src/libffmpeg/ff_audio_decoder.c	2007-08-19 01:36:49.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ff_audio_decoder.c	2007-11-11 00:31:03.000000000 +0100
@@ -15,12 +15,9 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: audio_decoder.c,v 1.33 2007/01/28 18:38:33 miguelfreitas Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  * xine audio decoder plugin using ffmpeg
- *
  */
  
 #ifdef HAVE_CONFIG_H
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ff_dvaudio_decoder.c xine-lib-1.1.8/src/libffmpeg/ff_dvaudio_decoder.c
--- xine-lib-1.1.8.orig/src/libffmpeg/ff_dvaudio_decoder.c	2007-08-19 01:36:49.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ff_dvaudio_decoder.c	2007-11-11 00:31:03.000000000 +0100
@@ -15,12 +15,9 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: dvaudio_decoder.c,v 1.12 2006/12/04 22:25:13 miguelfreitas Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  * dv audio decoder based on patch by Dan Dennedy <dan@dennedy.org>
- *
  */
  
 #ifdef HAVE_CONFIG_H
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ffmpeg_decoder.c xine-lib-1.1.8/src/libffmpeg/ffmpeg_decoder.c
--- xine-lib-1.1.8.orig/src/libffmpeg/ffmpeg_decoder.c	2007-08-19 01:36:50.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ffmpeg_decoder.c	2007-11-11 00:31:03.000000000 +0100
@@ -15,12 +15,9 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: xine_decoder.c,v 1.173 2007/01/13 21:19:52 miguelfreitas Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  * xine decoder plugin using ffmpeg
- *
  */
 
 #ifdef HAVE_CONFIG_H
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ffmpeg_decoder.h xine-lib-1.1.8/src/libffmpeg/ffmpeg_decoder.h
--- xine-lib-1.1.8.orig/src/libffmpeg/ffmpeg_decoder.h	2007-08-19 01:36:50.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ffmpeg_decoder.h	2007-11-11 00:31:03.000000000 +0100
@@ -15,10 +15,7 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: xine_decoder.h,v 1.7 2006/08/02 07:15:27 tmmm Exp $
- *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  */
  
 #ifndef HAVE_XINE_DECODER_H
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ffmpeg_encoder.c xine-lib-1.1.8/src/libffmpeg/ffmpeg_encoder.c
--- xine-lib-1.1.8.orig/src/libffmpeg/ffmpeg_encoder.c	2007-08-19 01:36:50.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ffmpeg_encoder.c	2007-12-07 19:26:33.000000000 +0100
@@ -15,9 +15,7 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: xine_encoder.c,v 1.25 2006/07/10 22:08:29 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  */
  
 /* mpeg encoders for the dxr3 video out plugin. */
@@ -76,7 +74,7 @@
   lavc_data_t* this;
   avcodec_init();
 
-  register_avcodec(&mpeg1video_encoder);  
+  avcodec_register_all();  
   lprintf("lavc init , version %x\n", avcodec_version());
   this = xine_xmalloc(sizeof(lavc_data_t));
   if (!this) return 0;
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ff_mpeg_parser.c xine-lib-1.1.8/src/libffmpeg/ff_mpeg_parser.c
--- xine-lib-1.1.8.orig/src/libffmpeg/ff_mpeg_parser.c	2007-08-19 01:36:49.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ff_mpeg_parser.c	2007-11-11 00:31:03.000000000 +0100
@@ -15,12 +15,10 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  * Simple MPEG-ES parser/framer by Thibaut Mattern (tmattern@noos.fr)
  *   based on libmpeg2 decoder.
- *
- * $Id: mpeg_parser.c,v 1.7 2007/03/29 18:52:45 dgp85 Exp $
  */
 #define LOG_MODULE "mpeg_parser"
 #define LOG_VERBOSE
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ff_mpeg_parser.h xine-lib-1.1.8/src/libffmpeg/ff_mpeg_parser.h
--- xine-lib-1.1.8.orig/src/libffmpeg/ff_mpeg_parser.h	2007-08-19 01:36:49.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ff_mpeg_parser.h	2007-11-11 00:31:03.000000000 +0100
@@ -15,12 +15,10 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  * Simple MPEG-ES parser/framer by Thibaut Mattern (tmattern@noos.fr)
  *   based on libmpeg2 decoder.
- *
- * $Id: mpeg_parser.h,v 1.5 2007/03/29 18:52:45 dgp85 Exp $
  */
 #ifndef HAVE_MPEG_PARSER_H
 #define HAVE_MPEG_PARSER_H
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/ff_video_decoder.c xine-lib-1.1.8/src/libffmpeg/ff_video_decoder.c
--- xine-lib-1.1.8.orig/src/libffmpeg/ff_video_decoder.c	2007-08-19 01:36:49.000000000 +0200
+++ xine-lib-1.1.8/src/libffmpeg/ff_video_decoder.c	2007-12-09 16:35:05.000000000 +0100
@@ -15,12 +15,9 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: video_decoder.c,v 1.73 2007/03/29 18:41:02 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  * xine video decoder plugin using ffmpeg
- *
  */
  
 #ifdef HAVE_CONFIG_H
@@ -67,6 +64,7 @@
   video_decoder_class_t   decoder_class;
 
   int                     pp_quality;
+  int                     thread_count;
   
   xine_t                 *xine;
 } ff_video_class_t;
@@ -87,6 +85,7 @@
   uint8_t           yuv_init:1;
   uint8_t           is_direct_rendering_disabled:1;
   uint8_t           cs_convert_init:1;
+  uint8_t           assume_bad_field_picture:1;
 
   xine_bmiheader    bih;
   unsigned char    *buf;
@@ -216,12 +215,14 @@
   ff_video_decoder_t *this = (ff_video_decoder_t *)context->opaque;
 
   if (av_frame->type == FF_BUFFER_TYPE_USER) {
-    vo_frame_t *img = (vo_frame_t *)av_frame->opaque;
+    if ( av_frame->opaque ) {
+      vo_frame_t *img = (vo_frame_t *)av_frame->opaque;
+
+      img->free(img);
+    }
+
     xine_list_iterator_t it;
     
-    assert(av_frame->opaque);  
-    img->free(img);
-    
     it = xine_list_find(this->dr1_frames, av_frame);
     assert(it);
     if( it != NULL )
@@ -244,6 +245,7 @@
   {BUF_VIDEO_WMV7,        CODEC_ID_WMV1,      "MS Windows Media Video 7 (ffmpeg)"},
   {BUF_VIDEO_WMV8,        CODEC_ID_WMV2,      "MS Windows Media Video 8 (ffmpeg)"},
   {BUF_VIDEO_WMV9,        CODEC_ID_WMV3,      "MS Windows Media Video 9 (ffmpeg)"},
+  {BUF_VIDEO_VC1,         CODEC_ID_VC1,       "MS Windows Media Video VC-1 (ffmpeg)"},
   {BUF_VIDEO_MPEG4,       CODEC_ID_MPEG4,     "ISO MPEG-4 (ffmpeg)"},
   {BUF_VIDEO_XVID,        CODEC_ID_MPEG4,     "ISO MPEG-4 (XviD, ffmpeg)"},
   {BUF_VIDEO_DIVX5,       CODEC_ID_MPEG4,     "ISO MPEG-4 (DivX5, ffmpeg)"},
@@ -368,6 +370,12 @@
     _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
     return;
   }
+
+  if (this->class->thread_count > 1) {
+    avcodec_thread_init(this->context, this->class->thread_count);
+    this->context->thread_count = this->class->thread_count;
+  }
+
   pthread_mutex_unlock(&ffmpeg_lock);
 
   lprintf("lavc decoder opened\n");
@@ -418,10 +426,19 @@
     case BUF_VIDEO_HUFFYUV:
       this->frame_flags |= VO_INTERLACED_FLAG;
       break;
+    case BUF_VIDEO_H264:
+      this->frame_flags |= VO_INTERLACED_FLAG;
+      break;
   }
 
 }
 
+static void thread_count_cb(void *user_data, xine_cfg_entry_t *entry) {
+  ff_video_class_t   *class = (ff_video_class_t *) user_data;
+  
+  class->thread_count = entry->num_value;
+}
+
 static void pp_quality_cb(void *user_data, xine_cfg_entry_t *entry) {
   ff_video_class_t   *class = (ff_video_class_t *) user_data;
   
@@ -1143,6 +1160,7 @@
     int         got_one_picture = 0;
     int         offset = 0;
     int         codec_type = buf->type & 0xFFFF0000;
+    int         video_step_to_use;
 
     /* pad input data */
     /* note: bitstream, alt bitstream reader or something will cause
@@ -1183,6 +1201,9 @@
         }
       }
 
+      /* use externally provided video_step or fall back to stream's time_base otherwise */
+      video_step_to_use = (this->video_step || !this->context->time_base.den) ? this->video_step : (int)(90000ll * this->context->time_base.num / this->context->time_base.den);
+
       /* aspect ratio provided by ffmpeg, override previous setting */
       if ((this->aspect_ratio_prio < 2) &&
 	  av_cmp_q(this->context->sample_aspect_ratio, avr00)) {
@@ -1227,9 +1248,10 @@
 	    set_stream_info(this);
 	  }
 
+          /* xine-lib expects the framesize to be a multiple of 16x16 (macroblock) */
           img = this->stream->video_out->get_frame (this->stream->video_out,
-                                                    this->bih.biWidth,
-                                                    this->bih.biHeight,
+                                                    (this->bih.biWidth  + 15) & ~15,
+                                                    (this->bih.biHeight + 15) & ~15,
                                                     this->aspect_ratio, 
                                                     this->output_format,
                                                     VO_BOTH_FIELDS|this->frame_flags);
@@ -1249,8 +1271,8 @@
           if(this->av_frame->opaque) {
             /* DR1 */
             img = this->stream->video_out->get_frame (this->stream->video_out,
-                                                      img->width,
-                                                      img->height,
+                                                      (img->width  + 15) & ~15,
+                                                      (img->height + 15) & ~15,
                                                       this->aspect_ratio, 
                                                       this->output_format,
                                                       VO_BOTH_FIELDS|this->frame_flags);
@@ -1273,19 +1295,24 @@
         this->pts = 0;
 
         /* workaround for weird 120fps streams */
-        if( this->video_step == 750 ) {
+        if( video_step_to_use == 750 ) {
           /* fallback to the VIDEO_PTS_MODE */
-          this->video_step = 0;
+          video_step_to_use = 0;
         }
         
         if (this->av_frame->repeat_pict)
-          img->duration = this->video_step * 3 / 2;
+          img->duration = video_step_to_use * 3 / 2;
         else
-          img->duration = this->video_step;
+          img->duration = video_step_to_use;
+
+        /* additionally crop away the extra pixels due to adjusting frame size above */
+        img->crop_right  = this->crop_right  + (img->width  - this->bih.biWidth);
+        img->crop_bottom = this->crop_bottom + (img->height - this->bih.biHeight);
+
+        /* transfer some more frame settings for deinterlacing */
+        img->progressive_frame = !this->av_frame->interlaced_frame;
+        img->top_field_first   = this->av_frame->top_field_first;
 
-        img->crop_right  = this->crop_right;
-        img->crop_bottom = this->crop_bottom;
-        
         this->skipframes = img->draw(img, this->stream);
         
         if(free_img)
@@ -1293,20 +1320,33 @@
       }
     }
 
-    if (!got_one_picture) {
-      /* skipped frame, output a bad frame */
+    /* workaround for demux_mpeg_pes sending fields as frames:
+     * do not generate a bad frame for the first field picture
+     */
+    if (!got_one_picture && (this->size || this->video_step || this->assume_bad_field_picture)) {
+      /* skipped frame, output a bad frame (use size 16x16, when size still uninitialized) */
       img = this->stream->video_out->get_frame (this->stream->video_out,
-                                                this->bih.biWidth,
-                                                this->bih.biHeight,
+                                                (this->bih.biWidth  <= 0) ? 16 : ((this->bih.biWidth  + 15) & ~15),
+                                                (this->bih.biHeight <= 0) ? 16 : ((this->bih.biHeight + 15) & ~15),
                                                 this->aspect_ratio, 
                                                 this->output_format,
                                                 VO_BOTH_FIELDS|this->frame_flags);
-      img->pts       = 0;
-      img->duration  = this->video_step;
+      /* set PTS to allow early syncing */
+      img->pts       = this->pts;
+      this->pts      = 0;
+
+      img->duration  = video_step_to_use;
+
+      /* additionally crop away the extra pixels due to adjusting frame size above */
+      img->crop_right  = ((this->bih.biWidth  <= 0) ? 0 : this->crop_right)  + (img->width  - this->bih.biWidth);
+      img->crop_bottom = ((this->bih.biHeight <= 0) ? 0 : this->crop_bottom) + (img->height - this->bih.biHeight);
+
       img->bad_frame = 1;
       this->skipframes = img->draw(img, this->stream);
       img->free(img);
     }
+
+    this->assume_bad_field_picture = !got_one_picture;
   }
 }
 
@@ -1527,6 +1567,15 @@
       "too much."),
     10, pp_quality_cb, this);
   
+  this->thread_count = xine->config->register_num(config, "video.processing.ffmpeg_thread_count", 1, 
+    _("FFmpeg video decoding thread count"),
+    _("You can adjust the number of video decoding threads which FFmpeg may use.\n"
+      "Higher values should speed up decoding but it depends on the codec used "
+      "whether parallel decoding is supported. A rule of thumb is to have one "
+      "decoding thread per logical CPU (typically 1 to 4). A change will take "
+      "effect with playing the next stream."),
+    10, thread_count_cb, this);
+
   return this;
 }
 
@@ -1549,6 +1598,9 @@
   #ifdef CONFIG_WMV3_DECODER
   BUF_VIDEO_WMV9,
   #endif
+  #ifdef CONFIG_VC1_DECODER
+  BUF_VIDEO_VC1,
+  #endif
   #ifdef CONFIG_MPEG4_DECODER
   BUF_VIDEO_MPEG4,
   #endif
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/libavcodec/ppc/dsputil_h264_altivec.c xine-lib-1.1.8/src/libffmpeg/libavcodec/ppc/dsputil_h264_altivec.c
--- xine-lib-1.1.8.orig/src/libffmpeg/libavcodec/ppc/dsputil_h264_altivec.c	1970-01-01 01:00:00.000000000 +0100
+++ xine-lib-1.1.8/src/libffmpeg/libavcodec/ppc/dsputil_h264_altivec.c	2007-04-17 20:46:43.000000000 +0200
@@ -0,0 +1,319 @@
+/*
+ * Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "../dsputil.h"
+
+#include "gcc_fixes.h"
+
+#include "dsputil_altivec.h"
+
+#define PUT_OP_U8_ALTIVEC(d, s, dst) d = s
+#define AVG_OP_U8_ALTIVEC(d, s, dst) d = vec_avg(dst, s)
+
+#define OP_U8_ALTIVEC                          PUT_OP_U8_ALTIVEC
+#define PREFIX_h264_chroma_mc8_altivec         put_h264_chroma_mc8_altivec
+#define PREFIX_h264_chroma_mc8_num             altivec_put_h264_chroma_mc8_num
+#define PREFIX_h264_qpel16_h_lowpass_altivec   put_h264_qpel16_h_lowpass_altivec
+#define PREFIX_h264_qpel16_h_lowpass_num       altivec_put_h264_qpel16_h_lowpass_num
+#define PREFIX_h264_qpel16_v_lowpass_altivec   put_h264_qpel16_v_lowpass_altivec
+#define PREFIX_h264_qpel16_v_lowpass_num       altivec_put_h264_qpel16_v_lowpass_num
+#define PREFIX_h264_qpel16_hv_lowpass_altivec  put_h264_qpel16_hv_lowpass_altivec
+#define PREFIX_h264_qpel16_hv_lowpass_num      altivec_put_h264_qpel16_hv_lowpass_num
+#include "dsputil_h264_template_altivec.c"
+#undef OP_U8_ALTIVEC
+#undef PREFIX_h264_chroma_mc8_altivec
+#undef PREFIX_h264_chroma_mc8_num
+#undef PREFIX_h264_qpel16_h_lowpass_altivec
+#undef PREFIX_h264_qpel16_h_lowpass_num
+#undef PREFIX_h264_qpel16_v_lowpass_altivec
+#undef PREFIX_h264_qpel16_v_lowpass_num
+#undef PREFIX_h264_qpel16_hv_lowpass_altivec
+#undef PREFIX_h264_qpel16_hv_lowpass_num
+
+#define OP_U8_ALTIVEC                          AVG_OP_U8_ALTIVEC
+#define PREFIX_h264_chroma_mc8_altivec         avg_h264_chroma_mc8_altivec
+#define PREFIX_h264_chroma_mc8_num             altivec_avg_h264_chroma_mc8_num
+#define PREFIX_h264_qpel16_h_lowpass_altivec   avg_h264_qpel16_h_lowpass_altivec
+#define PREFIX_h264_qpel16_h_lowpass_num       altivec_avg_h264_qpel16_h_lowpass_num
+#define PREFIX_h264_qpel16_v_lowpass_altivec   avg_h264_qpel16_v_lowpass_altivec
+#define PREFIX_h264_qpel16_v_lowpass_num       altivec_avg_h264_qpel16_v_lowpass_num
+#define PREFIX_h264_qpel16_hv_lowpass_altivec  avg_h264_qpel16_hv_lowpass_altivec
+#define PREFIX_h264_qpel16_hv_lowpass_num      altivec_avg_h264_qpel16_hv_lowpass_num
+#include "dsputil_h264_template_altivec.c"
+#undef OP_U8_ALTIVEC
+#undef PREFIX_h264_chroma_mc8_altivec
+#undef PREFIX_h264_chroma_mc8_num
+#undef PREFIX_h264_qpel16_h_lowpass_altivec
+#undef PREFIX_h264_qpel16_h_lowpass_num
+#undef PREFIX_h264_qpel16_v_lowpass_altivec
+#undef PREFIX_h264_qpel16_v_lowpass_num
+#undef PREFIX_h264_qpel16_hv_lowpass_altivec
+#undef PREFIX_h264_qpel16_hv_lowpass_num
+
+#define H264_MC(OPNAME, SIZE, CODETYPE) \
+static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## CODETYPE (uint8_t *dst, uint8_t *src, int stride){\
+    OPNAME ## pixels ## SIZE ## _ ## CODETYPE(dst, src, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){ \
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/8]);\
+    uint8_t * const half= (uint8_t*)temp;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src, half, stride, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(dst, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/8]);\
+    uint8_t * const half= (uint8_t*)temp;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src+1, half, stride, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/8]);\
+    uint8_t * const half= (uint8_t*)temp;\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src, half, stride, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(dst, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/8]);\
+    uint8_t * const half= (uint8_t*)temp;\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src+stride, half, stride, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/4]);\
+    uint8_t * const halfH= (uint8_t*)temp;\
+    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/4]);\
+    uint8_t * const halfH= (uint8_t*)temp;\
+    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src+1, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/4]);\
+    uint8_t * const halfH= (uint8_t*)temp;\
+    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src + stride, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*SIZE/4]);\
+    uint8_t * const halfH= (uint8_t*)temp;\
+    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src + stride, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src+1, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*(SIZE+8)/4]);\
+    int16_t * const tmp= (int16_t*)temp;\
+    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(dst, tmp, src, stride, SIZE, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4]);\
+    uint8_t * const halfH= (uint8_t*)temp;\
+    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
+    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfHV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4]);\
+    uint8_t * const halfH= (uint8_t*)temp;\
+    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
+    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src + stride, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfHV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4]);\
+    uint8_t * const halfV= (uint8_t*)temp;\
+    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
+    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfV, halfHV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
+    DECLARE_ALIGNED_16(uint64_t, temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4]);\
+    uint8_t * const halfV= (uint8_t*)temp;\
+    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
+    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
+    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src+1, SIZE, stride);\
+    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
+    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfV, halfHV, stride, SIZE, SIZE);\
+}\
+
+static inline void put_pixels16_l2_altivec( uint8_t * dst, const uint8_t * src1,
+                                    const uint8_t * src2, int dst_stride,
+                                    int src_stride1, int h)
+{
+    int i;
+    vector unsigned char a, b, d, tmp1, tmp2, mask, mask_, edges, align;
+
+    mask_ = vec_lvsl(0, src2);
+
+    for (i = 0; i < h; i++) {
+
+        tmp1 = vec_ld(i * src_stride1, src1);
+        mask = vec_lvsl(i * src_stride1, src1);
+        tmp2 = vec_ld(i * src_stride1 + 15, src1);
+
+        a = vec_perm(tmp1, tmp2, mask);
+
+        tmp1 = vec_ld(i * 16, src2);
+        tmp2 = vec_ld(i * 16 + 15, src2);
+
+        b = vec_perm(tmp1, tmp2, mask_);
+
+        tmp1 = vec_ld(0, dst);
+        mask = vec_lvsl(0, dst);
+        tmp2 = vec_ld(15, dst);
+
+        d = vec_avg(a, b);
+
+        edges = vec_perm(tmp2, tmp1, mask);
+
+        align = vec_lvsr(0, dst);
+
+        tmp1 = vec_perm(edges, d, align);
+        tmp2 = vec_perm(d, edges, align);
+
+        vec_st(tmp2, 15, dst);
+        vec_st(tmp1, 0 , dst);
+
+        dst += dst_stride;
+    }
+}
+
+static inline void avg_pixels16_l2_altivec( uint8_t * dst, const uint8_t * src1,
+                                    const uint8_t * src2, int dst_stride,
+                                    int src_stride1, int h)
+{
+    int i;
+    vector unsigned char a, b, d, tmp1, tmp2, mask, mask_, edges, align;
+
+    mask_ = vec_lvsl(0, src2);
+
+    for (i = 0; i < h; i++) {
+
+        tmp1 = vec_ld(i * src_stride1, src1);
+        mask = vec_lvsl(i * src_stride1, src1);
+        tmp2 = vec_ld(i * src_stride1 + 15, src1);
+
+        a = vec_perm(tmp1, tmp2, mask);
+
+        tmp1 = vec_ld(i * 16, src2);
+        tmp2 = vec_ld(i * 16 + 15, src2);
+
+        b = vec_perm(tmp1, tmp2, mask_);
+
+        tmp1 = vec_ld(0, dst);
+        mask = vec_lvsl(0, dst);
+        tmp2 = vec_ld(15, dst);
+
+        d = vec_avg(vec_perm(tmp1, tmp2, mask), vec_avg(a, b));
+
+        edges = vec_perm(tmp2, tmp1, mask);
+
+        align = vec_lvsr(0, dst);
+
+        tmp1 = vec_perm(edges, d, align);
+        tmp2 = vec_perm(d, edges, align);
+
+        vec_st(tmp2, 15, dst);
+        vec_st(tmp1, 0 , dst);
+
+        dst += dst_stride;
+    }
+}
+
+/* Implemented but could be faster
+#define put_pixels16_l2_altivec(d,s1,s2,ds,s1s,h) put_pixels16_l2(d,s1,s2,ds,s1s,16,h)
+#define avg_pixels16_l2_altivec(d,s1,s2,ds,s1s,h) avg_pixels16_l2(d,s1,s2,ds,s1s,16,h)
+ */
+
+  H264_MC(put_, 16, altivec)
+  H264_MC(avg_, 16, altivec)
+
+void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
+
+#ifdef HAVE_ALTIVEC
+  if (has_altivec()) {
+    c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
+    c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
+
+#define dspfunc(PFX, IDX, NUM) \
+    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_altivec; \
+    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_altivec; \
+    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_altivec; \
+    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_altivec; \
+    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_altivec; \
+    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_altivec; \
+    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_altivec; \
+    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_altivec
+
+    dspfunc(put_h264_qpel, 0, 16);
+    dspfunc(avg_h264_qpel, 0, 16);
+#undef dspfunc
+
+  } else
+#endif /* HAVE_ALTIVEC */
+  {
+    // Non-AltiVec PPC optimisations
+
+    // ... pending ...
+  }
+}
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/libavcodec/ppc/dsputil_h264_template_altivec.c xine-lib-1.1.8/src/libffmpeg/libavcodec/ppc/dsputil_h264_template_altivec.c
--- xine-lib-1.1.8.orig/src/libffmpeg/libavcodec/ppc/dsputil_h264_template_altivec.c	1970-01-01 01:00:00.000000000 +0100
+++ xine-lib-1.1.8/src/libffmpeg/libavcodec/ppc/dsputil_h264_template_altivec.c	2007-04-17 20:46:43.000000000 +0200
@@ -0,0 +1,717 @@
+/*
+ * Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* this code assume that stride % 16 == 0 */
+void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride, int h, int x, int y) {
+  POWERPC_PERF_DECLARE(PREFIX_h264_chroma_mc8_num, 1);
+    signed int ABCD[4] __attribute__((aligned(16))) =
+                        {((8 - x) * (8 - y)),
+                          ((x) * (8 - y)),
+                          ((8 - x) * (y)),
+                          ((x) * (y))};
+    register int i;
+    vector unsigned char fperm;
+    const vector signed int vABCD = vec_ld(0, ABCD);
+    const vector signed short vA = vec_splat((vector signed short)vABCD, 1);
+    const vector signed short vB = vec_splat((vector signed short)vABCD, 3);
+    const vector signed short vC = vec_splat((vector signed short)vABCD, 5);
+    const vector signed short vD = vec_splat((vector signed short)vABCD, 7);
+    const vector signed int vzero = vec_splat_s32(0);
+    const vector signed short v32ss = vec_sl(vec_splat_s16(1),vec_splat_u16(5));
+    const vector unsigned short v6us = vec_splat_u16(6);
+    register int loadSecond = (((unsigned long)src) % 16) <= 7 ? 0 : 1;
+    register int reallyBadAlign = (((unsigned long)src) % 16) == 15 ? 1 : 0;
+
+    vector unsigned char vsrcAuc, vsrcBuc, vsrcperm0, vsrcperm1;
+    vector unsigned char vsrc0uc, vsrc1uc;
+    vector signed short vsrc0ssH, vsrc1ssH;
+    vector unsigned char vsrcCuc, vsrc2uc, vsrc3uc;
+    vector signed short vsrc2ssH, vsrc3ssH, psum;
+    vector unsigned char vdst, ppsum, vfdst, fsum;
+
+  POWERPC_PERF_START_COUNT(PREFIX_h264_chroma_mc8_num, 1);
+
+    if (((unsigned long)dst) % 16 == 0) {
+      fperm = (vector unsigned char)AVV(0x10, 0x11, 0x12, 0x13,
+                                        0x14, 0x15, 0x16, 0x17,
+                                        0x08, 0x09, 0x0A, 0x0B,
+                                        0x0C, 0x0D, 0x0E, 0x0F);
+    } else {
+      fperm = (vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03,
+                                        0x04, 0x05, 0x06, 0x07,
+                                        0x18, 0x19, 0x1A, 0x1B,
+                                        0x1C, 0x1D, 0x1E, 0x1F);
+    }
+
+    vsrcAuc = vec_ld(0, src);
+
+    if (loadSecond)
+      vsrcBuc = vec_ld(16, src);
+    vsrcperm0 = vec_lvsl(0, src);
+    vsrcperm1 = vec_lvsl(1, src);
+
+    vsrc0uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm0);
+    if (reallyBadAlign)
+      vsrc1uc = vsrcBuc;
+    else
+      vsrc1uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm1);
+
+    vsrc0ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero,
+                                               (vector unsigned char)vsrc0uc);
+    vsrc1ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero,
+                                               (vector unsigned char)vsrc1uc);
+
+    if (!loadSecond) {// -> !reallyBadAlign
+      for (i = 0 ; i < h ; i++) {
+
+
+        vsrcCuc = vec_ld(stride + 0, src);
+
+        vsrc2uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm0);
+        vsrc3uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm1);
+
+        vsrc2ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero,
+                                                (vector unsigned char)vsrc2uc);
+        vsrc3ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero,
+                                                (vector unsigned char)vsrc3uc);
+
+        psum = vec_mladd(vA, vsrc0ssH, vec_splat_s16(0));
+        psum = vec_mladd(vB, vsrc1ssH, psum);
+        psum = vec_mladd(vC, vsrc2ssH, psum);
+        psum = vec_mladd(vD, vsrc3ssH, psum);
+        psum = vec_add(v32ss, psum);
+        psum = vec_sra(psum, v6us);
+
+        vdst = vec_ld(0, dst);
+        ppsum = (vector unsigned char)vec_packsu(psum, psum);
+        vfdst = vec_perm(vdst, ppsum, fperm);
+
+        OP_U8_ALTIVEC(fsum, vfdst, vdst);
+
+        vec_st(fsum, 0, dst);
+
+        vsrc0ssH = vsrc2ssH;
+        vsrc1ssH = vsrc3ssH;
+
+        dst += stride;
+        src += stride;
+      }
+    } else {
+        vector unsigned char vsrcDuc;
+      for (i = 0 ; i < h ; i++) {
+        vsrcCuc = vec_ld(stride + 0, src);
+        vsrcDuc = vec_ld(stride + 16, src);
+
+        vsrc2uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm0);
+        if (reallyBadAlign)
+          vsrc3uc = vsrcDuc;
+        else
+          vsrc3uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm1);
+
+        vsrc2ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero,
+                                                (vector unsigned char)vsrc2uc);
+        vsrc3ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero,
+                                                (vector unsigned char)vsrc3uc);
+
+        psum = vec_mladd(vA, vsrc0ssH, vec_splat_s16(0));
+        psum = vec_mladd(vB, vsrc1ssH, psum);
+        psum = vec_mladd(vC, vsrc2ssH, psum);
+        psum = vec_mladd(vD, vsrc3ssH, psum);
+        psum = vec_add(v32ss, psum);
+        psum = vec_sr(psum, v6us);
+
+        vdst = vec_ld(0, dst);
+        ppsum = (vector unsigned char)vec_pack(psum, psum);
+        vfdst = vec_perm(vdst, ppsum, fperm);
+
+        OP_U8_ALTIVEC(fsum, vfdst, vdst);
+
+        vec_st(fsum, 0, dst);
+
+        vsrc0ssH = vsrc2ssH;
+        vsrc1ssH = vsrc3ssH;
+
+        dst += stride;
+        src += stride;
+      }
+    }
+    POWERPC_PERF_STOP_COUNT(PREFIX_h264_chroma_mc8_num, 1);
+}
+
+/* this code assume stride % 16 == 0 */
+static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) {
+  POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_h_lowpass_num, 1);
+  register int i;
+
+  const vector signed int vzero = vec_splat_s32(0);
+  const vector unsigned char permM2 = vec_lvsl(-2, src);
+  const vector unsigned char permM1 = vec_lvsl(-1, src);
+  const vector unsigned char permP0 = vec_lvsl(+0, src);
+  const vector unsigned char permP1 = vec_lvsl(+1, src);
+  const vector unsigned char permP2 = vec_lvsl(+2, src);
+  const vector unsigned char permP3 = vec_lvsl(+3, src);
+  const vector signed short v5ss = vec_splat_s16(5);
+  const vector unsigned short v5us = vec_splat_u16(5);
+  const vector signed short v20ss = vec_sl(vec_splat_s16(5),vec_splat_u16(2));
+  const vector signed short v16ss = vec_sl(vec_splat_s16(1),vec_splat_u16(4));
+  const vector unsigned char dstperm = vec_lvsr(0, dst);
+  const vector unsigned char neg1 =
+                                (const vector unsigned char) vec_splat_s8(-1);
+
+  const vector unsigned char dstmask =
+                                vec_perm((const vector unsigned char)vzero,
+                                                               neg1, dstperm);
+
+  vector unsigned char srcM2, srcM1, srcP0, srcP1, srcP2, srcP3;
+
+  register int align = ((((unsigned long)src) - 2) % 16);
+
+  vector signed short srcP0A, srcP0B, srcP1A, srcP1B,
+                      srcP2A, srcP2B, srcP3A, srcP3B,
+                      srcM1A, srcM1B, srcM2A, srcM2B,
+                      sum1A, sum1B, sum2A, sum2B, sum3A, sum3B,
+                      pp1A, pp1B, pp2A, pp2B, pp3A, pp3B,
+                      psumA, psumB, sumA, sumB;
+
+  vector unsigned char sum, dst1, dst2, vdst, fsum,
+                       rsum, fdst1, fdst2;
+
+  POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_h_lowpass_num, 1);
+
+  for (i = 0 ; i < 16 ; i ++) {
+    vector unsigned char srcR1 = vec_ld(-2, src);
+    vector unsigned char srcR2 = vec_ld(14, src);
+
+    switch (align) {
+    default: {
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = vec_perm(srcR1, srcR2, permP1);
+      srcP2 = vec_perm(srcR1, srcR2, permP2);
+      srcP3 = vec_perm(srcR1, srcR2, permP3);
+    } break;
+    case 11: {
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = vec_perm(srcR1, srcR2, permP1);
+      srcP2 = vec_perm(srcR1, srcR2, permP2);
+      srcP3 = srcR2;
+    } break;
+    case 12: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = vec_perm(srcR1, srcR2, permP1);
+      srcP2 = srcR2;
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    case 13: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = srcR2;
+      srcP2 = vec_perm(srcR2, srcR3, permP2);
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    case 14: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = srcR2;
+      srcP1 = vec_perm(srcR2, srcR3, permP1);
+      srcP2 = vec_perm(srcR2, srcR3, permP2);
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    case 15: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = srcR2;
+      srcP0 = vec_perm(srcR2, srcR3, permP0);
+      srcP1 = vec_perm(srcR2, srcR3, permP1);
+      srcP2 = vec_perm(srcR2, srcR3, permP2);
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    }
+
+    srcP0A = (vector signed short)
+                vec_mergeh((vector unsigned char)vzero, srcP0);
+    srcP0B = (vector signed short)
+                vec_mergel((vector unsigned char)vzero, srcP0);
+    srcP1A = (vector signed short)
+                vec_mergeh((vector unsigned char)vzero, srcP1);
+    srcP1B = (vector signed short)
+                vec_mergel((vector unsigned char)vzero, srcP1);
+
+    srcP2A = (vector signed short)
+                vec_mergeh((vector unsigned char)vzero, srcP2);
+    srcP2B = (vector signed short)
+                vec_mergel((vector unsigned char)vzero, srcP2);
+    srcP3A = (vector signed short)
+                vec_mergeh((vector unsigned char)vzero, srcP3);
+    srcP3B = (vector signed short)
+                vec_mergel((vector unsigned char)vzero, srcP3);
+
+    srcM1A = (vector signed short)
+                vec_mergeh((vector unsigned char)vzero, srcM1);
+    srcM1B = (vector signed short)
+                vec_mergel((vector unsigned char)vzero, srcM1);
+    srcM2A = (vector signed short)
+                vec_mergeh((vector unsigned char)vzero, srcM2);
+    srcM2B = (vector signed short)
+                vec_mergel((vector unsigned char)vzero, srcM2);
+
+    sum1A = vec_adds(srcP0A, srcP1A);
+    sum1B = vec_adds(srcP0B, srcP1B);
+    sum2A = vec_adds(srcM1A, srcP2A);
+    sum2B = vec_adds(srcM1B, srcP2B);
+    sum3A = vec_adds(srcM2A, srcP3A);
+    sum3B = vec_adds(srcM2B, srcP3B);
+
+    pp1A = vec_mladd(sum1A, v20ss, v16ss);
+    pp1B = vec_mladd(sum1B, v20ss, v16ss);
+
+    pp2A = vec_mladd(sum2A, v5ss, (vector signed short)vzero);
+    pp2B = vec_mladd(sum2B, v5ss, (vector signed short)vzero);
+
+    pp3A = vec_add(sum3A, pp1A);
+    pp3B = vec_add(sum3B, pp1B);
+
+    psumA = vec_sub(pp3A, pp2A);
+    psumB = vec_sub(pp3B, pp2B);
+
+    sumA = vec_sra(psumA, v5us);
+    sumB = vec_sra(psumB, v5us);
+
+    sum = vec_packsu(sumA, sumB);
+
+    dst1 = vec_ld(0, dst);
+    dst2 = vec_ld(16, dst);
+    vdst = vec_perm(dst1, dst2, vec_lvsl(0, dst));
+
+    OP_U8_ALTIVEC(fsum, sum, vdst);
+
+    rsum = vec_perm(fsum, fsum, dstperm);
+    fdst1 = vec_sel(dst1, rsum, dstmask);
+    fdst2 = vec_sel(rsum, dst2, dstmask);
+
+    vec_st(fdst1, 0, dst);
+    vec_st(fdst2, 16, dst);
+
+    src += srcStride;
+    dst += dstStride;
+  }
+POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_h_lowpass_num, 1);
+}
+
+/* this code assume stride % 16 == 0 */
+static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) {
+  POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_v_lowpass_num, 1);
+
+  register int i;
+
+  const vector signed int vzero = vec_splat_s32(0);
+  const vector unsigned char perm = vec_lvsl(0, src);
+  const vector signed short v20ss = vec_sl(vec_splat_s16(5),vec_splat_u16(2));
+  const vector unsigned short v5us = vec_splat_u16(5);
+  const vector signed short v5ss = vec_splat_s16(5);
+  const vector signed short v16ss = vec_sl(vec_splat_s16(1),vec_splat_u16(4));
+  const vector unsigned char dstperm = vec_lvsr(0, dst);
+  const vector unsigned char neg1 = (const vector unsigned char)vec_splat_s8(-1);
+  const vector unsigned char dstmask = vec_perm((const vector unsigned char)vzero, neg1, dstperm);
+
+  uint8_t *srcbis = src - (srcStride * 2);
+
+  const vector unsigned char srcM2a = vec_ld(0, srcbis);
+  const vector unsigned char srcM2b = vec_ld(16, srcbis);
+  const vector unsigned char srcM2 = vec_perm(srcM2a, srcM2b, perm);
+//  srcbis += srcStride;
+  const vector unsigned char srcM1a = vec_ld(0, srcbis += srcStride);
+  const vector unsigned char srcM1b = vec_ld(16, srcbis);
+  const vector unsigned char srcM1 = vec_perm(srcM1a, srcM1b, perm);
+//  srcbis += srcStride;
+  const vector unsigned char srcP0a = vec_ld(0, srcbis += srcStride);
+  const vector unsigned char srcP0b = vec_ld(16, srcbis);
+  const vector unsigned char srcP0 = vec_perm(srcP0a, srcP0b, perm);
+//  srcbis += srcStride;
+  const vector unsigned char srcP1a = vec_ld(0, srcbis += srcStride);
+  const vector unsigned char srcP1b = vec_ld(16, srcbis);
+  const vector unsigned char srcP1 = vec_perm(srcP1a, srcP1b, perm);
+//  srcbis += srcStride;
+  const vector unsigned char srcP2a = vec_ld(0, srcbis += srcStride);
+  const vector unsigned char srcP2b = vec_ld(16, srcbis);
+  const vector unsigned char srcP2 = vec_perm(srcP2a, srcP2b, perm);
+//  srcbis += srcStride;
+
+  vector signed short srcM2ssA = (vector signed short)
+                                vec_mergeh((vector unsigned char)vzero, srcM2);
+  vector signed short srcM2ssB = (vector signed short)
+                                vec_mergel((vector unsigned char)vzero, srcM2);
+  vector signed short srcM1ssA = (vector signed short)
+                                vec_mergeh((vector unsigned char)vzero, srcM1);
+  vector signed short srcM1ssB = (vector signed short)
+                                vec_mergel((vector unsigned char)vzero, srcM1);
+  vector signed short srcP0ssA = (vector signed short)
+                                vec_mergeh((vector unsigned char)vzero, srcP0);
+  vector signed short srcP0ssB = (vector signed short)
+                                vec_mergel((vector unsigned char)vzero, srcP0);
+  vector signed short srcP1ssA = (vector signed short)
+                                vec_mergeh((vector unsigned char)vzero, srcP1);
+  vector signed short srcP1ssB = (vector signed short)
+                                vec_mergel((vector unsigned char)vzero, srcP1);
+  vector signed short srcP2ssA = (vector signed short)
+                                vec_mergeh((vector unsigned char)vzero, srcP2);
+  vector signed short srcP2ssB = (vector signed short)
+                                vec_mergel((vector unsigned char)vzero, srcP2);
+
+  vector signed short pp1A, pp1B, pp2A, pp2B, pp3A, pp3B,
+                      psumA, psumB, sumA, sumB,
+                      srcP3ssA, srcP3ssB,
+                      sum1A, sum1B, sum2A, sum2B, sum3A, sum3B;
+
+  vector unsigned char sum, dst1, dst2, vdst, fsum, rsum, fdst1, fdst2,
+                       srcP3a, srcP3b, srcP3;
+
+  POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_v_lowpass_num, 1);
+
+  for (i = 0 ; i < 16 ; i++) {
+    srcP3a = vec_ld(0, srcbis += srcStride);
+    srcP3b = vec_ld(16, srcbis);
+    srcP3 = vec_perm(srcP3a, srcP3b, perm);
+    srcP3ssA = (vector signed short)
+                                vec_mergeh((vector unsigned char)vzero, srcP3);
+    srcP3ssB = (vector signed short)
+                                vec_mergel((vector unsigned char)vzero, srcP3);
+//    srcbis += srcStride;
+
+    sum1A = vec_adds(srcP0ssA, srcP1ssA);
+    sum1B = vec_adds(srcP0ssB, srcP1ssB);
+    sum2A = vec_adds(srcM1ssA, srcP2ssA);
+    sum2B = vec_adds(srcM1ssB, srcP2ssB);
+    sum3A = vec_adds(srcM2ssA, srcP3ssA);
+    sum3B = vec_adds(srcM2ssB, srcP3ssB);
+
+    srcM2ssA = srcM1ssA;
+    srcM2ssB = srcM1ssB;
+    srcM1ssA = srcP0ssA;
+    srcM1ssB = srcP0ssB;
+    srcP0ssA = srcP1ssA;
+    srcP0ssB = srcP1ssB;
+    srcP1ssA = srcP2ssA;
+    srcP1ssB = srcP2ssB;
+    srcP2ssA = srcP3ssA;
+    srcP2ssB = srcP3ssB;
+
+    pp1A = vec_mladd(sum1A, v20ss, v16ss);
+    pp1B = vec_mladd(sum1B, v20ss, v16ss);
+
+    pp2A = vec_mladd(sum2A, v5ss, (vector signed short)vzero);
+    pp2B = vec_mladd(sum2B, v5ss, (vector signed short)vzero);
+
+    pp3A = vec_add(sum3A, pp1A);
+    pp3B = vec_add(sum3B, pp1B);
+
+    psumA = vec_sub(pp3A, pp2A);
+    psumB = vec_sub(pp3B, pp2B);
+
+    sumA = vec_sra(psumA, v5us);
+    sumB = vec_sra(psumB, v5us);
+
+    sum = vec_packsu(sumA, sumB);
+
+    dst1 = vec_ld(0, dst);
+    dst2 = vec_ld(16, dst);
+    vdst = vec_perm(dst1, dst2, vec_lvsl(0, dst));
+
+    OP_U8_ALTIVEC(fsum, sum, vdst);
+
+    rsum = vec_perm(fsum, fsum, dstperm);
+    fdst1 = vec_sel(dst1, rsum, dstmask);
+    fdst2 = vec_sel(rsum, dst2, dstmask);
+
+    vec_st(fdst1, 0, dst);
+    vec_st(fdst2, 16, dst);
+
+    dst += dstStride;
+  }
+  POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_v_lowpass_num, 1);
+}
+
+/* this code assume stride % 16 == 0 *and* tmp is properly aligned */
+static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp, uint8_t * src, int dstStride, int tmpStride, int srcStride) {
+  POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_hv_lowpass_num, 1);
+  register int i;
+  const vector signed int vzero = vec_splat_s32(0);
+  const vector unsigned char permM2 = vec_lvsl(-2, src);
+  const vector unsigned char permM1 = vec_lvsl(-1, src);
+  const vector unsigned char permP0 = vec_lvsl(+0, src);
+  const vector unsigned char permP1 = vec_lvsl(+1, src);
+  const vector unsigned char permP2 = vec_lvsl(+2, src);
+  const vector unsigned char permP3 = vec_lvsl(+3, src);
+  const vector signed short v20ss = vec_sl(vec_splat_s16(5),vec_splat_u16(2));
+  const vector unsigned int v10ui = vec_splat_u32(10);
+  const vector signed short v5ss = vec_splat_s16(5);
+  const vector signed short v1ss = vec_splat_s16(1);
+  const vector signed int v512si = vec_sl(vec_splat_s32(1),vec_splat_u32(9));
+  const vector unsigned int v16ui = vec_sl(vec_splat_u32(1),vec_splat_u32(4));
+
+  register int align = ((((unsigned long)src) - 2) % 16);
+
+  const vector unsigned char neg1 = (const vector unsigned char)
+                                                        vec_splat_s8(-1);
+
+  vector signed short srcP0A, srcP0B, srcP1A, srcP1B,
+                      srcP2A, srcP2B, srcP3A, srcP3B,
+                      srcM1A, srcM1B, srcM2A, srcM2B,
+                      sum1A, sum1B, sum2A, sum2B, sum3A, sum3B,
+                      pp1A, pp1B, pp2A, pp2B, psumA, psumB;
+
+  const vector unsigned char dstperm = vec_lvsr(0, dst);
+
+  const vector unsigned char dstmask = vec_perm((const vector unsigned char)vzero, neg1, dstperm);
+
+  const vector unsigned char mperm = (const vector unsigned char)
+    AVV(0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B,
+        0x04, 0x0C, 0x05, 0x0D, 0x06, 0x0E, 0x07, 0x0F);
+  int16_t *tmpbis = tmp;
+
+  vector signed short tmpM1ssA, tmpM1ssB, tmpM2ssA, tmpM2ssB,
+                      tmpP0ssA, tmpP0ssB, tmpP1ssA, tmpP1ssB,
+                      tmpP2ssA, tmpP2ssB;
+
+  vector signed int pp1Ae, pp1Ao, pp1Be, pp1Bo, pp2Ae, pp2Ao, pp2Be, pp2Bo,
+                    pp3Ae, pp3Ao, pp3Be, pp3Bo, pp1cAe, pp1cAo, pp1cBe, pp1cBo,
+                    pp32Ae, pp32Ao, pp32Be, pp32Bo, sumAe, sumAo, sumBe, sumBo,
+                    ssumAe, ssumAo, ssumBe, ssumBo;
+  vector unsigned char fsum, sumv, sum, dst1, dst2, vdst,
+                       rsum, fdst1, fdst2;
+  vector signed short ssume, ssumo;
+
+  POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_hv_lowpass_num, 1);
+  src -= (2 * srcStride);
+  for (i = 0 ; i < 21 ; i ++) {
+    vector unsigned char srcM2, srcM1, srcP0, srcP1, srcP2, srcP3;
+    vector unsigned char srcR1 = vec_ld(-2, src);
+    vector unsigned char srcR2 = vec_ld(14, src);
+
+    switch (align) {
+    default: {
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = vec_perm(srcR1, srcR2, permP1);
+      srcP2 = vec_perm(srcR1, srcR2, permP2);
+      srcP3 = vec_perm(srcR1, srcR2, permP3);
+    } break;
+    case 11: {
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = vec_perm(srcR1, srcR2, permP1);
+      srcP2 = vec_perm(srcR1, srcR2, permP2);
+      srcP3 = srcR2;
+    } break;
+    case 12: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = vec_perm(srcR1, srcR2, permP1);
+      srcP2 = srcR2;
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    case 13: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = vec_perm(srcR1, srcR2, permP0);
+      srcP1 = srcR2;
+      srcP2 = vec_perm(srcR2, srcR3, permP2);
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    case 14: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = vec_perm(srcR1, srcR2, permM1);
+      srcP0 = srcR2;
+      srcP1 = vec_perm(srcR2, srcR3, permP1);
+      srcP2 = vec_perm(srcR2, srcR3, permP2);
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    case 15: {
+      vector unsigned char srcR3 = vec_ld(30, src);
+      srcM2 = vec_perm(srcR1, srcR2, permM2);
+      srcM1 = srcR2;
+      srcP0 = vec_perm(srcR2, srcR3, permP0);
+      srcP1 = vec_perm(srcR2, srcR3, permP1);
+      srcP2 = vec_perm(srcR2, srcR3, permP2);
+      srcP3 = vec_perm(srcR2, srcR3, permP3);
+    } break;
+    }
+
+    srcP0A = (vector signed short)
+                            vec_mergeh((vector unsigned char)vzero, srcP0);
+    srcP0B = (vector signed short)
+                            vec_mergel((vector unsigned char)vzero, srcP0);
+    srcP1A = (vector signed short)
+                            vec_mergeh((vector unsigned char)vzero, srcP1);
+    srcP1B = (vector signed short)
+                            vec_mergel((vector unsigned char)vzero, srcP1);
+
+    srcP2A = (vector signed short)
+                            vec_mergeh((vector unsigned char)vzero, srcP2);
+    srcP2B = (vector signed short)
+                            vec_mergel((vector unsigned char)vzero, srcP2);
+    srcP3A = (vector signed short)
+                            vec_mergeh((vector unsigned char)vzero, srcP3);
+    srcP3B = (vector signed short)
+                            vec_mergel((vector unsigned char)vzero, srcP3);
+
+    srcM1A = (vector signed short)
+                            vec_mergeh((vector unsigned char)vzero, srcM1);
+    srcM1B = (vector signed short)
+                            vec_mergel((vector unsigned char)vzero, srcM1);
+    srcM2A = (vector signed short)
+                            vec_mergeh((vector unsigned char)vzero, srcM2);
+    srcM2B = (vector signed short)
+                            vec_mergel((vector unsigned char)vzero, srcM2);
+
+    sum1A = vec_adds(srcP0A, srcP1A);
+    sum1B = vec_adds(srcP0B, srcP1B);
+    sum2A = vec_adds(srcM1A, srcP2A);
+    sum2B = vec_adds(srcM1B, srcP2B);
+    sum3A = vec_adds(srcM2A, srcP3A);
+    sum3B = vec_adds(srcM2B, srcP3B);
+
+    pp1A = vec_mladd(sum1A, v20ss, sum3A);
+    pp1B = vec_mladd(sum1B, v20ss, sum3B);
+
+    pp2A = vec_mladd(sum2A, v5ss, (vector signed short)vzero);
+    pp2B = vec_mladd(sum2B, v5ss, (vector signed short)vzero);
+
+    psumA = vec_sub(pp1A, pp2A);
+    psumB = vec_sub(pp1B, pp2B);
+
+    vec_st(psumA, 0, tmp);
+    vec_st(psumB, 16, tmp);
+
+    src += srcStride;
+    tmp += tmpStride; /* int16_t*, and stride is 16, so it's OK here */
+  }
+
+  tmpM2ssA = vec_ld(0, tmpbis);
+  tmpM2ssB = vec_ld(16, tmpbis);
+  tmpbis += tmpStride;
+  tmpM1ssA = vec_ld(0, tmpbis);
+  tmpM1ssB = vec_ld(16, tmpbis);
+  tmpbis += tmpStride;
+  tmpP0ssA = vec_ld(0, tmpbis);
+  tmpP0ssB = vec_ld(16, tmpbis);
+  tmpbis += tmpStride;
+  tmpP1ssA = vec_ld(0, tmpbis);
+  tmpP1ssB = vec_ld(16, tmpbis);
+  tmpbis += tmpStride;
+  tmpP2ssA = vec_ld(0, tmpbis);
+  tmpP2ssB = vec_ld(16, tmpbis);
+  tmpbis += tmpStride;
+
+  for (i = 0 ; i < 16 ; i++) {
+    const vector signed short tmpP3ssA = vec_ld(0, tmpbis);
+    const vector signed short tmpP3ssB = vec_ld(16, tmpbis);
+
+    const vector signed short sum1A = vec_adds(tmpP0ssA, tmpP1ssA);
+    const vector signed short sum1B = vec_adds(tmpP0ssB, tmpP1ssB);
+    const vector signed short sum2A = vec_adds(tmpM1ssA, tmpP2ssA);
+    const vector signed short sum2B = vec_adds(tmpM1ssB, tmpP2ssB);
+    const vector signed short sum3A = vec_adds(tmpM2ssA, tmpP3ssA);
+    const vector signed short sum3B = vec_adds(tmpM2ssB, tmpP3ssB);
+
+    tmpbis += tmpStride;
+
+    tmpM2ssA = tmpM1ssA;
+    tmpM2ssB = tmpM1ssB;
+    tmpM1ssA = tmpP0ssA;
+    tmpM1ssB = tmpP0ssB;
+    tmpP0ssA = tmpP1ssA;
+    tmpP0ssB = tmpP1ssB;
+    tmpP1ssA = tmpP2ssA;
+    tmpP1ssB = tmpP2ssB;
+    tmpP2ssA = tmpP3ssA;
+    tmpP2ssB = tmpP3ssB;
+
+    pp1Ae = vec_mule(sum1A, v20ss);
+    pp1Ao = vec_mulo(sum1A, v20ss);
+    pp1Be = vec_mule(sum1B, v20ss);
+    pp1Bo = vec_mulo(sum1B, v20ss);
+
+    pp2Ae = vec_mule(sum2A, v5ss);
+    pp2Ao = vec_mulo(sum2A, v5ss);
+    pp2Be = vec_mule(sum2B, v5ss);
+    pp2Bo = vec_mulo(sum2B, v5ss);
+
+    pp3Ae = vec_sra((vector signed int)sum3A, v16ui);
+    pp3Ao = vec_mulo(sum3A, v1ss);
+    pp3Be = vec_sra((vector signed int)sum3B, v16ui);
+    pp3Bo = vec_mulo(sum3B, v1ss);
+
+    pp1cAe = vec_add(pp1Ae, v512si);
+    pp1cAo = vec_add(pp1Ao, v512si);
+    pp1cBe = vec_add(pp1Be, v512si);
+    pp1cBo = vec_add(pp1Bo, v512si);
+
+    pp32Ae = vec_sub(pp3Ae, pp2Ae);
+    pp32Ao = vec_sub(pp3Ao, pp2Ao);
+    pp32Be = vec_sub(pp3Be, pp2Be);
+    pp32Bo = vec_sub(pp3Bo, pp2Bo);
+
+    sumAe = vec_add(pp1cAe, pp32Ae);
+    sumAo = vec_add(pp1cAo, pp32Ao);
+    sumBe = vec_add(pp1cBe, pp32Be);
+    sumBo = vec_add(pp1cBo, pp32Bo);
+
+    ssumAe = vec_sra(sumAe, v10ui);
+    ssumAo = vec_sra(sumAo, v10ui);
+    ssumBe = vec_sra(sumBe, v10ui);
+    ssumBo = vec_sra(sumBo, v10ui);
+
+    ssume = vec_packs(ssumAe, ssumBe);
+    ssumo = vec_packs(ssumAo, ssumBo);
+
+    sumv = vec_packsu(ssume, ssumo);
+    sum = vec_perm(sumv, sumv, mperm);
+
+    dst1 = vec_ld(0, dst);
+    dst2 = vec_ld(16, dst);
+    vdst = vec_perm(dst1, dst2, vec_lvsl(0, dst));
+
+    OP_U8_ALTIVEC(fsum, sum, vdst);
+
+    rsum = vec_perm(fsum, fsum, dstperm);
+    fdst1 = vec_sel(dst1, rsum, dstmask);
+    fdst2 = vec_sel(rsum, dst2, dstmask);
+
+    vec_st(fdst1, 0, dst);
+    vec_st(fdst2, 16, dst);
+
+    dst += dstStride;
+  }
+  POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_hv_lowpass_num, 1);
+}
diff -uNr xine-lib-1.1.8.orig/src/libffmpeg/libavcodec/ws-snd1.c xine-lib-1.1.8/src/libffmpeg/libavcodec/ws-snd1.c
--- xine-lib-1.1.8.orig/src/libffmpeg/libavcodec/ws-snd1.c	1970-01-01 01:00:00.000000000 +0100
+++ xine-lib-1.1.8/src/libffmpeg/libavcodec/ws-snd1.c	2007-04-17 20:46:43.000000000 +0200
@@ -0,0 +1,144 @@
+/*
+ * Westwood SNDx codecs
+ * Copyright (c) 2005 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avcodec.h"
+
+/**
+ * @file ws-snd.c
+ * Westwood SNDx codecs.
+ *
+ * Reference documents about VQA format and its audio codecs
+ * can be found here:
+ * http://www.multimedia.cx
+ */
+
+static const char ws_adpcm_2bit[] = { -2, -1, 0, 1};
+static const char ws_adpcm_4bit[] = {
+    -9, -8, -6, -5, -4, -3, -2, -1,
+     0,  1,  2,  3,  4,  5,  6,  8 };
+
+#define CLIP8(a) if(a>127)a=127;if(a<-128)a=-128;
+
+static int ws_snd_decode_init(AVCodecContext * avctx)
+{
+//    WSSNDContext *c = avctx->priv_data;
+
+    return 0;
+}
+
+static int ws_snd_decode_frame(AVCodecContext *avctx,
+                void *data, int *data_size,
+                uint8_t *buf, int buf_size)
+{
+//    WSSNDContext *c = avctx->priv_data;
+
+    int in_size, out_size;
+    int sample = 0;
+    int i;
+    short *samples = data;
+
+    if (!buf_size)
+        return 0;
+
+    out_size = AV_RL16(&buf[0]);
+    *data_size = out_size * 2;
+    in_size = AV_RL16(&buf[2]);
+    buf += 4;
+
+    if (in_size == out_size) {
+        for (i = 0; i < out_size; i++)
+            *samples++ = (*buf++ - 0x80) << 8;
+        return buf_size;
+    }
+
+    while (out_size > 0) {
+        int code;
+        uint8_t count;
+        code = (*buf) >> 6;
+        count = (*buf) & 0x3F;
+        buf++;
+        switch(code) {
+        case 0: /* ADPCM 2-bit */
+            for (count++; count > 0; count--) {
+                code = *buf++;
+                sample += ws_adpcm_2bit[code & 0x3];
+                CLIP8(sample);
+                *samples++ = sample << 8;
+                sample += ws_adpcm_2bit[(code >> 2) & 0x3];
+                CLIP8(sample);
+                *samples++ = sample << 8;
+                sample += ws_adpcm_2bit[(code >> 4) & 0x3];
+                CLIP8(sample);
+                *samples++ = sample << 8;
+                sample += ws_adpcm_2bit[(code >> 6) & 0x3];
+                CLIP8(sample);
+                *samples++ = sample << 8;
+                out_size -= 4;
+            }
+            break;
+        case 1: /* ADPCM 4-bit */
+            for (count++; count > 0; count--) {
+                code = *buf++;
+                sample += ws_adpcm_4bit[code & 0xF];
+                CLIP8(sample);
+                *samples++ = sample << 8;
+                sample += ws_adpcm_4bit[code >> 4];
+                CLIP8(sample);
+                *samples++ = sample << 8;
+                out_size -= 2;
+            }
+            break;
+        case 2: /* no compression */
+            if (count & 0x20) { /* big delta */
+                char t;
+                t = count;
+                t <<= 3;
+                sample += t >> 3;
+                *samples++ = sample << 8;
+                out_size--;
+            } else { /* copy */
+                for (count++; count > 0; count--) {
+                    *samples++ = (*buf++ - 0x80) << 8;
+                    out_size--;
+                }
+                sample = buf[-1] - 0x80;
+            }
+            break;
+        default: /* run */
+            for(count++; count > 0; count--) {
+                *samples++ = sample << 8;
+                out_size--;
+            }
+        }
+    }
+
+    return buf_size;
+}
+
+AVCodec ws_snd1_decoder = {
+    "ws_snd1",
+    CODEC_TYPE_AUDIO,
+    CODEC_ID_WESTWOOD_SND1,
+    0,
+    ws_snd_decode_init,
+    NULL,
+    NULL,
+    ws_snd_decode_frame,
+};
diff -uNr xine-lib-1.1.8.orig/src/xine-engine/buffer.h xine-lib-1.1.8/src/xine-engine/buffer.h
--- xine-lib-1.1.8.orig/src/xine-engine/buffer.h	2007-08-19 01:36:59.000000000 +0200
+++ xine-lib-1.1.8/src/xine-engine/buffer.h	2007-12-09 16:35:05.000000000 +0100
@@ -15,9 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: buffer.h,v 1.162 2007/01/14 16:53:37 klan Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  *
  * contents:
@@ -28,7 +26,6 @@
  * free buffer pool management routines
  *
  * FIFO buffer structures/routines
- *
  */
 
 #ifndef HAVE_BUFFER_H
@@ -192,6 +189,7 @@
 #define BUF_VIDEO_CAVS		0x02620000
 #define BUF_VIDEO_VP6F		0x02630000
 #define BUF_VIDEO_THEORA_RAW	0x02640000
+#define BUF_VIDEO_VC1		0x02650000
 
 /* audio buffer types:  (please keep in sync with buffer_types.c) */
 
diff -uNr xine-lib-1.1.8.orig/src/xine-engine/buffer_types.c xine-lib-1.1.8/src/xine-engine/buffer_types.c
--- xine-lib-1.1.8.orig/src/xine-engine/buffer_types.c	2007-08-19 01:36:59.000000000 +0200
+++ xine-lib-1.1.8/src/xine-engine/buffer_types.c	2007-12-09 16:35:05.000000000 +0100
@@ -15,16 +15,13 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
- *
- * $Id: buffer_types.c,v 1.107 2006/12/26 03:18:56 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  *
  *
  * contents:
  *
  * buffer types management. 
  * convert FOURCC and audioformattag to BUF_xxx defines
- *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -38,14 +35,6 @@
 #include "buffer.h"
 #include "bswap.h"
 
-/* FOURCC will be manipulated using machine endian */
-#ifdef WORDS_BIGENDIAN
-#define meFOURCC BE_FOURCC
-#else
-#define meFOURCC LE_FOURCC
-#endif
-
-
 typedef struct video_db_s {
    uint32_t fourcc[20];
    uint32_t buf_type;
@@ -62,11 +51,12 @@
 static const video_db_t video_db[] = {
 {
   {
-    meFOURCC('m', 'p', 'e', 'g'),
-    meFOURCC('M', 'P', 'E', 'G'),
-    meFOURCC('P', 'I', 'M', '1'),
-    meFOURCC('m', 'p', 'g', '2'),
-    meFOURCC('m', 'p', 'g', '1'),
+    ME_FOURCC('m', 'p', 'e', 'g'),
+    ME_FOURCC('M', 'P', 'E', 'G'),
+    ME_FOURCC('P', 'I', 'M', '1'),
+    ME_FOURCC('m', 'p', 'g', '2'),
+    ME_FOURCC('m', 'p', 'g', '1'),
+    ME_FOURCC(0x02, 0, 0, 0x10),
     0
   },
   BUF_VIDEO_MPEG,
@@ -74,15 +64,15 @@
 },
 {
   {
-    meFOURCC('D', 'I', 'V', 'X'),
-    meFOURCC('d', 'i', 'v', 'x'),
-    meFOURCC('D', 'i', 'v', 'x'),
-    meFOURCC('D', 'i', 'v', 'X'),
-    meFOURCC('M', 'P', '4', 'S'),
-    meFOURCC('m', 'p', '4', 'v'),
-    meFOURCC('M', '4', 'S', '2'),
-    meFOURCC('m', '4', 's', '2'),
-    meFOURCC('F', 'M', 'P', '4'),
+    ME_FOURCC('D', 'I', 'V', 'X'),
+    ME_FOURCC('d', 'i', 'v', 'x'),
+    ME_FOURCC('D', 'i', 'v', 'x'),
+    ME_FOURCC('D', 'i', 'v', 'X'),
+    ME_FOURCC('M', 'P', '4', 'S'),
+    ME_FOURCC('m', 'p', '4', 'v'),
+    ME_FOURCC('M', '4', 'S', '2'),
+    ME_FOURCC('m', '4', 's', '2'),
+    ME_FOURCC('F', 'M', 'P', '4'),
     0
   },
   BUF_VIDEO_MPEG4,
@@ -90,8 +80,8 @@
 },
 {
   {
-    meFOURCC('X', 'V', 'I', 'D'),
-    meFOURCC('x', 'v', 'i', 'd'),
+    ME_FOURCC('X', 'V', 'I', 'D'),
+    ME_FOURCC('x', 'v', 'i', 'd'),
     0
   },
   BUF_VIDEO_XVID,
@@ -99,7 +89,7 @@
 },
 {
   {
-    meFOURCC('D', 'X', '5', '0'),
+    ME_FOURCC('D', 'X', '5', '0'),
     0
   },
   BUF_VIDEO_DIVX5,
@@ -107,7 +97,7 @@
 },
 {
   {
-    meFOURCC('c', 'v', 'i', 'd'),
+    ME_FOURCC('c', 'v', 'i', 'd'),
     0
   },
   BUF_VIDEO_CINEPAK,
@@ -115,9 +105,9 @@
 },
 {
   {
-    meFOURCC('S', 'V', 'Q', '1'),
-    meFOURCC('s', 'v', 'q', '1'),
-    meFOURCC('s', 'v', 'q', 'i'),
+    ME_FOURCC('S', 'V', 'Q', '1'),
+    ME_FOURCC('s', 'v', 'q', '1'),
+    ME_FOURCC('s', 'v', 'q', 'i'),
     0
   },
   BUF_VIDEO_SORENSON_V1,
@@ -125,8 +115,8 @@
 },
 {
   {
-    meFOURCC('S', 'V', 'Q', '3'),
-    meFOURCC('s', 'v', 'q', '3'),
+    ME_FOURCC('S', 'V', 'Q', '3'),
+    ME_FOURCC('s', 'v', 'q', '3'),
     0
   },
   BUF_VIDEO_SORENSON_V3,
@@ -134,10 +124,10 @@
 },
 {
   {
-    meFOURCC('M', 'P', '4', '1'),
-    meFOURCC('m', 'p', '4', '1'),
-    meFOURCC('M', 'P', 'G', '4'),
-    meFOURCC('m', 'p', 'g', '4'),
+    ME_FOURCC('M', 'P', '4', '1'),
+    ME_FOURCC('m', 'p', '4', '1'),
+    ME_FOURCC('M', 'P', 'G', '4'),
+    ME_FOURCC('m', 'p', 'g', '4'),
     0
   },
   BUF_VIDEO_MSMPEG4_V1,
@@ -145,12 +135,12 @@
 },
 {
   {
-    meFOURCC('M', 'P', '4', '1'),
-    meFOURCC('m', 'p', '4', '1'),
-    meFOURCC('M', 'P', '4', '2'),
-    meFOURCC('m', 'p', '4', '2'),
-    meFOURCC('D', 'I', 'V', '2'),
-    meFOURCC('d', 'i', 'v', '2'),
+    ME_FOURCC('M', 'P', '4', '1'),
+    ME_FOURCC('m', 'p', '4', '1'),
+    ME_FOURCC('M', 'P', '4', '2'),
+    ME_FOURCC('m', 'p', '4', '2'),
+    ME_FOURCC('D', 'I', 'V', '2'),
+    ME_FOURCC('d', 'i', 'v', '2'),
     0
   },
   BUF_VIDEO_MSMPEG4_V2,
@@ -158,20 +148,20 @@
 },
 {
   {
-    meFOURCC('M', 'P', '4', '3'),
-    meFOURCC('m', 'p', '4', '3'),
-    meFOURCC('D', 'I', 'V', '3'),
-    meFOURCC('d', 'i', 'v', '3'),
-    meFOURCC('D', 'I', 'V', '4'),
-    meFOURCC('d', 'i', 'v', '4'),
-    meFOURCC('D', 'I', 'V', '5'),
-    meFOURCC('d', 'i', 'v', '5'),
-    meFOURCC('D', 'I', 'V', '6'),
-    meFOURCC('d', 'i', 'v', '6'),
-    meFOURCC('A', 'P', '4', '1'),
-    meFOURCC('M', 'P', 'G', '3'),
-    meFOURCC('C', 'O', 'L', '1'),
-    meFOURCC('3', 'I', 'V', 'D'),
+    ME_FOURCC('M', 'P', '4', '3'),
+    ME_FOURCC('m', 'p', '4', '3'),
+    ME_FOURCC('D', 'I', 'V', '3'),
+    ME_FOURCC('d', 'i', 'v', '3'),
+    ME_FOURCC('D', 'I', 'V', '4'),
+    ME_FOURCC('d', 'i', 'v', '4'),
+    ME_FOURCC('D', 'I', 'V', '5'),
+    ME_FOURCC('d', 'i', 'v', '5'),
+    ME_FOURCC('D', 'I', 'V', '6'),
+    ME_FOURCC('d', 'i', 'v', '6'),
+    ME_FOURCC('A', 'P', '4', '1'),
+    ME_FOURCC('M', 'P', 'G', '3'),
+    ME_FOURCC('C', 'O', 'L', '1'),
+    ME_FOURCC('3', 'I', 'V', 'D'),
     0
   },
   BUF_VIDEO_MSMPEG4_V3,
@@ -179,8 +169,8 @@
 },
 {
   {
-    meFOURCC('3', 'I', 'V', '1'),
-    meFOURCC('3', 'I', 'V', '2'),
+    ME_FOURCC('3', 'I', 'V', '1'),
+    ME_FOURCC('3', 'I', 'V', '2'),
     0
   },
   BUF_VIDEO_3IVX,
@@ -188,11 +178,11 @@
 },
 {
   {
-    meFOURCC('d', 'm', 'b', '1'),
-    meFOURCC('M', 'J', 'P', 'G'),
-    meFOURCC('m', 'j', 'p', 'a'),
-    meFOURCC('A', 'V', 'R', 'n'),
-    meFOURCC('A', 'V', 'D', 'J'),
+    ME_FOURCC('d', 'm', 'b', '1'),
+    ME_FOURCC('M', 'J', 'P', 'G'),
+    ME_FOURCC('m', 'j', 'p', 'a'),
+    ME_FOURCC('A', 'V', 'R', 'n'),
+    ME_FOURCC('A', 'V', 'D', 'J'),
     0
   },
   BUF_VIDEO_MJPEG,
@@ -200,7 +190,7 @@
 },
 {
   {
-    meFOURCC('m', 'j', 'p', 'b'),
+    ME_FOURCC('m', 'j', 'p', 'b'),
     0
   },
   BUF_VIDEO_MJPEG_B,
@@ -208,8 +198,8 @@
 },
 {
   {
-    meFOURCC('I', 'V', '5', '0'),
-    meFOURCC('i', 'v', '5', '0'),
+    ME_FOURCC('I', 'V', '5', '0'),
+    ME_FOURCC('i', 'v', '5', '0'),
     0
   },
   BUF_VIDEO_IV50,
@@ -217,8 +207,8 @@
 },
 {
   {
-    meFOURCC('I', 'V', '4', '1'),
-    meFOURCC('i', 'v', '4', '1'),
+    ME_FOURCC('I', 'V', '4', '1'),
+    ME_FOURCC('i', 'v', '4', '1'),
     0
   },
   BUF_VIDEO_IV41,
@@ -226,8 +216,8 @@
 },
 {
   {
-    meFOURCC('I', 'V', '3', '2'),
-    meFOURCC('i', 'v', '3', '2'),
+    ME_FOURCC('I', 'V', '3', '2'),
+    ME_FOURCC('i', 'v', '3', '2'),
     0
   },
   BUF_VIDEO_IV32,
@@ -235,8 +225,8 @@
 },
 {
   {
-    meFOURCC('I', 'V', '3', '1'),
-    meFOURCC('i', 'v', '3', '1'),
+    ME_FOURCC('I', 'V', '3', '1'),
+    ME_FOURCC('i', 'v', '3', '1'),
     0
   },
   BUF_VIDEO_IV31,
@@ -244,7 +234,7 @@
 },
 {
   {
-    meFOURCC('V', 'C', 'R', '1'),
+    ME_FOURCC('V', 'C', 'R', '1'),
     0
   },
   BUF_VIDEO_ATIVCR1,
@@ -252,7 +242,7 @@
 },
 {
   {
-    meFOURCC('V', 'C', 'R', '2'),
+    ME_FOURCC('V', 'C', 'R', '2'),
     0
   },
   BUF_VIDEO_ATIVCR2,
@@ -260,11 +250,11 @@
 },
 {
   {
-    meFOURCC('I', '2', '6', '3'),
-    meFOURCC('i', '2', '6', '3'),
-    meFOURCC('V', 'I', 'V', 'O'),
-    meFOURCC('v', 'i', 'v', 'o'),
-    meFOURCC('v', 'i', 'v', '1'),
+    ME_FOURCC('I', '2', '6', '3'),
+    ME_FOURCC('i', '2', '6', '3'),
+    ME_FOURCC('V', 'I', 'V', 'O'),
+    ME_FOURCC('v', 'i', 'v', 'o'),
+    ME_FOURCC('v', 'i', 'v', '1'),
     0
   },
   BUF_VIDEO_I263,
@@ -272,8 +262,8 @@
 },
 {
   {
-    meFOURCC('D','I','B',' '),  /* device-independent bitmap */
-    meFOURCC('r','a','w',' '),
+    ME_FOURCC('D','I','B',' '),  /* device-independent bitmap */
+    ME_FOURCC('r','a','w',' '),
     0
   },
   BUF_VIDEO_RGB,
@@ -285,8 +275,8 @@
     else if (!strncasecmp (video, "yuv2", 4))
     this->video_type = BUF_VIDEO_YUY2;
     */
-    meFOURCC('y', 'u', 'v', '2'),
-    meFOURCC('Y', 'U', 'Y', '2'),
+    ME_FOURCC('y', 'u', 'v', '2'),
+    ME_FOURCC('Y', 'U', 'Y', '2'),
     0
   },
   BUF_VIDEO_YUY2,
@@ -294,8 +284,8 @@
 },
 {
   {
-    meFOURCC('j','p','e','g'),
-    meFOURCC('J','F','I','F'),
+    ME_FOURCC('j','p','e','g'),
+    ME_FOURCC('J','F','I','F'),
     0
   },
   BUF_VIDEO_JPEG,
@@ -303,7 +293,7 @@
 },
 {
   {
-    meFOURCC('W','M','V','1'),
+    ME_FOURCC('W','M','V','1'),
     0
   },
   BUF_VIDEO_WMV7,
@@ -311,7 +301,7 @@
 },
 {
   {
-    meFOURCC('W','M','V','2'),
+    ME_FOURCC('W','M','V','2'),
     0
   },
   BUF_VIDEO_WMV8,
@@ -319,8 +309,8 @@
 },
 {
   {
-    meFOURCC('W','M','V','3'),
-    meFOURCC('W','M','V','P'),
+    ME_FOURCC('W','M','V','3'),
+    ME_FOURCC('W','M','V','P'),
     0
   },
   BUF_VIDEO_WMV9,
@@ -328,12 +318,22 @@
 },
 {
   {
-    meFOURCC('c','r','a','m'),
-    meFOURCC('C','R','A','M'),
-    meFOURCC('M','S','V','C'),
-    meFOURCC('m','s','v','c'),
-    meFOURCC('W','H','A','M'),
-    meFOURCC('w','h','a','m'),
+    ME_FOURCC('W','V','C','1'),
+    ME_FOURCC('W','M','V','A'),
+    ME_FOURCC('v','c','-','1'),
+    0
+  },
+  BUF_VIDEO_VC1,
+  "Windows Media Video VC-1"
+},
+{
+  {
+    ME_FOURCC('c','r','a','m'),
+    ME_FOURCC('C','R','A','M'),
+    ME_FOURCC('M','S','V','C'),
+    ME_FOURCC('m','s','v','c'),
+    ME_FOURCC('W','H','A','M'),
+    ME_FOURCC('w','h','a','m'),
     0
   },
   BUF_VIDEO_MSVC,
@@ -341,9 +341,9 @@
 },
 {
   {
-    meFOURCC('D','V','S','D'),
-    meFOURCC('d','v','s','d'),
-    meFOURCC('d','v','c','p'),
+    ME_FOURCC('D','V','S','D'),
+    ME_FOURCC('d','v','s','d'),
+    ME_FOURCC('d','v','c','p'),
     0
   },
   BUF_VIDEO_DV,
@@ -351,11 +351,11 @@
 },
 {
   {
-    meFOURCC('V','P','3',' '),
-    meFOURCC('V','P','3','0'),
-    meFOURCC('v','p','3','0'),
-    meFOURCC('V','P','3','1'),
-    meFOURCC('v','p','3','1'),
+    ME_FOURCC('V','P','3',' '),
+    ME_FOURCC('V','P','3','0'),
+    ME_FOURCC('v','p','3','0'),
+    ME_FOURCC('V','P','3','1'),
+    ME_FOURCC('v','p','3','1'),
     0
   },
   BUF_VIDEO_VP31,
@@ -363,7 +363,7 @@
 },
 {
   {
-    meFOURCC('V','P','4','0'),
+    ME_FOURCC('V','P','4','0'),
     0,
   },
   BUF_VIDEO_VP4,
@@ -371,10 +371,10 @@
 },
 {
   {
-    meFOURCC('H', '2', '6', '3'),
-    meFOURCC('h', '2', '6', '3'),
-    meFOURCC('U', '2', '6', '3'),
-    meFOURCC('s', '2', '6', '3'),
+    ME_FOURCC('H', '2', '6', '3'),
+    ME_FOURCC('h', '2', '6', '3'),
+    ME_FOURCC('U', '2', '6', '3'),
+    ME_FOURCC('s', '2', '6', '3'),
     0
   },
   BUF_VIDEO_H263,
@@ -382,8 +382,8 @@
 },
 {
   {
-    meFOURCC('c', 'y', 'u', 'v'),
-    meFOURCC('C', 'Y', 'U', 'V'),
+    ME_FOURCC('c', 'y', 'u', 'v'),
+    ME_FOURCC('C', 'Y', 'U', 'V'),
     0
   },
   BUF_VIDEO_CYUV,
@@ -391,7 +391,7 @@
 },
 {
   {
-    meFOURCC('s', 'm', 'c', ' '),
+    ME_FOURCC('s', 'm', 'c', ' '),
     0
   },
   BUF_VIDEO_SMC,
@@ -399,8 +399,8 @@
 },
 {
   {
-    meFOURCC('r', 'p', 'z', 'a'),
-    meFOURCC('a', 'z', 'p', 'r'),
+    ME_FOURCC('r', 'p', 'z', 'a'),
+    ME_FOURCC('a', 'z', 'p', 'r'),
     0
   },
   BUF_VIDEO_RPZA,
@@ -408,7 +408,7 @@
 },
 {
   {
-    meFOURCC('r', 'l', 'e', ' '),
+    ME_FOURCC('r', 'l', 'e', ' '),
     0
   },
   BUF_VIDEO_QTRLE,
@@ -423,7 +423,7 @@
 },
 {
   {
-    meFOURCC('D', 'U', 'C', 'K'),
+    ME_FOURCC('D', 'U', 'C', 'K'),
     0
   },
   BUF_VIDEO_DUCKTM1,
@@ -431,7 +431,7 @@
 },
 {
   {
-    meFOURCC('M', 'S', 'S', '1'),
+    ME_FOURCC('M', 'S', 'S', '1'),
     0
   },
   BUF_VIDEO_MSS1,
@@ -439,7 +439,7 @@
 },
 {
   {
-    meFOURCC('P', 'G', 'V', 'V'),
+    ME_FOURCC('P', 'G', 'V', 'V'),
     0
   },
   BUF_VIDEO_PGVV,
@@ -447,7 +447,7 @@
 },
 {
   {
-    meFOURCC('Z', 'y', 'G', 'o'),
+    ME_FOURCC('Z', 'y', 'G', 'o'),
     0
   },
   BUF_VIDEO_ZYGO,
@@ -455,7 +455,7 @@
 },
 {
   {
-    meFOURCC('t', 's', 'c', 'c'),
+    ME_FOURCC('t', 's', 'c', 'c'),
     0
   },
   BUF_VIDEO_TSCC,
@@ -463,7 +463,7 @@
 },
 {
   {
-    meFOURCC('Y', 'V', 'U', '9'),
+    ME_FOURCC('Y', 'V', 'U', '9'),
     0
   },
   BUF_VIDEO_YVU9,
@@ -471,7 +471,7 @@
 },
 {
   {
-    meFOURCC('G', 'R', 'E', 'Y'),
+    ME_FOURCC('G', 'R', 'E', 'Y'),
     0
   },
   BUF_VIDEO_GREY,
@@ -479,9 +479,9 @@
 },
 {
   {
-    meFOURCC('X', 'x', 'a', 'n'),
-    meFOURCC('X', 'X', 'A', 'N'),
-    meFOURCC('x', 'x', 'a', 'n'),
+    ME_FOURCC('X', 'x', 'a', 'n'),
+    ME_FOURCC('X', 'X', 'A', 'N'),
+    ME_FOURCC('x', 'x', 'a', 'n'),
     0
   },
   BUF_VIDEO_XXAN,
@@ -489,8 +489,8 @@
 },
 {
   {
-    meFOURCC('Y', 'V', '1', '2'),
-    meFOURCC('y', 'v', '1', '2'),
+    ME_FOURCC('Y', 'V', '1', '2'),
+    ME_FOURCC('y', 'v', '1', '2'),
     0
   },
   BUF_VIDEO_YV12,
@@ -498,8 +498,8 @@
 },
 {
   {
-    meFOURCC('I', '4', '2', '0'),
-    meFOURCC('I', 'Y', 'U', 'V'),
+    ME_FOURCC('I', '4', '2', '0'),
+    ME_FOURCC('I', 'Y', 'U', 'V'),
     0
   },
   BUF_VIDEO_I420,
@@ -507,8 +507,8 @@
 },
 {
   {
-    meFOURCC('S', 'E', 'G', 'A'),
-    meFOURCC('s', 'e', 'g', 'a'),
+    ME_FOURCC('S', 'E', 'G', 'A'),
+    ME_FOURCC('s', 'e', 'g', 'a'),
     0
   },
   BUF_VIDEO_SEGA,
@@ -516,8 +516,8 @@
 },
 {
   {
-    meFOURCC('m', 'v', 'i', '2'),
-    meFOURCC('M', 'V', 'I', '2'),
+    ME_FOURCC('m', 'v', 'i', '2'),
+    ME_FOURCC('M', 'V', 'I', '2'),
     0
   },
   BUF_VIDEO_MVI2,
@@ -525,8 +525,8 @@
 },
 {
   {
-    meFOURCC('u', 'c', 'o', 'd'),
-    meFOURCC('U', 'C', 'O', 'D'),
+    ME_FOURCC('u', 'c', 'o', 'd'),
+    ME_FOURCC('U', 'C', 'O', 'D'),
     0
   },
   BUF_VIDEO_UCOD,
@@ -534,7 +534,7 @@
 },
 {
   {
-    meFOURCC('R', 'V', '1', '0'),
+    ME_FOURCC('R', 'V', '1', '0'),
     0
   },
   BUF_VIDEO_RV10,
@@ -542,7 +542,7 @@
 },
 {
   {
-    meFOURCC('R', 'V', '2', '0'),
+    ME_FOURCC('R', 'V', '2', '0'),
     0
   },
   BUF_VIDEO_RV20,
@@ -550,7 +550,7 @@
 },
 {
   {
-    meFOURCC('R', 'V', '3', '0'),
+    ME_FOURCC('R', 'V', '3', '0'),
     0
   },
   BUF_VIDEO_RV30,
@@ -558,7 +558,7 @@
 },
 {
   {
-    meFOURCC('R', 'V', '4', '0'),
+    ME_FOURCC('R', 'V', '4', '0'),
     0
   },
   BUF_VIDEO_RV40,
@@ -566,7 +566,7 @@
 },
 {
   {
-    meFOURCC('H', 'F', 'Y', 'U'),
+    ME_FOURCC('H', 'F', 'Y', 'U'),
     0,
   },
   BUF_VIDEO_HUFFYUV,
@@ -574,8 +574,8 @@
 },
 {
   {
-    meFOURCC('I', 'M', 'G', ' '),
-    meFOURCC('g', 'i', 'f', ' '),
+    ME_FOURCC('I', 'M', 'G', ' '),
+    ME_FOURCC('g', 'i', 'f', ' '),
     0,
   },
   BUF_VIDEO_IMAGE,
@@ -590,7 +590,7 @@
 },
 {
   {
-    meFOURCC('V','P','5','0'),
+    ME_FOURCC('V','P','5','0'),
     0
   },
   BUF_VIDEO_VP5,
@@ -598,9 +598,9 @@
 },
 {
   {
-    meFOURCC('V','P','6','0'),
-    meFOURCC('V','P','6','1'),
-    meFOURCC('V','P','6','2'),
+    ME_FOURCC('V','P','6','0'),
+    ME_FOURCC('V','P','6','1'),
+    ME_FOURCC('V','P','6','2'),
     0
   },
   BUF_VIDEO_VP6,
@@ -608,7 +608,15 @@
 },
 {
   {
-    meFOURCC('8','B', 'P','S'),
+    ME_FOURCC('V','P','6','F'),
+    0
+  },
+  BUF_VIDEO_VP6F,
+  "On2 VP6"
+},
+{
+  {
+    ME_FOURCC('8','B', 'P','S'),
     0
   },
   BUF_VIDEO_8BPS,
@@ -616,7 +624,7 @@
 },
 {
   {
-    meFOURCC('Z','L','I','B'),
+    ME_FOURCC('Z','L','I','B'),
     0
   },
   BUF_VIDEO_ZLIB,
@@ -624,7 +632,7 @@
 },
 {
   {
-    meFOURCC('M','S','Z','H'),
+    ME_FOURCC('M','S','Z','H'),
     0
   },
   BUF_VIDEO_MSZH,
@@ -632,7 +640,7 @@
 },
 {
   {
-    meFOURCC('A','S','V','1'),
+    ME_FOURCC('A','S','V','1'),
     0
   },
   BUF_VIDEO_ASV1,
@@ -640,7 +648,7 @@
 },
 {
   {
-    meFOURCC('A','S','V','2'),
+    ME_FOURCC('A','S','V','2'),
     0
   },
   BUF_VIDEO_ASV2,
@@ -648,9 +656,9 @@
 },
 {
   {
-    meFOURCC('a','v','c','1'),
-    meFOURCC('h','2','6','4'),
-    meFOURCC('H','2','6','4'),
+    ME_FOURCC('a','v','c','1'),
+    ME_FOURCC('h','2','6','4'),
+    ME_FOURCC('H','2','6','4'),
     0
   },
   BUF_VIDEO_H264,
@@ -658,7 +666,7 @@
 },
 {
   {
-    meFOURCC('A','A','S','C'),
+    ME_FOURCC('A','A','S','C'),
     0
   },
   BUF_VIDEO_AASC,
@@ -666,7 +674,7 @@
 },
 {
   {
-    meFOURCC('q','d','r','w'),
+    ME_FOURCC('q','d','r','w'),
     0
   },
   BUF_VIDEO_QDRW,
@@ -674,7 +682,7 @@
 },
 {
   {
-    meFOURCC('L','O','C','O'),
+    ME_FOURCC('L','O','C','O'),
     0
   },
   BUF_VIDEO_LOCO,
@@ -682,7 +690,7 @@
 },
 {
   {
-    meFOURCC('U','L','T','I'),
+    ME_FOURCC('U','L','T','I'),
     0
   },
   BUF_VIDEO_ULTI,
@@ -690,7 +698,7 @@
 },
 {
   {
-    meFOURCC('W','N','V','1'),
+    ME_FOURCC('W','N','V','1'),
     0
   },
   BUF_VIDEO_WNV1,
@@ -698,8 +706,8 @@
 },
 {
   {
-    meFOURCC('P','I','X','L'),
-    meFOURCC('X','I','X','L'),
+    ME_FOURCC('P','I','X','L'),
+    ME_FOURCC('X','I','X','L'),
     0
   },
   BUF_VIDEO_XL,
@@ -707,9 +715,9 @@
 },
 {
   {
-    meFOURCC('Q','P','E','G'),
-    meFOURCC('Q','1','.','0'),
-    meFOURCC('Q','1','.','1'),
+    ME_FOURCC('Q','P','E','G'),
+    ME_FOURCC('Q','1','.','0'),
+    ME_FOURCC('Q','1','.','1'),
     0
   },
   BUF_VIDEO_QPEG,
@@ -717,7 +725,7 @@
 },
 {
   {
-    meFOURCC('R','T','2','1'),
+    ME_FOURCC('R','T','2','1'),
     0
   },
   BUF_VIDEO_RT21,
@@ -725,7 +733,7 @@
 },
 {
   {
-    meFOURCC('F','P','S','1'),
+    ME_FOURCC('F','P','S','1'),
     0
   },
   BUF_VIDEO_FPS1,
@@ -733,7 +741,7 @@
 },
 {
   {
-    meFOURCC('T','M','2','0'),
+    ME_FOURCC('T','M','2','0'),
     0
   },
   BUF_VIDEO_DUCKTM2,
@@ -741,7 +749,7 @@
 },
 {
   {
-    meFOURCC('C','S','C','D'),
+    ME_FOURCC('C','S','C','D'),
     0
   },
   BUF_VIDEO_CSCD,
@@ -749,7 +757,7 @@
 },
 {
   {
-    meFOURCC('Z','M','B','V'),
+    ME_FOURCC('Z','M','B','V'),
     0
   },
   BUF_VIDEO_ZMBV,
@@ -757,7 +765,7 @@
 },
 {
   {
-    meFOURCC('K','M','V','C'),
+    ME_FOURCC('K','M','V','C'),
     0
   },
   BUF_VIDEO_KMVC,
@@ -771,7 +779,7 @@
 {
   {
     0x2000,
-    meFOURCC('m', 's', 0x20, 0x00),
+    ME_FOURCC('m', 's', 0x20, 0x00),
     0
   },
   BUF_AUDIO_A52,
@@ -780,9 +788,9 @@
 {
   {
     0x50, 0x55,
-    meFOURCC('.','m','p','3'),
-    meFOURCC('m', 's', 0, 0x55),
-    meFOURCC('M','P','3',' '),
+    ME_FOURCC('.','m','p','3'),
+    ME_FOURCC('m', 's', 0, 0x55),
+    ME_FOURCC('M','P','3',' '),
     0
   },
   BUF_AUDIO_MPEG,
@@ -790,8 +798,8 @@
 },
 {
   {
-    meFOURCC('t','w','o','s'),
-    meFOURCC('i','n','2','4'),
+    ME_FOURCC('t','w','o','s'),
+    ME_FOURCC('i','n','2','4'),
     0
   },
   BUF_AUDIO_LPCM_BE,
@@ -800,8 +808,8 @@
 {
   {
     0x01,
-    meFOURCC('r','a','w',' '),
-    meFOURCC('s','o','w','t'),
+    ME_FOURCC('r','a','w',' '),
+    ME_FOURCC('s','o','w','t'),
     0
   },
   BUF_AUDIO_LPCM_LE,
@@ -852,7 +860,7 @@
 {
   {
     0x02, 
-    meFOURCC('m', 's', 0, 0x02),
+    ME_FOURCC('m', 's', 0, 0x02),
     0
   },
   BUF_AUDIO_MSADPCM,
@@ -861,7 +869,7 @@
 {
   {
     0x11,
-    meFOURCC('m', 's', 0, 0x11),
+    ME_FOURCC('m', 's', 0, 0x11),
     0
   },
   BUF_AUDIO_MSIMAADPCM,
@@ -879,8 +887,8 @@
     /* these formattags are used by Vorbis ACM encoder and
        supported by NanDub, a variant of VirtualDub. */
     0x674f, 0x676f, 0x6750, 0x6770, 0x6751, 0x6771,
-    meFOURCC('O','g','g','S'),
-    meFOURCC('O','g','g','V'),
+    ME_FOURCC('O','g','g','S'),
+    ME_FOURCC('O','g','g','V'),
     0
   },
   BUF_AUDIO_VORBIS,
@@ -937,7 +945,7 @@
 },
 {
   {
-    meFOURCC('i', 'm', 'a', '4'),
+    ME_FOURCC('i', 'm', 'a', '4'),
     0
   },
   BUF_AUDIO_QTIMAADPCM,
@@ -945,8 +953,8 @@
 },
 {
   {
-    meFOURCC('m', 'a', 'c', '3'),
-    meFOURCC('M', 'A', 'C', '3'),
+    ME_FOURCC('m', 'a', 'c', '3'),
+    ME_FOURCC('M', 'A', 'C', '3'),
     0
   },
   BUF_AUDIO_MAC3,
@@ -954,8 +962,8 @@
 },
 {
   {
-    meFOURCC('m', 'a', 'c', '6'),
-    meFOURCC('M', 'A', 'C', '6'),
+    ME_FOURCC('m', 'a', 'c', '6'),
+    ME_FOURCC('M', 'A', 'C', '6'),
     0
   },
   BUF_AUDIO_MAC6,
@@ -963,7 +971,7 @@
 },
 {
   {
-    meFOURCC('Q', 'D', 'M', 'C'),
+    ME_FOURCC('Q', 'D', 'M', 'C'),
     0
   },
   BUF_AUDIO_QDESIGN1,
@@ -971,7 +979,7 @@
 },
 {
   {
-    meFOURCC('Q', 'D', 'M', '2'),
+    ME_FOURCC('Q', 'D', 'M', '2'),
     0
   },
   BUF_AUDIO_QDESIGN2,
@@ -980,11 +988,11 @@
 {
   {
     0xFF,
-    meFOURCC('m', 'p', '4', 'a'),
-    meFOURCC('M', 'P', '4', 'A'),
-    meFOURCC('r', 'a', 'a', 'c'),
-    meFOURCC('r', 'a', 'c', 'p'),
-    meFOURCC('A', 'A', 'C', ' '), 
+    ME_FOURCC('m', 'p', '4', 'a'),
+    ME_FOURCC('M', 'P', '4', 'A'),
+    ME_FOURCC('r', 'a', 'a', 'c'),
+    ME_FOURCC('r', 'a', 'c', 'p'),
+    ME_FOURCC('A', 'A', 'C', ' '), 
     0
   },
   BUF_AUDIO_AAC,
@@ -992,7 +1000,7 @@
 },
 {
   {
-    meFOURCC('d', 'n', 'e', 't'),
+    ME_FOURCC('d', 'n', 'e', 't'),
     0
   },
   BUF_AUDIO_DNET,
@@ -1000,7 +1008,7 @@
 },
 {
   {
-    meFOURCC('s', 'i', 'p', 'r'),
+    ME_FOURCC('s', 'i', 'p', 'r'),
     0
   },
   BUF_AUDIO_SIPRO,
@@ -1008,7 +1016,7 @@
 },
 {
   {
-    meFOURCC('c', 'o', 'o', 'k'),
+    ME_FOURCC('c', 'o', 'o', 'k'),
     0
   },
   BUF_AUDIO_COOK,
@@ -1016,7 +1024,7 @@
 },
 {
   {
-    meFOURCC('a', 't', 'r', 'c'),
+    ME_FOURCC('a', 't', 'r', 'c'),
     0
   },
   BUF_AUDIO_ATRK,
@@ -1024,7 +1032,7 @@
 },
 {
   {
-    meFOURCC('Q', 'c', 'l', 'p'),
+    ME_FOURCC('Q', 'c', 'l', 'p'),
     0
   },
   BUF_AUDIO_QCLP,
@@ -1033,7 +1041,7 @@
 {
   {
     0x7,
-    meFOURCC('u', 'l', 'a', 'w'),
+    ME_FOURCC('u', 'l', 'a', 'w'),
     0
   },
   BUF_AUDIO_MULAW,
@@ -1042,7 +1050,7 @@
 {
   {
     0x6,
-    meFOURCC('a', 'l', 'a', 'w'),
+    ME_FOURCC('a', 'l', 'a', 'w'),
     0
   },
   BUF_AUDIO_ALAW,
@@ -1050,7 +1058,7 @@
 },
 {
   {
-    meFOURCC('a', 'g', 's', 'm'),
+    ME_FOURCC('a', 'g', 's', 'm'),
     0
   },
   BUF_AUDIO_GSM610,
@@ -1072,7 +1080,7 @@
 },
 {
   {
-    meFOURCC('l', 'p', 'c', 'J'),
+    ME_FOURCC('l', 'p', 'c', 'J'),
     0
   },
   BUF_AUDIO_14_4,
@@ -1080,7 +1088,7 @@
 },
 {
   {
-    meFOURCC('2', '8', '_', '8'),
+    ME_FOURCC('2', '8', '_', '8'),
     0
   },
   BUF_AUDIO_28_8,
@@ -1095,7 +1103,7 @@
 },
 {
   {
-    meFOURCC('a', 'l', 'a', 'c'),
+    ME_FOURCC('a', 'l', 'a', 'c'),
   },
   BUF_AUDIO_ALAC,
   "Apple Lossless Audio Codec"
@@ -1220,3 +1228,4 @@
   wavex->wBitsPerSample = le2me_16(wavex->wBitsPerSample);
   wavex->cbSize = le2me_16(wavex->cbSize);
 }
+
