changeset 22228:55aeb86425cb

swap palette on big endian
author michael
date Sat, 17 Feb 2007 12:58:35 +0000
parents cec1eb5be9e4
children 44c3544fd926
files libmpcodecs/vf_scale.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_scale.c	Sat Feb 17 11:40:01 2007 +0000
+++ b/libmpcodecs/vf_scale.c	Sat Feb 17 12:58:35 2007 +0000
@@ -11,6 +11,7 @@
 #include "mp_image.h"
 #include "vf.h"
 #include "fmt-conversion.h"
+#include "bswap.h"
 
 #include "libvo/fastmemcpy.h"
 #include "libswscale/swscale.h"
@@ -323,9 +324,19 @@
 
 static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src[3], int src_stride[3], int y, int h, 
                   uint8_t *dst[3], int dst_stride[3], int interlaced){
+    uint8_t *src2[3]={src[0], src[1], src[2]};
+#ifdef WORDS_BIGENDIAN
+    uint32_t pal2[256];
+    if (src[1] && !src[2]){
+        int i;
+        for(i=0; i<256; i++)
+            pal2[i]= bswap_32(((uint32_t*)src[1])[i]);
+        src2[1]= pal2;
+    }
+#endif
+
     if(interlaced){
         int i;
-        uint8_t *src2[3]={src[0], src[1], src[2]};
         uint8_t *dst2[3]={dst[0], dst[1], dst[2]};
         int src_stride2[3]={2*src_stride[0], 2*src_stride[1], 2*src_stride[2]};
         int dst_stride2[3]={2*dst_stride[0], 2*dst_stride[1], 2*dst_stride[2]};
@@ -337,7 +348,7 @@
         }
         sws_scale_ordered(sws2, src2, src_stride2, y>>1, h>>1, dst2, dst_stride2);
     }else{
-        sws_scale_ordered(sws1, src, src_stride, y, h, dst, dst_stride);
+        sws_scale_ordered(sws1, src2, src_stride, y, h, dst, dst_stride);
     }                  
 }