gephex--main--0.4--patch-1811

[email protected]
Newsgroups gmane.comp.video.gephex.devel
Message-ID <[email protected]>
Archive: [email protected]
New revision: gephex--main--0.4--patch-1811

--
Revision: gephex--main--0.4--patch-1811
Archive: [email protected]
Creator: GePhex <[email protected]>
Date: Fri Oct 29 09:29:31 CEST 2004
Standard-date: 2004-10-29 07:29:31 GMT
Modified-files: build/gephex.dsw
    modules/src/chromakeymodule/chromakeymodule.c
    modules/src/chromakeymodule/chromakeymodule_x86.asm
    modules/src/gradnormmodule/roberts_cross_x86.asm
    modules/src/imgarithmodule/imgarithmodule_x86.asm
    modules/src/staticcolormodule/staticcolormodule_x86.asm
    modules/src/xfademodule/xfademodule_x86.asm
    modules/src/y4minmodule/y4minmodule.c
    modules/src/y4minmodule/y4minmodule.dep
    modules/src/y4minmodule/y4minmodule.mak
    modules/src/yuv4mpeg2module/Makefile.am
    modules/src/yuv4mpeg2module/y4moutputmodule.cpp
    modules/src/yuv4mpeg2module/y4moutputmodule.dep
    modules/src/yuv4mpeg2module/y4moutputmodule.dsp
    modules/src/yuv4mpeg2module/y4moutputmodule.mak
    modules/src/yuv4mpeg2module/y4moutputmodule.spec
New-patches: [email protected]/gephex--georg--0.4--patch-345
    [email protected]/gephex--georg--0.4--patch-346
    [email protected]/gephex--georg--0.4--patch-347
    [email protected]/gephex--main--0.4--patch-1811
Summary: added bgra8888 streaming to the y4m modules, fixed several bugs in external asm files, fixed bug in chromakeymodule
Keywords: 

Patches applied:

 * [email protected]/gephex--georg--0.4--patch-345
   Added bgra8888 support to yuv4mpeg output and input

 * [email protected]/gephex--georg--0.4--patch-346
   new libscale dependency for yuv4mpeg modules for vs6 build

 * [email protected]/gephex--georg--0.4--patch-347
   Fixed several bugs in external asm code: now all registers are saved (win2k for example requires edi and esi to be preserved, PIC on linux requires ebx to be preserved...). Fixed bug in chroma_key.

* added files

    {arch}/gephex/gephex--georg/gephex--georg--0.4/[email protected]/patch-log/patch-345
    {arch}/gephex/gephex--georg/gephex--georg--0.4/[email protected]/patch-log/patch-346
    {arch}/gephex/gephex--georg/gephex--georg--0.4/[email protected]/patch-log/patch-347
    {arch}/gephex/gephex--main/gephex--main--0.4/[email protected]/patch-log/patch-1811

* modified files

--- orig/build/gephex.dsw
+++ mod/build/gephex.dsw
@@ -1709,6 +1709,9 @@
     Begin Project Dependency
     Project_Dep_Name libcolorconv
     End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libscale
+    End Project Dependency
 }}}
 
 ###############################################################################
@@ -1724,6 +1727,9 @@
     Begin Project Dependency
     Project_Dep_Name libcolorconv
     End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libscale
+    End Project Dependency
 }}}
 
 ###############################################################################


--- orig/modules/src/chromakeymodule/chromakeymodule.c
+++ mod/modules/src/chromakeymodule/chromakeymodule.c
@@ -248,9 +248,6 @@
   MyInstancePtr my = inst->my;
 
   double tolerance = trim_double(inst->in_tolerance->number, 0, 1);
-  double r = trim_double(inst->in_color->r, 0, 1);
-  double g = trim_double(inst->in_color->g, 0, 1);
-  double b = trim_double(inst->in_color->b, 0, 1);
 
   uint_32* fg = 0;
   uint_32* bg = 0;
@@ -258,9 +255,17 @@
 
   int xsize = 0, ysize = 0;
 
+  double r;
+  double g;
+  double b;
+
   if (do_patch(tolerance))
     return;
 
+  r = trim_double(inst->in_color->r, 0, 1);
+  g = trim_double(inst->in_color->g, 0, 1);
+  b = trim_double(inst->in_color->b, 0, 1);
+
   if (strcmp(my->mode.text, inst->in_mode->text) != 0)
     {
       string_assign(&my->mode, inst->in_mode);


--- orig/modules/src/chromakeymodule/chromakeymodule_x86.asm
+++ mod/modules/src/chromakeymodule/chromakeymodule_x86.asm
@@ -15,7 +15,7 @@
         push    ebp
         mov     ebp, esp
         sub     esp, 0x10        ; 16 bytes of local stack space
-        push    ebx
+        pusha; push    ebx
 
 .rr	equ     8
 .gg	equ     12
@@ -128,7 +128,7 @@
 .end:
 	emms
 
-        pop     ebx
+        popa; pop     ebx
         leave                   ; mov esp,ebp / pop ebp
         ret
 
@@ -146,7 +146,7 @@
         push    ebp
         mov     ebp, esp
         sub     esp, 0x10        ; 64 bytes of local stack space
-        push    ebx
+        pusha ;push    ebx
 
 .rr	equ     8
 .gg	equ     12
@@ -251,7 +251,7 @@
 .end:    
 	femms
 
-        pop ebx
+        popa ; pop ebx
         leave                   ; mov esp,ebp / pop ebp
         ret
 


--- orig/modules/src/gradnormmodule/roberts_cross_x86.asm
+++ mod/modules/src/gradnormmodule/roberts_cross_x86.asm
@@ -14,7 +14,7 @@
         push    ebp
         mov     ebp, esp 
         sub     esp, 0x4        ; 4 bytes of local stack space
-        push    ebx
+        pusha; push    ebx
 
         
 xsize	equ     8
@@ -23,7 +23,7 @@
 dst     equ     20
 scale	equ	24
 
-yi      equ     4
+yi      equ     -4
                         
         mov     esi, [ebp + src]
         mov     edi, [ebp + dst]
@@ -111,7 +111,7 @@
 roberts_cross_e3dnow_yloop_done:
         
         femms
-        pop ebx
+        popa ;pop ebx
         leave                   ; mov esp,ebp / pop ebp 
         ret
 


--- orig/modules/src/imgarithmodule/imgarithmodule_x86.asm
+++ mod/modules/src/imgarithmodule/imgarithmodule_x86.asm
@@ -11,7 +11,7 @@
 	push	ebp 
 	mov	ebp,esp 
 	sub	esp,0x08	; 8 bytes of local stack space
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -108,7 +108,7 @@
 	;; TODO: process last pixel manually
 
 .quit:
-	pop	ebx
+	popa; pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret
 
@@ -124,7 +124,7 @@
 _invert_mmx: 
 	push	ebp 
 	mov	ebp,esp 
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -165,7 +165,7 @@
 
 	;; TODO: process last pixels manually
 	
-	pop	ebx
+	popa ;pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret
 
@@ -181,7 +181,7 @@
 _mulc_mmx: 
 	push	ebp 
 	mov	ebp,esp 
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -234,7 +234,7 @@
 
 	;; TODO: process last pixel manually
 	
-	pop	ebx
+	popa; pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret
 
@@ -250,7 +250,7 @@
 _subc_mmx: 
 	push	ebp 
 	mov	ebp,esp 
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -291,7 +291,7 @@
 .end:
 	;; TODO: process last pixel manually
 	
-	pop	ebx
+	popa; pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret
 
@@ -306,7 +306,7 @@
 _addc_mmx: 
 	push	ebp 
 	mov	ebp,esp 
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -347,7 +347,7 @@
 .end:
 	;; TODO: process last pixel manually
 	
-	pop	ebx
+	popa; pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret
 
@@ -362,7 +362,7 @@
 _add_mmx: 
 	push	ebp 
 	mov	ebp,esp 
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -411,7 +411,7 @@
 .end:
 	;; TODO: process last pixel manually
 	
-	pop	ebx
+	popa; pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret
 
@@ -426,7 +426,7 @@
 _sub_mmx: 
 	push	ebp 
 	mov	ebp,esp 
-	push	ebx
+	pusha; push	ebx
 
 .size	equ	8
 .fb1	equ	12
@@ -475,6 +475,6 @@
 .end:
 	;; TODO: process last pixel manually
 	
-	pop	ebx
+	popa; pop	ebx
 	leave			; mov esp,ebp / pop ebp 
 	ret


--- orig/modules/src/staticcolormodule/staticcolormodule_x86.asm
+++ mod/modules/src/staticcolormodule/staticcolormodule_x86.asm
@@ -10,7 +10,7 @@
 
         push    ebp
         mov     ebp, esp
-        push    ebx
+        pusha; push    ebx
 
 .dst	equ     8
 .size	equ     12
@@ -41,6 +41,6 @@
 .end:
         ;; TODO: restpixel bearbeiten
 
-        pop     ebx
+        popa; pop     ebx
         leave                   ; mov esp,ebp / pop ebp
         ret


--- orig/modules/src/xfademodule/xfademodule_x86.asm
+++ mod/modules/src/xfademodule/xfademodule_x86.asm
@@ -13,7 +13,7 @@
         push    ebp
         mov     ebp, esp
         sub     esp, 0x08        ; 8 bytes of local stack space
-        push    ebx
+        pusha   ;push    ebx
 
 .size	equ     8
 .fb1	equ     12
@@ -91,7 +91,7 @@
         ;; TODO: restpixel bearbeiten
         emms
 
-        pop     ebx
+        popa; pop     ebx
         leave                   ; mov esp,ebp / pop ebp
         ret
 
@@ -109,7 +109,7 @@
         push    ebp
         mov     ebp, esp
         sub     esp, 0x08        ; 8 bytes of local stack space
-        push    ebx
+	pusha                    ;push    ebx
 
 .size	equ     8
 .fb1	equ     12
@@ -190,6 +190,7 @@
         ;; TODO: restpixel bearbeiten
         femms
 
-        pop     ebx
-        leave                   ; mov esp,ebp / pop ebp
+        popa                    ; pop     ebx
+        leave                   ;mov esp,ebp / pop ebp
+
         ret


--- orig/modules/src/y4minmodule/y4minmodule.c
+++ mod/modules/src/y4minmodule/y4minmodule.c
@@ -55,8 +55,11 @@
 
 //---------------------------------------------------------------------
 
+typedef enum  {NONE, YUV420P, BGRA8888} color_model_t;
+
 struct stream_info
 {
+  color_model_t color_model;
   int width;
   int height;
   double fps;
@@ -66,7 +69,8 @@
 
 static void info_print(const struct stream_info* info)
 {
-  printf("WXH = %ix%i, fps = %f, I = %c, A = %f
",
+  printf("%s WXH = %ix%i, fps = %f, I = %c, A = %f
",
+         info->color_model == YUV420P ? "YUV420P" : "BGRA8888",
          info->width, info->height, info->fps, info->c, info->A);
 }
 
@@ -177,9 +181,18 @@
   FrameBufferType scaled_fb;
 } MyInstance, *MyInstancePtr;
 
-static int frame_size(int w, int h)
+static int get_frame_size(int w, int h, color_model_t cm)
 {
-  return (int) (w*h*1.5);
+  switch(cm)
+    {
+    case YUV420P:
+      return (w*h*6)/4;
+    case BGRA8888:
+      return w*h*4;
+    default:
+      assert(!"invalid color model in get_frame_size()");
+      return 0;
+    }
 }
 
 //---------------------------------------------------------------------
@@ -231,9 +244,12 @@
 
   my->info.width = my->info.height = 0;
 
+  my->info.color_model = NONE;
+
   my->status.stream_header_read = 0;
   my->status.frame_header_read = 0;
 
+
   framebuffer_initInstance(&my->scaled_fb);
 
   return my;
@@ -364,6 +380,7 @@
 static int scan_stream_header(const uint8_t* data, int len,
                               struct stream_info* info)
 {
+  color_model_t cm = YUV420P;
   int retval;
   int bytes_left = len;
   const uint8_t* ptr = data;
@@ -372,6 +389,11 @@
     return 0;
 
   retval = scan_const_string(ptr, bytes_left, "YUV4MPEG2");
+  if (retval == 0) 
+    {
+      retval = scan_const_string(ptr, bytes_left, "BGRA8888");
+      cm     = BGRA8888;
+    }
   if (retval == 0) return 0; else { bytes_left -= retval; ptr += retval; }
   
   retval = scan_const_string(ptr, bytes_left, " W");
@@ -401,6 +423,8 @@
   retval = scan_const_string(ptr, bytes_left, "
");
   if (retval == 0) return 0; else { bytes_left -= retval; ptr += retval; }
 
+  info->color_model = cm;
+
   info_print(info);
 
   assert(len - bytes_left == ptr - data);
@@ -454,7 +478,7 @@
       status->frame_header_read = 1;
     }
 
-  framesize = frame_size(info->width,info->height);
+  framesize = get_frame_size(info->width, info->height, info->color_model);
   if (bytes_left >= framesize)   // whole frame available
     {
       int need_scale;
@@ -489,8 +513,12 @@
           target = out->framebuffer;
         }
 
-      cvt_yuv420p_to_bgra((uint8_t*) target, ptr,
-                          info->width, info->height);
+      if (info->color_model == YUV420P)
+        cvt_yuv420p_to_bgra((uint8_t*) target, ptr,
+                            info->width, info->height);
+      else
+        memcpy(target, ptr, get_frame_size(info->width,info->height,
+                                           info->color_model));
 
       if (need_scale)
         {
@@ -542,6 +570,7 @@
       my->file_handle = open_file(new_filename);
       string_assign(&my->filename, inst->in_fname);
       my->info.width = my->info.height = 0;
+      my->info.color_model             = NONE;
       my->status.stream_header_read    = 0;
       my->status.frame_header_read     = 0;
       queue_flush(&my->queue);
@@ -586,10 +615,13 @@
     {
       // read all available data into the queue
       // has the width and height info already been read?
-      if (my->info.width == 0 || my->info.height == 0)
-        read_size = frame_size(320,240) + 40;
+      if (my->info.width == 0 || my->info.height == 0 ||
+          my->info.color_model == NONE)
+        read_size = get_frame_size(320,240, YUV420P) + 40;
       else
-        read_size = frame_size(my->info.width,my->info.height) + 6
+        read_size = get_frame_size(my->info.width,
+                                   my->info.height,
+                                   my->info.color_model) + 6
           - my->queue.buf_len;
 
       // make sure we have enough space in the queue


--- orig/modules/src/y4minmodule/y4minmodule.dep
+++ mod/modules/src/y4minmodule/y4minmodule.dep
@@ -2,8 +2,25 @@
 
 .\y4minmodule.c : \
 	"..\..\..onfig.h"\
+	"..\..\..\engine\src\engine\dllmodule.h"\
+	"..\..\..	ypes\srcramebuffertyperamebuffertype.h"\
+	"..\..\..	ypes\src
umbertype
umbertype.h"\
+	"..\..\..	ypes\src\stringtype\stringtype.h"\
 	"..\..\..\util\includeasic_types.h"\
 	"..\libcolorconv\libcolorconv.h"\
+	".\y4minmodule.h"\
+	
+
+.\y4minmodule_auto.c : \
+	"..\..\..onfig.h"\
+	"..\..\..\engine\src\engine\dllmodule.h"\
+	"..\..\..\engine\src\engine\dllutils.h"\
+	"..\..\..	ypes\srcramebuffertyperamebuffertype.h"\
+	"..\..\..	ypes\src
umbertype
umbertype.h"\
+	"..\..\..	ypes\src\stringtype\stringtype.h"\
+	"..\..\..\util\includeasic_types.h"\
+	".\y4minmodule.h"\
+	".\y4minmodule.xpm"\
 	
 
 !IF  "$(CFG)" == "y4minmodule - Win32 Release"


--- orig/modules/src/y4minmodule/y4minmodule.mak
+++ mod/modules/src/y4minmodule/y4minmodule.mak
@@ -43,12 +43,12 @@
 
 !ELSE 
 
-ALL : "libcolorconv - Win32 Release" "$(OUTDIR)\y4minmodule.dll"
+ALL : "libscale - Win32 Release" "libcolorconv - Win32 Release" "$(OUTDIR)\y4minmodule.dll"
 
 !ENDIF 
 
 !IF "$(RECURSE)" == "1" 
-CLEAN :"libcolorconv - Win32 ReleaseCLEAN" 
+CLEAN :"libcolorconv - Win32 ReleaseCLEAN" "libscale - Win32 ReleaseCLEAN" 
 !ELSE 
 CLEAN :
 !ENDIF 
@@ -75,7 +75,8 @@
 LINK32_OBJS= \
 	"$(INTDIR)\y4minmodule.obj" \
 	"$(INTDIR)\y4minmodule_auto.obj" \
-	"..\libcolorconv\Release\libcolorconv.lib"
+	"..\libcolorconv\Release\libcolorconv.lib" \
+	"..\libscale\Release\libscale.lib"
 
 "$(OUTDIR)\y4minmodule.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
     $(LINK32) @<<
@@ -93,7 +94,7 @@
 OutDir=.\Release
 # End Custom Macros
 
-$(DS_POSTBUILD_DEP) : "libcolorconv - Win32 Release" "$(OUTDIR)\y4minmodule.dll"
+$(DS_POSTBUILD_DEP) : "libscale - Win32 Release" "libcolorconv - Win32 Release" "$(OUTDIR)\y4minmodule.dll"
    copy .\Release\y4minmodule.dll ..\..\..\dlls\modules
 	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
 
@@ -111,12 +112,12 @@
 
 !ELSE 
 
-ALL : "libcolorconv - Win32 Debug" ".\y4minmodule_auto.c" ".\y4minmodule.h" ".\y4minmodule.def" "$(OUTDIR)\y4minmodule.dll"
+ALL : "libscale - Win32 Debug" "libcolorconv - Win32 Debug" ".\y4minmodule_auto.c" ".\y4minmodule.h" ".\y4minmodule.def" "$(OUTDIR)\y4minmodule.dll"
 
 !ENDIF 
 
 !IF "$(RECURSE)" == "1" 
-CLEAN :"libcolorconv - Win32 DebugCLEAN" 
+CLEAN :"libcolorconv - Win32 DebugCLEAN" "libscale - Win32 DebugCLEAN" 
 !ELSE 
 CLEAN :
 !ENDIF 
@@ -149,7 +150,8 @@
 LINK32_OBJS= \
 	"$(INTDIR)\y4minmodule.obj" \
 	"$(INTDIR)\y4minmodule_auto.obj" \
-	"..\libcolorconv\Debug\libcolorconv.lib"
+	"..\libcolorconv\Debug\libcolorconv.lib" \
+	"..\libscale\Debug\libscale.lib"
 
 "$(OUTDIR)\y4minmodule.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
     $(LINK32) @<<
@@ -167,7 +169,7 @@
 OutDir=.\Debug
 # End Custom Macros
 
-$(DS_POSTBUILD_DEP) : "libcolorconv - Win32 Debug" ".\y4minmodule_auto.c" ".\y4minmodule.h" ".\y4minmodule.def" "$(OUTDIR)\y4minmodule.dll"
+$(DS_POSTBUILD_DEP) : "libscale - Win32 Debug" "libcolorconv - Win32 Debug" ".\y4minmodule_auto.c" ".\y4minmodule.h" ".\y4minmodule.def" "$(OUTDIR)\y4minmodule.dll"
    copy .\Debug\y4minmodule.dll ..\..\..\dlls\modules
 	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
 
@@ -240,7 +242,7 @@
 
 SOURCE=.\y4minmodule_auto.c
 
-"$(INTDIR)\y4minmodule_auto.obj" : $(SOURCE) "$(INTDIR)"
+"$(INTDIR)\y4minmodule_auto.obj" : $(SOURCE) "$(INTDIR)" ".\y4minmodule.h"
 
 
 !IF  "$(CFG)" == "y4minmodule - Win32 Release"
@@ -269,6 +271,32 @@
 
 !ENDIF 
 
+!IF  "$(CFG)" == "y4minmodule - Win32 Release"
+
+"libscale - Win32 Release" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Release" 
+   cd "..\y4minmodule"
+
+"libscale - Win32 ReleaseCLEAN" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Release" RECURSE=1 CLEAN 
+   cd "..\y4minmodule"
+
+!ELSEIF  "$(CFG)" == "y4minmodule - Win32 Debug"
+
+"libscale - Win32 Debug" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Debug" 
+   cd "..\y4minmodule"
+
+"libscale - Win32 DebugCLEAN" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Debug" RECURSE=1 CLEAN 
+   cd "..\y4minmodule"
+
+!ENDIF 
+
 SOURCE=.\y4minmodule.spec
 
 !IF  "$(CFG)" == "y4minmodule - Win32 Release"


--- orig/modules/src/yuv4mpeg2module/Makefile.am
+++ mod/modules/src/yuv4mpeg2module/Makefile.am
@@ -21,7 +21,7 @@
 			       @builddir@/../libcolorconv/libcolorconv.a
 
 
-y4moutputmodule_la_LDFLAGS = -module -avoid-version -no-undefined -L@builddir@/../libscale -L@builddir@/../libcolorconv  @builddir@/../libcolorconv/libcolorconv.a
+y4moutputmodule_la_LDFLAGS = -module -avoid-version -no-undefined -L@builddir@/../libscale -L@builddir@/../libcolorconv  @builddir@/../libcolorconv/libcolorconv.a @builddir@/../libscale/libscale.a
 
 INCLUDES = -I@srcdir@/../../../engine/src/engine \
            -I@srcdir@/../../../util/include \


--- orig/modules/src/yuv4mpeg2module/y4moutputmodule.cpp
+++ mod/modules/src/yuv4mpeg2module/y4moutputmodule.cpp
@@ -31,6 +31,7 @@
 #include <stdexcept>
 
 #include "libcolorconv.h"
+#include "libscale.h"
 
 static logT s_log;
 
@@ -44,10 +45,13 @@
 //#define write _write
 #endif
 
+enum color_model_t {NONE, YUV420P, BGRA8888};
+
+
 struct stream_dsc
 {
   stream_dsc()
-    : fd(0)
+    : color_model(NONE), fd(0)
   {
     scaledFb=framebuffer_newInstance();
   }
@@ -60,6 +64,7 @@
   }
 
   std::string filename;
+  color_model_t color_model;
   int fd;
   size_t x_res;
   size_t y_res;
@@ -109,6 +114,20 @@
   delete my;
 }
 
+static int get_frame_size(int w, int h, color_model_t cm)
+{
+  switch(cm)
+    {
+    case YUV420P:
+      return (w*h*6)/4;
+    case BGRA8888:
+      return w*h*4;
+    default:
+      assert(!"invalid color model in get_frame_size()");
+      return 0;
+    }
+}
+
 void update(void* instance)
 {
   InstancePtr inst = (InstancePtr) instance;
@@ -121,6 +140,22 @@
     }
 
   std::string filename(inst->in_filename->text);
+  std::string color_model_s(inst->in_color_model->text);
+  color_model_t color_model;
+
+  if (color_model_s == "yuv420p")
+    color_model = YUV420P;
+  else if (color_model_s == "bgra8888")
+    color_model = BGRA8888;
+  else
+    {
+      std::ostringstream os;
+      os << "Unknown colormodel '" << color_model_s << "', using 'yuv420p'";
+      s_log(1, os.str().c_str());
+
+      color_model = YUV420P;
+    }
+
   std::map<std::string,stream_dsc*>::iterator it;
   it=stream_registry.find(filename);
   if (it == stream_registry.end())
@@ -145,7 +180,8 @@
   if (stream.fd == 0 || 
       filename != stream.filename ||
       xsize != stream.x_res || 
-      ysize != stream.y_res)
+      ysize != stream.y_res ||
+      color_model != stream.color_model)
     {
       if (stream.fd != 0)
 	{
@@ -160,13 +196,14 @@
 	}
       
       // new stream
-      stream.x_res=xsize;
-      stream.y_res=ysize;
-      stream.filename=filename;
+      stream.x_res       = xsize;
+      stream.y_res       = ysize;
+      stream.filename    = filename;
+      stream.color_model = color_model;
       
       // open new file
       
-      stream.fd= open(filename.c_str(),O_WRONLY|O_CREAT|O_TRUNC,00666);
+      stream.fd = open(filename.c_str(),O_WRONLY|O_CREAT|O_TRUNC,00666);
       if (stream.fd == -1)
 	{
 	  stream.fd = 0;
@@ -174,7 +211,14 @@
 	}
       
       std::ostringstream stream_header_str;
-      stream_header_str << "YUV4MPEG2 ";
+
+      switch(stream.color_model)
+        {
+        case YUV420P:  stream_header_str << "YUV4MPEG2 "; break;
+        case BGRA8888: stream_header_str << "BGRA8888 "; break;
+        default: assert(!"invalid color model");
+        }
+
       stream_header_str << "W" << stream.x_res << " ";
       stream_header_str << "H" << stream.y_res << " ";
       stream_header_str << "F25:1 Ip A0:0
";
@@ -186,8 +230,10 @@
       stream.frame_header_size=frame_header.length();
       
       stream.yuv_buf.resize(stream.stream_header_size +
-			stream.frame_header_size + 
-			(stream.x_res*stream.y_res*6)/4);
+                            stream.frame_header_size + 
+                            get_frame_size(stream.x_res,
+                                           stream.y_res,
+                                           stream.color_model));
       
       // stream_header
       std::copy(stream_header.begin(),
@@ -203,38 +249,49 @@
       stream.wrote_header=false;
     }
 
-  // the framebuffer
-  uint32_t* fb;
+  uint8_t* buf = &stream.yuv_buf[stream.stream_header_size +
+    stream.frame_header_size];
 
-  if (inst->in_in->xsize != stream.x_res || inst->in_in->ysize != stream.y_res)
+  if (stream.color_model == YUV420P)
     {
-      FrameBufferAttributes  in_attr;
-      framebuffer_getAttributes(inst->in_in, &in_attr);
-      in_attr.xsize=stream.x_res;
-      in_attr.ysize=stream.y_res;
-      framebuffer_convertType(stream.scaledFb, inst->in_in , &in_attr);
-      
-      // use the scaled one
-      fb=stream.scaledFb->framebuffer;
+      // the framebuffer
+      uint32_t* fb;
+
+      if (inst->in_in->xsize != stream.x_res ||
+          inst->in_in->ysize != stream.y_res)
+        {
+          FrameBufferAttributes  in_attr;
+          framebuffer_getAttributes(inst->in_in, &in_attr);
+          in_attr.xsize=stream.x_res;
+          in_attr.ysize=stream.y_res;
+          framebuffer_convertType(stream.scaledFb, inst->in_in , &in_attr);
+      
+          // use the scaled one
+          fb = stream.scaledFb->framebuffer;
+        }
+      else
+        {
+          // use the original
+          fb = inst->in_in->framebuffer;
+        }
+
+      // convert
+      int pitches[3] ={stream.x_res, stream.x_res/2, stream.x_res/2 };
+      int offsets[3] ={0, stream.x_res*stream.y_res,
+                       5*(stream.x_res*stream.y_res)/4};
+
+      cvt_rgb32_to_i420(buf, fb,
+                        stream.x_res, stream.y_res,
+                        pitches, offsets);
     }
-  else
+  else if (stream.color_model == BGRA8888)
     {
-      // use the original
-      fb=inst->in_in->framebuffer;
+      ls_scale32((uint32_t*) buf, stream.x_res, stream.y_res,
+                 inst->in_in->framebuffer,
+                 inst->in_in->xsize,
+                 inst->in_in->ysize);
     }
 
-  // convert
-  {
-    int pitches[3] ={ stream.x_res, stream.x_res/2, stream.x_res/2 };
-    int offsets[3] ={0, stream.x_res*stream.y_res, 5*(stream.x_res*stream.y_res)/4};
-
-    cvt_rgb32_to_i420(&stream.yuv_buf[stream.stream_header_size +stream.frame_header_size],
-		      fb,
-		      stream.x_res, stream.y_res,
-		      pitches, offsets);
-    
-  }
-
   // and write  
   {
     uint8_t* start;


--- orig/modules/src/yuv4mpeg2module/y4moutputmodule.dep
+++ mod/modules/src/yuv4mpeg2module/y4moutputmodule.dep
@@ -8,6 +8,8 @@
 	"..\..\..	ypes\src\stringtype\stringtype.h"\
 	"..\..\..\util\includeasic_types.h"\
 	"..\libcolorconv\libcolorconv.h"\
+	"..\libscale\libscale.h"\
+	".\y4moutputmodule.h"\
 	
 
 .\y4moutputmodule_auto.c : \
@@ -18,6 +20,7 @@
 	"..\..\..	ypes\src
umbertype
umbertype.h"\
 	"..\..\..	ypes\src\stringtype\stringtype.h"\
 	"..\..\..\util\includeasic_types.h"\
+	".\y4moutputmodule.h"\
 	".\y4moutputmodule.xpm"\
 	
 


--- orig/modules/src/yuv4mpeg2module/y4moutputmodule.dsp
+++ mod/modules/src/yuv4mpeg2module/y4moutputmodule.dsp
@@ -43,7 +43,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /Ob2 /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "NDEBUG" /D "HAVE_CONFIG_H" /YX /FD /c
+# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /Ob2 /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /I "../libscale" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "NDEBUG" /D "HAVE_CONFIG_H" /YX /FD /c
 # SUBTRACT CPP /X
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -76,7 +76,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /G6 /MDd /W2 /Gm /GX /ZI /Od /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "_DEBUG" /D "HAVE_CONFIG_H" /YX /FD /GZ /c
+# ADD CPP /nologo /G6 /MDd /W2 /Gm /GX /ZI /Od /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /I "../libscale" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "_DEBUG" /D "HAVE_CONFIG_H" /YX /FD /GZ /c
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x407 /d "_DEBUG"


--- orig/modules/src/yuv4mpeg2module/y4moutputmodule.mak
+++ mod/modules/src/yuv4mpeg2module/y4moutputmodule.mak
@@ -43,12 +43,12 @@
 
 !ELSE 
 
-ALL : "libcolorconv - Win32 Release" "$(OUTDIR)\y4moutputmodule.dll"
+ALL : "libscale - Win32 Release" "libcolorconv - Win32 Release" "$(OUTDIR)\y4moutputmodule.dll"
 
 !ENDIF 
 
 !IF "$(RECURSE)" == "1" 
-CLEAN :"libcolorconv - Win32 ReleaseCLEAN" 
+CLEAN :"libcolorconv - Win32 ReleaseCLEAN" "libscale - Win32 ReleaseCLEAN" 
 !ELSE 
 CLEAN :
 !ENDIF 
@@ -62,7 +62,7 @@
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
-CPP_PROJ=/nologo /G6 /MD /W3 /GX /O2 /Ob2 /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "NDEBUG" /D "HAVE_CONFIG_H" /Fp"$(INTDIR)\y4moutputmodule.pch" /YX /Fo"$(INTDIR)\" /Fd"$(INTDIR)\" /FD /c 
+CPP_PROJ=/nologo /G6 /MD /W3 /GX /O2 /Ob2 /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /I "../libscale" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "NDEBUG" /D "HAVE_CONFIG_H" /Fp"$(INTDIR)\y4moutputmodule.pch" /YX /Fo"$(INTDIR)\" /Fd"$(INTDIR)\" /FD /c 
 MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
 BSC32=bscmake.exe
 BSC32_FLAGS=/nologo /o"$(OUTDIR)\y4moutputmodule.bsc" 
@@ -75,7 +75,8 @@
 LINK32_OBJS= \
 	"$(INTDIR)\y4moutputmodule.obj" \
 	"$(INTDIR)\y4moutputmodule_auto.obj" \
-	"..\libcolorconv\Release\libcolorconv.lib"
+	"..\libcolorconv\Release\libcolorconv.lib" \
+	"..\libscale\Release\libscale.lib"
 
 "$(OUTDIR)\y4moutputmodule.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
     $(LINK32) @<<
@@ -93,7 +94,7 @@
 OutDir=.\Release
 # End Custom Macros
 
-$(DS_POSTBUILD_DEP) : "libcolorconv - Win32 Release" "$(OUTDIR)\y4moutputmodule.dll"
+$(DS_POSTBUILD_DEP) : "libscale - Win32 Release" "libcolorconv - Win32 Release" "$(OUTDIR)\y4moutputmodule.dll"
    copy .\Release\y4moutputmodule.dll ..\..\..\dlls\modules
 	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
 
@@ -111,12 +112,12 @@
 
 !ELSE 
 
-ALL : "libcolorconv - Win32 Debug" ".\y4moutputmodule_auto.c" ".\y4moutputmodule.h" ".\y4moutputmodule.def" "$(OUTDIR)\y4moutputmodule.dll"
+ALL : "libscale - Win32 Debug" "libcolorconv - Win32 Debug" ".\y4moutputmodule_auto.c" ".\y4moutputmodule.h" ".\y4moutputmodule.def" "$(OUTDIR)\y4moutputmodule.dll"
 
 !ENDIF 
 
 !IF "$(RECURSE)" == "1" 
-CLEAN :"libcolorconv - Win32 DebugCLEAN" 
+CLEAN :"libcolorconv - Win32 DebugCLEAN" "libscale - Win32 DebugCLEAN" 
 !ELSE 
 CLEAN :
 !ENDIF 
@@ -136,7 +137,7 @@
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
-CPP_PROJ=/nologo /G6 /MDd /W2 /Gm /GX /ZI /Od /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "_DEBUG" /D "HAVE_CONFIG_H" /Fp"$(INTDIR)\y4moutputmodule.pch" /YX /Fo"$(INTDIR)\" /Fd"$(INTDIR)\" /FD /GZ /c 
+CPP_PROJ=/nologo /G6 /MDd /W2 /Gm /GX /ZI /Od /I "../../../types/src/stringtype" /I "../../../types/src/framebuffertype" /I "../../../types/src/numbertype" /I "../../../" /I "../../../engine/src/engine" /I "../../../util/include" /I "../libcolorconv" /I "../libscale" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "y4moutputmodule_EXPORTS" /D "WIN32" /D "_DEBUG" /D "HAVE_CONFIG_H" /Fp"$(INTDIR)\y4moutputmodule.pch" /YX /Fo"$(INTDIR)\" /Fd"$(INTDIR)\" /FD /GZ /c 
 MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
 BSC32=bscmake.exe
 BSC32_FLAGS=/nologo /o"$(OUTDIR)\y4moutputmodule.bsc" 
@@ -149,7 +150,8 @@
 LINK32_OBJS= \
 	"$(INTDIR)\y4moutputmodule.obj" \
 	"$(INTDIR)\y4moutputmodule_auto.obj" \
-	"..\libcolorconv\Debug\libcolorconv.lib"
+	"..\libcolorconv\Debug\libcolorconv.lib" \
+	"..\libscale\Debug\libscale.lib"
 
 "$(OUTDIR)\y4moutputmodule.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
     $(LINK32) @<<
@@ -167,7 +169,7 @@
 OutDir=.\Debug
 # End Custom Macros
 
-$(DS_POSTBUILD_DEP) : "libcolorconv - Win32 Debug" ".\y4moutputmodule_auto.c" ".\y4moutputmodule.h" ".\y4moutputmodule.def" "$(OUTDIR)\y4moutputmodule.dll"
+$(DS_POSTBUILD_DEP) : "libscale - Win32 Debug" "libcolorconv - Win32 Debug" ".\y4moutputmodule_auto.c" ".\y4moutputmodule.h" ".\y4moutputmodule.def" "$(OUTDIR)\y4moutputmodule.dll"
    copy .\Debug\y4moutputmodule.dll ..\..\..\dlls\modules
 	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
 
@@ -250,6 +252,32 @@
 
 !ENDIF 
 
+!IF  "$(CFG)" == "y4moutputmodule - Win32 Release"
+
+"libscale - Win32 Release" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Release" 
+   cd "..\yuv4mpeg2module"
+
+"libscale - Win32 ReleaseCLEAN" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Release" RECURSE=1 CLEAN 
+   cd "..\yuv4mpeg2module"
+
+!ELSEIF  "$(CFG)" == "y4moutputmodule - Win32 Debug"
+
+"libscale - Win32 Debug" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Debug" 
+   cd "..\yuv4mpeg2module"
+
+"libscale - Win32 DebugCLEAN" : 
+   cd "ode\gephex-0.4\modules\src\libscale"
+   $(MAKE) /$(MAKEFLAGS) /F ".\libscale.mak" CFG="libscale - Win32 Debug" RECURSE=1 CLEAN 
+   cd "..\yuv4mpeg2module"
+
+!ENDIF 
+
 SOURCE=.\y4moutputmodule.spec
 
 !IF  "$(CFG)" == "y4moutputmodule - Win32 Release"


--- orig/modules/src/yuv4mpeg2module/y4moutputmodule.spec
+++ mod/modules/src/yuv4mpeg2module/y4moutputmodule.spec
@@ -27,7 +27,7 @@
         const             = true
         strong_dependency = true
         hidden            = false
-    }    
+    }
 
     xsize
     {
@@ -62,6 +62,18 @@
         precision         = 0
     }
 
+    color_model
+    {
+        name              = ColorModel
+        type              = typ_StringType
+        const             = true
+        strong_dependency = true
+        hidden            = false
+        default           = yuv420p
+        widget_type       = combo_box
+        values            = yuv420p,bgra8888
+    }
+
 }
 
 outputs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.