From f92c0d7f58f95211eb78f9fdae6c0cd2307fd126 Mon Sep 17 00:00:00 2001
From: Albrecht Lohoefener <lohoefat@iis.fraunhofer.de>
Date: Mon, 14 Dec 2009 14:03:53 +0100
Subject: [PATCH] 	modified:   modules/video_output/vmem.c

---
 modules/video_output/vmem.c |   66 +-
 mode change 100644 => 100755 modules/video_output/vmem.c

diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
old mode 100644
new mode 100755
index a63be9b..51ee58c
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -52,6 +52,10 @@
 #define LT_CHROMA N_("Output chroma for the memory image as a 4-character " \
                       "string, eg. \"RV32\".")
 
+#define T_ENDIANESS N_( "Endianess" )
+#define LT_ENDIANESS N_( "Set the endianess of the output." \
+			  "0 Little Endian (default), 1 Big Endian" )
+
 #define T_LOCK N_("Lock function")
 #define LT_LOCK N_("Address of the locking callback function. This " \
                     "function must fill in valid plane memory address " \
@@ -77,6 +81,7 @@ vlc_module_begin()
     add_integer("vmem-width", 320, NULL, T_WIDTH, LT_WIDTH, false)
     add_integer("vmem-height", 200, NULL, T_HEIGHT, LT_HEIGHT, false)
     add_integer("vmem-pitch", 640, NULL, T_PITCH, LT_PITCH, false)
+	add_integer("vmem-endianess", 0, NULL, T_ENDIANESS, LT_ENDIANESS, false )
     add_string("vmem-chroma", "RV16", NULL, T_CHROMA, LT_CHROMA, true)
     add_string("vmem-lock", "0", NULL, T_LOCK, LT_LOCK, true)
     add_string("vmem-unlock", "0", NULL, T_UNLOCK, LT_UNLOCK, true)
@@ -118,6 +123,7 @@ static int Open(vlc_object_t *object)
     /* */
     char *chroma_format = var_CreateGetString(vd, "vmem-chroma");
     const vlc_fourcc_t chroma = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma_format);
+	int i_endianess = var_CreateGetInteger(vd, "vmem-endianess");
     free(chroma_format);
     if (!chroma) {
         msg_Err(vd, "vmem-chroma should be 4 characters long");
@@ -157,24 +163,60 @@ static int Open(vlc_object_t *object)
     switch (chroma)
     {
     case VLC_CODEC_RGB15:
-        fmt.i_rmask = 0x001f;
-        fmt.i_gmask = 0x03e0;
-        fmt.i_bmask = 0x7c00;
+        if(i_endianess)
+		{
+			fmt.i_rmask = 0xfc00;
+			fmt.i_gmask = 0x03e0;
+			fmt.i_bmask = 0x001f;
+		}
+		else
+		{
+			fmt.i_rmask = 0x001f;
+			fmt.i_gmask = 0x03e0;
+			fmt.i_bmask = 0x7c00;		
+		}
         break;
     case VLC_CODEC_RGB16:
-        fmt.i_rmask = 0x001f;
-        fmt.i_gmask = 0x07e0;
-        fmt.i_bmask = 0xf800;
+        if(i_endianess)
+		{
+			fmt.i_rmask = 0xf800;
+			fmt.i_gmask = 0x07e0;
+			fmt.i_bmask = 0x001f;
+		}
+		else
+		{
+			fmt.i_rmask = 0x001f;
+			fmt.i_gmask = 0x07e0;
+			fmt.i_bmask = 0xf800;		
+		}
         break;
     case VLC_CODEC_RGB24:
-        fmt.i_rmask = 0xff0000;
-        fmt.i_gmask = 0x00ff00;
-        fmt.i_bmask = 0x0000ff;
+        if(i_endianess)
+		{
+			fmt.i_rmask = 0x000000ff;
+			fmt.i_gmask = 0x0000ff00;
+			fmt.i_bmask = 0x00ff0000;
+		}
+		else
+		{
+			fmt.i_rmask = 0xff0000;
+			fmt.i_gmask = 0x00ff00;
+			fmt.i_bmask = 0x0000ff;
+		}
         break;
     case VLC_CODEC_RGB32:
-        fmt.i_rmask = 0xff0000;
-        fmt.i_gmask = 0x00ff00;
-        fmt.i_bmask = 0x0000ff;
+        if(i_endianess)
+		{
+			fmt.i_rmask = 0x000000ff;
+			fmt.i_gmask = 0x0000ff00;
+			fmt.i_bmask = 0x00ff0000;
+		}
+		else
+		{
+			fmt.i_rmask = 0xff0000;
+			fmt.i_gmask = 0x00ff00;
+			fmt.i_bmask = 0x0000ff;
+		}
         break;
     default:
         fmt.i_rmask = 0;

--
1.6.3.3

