]> git.sesse.net Git - vlc/commitdiff
Bon, puisque �a semble commiter sous BeOS, je commite.
authorSam Hocevar <sam@videolan.org>
Tue, 4 Jul 2000 02:37:21 +0000 (02:37 +0000)
committerSam Hocevar <sam@videolan.org>
Tue, 4 Jul 2000 02:37:21 +0000 (02:37 +0000)
Voil� le changelog appoximatif :

 . fichier INSTALL plus clair
 . vir� quelques warnings
 . *PATH sont maintenant d�finis dans config.h
 . quelques fautes d'orthographe
 . l'option --enable-ppro n'est pas mise par d�faut car elle ne fonctionne
  pas sur un K6-2
 . nouvelle API des plugins
 . le client framebuffer ne d�truit plus la console quand on quitte
 . r�paration de la YUV 8 bits
 . mise des YUV en plugins
 . transfo YUV 32bits MMX chour�e dans la libmpeg2

90 files changed:
ChangeLog
INSTALL
Makefile.dep
Makefile.in
README
configure
configure.in
debian/changelog
include/ac3_decoder.h
include/ac3_decoder_thread.h
include/audio_decoder.h
include/audio_decoder_thread.h
include/audio_output.h
include/beos_specific.h
include/common.h
include/config.h.in
include/decoder_fifo.h
include/interface.h
include/main.h
include/playlist.h [new file with mode: 0644]
include/plugins.h
include/plugins_export.h [new file with mode: 0644]
include/spu_decoder.h
include/video_decoder.h
include/video_output.h
include/vpar_synchro.h
plugins/beos/beos.cpp [new file with mode: 0644]
plugins/dsp/dsp.c [new file with mode: 0644]
plugins/dummy/dummy.c [new file with mode: 0644]
plugins/dummy/vout_dummy.c
plugins/esd/esd.c [new file with mode: 0644]
plugins/fb/fb.c [new file with mode: 0644]
plugins/fb/intf_fb.c
plugins/fb/vout_fb.c
plugins/ggi/ggi.c [new file with mode: 0644]
plugins/ggi/intf_ggi.c
plugins/ggi/vout_ggi.c
plugins/glide/glide.c [new file with mode: 0644]
plugins/gnome/gnome.c [new file with mode: 0644]
plugins/gnome/vout_gnome.c
plugins/mga/mga.c [new file with mode: 0644]
plugins/mga/vout_mga.c
plugins/x11/vout_x11.c
plugins/x11/x11.c [new file with mode: 0644]
plugins/yuv/video_yuv.c [new file with mode: 0644]
plugins/yuv/video_yuv.h [new file with mode: 0644]
plugins/yuv/video_yuv15.c [new file with mode: 0644]
plugins/yuv/video_yuv16.c [new file with mode: 0644]
plugins/yuv/video_yuv24.c [new file with mode: 0644]
plugins/yuv/video_yuv32.c [new file with mode: 0644]
plugins/yuv/video_yuv8.c [new file with mode: 0644]
plugins/yuv/video_yuv_macros.h [new file with mode: 0644]
plugins/yuv/video_yuv_macros_8bpp.h [new file with mode: 0644]
plugins/yuv/yuv.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv.h [new file with mode: 0644]
plugins/yuvmmx/video_yuv15.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv16.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv24.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv32.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv8.c [new file with mode: 0644]
plugins/yuvmmx/video_yuv_asm.h [new file with mode: 0644]
plugins/yuvmmx/video_yuv_macros.h [new file with mode: 0644]
plugins/yuvmmx/yuvmmx.c [new file with mode: 0644]
src/ac3_decoder/ac3_decoder_thread.c
src/ac3_decoder/ac3_mantissa.c
src/audio_output/audio_output.c
src/input/input.c
src/input/input_ctrl.c
src/input/input_file.c
src/input/input_network.c
src/input/input_psi.c
src/input/input_vlan.c
src/interface/interface.c
src/interface/intf_cmd.c
src/interface/intf_ctrl.c
src/interface/main.c
src/misc/beos_specific.cpp
src/misc/playlist.c [new file with mode: 0644]
src/misc/plugins.c
src/spu_decoder/spu_decoder.c
src/video_decoder/vdec_motion.c
src/video_decoder/vdec_motion_inner.c
src/video_output/video_output.c
src/video_output/video_text.c
src/video_output/video_yuv.c
src/video_output/video_yuv.h
src/video_parser/video_parser.c
src/video_parser/vpar_synchro.c
vlc.spec

index bec708be96bcf70cb6e5421a4a30ad069d59f709..2cef8316995feefd2fc08f1db263d6d628f152a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,30 @@
-Tue Jun 20 14:17:56 CEST 2000
+[insert date here]
 0.1.99d :
 
   * fixed RPM build
   * .deb is now more lintian-friendly
+  * fixed vlc.spec to install nicely
+  * PLUGIN_PATH and DATA_PATH now in include/*.h
+  * removed a few useless warning messages
+  * removed remaining header stuff related to the old non-free decoder
+  * fixed the MGA build (doesn't work yet, though)
+  * new plugin API
+  * updated the INSTALL document
+  * plugin auto-detection
+  * fixed a few misspellings in the code
+  * removed the default --enable-ppro option because it didn't work on K6-2
+  * the framebuffer client now leaves the console in a working state
+  * the dithered 8 bpp YUV transformation works again (blame bbp !)
+  * the YUV transformations are now plugins as well
+  * alternative symlinks like gvlc, fbvlc are now created at compile time
+  * borrowed libmpeg2's GPLed MMX YUV transformations (16 and 32 bits)
 
 Sun Jun 18 18:54:48 CEST 2000
 0.1.99c :
 
   * fixed Makefile.in for debug version
   * caught Delete Window event in Gnome and X11 modes
-  * fixed manpage
+  * fixed man page
   * GGI output now works
   * fixed a segfault on exit for the Gnome plugin
   * fixed compile problems for BeOS
@@ -24,3 +39,8 @@ Sat Jun 17 03:35:02 CEST 2000
   * new VLAN changing code
   * created the ChangeLog file :)
 
+Thu Jun 15 20:48:54 CEST 2000
+0.1.99a :
+
+  * first public release
+
diff --git a/INSTALL b/INSTALL
index ab1379a84919e31fe6d04a2e56229f6f25ee535a..678730e22a6cc2bdf89cca276aca5a107145f5eb 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -6,7 +6,7 @@ Building VideoLAN
 
 A typical way to configure the vlc is :
 
-   ./configure --prefix=/usr --enable-ppro --enable-mmx --enable-gnome
+   ./configure --prefix=/usr --enable-mmx --enable-gnome
 
 See `./configure --help' for more information.
 
index dbe2c3184e1128ead55cbc516d0e3e3d0244efed..6677e2f97a0be0dd1d6ea1a2dff619c8e25b88fd 100644 (file)
@@ -14,8 +14,8 @@
 ################################################################################
 
 default:
-       @echo "This Makefile should not be called directly - see notes at end of"
-       @echo "main Makefile."
+       @echo "This Makefile should not be called directly,"
+       @echo "see notes at end of main Makefile."
 
 ################################################################################
 # Dependancies creation
@@ -30,6 +30,7 @@ $(dependancies): .dep/%.d: %.c
        @test -d .dep/$(dir $*) || mkdir -p .dep/$(dir $*)
        #@echo "generating dependancies for $*.c"
        @$(SHELL) -ec '$(CC) $(DCFLAGS) $(CFLAGS) $(DEFINE) $< \
-               | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
-               .dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
-               [ -s $@ ] || rm -f $@'
+       | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
+       .dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
+       [ -s $@ ] || rm -f $@'
+
index 7e7ef54f9f06271602dcf0a6ad3868975d4b5d46..ce809732feed74bb62281670f25131100653bc4d 100644 (file)
@@ -41,8 +41,6 @@ PROGRAM_BUILD = `date` $(USER)
 # DEFINE will contain some of the constants definitions decided in Makefile, 
 # including SYS_xx. It will be passed to C compiler.
 DEFINE += -DSYS_$(shell echo $(SYS) | sed 's/-.*//' | tr a-z A-Z)
-DEFINE += -DPLUGIN_PATH="\"$(prefix)/lib/videolan/vlc\""
-DEFINE += -DDATA_PATH="\"$(prefix)/share/videolan/vlc\""
 
 ################################################################################
 # Tuning and other variables - do not change anything except if you know
@@ -211,6 +209,7 @@ video_decoder_obj =         video_decoder/video_decoder.o \
 misc_obj =                     misc/mtime.o \
                                                misc/rsc_files.o \
                                                misc/netutils.o \
+                                               misc/playlist.o \
                                                misc/plugins.o \
                                                misc/decoder_fifo.o
 
@@ -248,42 +247,68 @@ endif
 #
 PLUGINS := $(PLUGINS:%=lib/%.so)
 
-PLUGIN_BEOS   = plugins/beos/aout_beos.o \
+PLUGIN_BEOS   = plugins/beos/beos.o \
+               plugins/beos/aout_beos.o \
                plugins/beos/intf_beos.o \
                plugins/beos/vout_beos.o
 
-PLUGIN_DSP    = plugins/dsp/aout_dsp.o
+PLUGIN_DSP    = plugins/dsp/dsp.o \
+               plugins/dsp/aout_dsp.o \
 
-PLUGIN_DUMMY  = plugins/dummy/aout_dummy.o \
+PLUGIN_DUMMY  = plugins/dummy/dummy.o \
+               plugins/dummy/aout_dummy.o \
                plugins/dummy/intf_dummy.o \
                plugins/dummy/vout_dummy.o
 
-PLUGIN_ESD    = plugins/esd/aout_esd.o
+PLUGIN_ESD    = plugins/esd/esd.o \
+               plugins/esd/aout_esd.o
 
-PLUGIN_FB     = plugins/fb/intf_fb.o \
+PLUGIN_FB     = plugins/fb/fb.o \
+               plugins/fb/intf_fb.o \
                plugins/fb/vout_fb.o
 
-PLUGIN_GGI    = plugins/ggi/intf_ggi.o \
+PLUGIN_GGI    = plugins/ggi/ggi.o \
+               plugins/ggi/intf_ggi.o \
                plugins/ggi/vout_ggi.o
 
-PLUGIN_GLIDE  = plugins/glide/intf_glide.o \
+PLUGIN_GLIDE  = plugins/glide/glide.o \
+               plugins/glide/intf_glide.o \
                plugins/glide/vout_glide.o
 
-PLUGIN_GNOME  = plugins/gnome/intf_gnome.o \
+PLUGIN_GNOME  = plugins/gnome/gnome.o \
+               plugins/gnome/intf_gnome.o \
                plugins/gnome/intf_gnome_callbacks.o \
                plugins/gnome/intf_gnome_interface.o \
                plugins/gnome/intf_gnome_support.o \
                plugins/gnome/vout_gnome.o
 
-PLUGIN_MGA    = plugins/mga/intf_mga.o \
-               plugins/fb/vout_mga.o
+PLUGIN_MGA    = plugins/mga/mga.o \
+               plugins/mga/intf_mga.o \
+               plugins/mga/vout_mga.o
 
-PLUGIN_X11    = plugins/x11/intf_x11.o \
+PLUGIN_X11    = plugins/x11/x11.o \
+               plugins/x11/intf_x11.o \
                plugins/x11/vout_x11.o
 
+PLUGIN_YUV    = plugins/yuv/yuv.o \
+               plugins/yuv/video_yuv.o \
+               plugins/yuv/video_yuv8.o \
+               plugins/yuv/video_yuv15.o \
+               plugins/yuv/video_yuv16.o \
+               plugins/yuv/video_yuv24.o \
+               plugins/yuv/video_yuv32.o
+
+PLUGIN_YUVMMX = plugins/yuvmmx/yuvmmx.o \
+               plugins/yuvmmx/video_yuv.o \
+               plugins/yuvmmx/video_yuv8.o \
+               plugins/yuvmmx/video_yuv15.o \
+               plugins/yuvmmx/video_yuv16.o \
+               plugins/yuvmmx/video_yuv24.o \
+               plugins/yuvmmx/video_yuv32.o
+
 PLUGIN_OBJ = $(PLUGIN_BEOS) $(PLUGIN_DSP) $(PLUGIN_DUMMY) $(PLUGIN_ESD) \
                $(PLUGIN_FB) $(PLUGIN_GGI) $(PLUGIN_GLIDE) $(PLUGIN_GNOME) \
-               $(PLUGIN_MGA) $(PLUGIN_X11)
+               $(PLUGIN_MGA) $(PLUGIN_X11) $(PLUGIN_YUV) $(PLUGIN_YUVMMX)
 #
 # Other lists of files
 #
@@ -303,32 +328,32 @@ export
 #
 # Virtual targets
 #
-all: vlc plugins
+all: vlc @ALIASES@ plugins
 
 clean:
        rm -f $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ)
+       rm -f vlc @ALIASES@ lib/*.so
 
 distclean: clean
-       rm -f src/*/*.o plugins/*/*.o lib/*.so **/*~ *.log
+       rm -f src/*/*.o plugins/*/*.o **/*~ *.log
        rm -f Makefile include/defs.h include/config.h
        rm -f config.status config.cache config.log
-       rm -f vlc gmon.out core build-stamp
+       rm -f gmon.out core build-stamp
        rm -rf .dep
 
 install:
        $(INSTALL) vlc $(prefix)/bin
        mkdir -p $(prefix)/lib/videolan/vlc
-       mkdir -p $(prefix)/share/videolan/vlc
+       mkdir -p $(prefix)/share/videolan
        $(INSTALL) -m 644 $(PLUGINS) $(prefix)/lib/videolan/vlc
-       $(INSTALL) -m 644 share/*.psf $(prefix)/share/videolan/vlc
-       $(INSTALL) -m 644 share/*.png $(prefix)/share/videolan/vlc
+       $(INSTALL) -m 644 share/*.psf $(prefix)/share/videolan
+       $(INSTALL) -m 644 share/*.png $(prefix)/share/videolan
 
 show:
-       @echo "Command line for C objects:"
-       @echo $(CC) $(CCFLAGS) $(CFLAGS) -c -o "<dest.o>" "<src.c>"
-       @echo
-       @echo "Command line for assembler objects:"
-       @echo $(CC) $(CFLAGS) -c -o "<dest.o>" "<src.S>"
+       @echo CC: $(CC)
+       @echo CCFLAGS: $(CCFLAGS)
+       @echo DCFLAGS: $(DCFLAGS)
+       @echo LCFLAGS: $(CCFLAGS)
 
 # ugliest of all, but I have no time to do it -- sam
 snapshot:
@@ -359,6 +384,9 @@ else
        $(CC) $(CCFLAGS) $(LCFLAGS) $(CFLAGS) --export-dynamic -rdynamic -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)   
 endif
 
+gvlc xvlc fbvlc ggivlc glidevlc: vlc
+       rm -f $@ && ln -s vlc $@
+
 plugins: $(PLUGINS)
 
 #
@@ -382,11 +410,9 @@ $(ASM_OBJ): %.o: %.S
 #$(PLUGIN_OBJ): %.so: Makefile.dep
 #$(PLUGIN_OBJ): %.so: .dep/%.d
 
-#$(CC) $(LCFLAGS) $(CCFLAGS) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $< plugins/_APP_
-               
 lib/beos.so: $(PLUGIN_BEOS)
-       ld -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
-$(PLUGIN_BEOS): %.o: %.c
+       $(CC) $(CCFLAGS) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
+$(PLUGIN_BEOS): %.o: %.cpp
        $(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
 
 lib/esd.so: $(PLUGIN_ESD)
@@ -398,6 +424,11 @@ endif
 $(PLUGIN_ESD): %.o: %.c
        $(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
 
+lib/dsp.so: $(PLUGIN_DSP)
+       ld -shared -o $@ $^
+$(PLUGIN_DSP): %.o: %.c
+       $(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
+
 lib/dummy.so: $(PLUGIN_DUMMY)
        ld -shared -o $@ $^
 $(PLUGIN_DUMMY): %.o: %.c
@@ -421,7 +452,7 @@ $(PLUGIN_MGA): %.o: %.c
 lib/gnome.so: $(PLUGIN_GNOME)
        ld -shared `gnome-config --libs gnomeui | sed 's,-rdynamic,,'` -o $@ $^
 $(PLUGIN_GNOME): %.o: %.c
-       $(CC) $(CCFLAGS) $(CFLAGS) `gnome-config --cflags gnomeui`-c -o $@ $<
+       $(CC) $(CCFLAGS) $(CFLAGS) `gnome-config --cflags gnomeui` -c -o $@ $<
 
 lib/glide.so: $(PLUGIN_GLIDE)
        ld -shared -lglide2x -o $@ $^
@@ -433,6 +464,16 @@ lib/ggi.so: $(PLUGIN_GGI)
 $(PLUGIN_GGI): %.o: %.c
        $(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
 
+lib/yuv.so: $(PLUGIN_YUV)
+       ld -shared -o $@ $^
+$(PLUGIN_YUV): %.o: %.c
+       $(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
+
+lib/yuvmmx.so: $(PLUGIN_YUVMMX)
+       ld -shared -o $@ $^
+$(PLUGIN_YUVMMX): %.o: %.c
+       $(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
+
 ################################################################################
 # Note on generic rules and dependancies
 ################################################################################
diff --git a/README b/README
index f9803ea21fff89da9116fa4947978f7698826483..290ce66057542c12bf6d80829aaddd6cc9bad4a5 100644 (file)
--- a/README
+++ b/README
@@ -4,7 +4,9 @@ README for vlc, the VideoLAN Client
 Introduction
 ============
 
-[ nothing appropriate yet ]
+The vlc is part of the VideoLAN project, a full MPEG2 client/server
+solution. The VideoLAN Client can also be used as a standalone program
+to play MPEG2 streams from a hard disk or a DVD.
 
 
 Building, Installing and Running VideoLAN
@@ -38,7 +40,13 @@ distribution, what plugins you were trying, and so on).
 Resources
 =========
 
-[ nothing appropriate yet ]
+The VideoLAN web site at http://www.videolan.org/ is a good start for
+information about MPEG and DVD playing. Have a look at the documentation
+section, as well as the bookmarks.
+
+You can also try the OpenDVD site at http://www.opendvd.org/ or the
+the LiVid project at http://www.linuxvideo.org/. They have lots of
+information, too.
 
 
 The team
index 0ced8394c32d22139bdee9e83964c4f2a6e25732..bfebd618b4e311e668047383efbc8e1a48a06be9 100755 (executable)
--- a/configure
+++ b/configure
@@ -12,9 +12,13 @@ ac_help=
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
-  --enable-dsp            Linux /dev/dsp support (default enabled)"
+  --enable-ppro           Enable PentiumPro optimizations (default is no)"
+ac_help="$ac_help
+  --enable-mmx            Enable MMX optimizations (default is no)"
 ac_help="$ac_help
   --enable-dummy          dummy audio and video support (default enabled)"
+ac_help="$ac_help
+  --enable-dsp            Linux /dev/dsp support (default enabled)"
 ac_help="$ac_help
   --enable-esd            Esound library support (default disabled)"
 ac_help="$ac_help
@@ -27,10 +31,6 @@ ac_help="$ac_help
   --enable-gnome          Gnome support (default disabled)"
 ac_help="$ac_help
   --enable-x11            X11 support (default enabled)"
-ac_help="$ac_help
-  --enable-ppro           Enable PentiumPro optimizations (default is no)"
-ac_help="$ac_help
-  --enable-mmx            Enable MMX optimizations (default is no)"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -3041,13 +3041,30 @@ EOF
 fi
 
 
-# Check whether --enable-dsp or --disable-dsp was given.
-if test "${enable_dsp+set}" = set; then
-  enableval="$enable_dsp"
-  :
+PLUGINS=${PLUGINS}"yuv ";
+
+ARCH=${host_cpu}
+# Check whether --enable-ppro or --disable-ppro was given.
+if test "${enable_ppro+set}" = set; then
+  enableval="$enable_ppro"
+   if test x$enableval = xyes; then ARCH=${ARCH}" pentiumpro"; fi 
 fi
 
-if test x$enable_dsp != xno; then PLUGINS=${PLUGINS}"dsp "; fi
+# Check whether --enable-mmx or --disable-mmx was given.
+if test "${enable_mmx+set}" = set; then
+  enableval="$enable_mmx"
+   if test x$enableval = xyes; then ARCH=${ARCH}" mmx"; PLUGINS=${PLUGINS}"yuvmmx "; fi 
+fi
+
+
+SYS=${host_os}
+
+# special cases
+if test x$host_os = xbeos; then
+    PLUGINS=${PLUGINS}"dummy beos "
+
+else
+
 # Check whether --enable-dummy or --disable-dummy was given.
 if test "${enable_dummy+set}" = set; then
   enableval="$enable_dummy"
@@ -3055,6 +3072,13 @@ if test "${enable_dummy+set}" = set; then
 fi
 
 if test x$enable_dummy != xno; then PLUGINS=${PLUGINS}"dummy "; fi
+# Check whether --enable-dsp or --disable-dsp was given.
+if test "${enable_dsp+set}" = set; then
+  enableval="$enable_dsp"
+  :
+fi
+
+if test x$enable_dsp != xno; then PLUGINS=${PLUGINS}"dsp "; fi
 # Check whether --enable-esd or --disable-esd was given.
 if test "${enable_esd+set}" = set; then
   enableval="$enable_esd"
@@ -3064,25 +3088,25 @@ fi
 # Check whether --enable-fb or --disable-fb was given.
 if test "${enable_fb+set}" = set; then
   enableval="$enable_fb"
-  if test x$enable_fb = xyes; then PLUGINS=${PLUGINS}"fb "; fi
+  if test x$enable_fb = xyes; then PLUGINS=${PLUGINS}"fb "; ALIASES=${ALIASES}"fbvlc "; fi
 fi
 
 # Check whether --enable-ggi or --disable-ggi was given.
 if test "${enable_ggi+set}" = set; then
   enableval="$enable_ggi"
-  if test x$enable_ggi = xyes; then PLUGINS=${PLUGINS}"ggi "; fi
+  if test x$enable_ggi = xyes; then PLUGINS=${PLUGINS}"ggi "; ALIASES=${ALIASES}"ggivlc "; fi
 fi
 
 # Check whether --enable-glide or --disable-glide was given.
 if test "${enable_glide+set}" = set; then
   enableval="$enable_glide"
-  if test x$enable_glide = xyes; then PLUGINS=${PLUGINS}"glide "; fi
+  if test x$enable_glide = xyes; then PLUGINS=${PLUGINS}"glide "; ALIASES=${ALIASES}"glidevlc "; fi
 fi
 
 # Check whether --enable-gnome or --disable-gnome was given.
 if test "${enable_gnome+set}" = set; then
   enableval="$enable_gnome"
-  if test x$enable_gnome = xyes; then PLUGINS=${PLUGINS}"gnome "; fi
+  if test x$enable_gnome = xyes; then PLUGINS=${PLUGINS}"gnome "; ALIASES=${ALIASES}"gvlc "; fi
 fi
 
 # Check whether --enable-x11 or --disable-x11 was given.
@@ -3091,29 +3115,11 @@ if test "${enable_x11+set}" = set; then
   :
 fi
 
-if test x$enable_x11 != xno; then PLUGINS=${PLUGINS}"x11 "; fi
-
-ARCH=${host_cpu}
-# Check whether --enable-ppro or --disable-ppro was given.
-if test "${enable_ppro+set}" = set; then
-  enableval="$enable_ppro"
-   if test x$enableval = xyes; then ARCH=${ARCH}" pentiumpro"; fi 
-fi
+if test x$enable_x11 != xno; then PLUGINS=${PLUGINS}"x11 "; ALIASES=${ALIASES}"xvlc "; fi
 
-# Check whether --enable-mmx or --disable-mmx was given.
-if test "${enable_mmx+set}" = set; then
-  enableval="$enable_mmx"
-   if test x$enableval = xyes; then ARCH=${ARCH}" mmx"; fi 
 fi
 
 
-SYS=${host_os}
-
-# special cases
-if test x$host_os = xbeos; then
-    PLUGINS="dummy beos"
-fi
-
 
 
 
@@ -3268,6 +3274,7 @@ s%@LIBOBJS@%$LIBOBJS%g
 s%@SYS@%$SYS%g
 s%@ARCH@%$ARCH%g
 s%@PLUGINS@%$PLUGINS%g
+s%@ALIASES@%$ALIASES%g
 
 CEOF
 EOF
@@ -3495,4 +3502,5 @@ vlc version           : ${VLC_VERSION}
 system                : ${SYS}
 architecture          : ${ARCH}
 plugins               : ${PLUGINS}
+vlc aliases           : ${ALIASES}
 "
index 8089b09f87e78ebcf6dbefac7469f1c4a0cbb294..25c2af31bbf8eecbd9cbd8870a8c69288278c7fc 100644 (file)
@@ -58,49 +58,57 @@ AC_C_CONST
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
 
-AC_ARG_ENABLE(dsp,
-  [  --enable-dsp            Linux /dev/dsp support (default enabled)])
-if test x$enable_dsp != xno; then PLUGINS=${PLUGINS}"dsp "; fi
+dnl default plugins 
+PLUGINS=${PLUGINS}"yuv ";
+
+ARCH=${host_cpu}
+AC_ARG_ENABLE(ppro,
+[  --enable-ppro           Enable PentiumPro optimizations (default is no)],
+[ if test x$enableval = xyes; then ARCH=${ARCH}" pentiumpro"; fi ])
+AC_ARG_ENABLE(mmx,
+[  --enable-mmx            Enable MMX optimizations (default is no)],
+[ if test x$enableval = xyes; then ARCH=${ARCH}" mmx"; PLUGINS=${PLUGINS}"yuvmmx "; fi ])
+
+SYS=${host_os}
+
+# special cases
+if test x$host_os = xbeos; then
+    PLUGINS=${PLUGINS}"dummy beos "
+
+dnl default case
+else
+
 AC_ARG_ENABLE(dummy,
   [  --enable-dummy          dummy audio and video support (default enabled)])
 if test x$enable_dummy != xno; then PLUGINS=${PLUGINS}"dummy "; fi
+AC_ARG_ENABLE(dsp,
+  [  --enable-dsp            Linux /dev/dsp support (default enabled)])
+if test x$enable_dsp != xno; then PLUGINS=${PLUGINS}"dsp "; fi
 AC_ARG_ENABLE(esd,
   [  --enable-esd            Esound library support (default disabled)],
   [if test x$enable_gnome = xyes; then PLUGINS=${PLUGINS}"esd "; fi])
 AC_ARG_ENABLE(fb,
   [  --enable-fb             Linux framebuffer support (default disabled)],
-  [if test x$enable_fb = xyes; then PLUGINS=${PLUGINS}"fb "; fi])
+  [if test x$enable_fb = xyes; then PLUGINS=${PLUGINS}"fb "; ALIASES=${ALIASES}"fbvlc "; fi])
 AC_ARG_ENABLE(ggi,
   [  --enable-ggi            GGI support (default disabled)],
-  [if test x$enable_ggi = xyes; then PLUGINS=${PLUGINS}"ggi "; fi])
+  [if test x$enable_ggi = xyes; then PLUGINS=${PLUGINS}"ggi "; ALIASES=${ALIASES}"ggivlc "; fi])
 AC_ARG_ENABLE(glide,
   [  --enable-glide          Glide (3dfx) support (default disabled)],
-  [if test x$enable_glide = xyes; then PLUGINS=${PLUGINS}"glide "; fi])
+  [if test x$enable_glide = xyes; then PLUGINS=${PLUGINS}"glide "; ALIASES=${ALIASES}"glidevlc "; fi])
 AC_ARG_ENABLE(gnome,
   [  --enable-gnome          Gnome support (default disabled)],
-  [if test x$enable_gnome = xyes; then PLUGINS=${PLUGINS}"gnome "; fi])
+  [if test x$enable_gnome = xyes; then PLUGINS=${PLUGINS}"gnome "; ALIASES=${ALIASES}"gvlc "; fi])
 AC_ARG_ENABLE(x11,
   [  --enable-x11            X11 support (default enabled)])
-if test x$enable_x11 != xno; then PLUGINS=${PLUGINS}"x11 "; fi
+if test x$enable_x11 != xno; then PLUGINS=${PLUGINS}"x11 "; ALIASES=${ALIASES}"xvlc "; fi
 
-ARCH=${host_cpu}
-AC_ARG_ENABLE(ppro,
-[  --enable-ppro           Enable PentiumPro optimizations (default is no)],
-[ if test x$enableval = xyes; then ARCH=${ARCH}" pentiumpro"; fi ])
-AC_ARG_ENABLE(mmx,
-[  --enable-mmx            Enable MMX optimizations (default is no)],
-[ if test x$enableval = xyes; then ARCH=${ARCH}" mmx"; fi ])
-
-SYS=${host_os}
-
-# special cases
-if test x$host_os = xbeos; then
-    PLUGINS="dummy beos"
 fi
 
 AC_SUBST(SYS)
 AC_SUBST(ARCH)
 AC_SUBST(PLUGINS)
+AC_SUBST(ALIASES)
 
 AC_OUTPUT([Makefile include/config.h])
 
@@ -111,4 +119,5 @@ vlc version           : ${VLC_VERSION}
 system                : ${SYS}
 architecture          : ${ARCH}
 plugins               : ${PLUGINS}
+vlc aliases           : ${ALIASES}
 "
index 4972fd7e02b2ebaf70b7f6a3844f7387af26e3b6..c3c980c54559b03170bf0b3953501a694a68247f 100644 (file)
@@ -2,7 +2,7 @@ vlc (0.1.99d) unstable; urgency=low
 
   * .deb is now more lintian-friendly
 
- -- Samuel Hocevar <sam@via.ecp.fr>  Tue, 20 Jun 2000 14:17:33 +0200
+ -- Samuel Hocevar <sam@via.ecp.fr>  [Insert date here]
 
 vlc (0.1.99c) unstable; urgency=low
 
index 2d46f364cd2d248f11dba87e0d1cb41c69b16f0b..7ba3061737cdd59a77172057e52f4919324efa7e 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1999, 2000 VideoLAN
  *
  * Authors:
+ * Michel Kaempf <maxx@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 5d299ce492745b9d034966d45ddb2b864ffb5798..675a3ea7ac44234c1a9077aa639c7946594f765d 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1999, 2000 VideoLAN
  *
  * Authors:
+ * Michel Kaempf <maxx@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index ad9b891e1a3cfe1d0816f15b1ececbcc81419005..e9dac8aa513067eeef4f4d0cf879e88a12cb4132 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1999, 2000 VideoLAN
  *
  * Authors:
+ * Michel Kaempf <maxx@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index eb64c86545e9373e5ee5d0324d1ed651b0cfed62..52d131323eac17c743c8b2b55ffe2b9ca52ba6f8 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1999, 2000 VideoLAN
  *
  * Authors:
+ * Michel Kaempf <maxx@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 64d730d75fb0d8e443393a5d47cf6237913e81f7..80d909104fd321115b939b1952a2933701383512 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1999, 2000 VideoLAN
  *
  * Authors:
+ * Michel Kaempf <maxx@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -191,7 +192,6 @@ typedef struct aout_thread_s
     aout_fifo_t         fifo[ AOUT_MAX_FIFOS ];
 
     /* Plugins */
-    plugin_id_t                 aout_plugin;          /* video output plugin */
     aout_sys_open_t *           p_sys_open;
     aout_sys_reset_t *          p_sys_reset;
     aout_sys_setformat_t *      p_sys_setformat;
index c9291629c3ac894dded59f0bc6787d6c23f84bcb..f23b03e960a95bb2c5103ab4d1b2e1a67a1817b4 100644 (file)
@@ -29,8 +29,8 @@
 extern "C" {
 #endif
 
-void       beos_Init( void );
-void       beos_Clean( void );
+void       beos_Create( void );
+void       beos_Destroy( void );
 char *     beos_GetProgramPath( void );
 
 #ifdef __cplusplus
index 813da8077ec0e5340ad9adf1a85bd16458ee14f1..ced9d4bb4e08ba9d4edeeefdf6d3af7746b8a7bf 100644 (file)
@@ -47,6 +47,18 @@ typedef unsigned long       count_t;
  * Classes declaration
  *****************************************************************************/
 
+/* Plugins */
+struct plugin_bank_s;
+struct plugin_info_s;
+
+typedef struct plugin_bank_s *          p_plugin_bank_t;
+typedef struct plugin_info_s *          p_plugin_info_t;
+
+/* Playlist */
+struct playlist_s;
+
+typedef struct playlist_s *             p_playlist_t;
+
 /* Interface */
 struct intf_thread_s;
 struct intf_sys_s;
index fc7bba9cc2696408d25dab1a9fee5887448ab6ab..c5b1e7a657a9dd1c290f2db83ea4a0ecd2a72baa 100644 (file)
@@ -27,8 +27,8 @@
  * - Symbols should begin with a prefix indicating in which module they are
  *   used, such as INTF_, VOUT_ or ADEC_.
  *
- * - Regarding environment variables, which are used as initialization parameters
- *   for threads :
+ * - Regarding environment variables, which are used as initialization
+ *  parameters for threads :
  *   + variable names should end with '_VAR'
  *   + environment variable default value should end with '_DEFAULT'
  *   + values having a special meaning with '_VAL'
@@ -41,7 +41,7 @@
 
 /* Program version and copyright message */
 #define VERSION_MESSAGE     "vlc @VLC_VERSION@ @VLC_CODENAME@ " \
-                            /* "(" PROGRAM_BUILD ") (" PROGRAM_OPTIONS ")\n" */ \
+                          /* "(" PROGRAM_BUILD ") (" PROGRAM_OPTIONS ")\n" */ \
                             "Copyright 1996-2000 VideoLAN\n"
 #define COPYRIGHT_MESSAGE   "VideoLAN Client - version @VLC_VERSION@" \
                             " @VLC_CODENAME@ - (c)1996-2000 VideoLAN"
 /* Size of the FIFO. FIFO_SIZE+1 must be a power of 2 */
 #define FIFO_SIZE                       1023
 
+/*
+ * Paths
+ */
+
+#define DATA_PATH                       "@prefix@/share/videolan"
+#define PLUGIN_PATH                     "@prefix@/lib/videolan/vlc"
+
+#define MAX_PLUGIN_COUNT                32
 
 /*****************************************************************************
  * Interface configuration
 #define VOUT_DISPLAY_VAR                "vlc_display"
 
 /* Default dimensions for display window - these dimensions are enough for the
- * standard width and height broadcasted MPEG-2 streams */
+ * standard width and height broadcasted MPEG-2 streams or DVDs */
 #define VOUT_WIDTH_VAR                  "vlc_width"
 #define VOUT_HEIGHT_VAR                 "vlc_height"
-#define VOUT_WIDTH_DEFAULT              720
-#define VOUT_HEIGHT_DEFAULT             576
+#define VOUT_WIDTH_DEFAULT              360
+#define VOUT_HEIGHT_DEFAULT             288
 
 /* Maximum width of a scaled source picture - this should be relatively high,
  * since higher stream values will result in no display at all. */
 
 /* Optimization level, from 0 to 2 - 1 is generally a good compromise. Remember
  * that raising this level dramatically lengthens the compilation time. */
-#define VPAR_OPTIM_LEVEL                1
+#define VPAR_OPTIM_LEVEL                2
 
 /* The following directives only apply if you define VDEC_SMP below. */
 
index 2c8877939cdc599d49a3eb01ea67140c8d2c2a09..236700a0be85f0cd3fa1734829393a93201f9325 100644 (file)
  *****************************************************************************/
 
 /* FIXME: move to inline functions ??*/
-#define DECODER_FIFO_ISEMPTY( fifo )    ( (fifo).i_start == (fifo).i_end )
-#define DECODER_FIFO_ISFULL( fifo )     ( ( ( (fifo).i_end + 1 - (fifo).i_start ) \
+#define DECODER_FIFO_ISEMPTY( fifo )  ( (fifo).i_start == (fifo).i_end )
+#define DECODER_FIFO_ISFULL( fifo )   ( ( ((fifo).i_end + 1 - (fifo).i_start)\
                                           & FIFO_SIZE ) == 0 )
-#define DECODER_FIFO_START( fifo )      ( (fifo).buffer[ (fifo).i_start ] )
-#define DECODER_FIFO_INCSTART( fifo )   ( (fifo).i_start = ((fifo).i_start + 1)\
-                                                           & FIFO_SIZE )
-#define DECODER_FIFO_END( fifo )        ( (fifo).buffer[ (fifo).i_end ] )
-#define DECODER_FIFO_INCEND( fifo )     ( (fifo).i_end = ((fifo).i_end + 1) \
+#define DECODER_FIFO_START( fifo )    ( (fifo).buffer[ (fifo).i_start ] )
+#define DECODER_FIFO_INCSTART( fifo ) ( (fifo).i_start = ((fifo).i_start + 1)\
                                                          & FIFO_SIZE )
+#define DECODER_FIFO_END( fifo )      ( (fifo).buffer[ (fifo).i_end ] )
+#define DECODER_FIFO_INCEND( fifo )   ( (fifo).i_end = ((fifo).i_end + 1) \
+                                                       & FIFO_SIZE )
 
 /*****************************************************************************
  * decoder_fifo_t
@@ -239,5 +239,6 @@ static __inline__ u32 GetBits32( bit_stream_t * p_bit_stream )
  *****************************************************************************/
 static __inline__ void RealignBits( bit_stream_t * p_bit_stream )
 {
-    DumpBits( p_bit_stream, p_bit_stream->fifo.i_available & 7 );
+    DumpBits( p_bit_stream, p_bit_stream->fifo.i_available & 0x7 );
 }
+
index 296806d388e1d9d4cc2612cf92f15baa1a960a42..1b75eef038ffcac26fc9859646b1ee058a15a6a6 100644 (file)
@@ -57,16 +57,12 @@ typedef struct intf_thread_s
     p_intf_sys_t        p_sys;                           /* system interface */
 
     /* Plugin */
-    plugin_id_t             intf_plugin;                 /* interface plugin */
     intf_sys_create_t *     p_sys_create;         /* create interface thread */
     intf_sys_manage_t *     p_sys_manage;                       /* main loop */
     intf_sys_destroy_t *    p_sys_destroy;              /* destroy interface */
 
     /* XXX: Channels array - new API */
-    //p_intf_channel_t *  p_channel[INTF_MAX_CHANNELS];/* channel descriptions */
-    /* file list - quick hack */
-    char **p_playlist;
-    int i_list_index;
+  //p_intf_channel_t *  p_channel[INTF_MAX_CHANNELS];/* channel descriptions */
 
     /* Channels array - NULL if not used */
     p_intf_channel_t    p_channel;                /* description of channels */
index bfe5b51bebe9d82704bc64121de84dc8201bf24a..b55bc743fc50fad12cd6645f90a7264b0512ac31 100644 (file)
@@ -31,6 +31,7 @@
  * it when you can access the members you need in an other way. In fact, it
  * should only be used by interface thread.
  *****************************************************************************/
+
 typedef struct
 {
     /* Global properties */
@@ -49,6 +50,8 @@ typedef struct
 
     /* Shared data - these structures are accessed directly from p_main by
      * several modules */
+    p_plugin_bank_t        p_bank;                            /* plugin bank */
+    p_playlist_t           p_playlist;                        /* plugin bank */
     p_intf_msg_t           p_msg;                 /* messages interface data */
     p_input_vlan_t         p_vlan;                      /* vlan library data */
 } main_t;
@@ -63,3 +66,4 @@ int    main_GetIntVariable( char *psz_name, int i_default );
 char * main_GetPszVariable( char *psz_name, char *psz_default );
 void   main_PutIntVariable( char *psz_name, int i_value );
 void   main_PutPszVariable( char *psz_name, char *psz_value );
+
diff --git a/include/playlist.h b/include/playlist.h
new file mode 100644 (file)
index 0000000..9556fe1
--- /dev/null
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * playlist.h : Playlist functions
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+typedef struct playlist_s
+{
+    int               i_index;
+    char**            p_list;
+} playlist_t;
+
+playlist_t * playlist_Create   ( void );
+void         playlist_Init     ( playlist_t * p_playlist, int i_optind );
+void         playlist_Destroy  ( playlist_t * p_playlist );
+
index 31fa941d9ce3f49d0de2bf8ee978a444f26c0214..818e34970b23688bc29a97ec6b9b671d6ac049ac 100644 (file)
 
 #ifdef SYS_BEOS
 typedef int plugin_id_t;
+#define GET_PLUGIN( p_func, plugin_id, psz_name ) \
+    get_image_symbol( plugin_id, psz_name, B_SYMBOL_TYPE_TEXT, &p_func );
 #else
-typedef void* plugin_id_t;
+typedef void *plugin_id_t;
+#define GET_PLUGIN( p_func, plugin_id, psz_name ) \
+    p_func = dlsym( plugin_id, psz_name );
 #endif
 
-int    RequestPlugin     ( plugin_id_t * p_plugin, char * psz_name );
-void   TrashPlugin       ( plugin_id_t p_plugin );
-void * GetPluginFunction ( plugin_id_t plugin, char *name );
+typedef struct plugin_info_s
+{
+    plugin_id_t plugin_id;
+
+    char *      psz_filename;
+    char *      psz_name;
+    char *      psz_version;
+    char *      psz_author;
+
+    void *      aout_GetPlugin;
+    void *      vout_GetPlugin;
+    void *      intf_GetPlugin;
+    void *      yuv_GetPlugin;
+} plugin_info_t;
+
+typedef struct plugin_bank_s
+{
+    int               i_plugin_count;
+    plugin_info_t *   p_info[ MAX_PLUGIN_COUNT ];
+} plugin_bank_t;
+
+plugin_bank_t *  bank_Create       ( void );
+void             bank_Init         ( plugin_bank_t * p_bank );
+void             bank_Destroy      ( plugin_bank_t * p_bank );
 
diff --git a/include/plugins_export.h b/include/plugins_export.h
new file mode 100644 (file)
index 0000000..04abe77
--- /dev/null
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * plugins_export.h : exporting plugins structure
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Prototypes
+ *****************************************************************************/
+
+/* audio output */
+int     aout_SysOpen         ( aout_thread_t *p_aout );
+int     aout_SysReset        ( aout_thread_t *p_aout );
+int     aout_SysSetFormat    ( aout_thread_t *p_aout );
+int     aout_SysSetChannels  ( aout_thread_t *p_aout );
+int     aout_SysSetRate      ( aout_thread_t *p_aout );
+long    aout_SysGetBufInfo   ( aout_thread_t *p_aout, long l_buffer_info );
+void    aout_SysPlaySamples  ( aout_thread_t *p_aout, byte_t *buffer,
+                               int i_size );
+void    aout_SysClose        ( aout_thread_t *p_aout );
+
+/* video output */
+int     vout_SysCreate       ( vout_thread_t *p_vout, char *psz_display,
+                               int i_root_window, void *p_data );
+int     vout_SysInit         ( p_vout_thread_t p_vout );
+void    vout_SysEnd          ( p_vout_thread_t p_vout );
+void    vout_SysDestroy      ( p_vout_thread_t p_vout );
+int     vout_SysManage       ( p_vout_thread_t p_vout );
+void    vout_SysDisplay      ( p_vout_thread_t p_vout );
+void    vout_SetPalette      ( p_vout_thread_t p_vout,
+                               u16 *red, u16 *green, u16 *blue, u16 *transp );
+
+/* interface */
+int     intf_SysCreate       ( p_intf_thread_t p_intf );
+void    intf_SysDestroy      ( p_intf_thread_t p_intf );
+void    intf_SysManage       ( p_intf_thread_t p_intf );
+
+/* YUV transformations */
+int     yuv_SysInit          ( p_vout_thread_t p_vout );
+int     yuv_SysReset         ( p_vout_thread_t p_vout );
+void    yuv_SysEnd           ( p_vout_thread_t p_vout );
+
index 6e6be23111c97e66c7f62728d14290b3244e353b..25c63773f1bdd25ff5c28f46f8000e1bb867532f 100644 (file)
@@ -50,6 +50,18 @@ typedef struct spudec_thread_s
 
 } spudec_thread_t;
 
+/*****************************************************************************
+ * SPU commands
+ *****************************************************************************/
+#define SPU_CMD_FORCE_DISPLAY       0x00
+#define SPU_CMD_START_DISPLAY       0x01
+#define SPU_CMD_STOP_DISPLAY        0x02
+#define SPU_CMD_SET_PALETTE         0x03
+#define SPU_CMD_SET_ALPHACHANNEL    0x04
+#define SPU_CMD_SET_COORDINATES     0x05
+#define SPU_CMD_SET_OFFSETS         0x06
+#define SPU_CMD_END                 0xff
+
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
index 9fe26f5dd3fa8c29e1f82a775a4f3e2a3ee691ed..7515e779a5b307d69f19f7e9f4848a52c56f7c0f 100644 (file)
@@ -50,17 +50,6 @@ typedef struct vdec_thread_s
     /* XXX?? */
 //    int *pi_status;
 
-#ifdef OLD_DECODER
-    /* Input properties */
-    decoder_fifo_t      fifo;                              /* PES input fifo */
-
-    /* The bit stream structure handles the PES stream at the bit level */
-    bit_stream_t        bit_stream;
-
-    /* Output properties */
-    vout_thread_t *     p_vout;                       /* video output thread */
-    int                 i_stream;                         /* video stream id */
-#else
     /* idct iformations */
     dctelem_t              p_pre_idct[64*64];
 
@@ -72,18 +61,11 @@ typedef struct vdec_thread_s
     u8              pi_crop_buf[VDEC_CROPRANGE];
     u8 *            pi_crop;
 //#endif
-#endif
 
 #ifdef STATS
     /* Statistics */
     count_t         c_loops;                              /* number of loops */
     count_t         c_idle_loops;                    /* number of idle loops */
-#ifdef OLD_DECODER
-    count_t         c_pictures;                   /* number of pictures read */
-    count_t         c_i_pictures;               /* number of I pictures read */
-    count_t         c_p_pictures;               /* number of P pictures read */
-    count_t         c_b_pictures;               /* number of B pictures read */
-#endif
     count_t         c_decoded_pictures;        /* number of pictures decoded */
     count_t         c_decoded_i_pictures;    /* number of I pictures decoded */
     count_t         c_decoded_p_pictures;    /* number of P pictures decoded */
@@ -94,21 +76,17 @@ typedef struct vdec_thread_s
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
-#ifndef OLD_DECODER
 struct vpar_thread_s;
 struct macroblock_s;
-#endif
 
 /* Thread management functions */
-#ifdef OLD_DECODER
-p_vdec_thread_t  vdec_CreateThread       ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*,
-                                          vout_thread_t *p_vout, int *pi_status */ );
-void             vdec_DestroyThread      ( vdec_thread_t *p_vdec /*, int *pi_status */ );
-#else
 #ifndef VDEC_SMP
 int             vdec_InitThread         ( struct vdec_thread_s *p_vdec );
-void            vdec_DecodeMacroblock   ( struct vdec_thread_s *p_vdec, struct macroblock_s *p_mb );
-#endif
-vdec_thread_t * vdec_CreateThread       ( struct vpar_thread_s *p_vpar /*, int *pi_status */ );
-void vdec_DestroyThread      ( vdec_thread_t *p_vdec /*, int *pi_status */ );
+void            vdec_DecodeMacroblock   ( struct vdec_thread_s *p_vdec,
+                                          struct macroblock_s *p_mb );
 #endif
+vdec_thread_t * vdec_CreateThread       ( struct vpar_thread_s *p_vpar /*,
+                                          int *pi_status */ );
+void            vdec_DestroyThread      ( vdec_thread_t *p_vdec /*,
+                                          int *pi_status */ );
+
index 80fb7f82a686713fd236d89f6703e276b821345a..fac2829ef24688bd6832dfbf7b271ea3d371faf9 100644 (file)
@@ -109,9 +109,14 @@ typedef void (vout_sys_end_t)       ( p_vout_thread_t p_vout );
 typedef void (vout_sys_destroy_t)   ( p_vout_thread_t p_vout );
 typedef int  (vout_sys_manage_t)    ( p_vout_thread_t p_vout );
 typedef void (vout_sys_display_t)   ( p_vout_thread_t p_vout );
+
 typedef void (vout_set_palette_t)   ( p_vout_thread_t p_vout, u16 *red,
                                       u16 *green, u16 *blue, u16 *transp );
 
+typedef int  (yuv_sys_init_t)       ( p_vout_thread_t p_vout );
+typedef int  (yuv_sys_reset_t)      ( p_vout_thread_t p_vout );
+typedef void (yuv_sys_end_t)        ( p_vout_thread_t p_vout );
+
 typedef struct vout_thread_s
 {
     /* Thread properties and lock */
@@ -152,14 +157,18 @@ typedef struct vout_thread_s
     u32                 i_blue_pixel;                                /* blue */
 
     /* Plugins */
-    plugin_id_t             vout_plugin;              /* video output plugin */
     vout_sys_create_t *     p_sys_create;          /* allocate output method */
     vout_sys_init_t *       p_sys_init;          /* initialize output method */
     vout_sys_end_t *        p_sys_end;            /* terminate output method */
     vout_sys_destroy_t *    p_sys_destroy;          /* destroy output method */
     vout_sys_manage_t *     p_sys_manage;                   /* handle events */
     vout_sys_display_t *    p_sys_display;         /* display rendered image */
-    vout_set_palette_t *    p_set_palette;              /* sets 8bpp palette */
+
+    vout_set_palette_t *    p_set_palette;               /* set 8bpp palette */
+
+    yuv_sys_init_t *        p_yuv_init;             /* initialize YUV tables */
+    yuv_sys_reset_t *       p_yuv_reset;                 /* reset YUV tables */
+    yuv_sys_end_t *         p_yuv_end;                    /* free YUV tables */
 
     /* Pictures and rendering properties */
     boolean_t           b_grayscale;           /* color or grayscale display */
index 3f163a76da7a7e67acc55fb880818860252ce07d..6f7bdfc441088c77b606df7a9ebb420872569f86 100644 (file)
  *  "video_fifo.h"
  *****************************************************************************/
 
-#define POLUX_SYNCHRO
+#define SAM_SYNCHRO
+//#define POLUX_SYNCHRO
+//#define MEUUH_SYNCHRO
 
 /*****************************************************************************
  * video_synchro_t and video_synchro_tab_s : timers for the video synchro
  *****************************************************************************/
 #ifdef SAM_SYNCHRO
-typedef struct video_synchro_tab_s
-{
-    double mean;
-    double deviation;
-
-} video_synchro_tab_t;
-
-typedef struct video_synchro_fifo_s
-{
-    /* type of image to be decoded, and decoding date */
-    int i_image_type;
-    mtime_t i_decode_date;
-    mtime_t i_pts;
-
-} video_synchro_fifo_t;
-
 typedef struct video_synchro_s
 {
     /* fifo containing decoding dates */
-    video_synchro_fifo_t fifo[16];
-    unsigned int i_fifo_start;
-    unsigned int i_fifo_stop;
+    mtime_t      i_date_fifo[16];
+    unsigned int i_start;
+    unsigned int i_stop;
 
     /* mean decoding time */
-    mtime_t i_mean_decode_time;
-    /* dates */
-    mtime_t i_last_display_pts;           /* pts of the last displayed image */
-    mtime_t i_last_decode_pts;              /* pts of the last decoded image */
-    mtime_t i_last_i_pts;                         /* pts of the last I image */
-    mtime_t i_last_nondropped_i_pts;      /* pts of last non-dropped I image */
-    unsigned int i_images_since_pts;
+    mtime_t i_delay;
+    mtime_t i_theorical_delay;
 
-    /* il manquait un compteur */
-    unsigned int modulo;
+    /* dates */
+    mtime_t i_last_pts;                   /* pts of the last displayed image */
+    mtime_t i_last_seen_I_pts;              /* date of the last I we decoded */
+    mtime_t i_last_kept_I_pts;            /* pts of last non-dropped I image */
 
     /* P images since the last I */
-    unsigned int current_p_count;
-    unsigned int nondropped_p_count;
-    double p_count_predict;
+    unsigned int i_P_seen;
+    unsigned int i_P_kept;
     /* B images since the last I */
-    unsigned int current_b_count;
-    unsigned int nondropped_b_count;
-    double b_count_predict;
+    unsigned int i_B_seen;
+    unsigned int i_B_kept;
 
     /* can we display pictures ? */
-    unsigned int    can_display_i;
-    unsigned int    can_display_p;
-    double          displayable_p;
-    unsigned int    can_display_b;
-    double          displayable_b;
+    boolean_t     b_all_I;
+    boolean_t     b_all_P;
+    double        displayable_p;
+    boolean_t     b_all_B;
+    double        displayable_b;
 
-    /* 1 for linear count, 2 for binary count, 3 for ternary count */
-    video_synchro_tab_t tab_p[6];
-    video_synchro_tab_t tab_b[6];
+} video_synchro_t;
 
-    double theorical_fps;
-    double actual_fps;
+#define FIFO_INCREMENT( i_counter ) \
+    p_vpar->synchro.i_counter = (p_vpar->synchro.i_counter + 1) & 0xf;
 
-} video_synchro_t;
 #endif
 
 #ifdef MEUUH_SYNCHRO
@@ -140,15 +118,15 @@ typedef struct video_synchro_s
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
-boolean_t vpar_SynchroChoose( struct vpar_thread_s * p_vpar, int i_coding_type,
-                         int i_structure );
-void vpar_SynchroTrash( struct vpar_thread_s * p_vpar, int i_coding_type,
-                        int i_structure );
-void vpar_SynchroDecode( struct vpar_thread_s * p_vpar, int i_coding_type,
-                            int i_structure );
-void vpar_SynchroEnd( struct vpar_thread_s * p_vpar );
-mtime_t vpar_SynchroDate( struct vpar_thread_s * p_vpar );
+boolean_t vpar_SynchroChoose    ( struct vpar_thread_s * p_vpar,
+                                  int i_coding_type, int i_structure );
+void vpar_SynchroTrash          ( struct vpar_thread_s * p_vpar,
+                                  int i_coding_type, int i_structure );
+void vpar_SynchroDecode         ( struct vpar_thread_s * p_vpar,
+                                  int i_coding_type, int i_structure );
+void vpar_SynchroEnd            ( struct vpar_thread_s * p_vpar );
+mtime_t vpar_SynchroDate        ( struct vpar_thread_s * p_vpar );
 
 #ifndef SAM_SYNCHRO
-void vpar_SynchroKludge( struct vpar_thread_s *, mtime_t );
+void vpar_SynchroKludge         ( struct vpar_thread_s *, mtime_t );
 #endif
diff --git a/plugins/beos/beos.cpp b/plugins/beos/beos.cpp
new file mode 100644 (file)
index 0000000..2ff6280
--- /dev/null
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * beos.cpp : BeOS plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+extern "C"
+{
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void aout_GetPlugin( p_aout_thread_t p_aout );
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "BeOS";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = aout_GetPlugin;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* the BeOS plugin always works under BeOS :) */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void aout_GetPlugin( p_aout_thread_t p_aout )
+{
+    p_aout->p_sys_open        = aout_SysOpen;
+    p_aout->p_sys_reset       = aout_SysReset;
+    p_aout->p_sys_setformat   = aout_SysSetFormat;
+    p_aout->p_sys_setchannels = aout_SysSetChannels;
+    p_aout->p_sys_setrate     = aout_SysSetRate;
+    p_aout->p_sys_getbufinfo  = aout_SysGetBufInfo;
+    p_aout->p_sys_playsamples = aout_SysPlaySamples;
+    p_aout->p_sys_close       = aout_SysClose;
+}
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
+} /* extern "C" */
diff --git a/plugins/dsp/dsp.c b/plugins/dsp/dsp.c
new file mode 100644 (file)
index 0000000..05376bb
--- /dev/null
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * dsp.c : OSS /dev/dsp plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void aout_GetPlugin( p_aout_thread_t p_aout );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "OSS /dev/dsp";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = aout_GetPlugin;
+    p_info->vout_GetPlugin = NULL;
+    p_info->intf_GetPlugin = NULL;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: check if suitable */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void aout_GetPlugin( p_aout_thread_t p_aout )
+{
+    p_aout->p_sys_open        = aout_SysOpen;
+    p_aout->p_sys_reset       = aout_SysReset;
+    p_aout->p_sys_setformat   = aout_SysSetFormat;
+    p_aout->p_sys_setchannels = aout_SysSetChannels;
+    p_aout->p_sys_setrate     = aout_SysSetRate;
+    p_aout->p_sys_getbufinfo  = aout_SysGetBufInfo;
+    p_aout->p_sys_playsamples = aout_SysPlaySamples;
+    p_aout->p_sys_close       = aout_SysClose;
+}
+
diff --git a/plugins/dummy/dummy.c b/plugins/dummy/dummy.c
new file mode 100644 (file)
index 0000000..28a091d
--- /dev/null
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * dummy.c : dummy plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void aout_GetPlugin( p_aout_thread_t p_aout );
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "Dummy";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = aout_GetPlugin;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* the dummy plugin always works */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void aout_GetPlugin( p_aout_thread_t p_aout )
+{
+    p_aout->p_sys_open        = aout_SysOpen;
+    p_aout->p_sys_reset       = aout_SysReset;
+    p_aout->p_sys_setformat   = aout_SysSetFormat;
+    p_aout->p_sys_setchannels = aout_SysSetChannels;
+    p_aout->p_sys_setrate     = aout_SysSetRate;
+    p_aout->p_sys_getbufinfo  = aout_SysGetBufInfo;
+    p_aout->p_sys_playsamples = aout_SysPlaySamples;
+    p_aout->p_sys_close       = aout_SysClose;
+}
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
index c0b77eda89ec33fe20787e0d53a6317af704da01..fda4744a2dbc316d35da355b3df6d283987b2fc4 100644 (file)
@@ -40,8 +40,8 @@
 
 #include "intf_msg.h"
 
-#define WIDTH 128
-#define HEIGHT 64
+#define WIDTH 16
+#define HEIGHT 16
 #define BITS_PER_PLANE 16
 #define BYTES_PER_PIXEL 2
 
diff --git a/plugins/esd/esd.c b/plugins/esd/esd.c
new file mode 100644 (file)
index 0000000..afde060
--- /dev/null
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * esd.c : Esound plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void aout_GetPlugin( p_aout_thread_t p_aout );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "Esound";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = aout_GetPlugin;
+    p_info->vout_GetPlugin = NULL;
+    p_info->intf_GetPlugin = NULL;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: check if suitable */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void aout_GetPlugin( p_aout_thread_t p_aout )
+{
+    p_aout->p_sys_open        = aout_SysOpen;
+    p_aout->p_sys_reset       = aout_SysReset;
+    p_aout->p_sys_setformat   = aout_SysSetFormat;
+    p_aout->p_sys_setchannels = aout_SysSetChannels;
+    p_aout->p_sys_setrate     = aout_SysSetRate;
+    p_aout->p_sys_getbufinfo  = aout_SysGetBufInfo;
+    p_aout->p_sys_playsamples = aout_SysPlaySamples;
+    p_aout->p_sys_close       = aout_SysClose;
+}
+
diff --git a/plugins/fb/fb.c b/plugins/fb/fb.c
new file mode 100644 (file)
index 0000000..836d82a
--- /dev/null
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * fb.c : Linux framebuffer plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "Linux framebuffer";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: detect the framebuffer ioctl()s in the kernel */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+    
+    /* optional functions */
+    p_vout->p_set_palette = vout_SetPalette;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
index c60bac25d0265a55cdbf963742d02f5f00b02084..348b3cc1556300ae2b8e166492fdf3d7a3c5aea0 100644 (file)
@@ -104,9 +104,14 @@ int intf_SysCreate( intf_thread_t *p_intf )
 
     /* set keyboard settings */
     if (tcgetattr(0, &p_intf->p_sys->old_termios) == -1)
+    {
         intf_ErrMsg( "intf error: tcgetattr" );
+    }
+
     if (tcgetattr(0, &p_intf->p_sys->new_termios) == -1)
+    {
         intf_ErrMsg( "intf error: tcgetattr" );
+    }
 
     p_intf->p_sys->new_termios.c_lflag &= ~ (ICANON | ISIG);
     p_intf->p_sys->new_termios.c_lflag |= (ECHO | ECHOCTL);
@@ -115,7 +120,9 @@ int intf_SysCreate( intf_thread_t *p_intf )
     p_intf->p_sys->new_termios.c_cc[VTIME] = 0;
 
     if (tcsetattr(0, TCSAFLUSH, &p_intf->p_sys->new_termios) == -1)
+    {
         intf_ErrMsg( "intf error: tcsetattr" );
+    }
 
     ioctl(p_intf->p_sys->i_tty_dev, VT_RELDISP, VT_ACKACQ);
 
@@ -126,17 +133,22 @@ int intf_SysCreate( intf_thread_t *p_intf )
     if( sigaction( SIGUSR1, &sig_tty, &p_intf->p_sys->sig_usr1 ) ||
         sigaction( SIGUSR2, &sig_tty, &p_intf->p_sys->sig_usr2 ) )
     {
-        intf_ErrMsg("intf error: can't set up signal handler (%s)\n", strerror(errno) );
+        intf_ErrMsg( "intf error: can't set up signal handler (%s)\n",
+                     strerror(errno) );
+        tcsetattr(0, 0, &p_intf->p_sys->old_termios);
         FBTextMode( p_intf->p_sys->i_tty_dev );
         return( 1 );
     }
 
     /* Set-up tty according to new signal handler */
-    if( ioctl(p_intf->p_sys->i_tty_dev, VT_GETMODE, &p_intf->p_sys->vt_mode) == -1 )
+    if( ioctl(p_intf->p_sys->i_tty_dev, VT_GETMODE, &p_intf->p_sys->vt_mode)
+        == -1 )
     {
-        intf_ErrMsg("intf error: cant get terminal mode (%s)\n", strerror(errno) );
+        intf_ErrMsg( "intf error: cant get terminal mode (%s)\n",
+                     strerror(errno) );
         sigaction( SIGUSR1, &p_intf->p_sys->sig_usr1, NULL );
         sigaction( SIGUSR2, &p_intf->p_sys->sig_usr2, NULL );
+        tcsetattr(0, 0, &p_intf->p_sys->old_termios);
         FBTextMode( p_intf->p_sys->i_tty_dev );
         return( 1 );
     }
@@ -148,9 +160,11 @@ int intf_SysCreate( intf_thread_t *p_intf )
 
     if( ioctl(p_intf->p_sys->i_tty_dev, VT_SETMODE, &vt_mode) == -1 )
     {
-        intf_ErrMsg("intf error: can't set terminal mode (%s)\n", strerror(errno) );
+        intf_ErrMsg( "intf error: can't set terminal mode (%s)\n",
+                     strerror(errno) );
         sigaction( SIGUSR1, &p_intf->p_sys->sig_usr1, NULL );
         sigaction( SIGUSR2, &p_intf->p_sys->sig_usr2, NULL );
+        tcsetattr(0, 0, &p_intf->p_sys->old_termios);
         FBTextMode( p_intf->p_sys->i_tty_dev );
         return( 1 );
     }
@@ -160,14 +174,17 @@ int intf_SysCreate( intf_thread_t *p_intf )
     {
         p_intf->p_vout = vout_CreateThread( NULL, 0,
                                             p_intf->p_sys->i_width,
-                                            p_intf->p_sys->i_height, NULL, 0, NULL );
+                                            p_intf->p_sys->i_height,
+                                            NULL, 0, NULL );
         if( p_intf->p_vout == NULL )                          /* XXX?? error */
         {
             intf_ErrMsg("intf error: can't create output thread\n" );
-            ioctl(p_intf->p_sys->i_tty_dev, VT_SETMODE, &p_intf->p_sys->vt_mode);
+            ioctl( p_intf->p_sys->i_tty_dev, VT_SETMODE,
+                   &p_intf->p_sys->vt_mode );
             sigaction( SIGUSR1, &p_intf->p_sys->sig_usr1, NULL );
             sigaction( SIGUSR2, &p_intf->p_sys->sig_usr2, NULL );
             free( p_intf->p_sys );
+            tcsetattr(0, 0, &p_intf->p_sys->old_termios);
             FBTextMode( p_intf->p_sys->i_tty_dev );
             return( 1 );
         }
@@ -224,8 +241,8 @@ void intf_SysManage( intf_thread_t *p_intf )
 /*****************************************************************************
  * FBSwitchDisplay: VT change signal handler
  *****************************************************************************
- * This function activate or desactivate the output of the thread. It is called
- * by the VT driver, on terminal change.
+ * This function activates or deactivates the output of the thread. It is
+ * called by the VT driver, on terminal change.
  *****************************************************************************/
 static void FBSwitchDisplay(int i_signal)
 {
index 228ff350da6109357db57dbe8ed94bb63286bc20..15c1e7724259fc795e24c426d3a7c72ac405d12e 100644 (file)
@@ -73,8 +73,6 @@ typedef struct vout_sys_s
  *****************************************************************************/
 static int     FBOpenDisplay   ( vout_thread_t *p_vout );
 static void    FBCloseDisplay  ( vout_thread_t *p_vout );
-static void    FBSetPalette    ( p_vout_thread_t p_vout,
-                                 u16 *red, u16 *green, u16 *blue, u16 *transp );
 
 /*****************************************************************************
  * vout_SysCreate: allocates FB video thread output method
@@ -108,7 +106,6 @@ int vout_SysCreate( vout_thread_t *p_vout, char *psz_display,
  *****************************************************************************/
 int vout_SysInit( vout_thread_t *p_vout )
 {
-    p_vout->p_set_palette       = FBSetPalette;
     return( 0 );
 }
 
@@ -186,6 +183,20 @@ void vout_SysDisplay( vout_thread_t *p_vout )
     ioctl( p_vout->p_sys->i_fb_dev, FBIOPAN_DISPLAY, &p_vout->p_sys->var_info );
 }
 
+/*****************************************************************************
+ * vout_SetPalette: sets an 8 bpp palette
+ *****************************************************************************
+ * This function sets the palette given as an argument. It does not return
+ * anything, but could later send information on which colors it was unable
+ * to set.
+ *****************************************************************************/
+void vout_SetPalette( p_vout_thread_t p_vout,
+                      u16 *red, u16 *green, u16 *blue, u16 *transp )
+{
+    struct fb_cmap cmap = { 0, 256, red, green, blue, transp };
+    ioctl( p_vout->p_sys->i_fb_dev, FBIOPUTCMAP, &cmap );
+}
+
 /* following functions are local */
 
 /*****************************************************************************
@@ -349,17 +360,4 @@ static void FBCloseDisplay( vout_thread_t *p_vout )
     close( p_vout->p_sys->i_fb_dev );
 }
 
-/*****************************************************************************
- * FBSetPalette: sets an 8 bpp palette
- *****************************************************************************
- * This function sets the palette given as an argument. It does not return
- * anything, but could later send information on which colors it was unable
- * to set.
- *****************************************************************************/
-static void    FBSetPalette   ( p_vout_thread_t p_vout,
-                                u16 *red, u16 *green, u16 *blue, u16 *transp )
-{
-    struct fb_cmap cmap = { 0, 256, red, green, blue, transp };
-    ioctl( p_vout->p_sys->i_fb_dev, FBIOPUTCMAP, &cmap );
-}
 
diff --git a/plugins/ggi/ggi.c b/plugins/ggi/ggi.c
new file mode 100644 (file)
index 0000000..2ff0e10
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * ggi.c : GGI plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "GGI";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: detect GGI_DISPLAY or whatever */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
index d1eac68e9c9142054556d359263986fd3591cdf9..c22d50752ddf41cf3fdb68e27da978b89cfdff80 100644 (file)
@@ -100,8 +100,6 @@ int intf_SysCreate( intf_thread_t *p_intf )
                                         NULL, 0,
                                         (void *)&p_intf->p_sys->p_display );
 
-    fprintf(stderr, "display is %i\n", p_intf->p_sys->p_display);
-    
     if( p_intf->p_vout == NULL )                                  /* error */
     {
         intf_ErrMsg("error: can't create video output thread\n" );
index 873f3354adb93d0735a11a2c62a302f1bbe4c43a..e3cdd9fff3aa857fb0f02195c35723347d9094da 100644 (file)
@@ -203,7 +203,6 @@ static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display, void *p_dat
     }
 
     /* give the data back to the interface */
-    fprintf(stderr, "display is %i\n", p_vout->p_sys->p_display);
     *(ggi_visual_t *)p_data = p_vout->p_sys->p_display;
 
     /* Find most appropriate mode */
@@ -237,7 +236,7 @@ static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display, void *p_dat
     {
         /* Get buffer address */
         p_vout->p_sys->p_buffer[ i_index ] =
-            ggiDBGetBuffer( p_vout->p_sys->p_display, i_index );
+            (ggi_directbuffer *)ggiDBGetBuffer( p_vout->p_sys->p_display, i_index );
         if( p_vout->p_sys->p_buffer[ i_index ] == NULL )
         {
             intf_ErrMsg("error: double buffering is not possible\n");
diff --git a/plugins/glide/glide.c b/plugins/glide/glide.c
new file mode 100644 (file)
index 0000000..cf9ed83
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * glide.c : 3dfx Glide plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "3dfx Glide";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: detect a 3dfx card */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
diff --git a/plugins/gnome/gnome.c b/plugins/gnome/gnome.c
new file mode 100644 (file)
index 0000000..fe626e5
--- /dev/null
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * gnome.c : Gnome plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "Gnome";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: detect an X display or Gnome libs */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+
+    /* optional functions */
+    p_vout->p_set_palette = vout_SetPalette;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
index 3dcbbd95cdc7eb2bfefbdaa2200b8da6b4f56a91..eec5edac452d3c88586821a9442ad3170606c682 100644 (file)
@@ -89,8 +89,6 @@ static int  X11CreateShmImage   ( vout_thread_t *p_vout, XImage **pp_ximage,
                                   XShmSegmentInfo *p_shm_info );
 static void X11DestroyShmImage  ( vout_thread_t *p_vout, XImage *p_ximage,
                                   XShmSegmentInfo *p_shm_info );
-static void X11SetPalette       ( p_vout_thread_t p_vout,
-                                  u16 *red, u16 *green, u16 *blue, u16 *transp );
 
 /*****************************************************************************
  * vout_SysCreate: allocate X11 video thread output method
@@ -134,9 +132,6 @@ int vout_SysInit( vout_thread_t *p_vout )
 {
     int i_err;
 
-    /* Initialize palette changing procedure */
-    p_vout->p_set_palette       = X11SetPalette;
-
     /* Create XImages using XShm extension - on failure, fall back to regular
      * way (and destroy the first image if it was created successfully) */
     if( p_vout->p_sys->b_shm )
@@ -157,7 +152,7 @@ int vout_SysInit( vout_thread_t *p_vout )
         }
         if( i_err )                                      /* an error occured */
         {
-            intf_Msg("XShm video sextension desactivated\n" );
+            intf_Msg("XShm video extension deactivated\n" );
             p_vout->p_sys->b_shm = 0;
         }
     }
@@ -303,6 +298,37 @@ void vout_SysDisplay( vout_thread_t *p_vout )
     }
 }
 
+/*****************************************************************************
+ * vout_SetPalette: sets an 8 bpp palette
+ *****************************************************************************
+ * This function sets the palette given as an argument. It does not return
+ * anything, but could later send information on which colors it was unable
+ * to set.
+ *****************************************************************************/
+void vout_SetPalette( p_vout_thread_t p_vout,
+                      u16 *red, u16 *green, u16 *blue, u16 *transp )
+{
+    int i;
+    XColor color[255];
+
+    intf_DbgMsg( "Palette change called\n" );
+
+    /* allocate palette */
+    for( i = 0; i < 255; i++ )
+    {
+        /* kludge: colors are indexed reversely because color 255 seems
+         * to be reserved for black even if we try to set it to white */
+        color[i].pixel = 255-i;
+        color[i].pad = 0;
+        color[i].flags = DoRed|DoGreen|DoBlue;
+        color[i].red = red[255-i];
+        color[i].blue = blue[255-i];
+        color[i].green = green[255-i];
+    }
+
+    XStoreColors( p_vout->p_sys->p_display, p_vout->p_sys->colormap, color, 256 );
+}
+
 /* following functions are local */
 
 /*****************************************************************************
@@ -659,34 +685,4 @@ static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage,
     }
 }
 
-/*****************************************************************************
- * X11SetPalette: sets an 8 bpp palette
- *****************************************************************************
- * This function sets the palette given as an argument. It does not return
- * anything, but could later send information on which colors it was unable
- * to set.
- *****************************************************************************/
-static void X11SetPalette       ( p_vout_thread_t p_vout,
-                                  u16 *red, u16 *green, u16 *blue, u16 *transp )
-{
-    int i;
-    XColor color[255];
-
-    intf_DbgMsg( "Palette change called\n" );
-
-    /* allocate palette */
-    for( i = 0; i < 255; i++ )
-    {
-        /* kludge: colors are indexed reversely because color 255 seems
-         * to be reserved for black even if we try to set it to white */
-        color[i].pixel = 255-i;
-        color[i].pad = 0;
-        color[i].flags = DoRed|DoGreen|DoBlue;
-        color[i].red = red[255-i];
-        color[i].blue = blue[255-i];
-        color[i].green = green[255-i];
-    }
-
-    XStoreColors( p_vout->p_sys->p_display, p_vout->p_sys->colormap, color, 256 );
-}
 
diff --git a/plugins/mga/mga.c b/plugins/mga/mga.c
new file mode 100644 (file)
index 0000000..10b4801
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * mga.c : Matrox Graphic Array plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "Matrox Acceleration";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: detect an MGA card ? */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
index dcf387a892a453ec139e86f9c9107e9460263e28..a8a59d19297ca3770b6a960031674058f625a8e0 100644 (file)
@@ -112,7 +112,7 @@ int vout_SysCreate( vout_thread_t *p_vout, char *psz_display,
  *****************************************************************************/
 int vout_SysInit( vout_thread_t *p_vout )
 {
-    int i_err, i_dummy;
+    int i_err;
 
     /* create the MGA output */
     p_vout->p_sys->p_mga->src_width = p_vout->i_width;
@@ -180,7 +180,7 @@ int vout_SysInit( vout_thread_t *p_vout )
         }
         if( i_err )                                      /* an error occured */
         {
-            intf_Msg("XShm video sextension desactivated\n" );
+            intf_Msg("XShm video sextension deactivated\n" );
             p_vout->p_sys->b_shm = 0;
         }
     }
index 14be4a55481e9351418e914d63b69ab6db78cb74..20031ddd865b5be21612e96ea30996795a048dea 100644 (file)
@@ -89,8 +89,6 @@ static int  X11CreateShmImage   ( vout_thread_t *p_vout, XImage **pp_ximage,
                                   XShmSegmentInfo *p_shm_info );
 static void X11DestroyShmImage  ( vout_thread_t *p_vout, XImage *p_ximage,
                                   XShmSegmentInfo *p_shm_info );
-static void X11SetPalette       ( p_vout_thread_t p_vout,
-                                  u16 *red, u16 *green, u16 *blue, u16 *transp );
 
 /*****************************************************************************
  * vout_SysCreate: allocate X11 video thread output method
@@ -134,9 +132,6 @@ int vout_SysInit( vout_thread_t *p_vout )
 {
     int i_err;
 
-    /* Initialize palette changing procedure */
-    p_vout->p_set_palette       = X11SetPalette;
-
     /* Create XImages using XShm extension - on failure, fall back to regular
      * way (and destroy the first image if it was created successfully) */
     if( p_vout->p_sys->b_shm )
@@ -157,7 +152,7 @@ int vout_SysInit( vout_thread_t *p_vout )
         }
         if( i_err )                                      /* an error occured */
         {
-            intf_Msg("XShm video sextension desactivated\n" );
+            intf_Msg("XShm video sextension deactivated\n" );
             p_vout->p_sys->b_shm = 0;
         }
     }
@@ -234,7 +229,8 @@ int vout_SysManage( vout_thread_t *p_vout )
     /*
      * Color/Grayscale or gamma change: in 8bpp, just change the colormap
      */
-    if( (p_vout->i_changes & VOUT_GRAYSCALE_CHANGE) && (p_vout->i_screen_depth == 8) )
+    if( (p_vout->i_changes & VOUT_GRAYSCALE_CHANGE)
+        && (p_vout->i_screen_depth == 8) )
     {
         /* FIXME: clear flags ?? */
     }
@@ -262,7 +258,8 @@ int vout_SysManage( vout_thread_t *p_vout )
         }
 
         /* Tell the video output thread that it will need to rebuild YUV
-         * tables. This is needed since conversion buffer size may have changed */
+         * tables. This is needed since conversion buffer size may have
+        * changed */
         p_vout->i_changes |= VOUT_YUV_CHANGE;
         intf_Msg("Video display resized (%dx%d)\n", p_vout->i_width, p_vout->i_height);
     }
@@ -303,6 +300,37 @@ void vout_SysDisplay( vout_thread_t *p_vout )
     }
 }
 
+/*****************************************************************************
+ * vout_SetPalette: sets an 8 bpp palette
+ *****************************************************************************
+ * This function sets the palette given as an argument. It does not return
+ * anything, but could later send information on which colors it was unable
+ * to set.
+ *****************************************************************************/
+void vout_SetPalette( p_vout_thread_t p_vout,
+                      u16 *red, u16 *green, u16 *blue, u16 *transp )
+{
+    int i;
+    XColor color[255];
+
+    intf_DbgMsg( "Palette change called\n" );
+
+    /* allocate palette */
+    for( i = 0; i < 255; i++ )
+    {
+        /* kludge: colors are indexed reversely because color 255 seems
+         * to be reserved for black even if we try to set it to white */
+        color[i].pixel = 255-i;
+        color[i].pad = 0;
+        color[i].flags = DoRed|DoGreen|DoBlue;
+        color[i].red = red[255-i];
+        color[i].blue = blue[255-i];
+        color[i].green = green[255-i];
+    }
+
+    XStoreColors( p_vout->p_sys->p_display, p_vout->p_sys->colormap, color, 256 );
+}
+
 /* following functions are local */
 
 /*****************************************************************************
@@ -661,34 +689,4 @@ static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage,
     }
 }
 
-/*****************************************************************************
- * X11SetPalette: sets an 8 bpp palette
- *****************************************************************************
- * This function sets the palette given as an argument. It does not return
- * anything, but could later send information on which colors it was unable
- * to set.
- *****************************************************************************/
-static void X11SetPalette       ( p_vout_thread_t p_vout,
-                                  u16 *red, u16 *green, u16 *blue, u16 *transp )
-{
-    int i;
-    XColor color[255];
-
-    intf_DbgMsg( "Palette change called\n" );
-
-    /* allocate palette */
-    for( i = 0; i < 255; i++ )
-    {
-        /* kludge: colors are indexed reversely because color 255 seems
-         * to be reserved for black even if we try to set it to white */
-        color[i].pixel = 255-i;
-        color[i].pad = 0;
-        color[i].flags = DoRed|DoGreen|DoBlue;
-        color[i].red = red[255-i];
-        color[i].blue = blue[255-i];
-        color[i].green = green[255-i];
-    }
-
-    XStoreColors( p_vout->p_sys->p_display, p_vout->p_sys->colormap, color, 256 );
-}
 
diff --git a/plugins/x11/x11.c b/plugins/x11/x11.c
new file mode 100644 (file)
index 0000000..3a104d3
--- /dev/null
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * x11.c : X11 plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void vout_GetPlugin( p_vout_thread_t p_vout );
+void intf_GetPlugin( p_intf_thread_t p_intf );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "X Window System";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = vout_GetPlugin;
+    p_info->intf_GetPlugin = intf_GetPlugin;
+    p_info->yuv_GetPlugin  = NULL;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    /* TODO: detect an X display */
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void vout_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_sys_create  = vout_SysCreate;
+    p_vout->p_sys_init    = vout_SysInit;
+    p_vout->p_sys_end     = vout_SysEnd;
+    p_vout->p_sys_destroy = vout_SysDestroy;
+    p_vout->p_sys_manage  = vout_SysManage;
+    p_vout->p_sys_display = vout_SysDisplay;
+
+    /* optional functions */
+    p_vout->p_set_palette = vout_SetPalette;
+}
+
+void intf_GetPlugin( p_intf_thread_t p_intf )
+{
+    p_intf->p_sys_create  = intf_SysCreate;
+    p_intf->p_sys_destroy = intf_SysDestroy;
+    p_intf->p_sys_manage  = intf_SysManage;
+}
+
diff --git a/plugins/yuv/video_yuv.c b/plugins/yuv/video_yuv.c
new file mode 100644 (file)
index 0000000..20a43e2
--- /dev/null
@@ -0,0 +1,526 @@
+/*****************************************************************************
+ * video_yuv.c: YUV transformation functions
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * Constants
+ *****************************************************************************/
+
+int     yuv_SysInit     ( vout_thread_t *p_vout );
+int     yuv_SysReset    ( vout_thread_t *p_vout );
+void    yuv_SysEnd      ( vout_thread_t *p_vout );
+
+/*****************************************************************************
+ * vout_InitYUV: allocate and initialize translations tables
+ *****************************************************************************
+ * This function will allocate memory to store translation tables, depending
+ * of the screen depth.
+ *****************************************************************************/
+int yuv_SysInit( vout_thread_t *p_vout )
+{
+    size_t      tables_size;                        /* tables size, in bytes */
+
+    /* Computes tables size - 3 Bpp use 32 bits pixel entries in tables */
+    switch( p_vout->i_bytes_per_pixel )
+    {
+    case 1:
+        tables_size = sizeof( u8 )
+                * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : PALETTE_TABLE_SIZE);
+        break;
+    case 2:
+        tables_size = sizeof( u16 )
+                * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
+        break;
+    case 3:
+    case 4:
+    default:
+        tables_size = sizeof( u32 )
+                * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
+        break;
+    }
+
+    /* Allocate memory */
+    p_vout->yuv.p_base = malloc( tables_size );
+    if( p_vout->yuv.p_base == NULL )
+    {
+        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        return( 1 );
+    }
+
+    /* Allocate memory for conversion buffer and offset array */
+    p_vout->yuv.p_buffer = malloc( VOUT_MAX_WIDTH * p_vout->i_bytes_per_pixel );
+    if( p_vout->yuv.p_buffer == NULL )
+    {
+        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        free( p_vout->yuv.p_base );
+        return( 1 );
+    }
+    p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );
+    if( p_vout->yuv.p_offset == NULL )
+    {
+        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        free( p_vout->yuv.p_base );
+        free( p_vout->yuv.p_buffer );
+        return( 1 );
+    }
+
+    /* Initialize tables */
+    SetYUV( p_vout );
+    return( 0 );
+}
+
+/*****************************************************************************
+ * yuv_SysReset: re-initialize translations tables
+ *****************************************************************************
+ * This function will initialize the tables allocated by vout_CreateTables and
+ * set functions pointers.
+ *****************************************************************************/
+int yuv_SysReset( vout_thread_t *p_vout )
+{
+    yuv_SysEnd( p_vout );
+    return( yuv_SysInit( p_vout ) );
+}
+
+/*****************************************************************************
+ * yuv_SysEnd: destroy translations tables
+ *****************************************************************************
+ * Free memory allocated by yuv_SysCreate.
+ *****************************************************************************/
+void yuv_SysEnd( vout_thread_t *p_vout )
+{
+    free( p_vout->yuv.p_base );
+    free( p_vout->yuv.p_buffer );
+    free( p_vout->yuv.p_offset );
+}
+
+/* following functions are local */
+
+/*****************************************************************************
+ * SetGammaTable: return intensity table transformed by gamma curve.
+ *****************************************************************************
+ * pi_table is a table of 256 entries from 0 to 255.
+ *****************************************************************************/
+void SetGammaTable( int *pi_table, double f_gamma )
+{
+    int         i_y;                                       /* base intensity */
+
+    /* Use exp(gamma) instead of gamma */
+    f_gamma = exp( f_gamma );
+
+    /* Build gamma table */
+    for( i_y = 0; i_y < 256; i_y++ )
+    {
+        pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256;
+    }
+ }
+
+/*****************************************************************************
+ * SetYUV: compute tables and set function pointers
++ *****************************************************************************/
+void SetYUV( vout_thread_t *p_vout )
+{
+    int         pi_gamma[256];                                /* gamma table */
+    int         i_index;                                  /* index in tables */
+
+    /* Build gamma table */
+    SetGammaTable( pi_gamma, p_vout->f_gamma );
+
+    /*
+     * Set pointers and build YUV tables
+     */
+    if( p_vout->b_grayscale )
+    {
+        /* Grayscale: build gray table */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            {
+                u16 bright[256], transp[256];
+
+                p_vout->yuv.yuv.p_gray8 =  (u8 *)p_vout->yuv.p_base + GRAY_MARGIN;
+                for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
+                {
+                    p_vout->yuv.yuv.p_gray8[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
+                    p_vout->yuv.yuv.p_gray8[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
+                }
+                for( i_index = 0; i_index < 256; i_index++)
+                {
+                    p_vout->yuv.yuv.p_gray8[ i_index ] = pi_gamma[ i_index ];
+                    bright[ i_index ] = i_index << 8;
+                    transp[ i_index ] = 0;
+                }
+                /* the colors have been allocated, we can set the palette */
+                p_vout->p_set_palette( p_vout, bright, bright, bright, transp );
+                p_vout->i_white_pixel = 0xff;
+                p_vout->i_black_pixel = 0x00;
+                p_vout->i_gray_pixel = 0x44;
+                p_vout->i_blue_pixel = 0x3b;
+
+                break;
+            }
+        case 2:
+            p_vout->yuv.yuv.p_gray16 =  (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
+            for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_gray16[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
+                p_vout->yuv.yuv.p_gray16[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++)
+            {
+                p_vout->yuv.yuv.p_gray16[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
+            }
+            break;
+        case 3:
+        case 4:
+            p_vout->yuv.yuv.p_gray32 =  (u32 *)p_vout->yuv.p_base + GRAY_MARGIN;
+            for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_gray32[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
+                p_vout->yuv.yuv.p_gray32[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++)
+            {
+                p_vout->yuv.yuv.p_gray32[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
+            }
+            break;
+         }
+    }
+    else
+    {
+        /* Color: build red, green and blue tables */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            {
+                #define RGB_MIN 0
+                #define RGB_MAX 255
+                #define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 )
+
+                int y,u,v;
+                int r,g,b;
+                int uvr, uvg, uvb;
+                int i = 0, j = 0;
+                u16 red[256], green[256], blue[256], transp[256];
+                unsigned char lookup[PALETTE_TABLE_SIZE];
+
+                p_vout->yuv.yuv.p_rgb8 = (u8 *)p_vout->yuv.p_base;
+
+                /* this loop calculates the intersection of an YUV box
+                 * and the RGB cube. */
+                for ( y = 0; y <= 256; y += 16 )
+                {
+                    for ( u = 0; u <= 256; u += 32 )
+                    for ( v = 0; v <= 256; v += 32 )
+                    {
+                        uvr = (V_RED_COEF*(v-128)) >> SHIFT;
+                        uvg = (U_GREEN_COEF*(u-128) + V_GREEN_COEF*(v-128)) >> SHIFT;
+                        uvb = (U_BLUE_COEF*(u-128)) >> SHIFT;
+                        r = y + uvr;
+                        g = y + uvg;
+                        b = y + uvb;
+
+                        if( r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN
+                                && r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX )
+                        {
+                            /* this one should never happen unless someone fscked up my code */
+                            if(j == 256) { intf_ErrMsg( "vout error: no colors left to build palette\n" ); break; }
+
+                            /* clip the colors */
+                            red[j] = CLIP( r );
+                            green[j] = CLIP( g );
+                            blue[j] = CLIP( b );
+                            transp[j] = 0;
+
+                            /* allocate color */
+                            lookup[i] = 1;
+                            p_vout->yuv.yuv.p_rgb8[i++] = j;
+                            j++;
+                        }
+                        else
+                        {
+                            lookup[i] = 0;
+                            p_vout->yuv.yuv.p_rgb8[i++] = 0;
+                        }
+                    }
+                    i += 128-81;
+                }
+
+                /* the colors have been allocated, we can set the palette */
+                /* there will eventually be a way to know which colors
+                 * couldn't be allocated and try to find a replacement */
+                p_vout->p_set_palette( p_vout, red, green, blue, transp );
+
+                p_vout->i_white_pixel = 0xff;
+                p_vout->i_black_pixel = 0x00;
+                p_vout->i_gray_pixel = 0x44;
+                p_vout->i_blue_pixel = 0x3b;
+
+                i = 0;
+                /* this loop allocates colors that got outside
+                 * the RGB cube */
+                for ( y = 0; y <= 256; y += 16 )
+                {
+                    for ( u = 0; u <= 256; u += 32 )
+                    for ( v = 0; v <= 256; v += 32 )
+                    {
+                        int u2, v2;
+                        int dist, mindist = 100000000;
+
+                        if( lookup[i] || y==0)
+                        {
+                            i++;
+                            continue;
+                        }
+
+                        /* heavy. yeah. */
+                        for( u2 = 0; u2 <= 256; u2 += 32 )
+                        for( v2 = 0; v2 <= 256; v2 += 32 )
+                        {
+                            j = ((y>>4)<<7) + (u2>>5)*9 + (v2>>5);
+                            dist = (u-u2)*(u-u2) + (v-v2)*(v-v2);
+                            if( lookup[j] )
+                            /* find the nearest color */
+                            if( dist < mindist )
+                            {
+                                p_vout->yuv.yuv.p_rgb8[i] = p_vout->yuv.yuv.p_rgb8[j];
+                                mindist = dist;
+                            }
+                            j -= 128;
+                            if( lookup[j] )
+                            /* find the nearest color */
+                            if( dist + 128 < mindist )
+                            {
+                                p_vout->yuv.yuv.p_rgb8[i] = p_vout->yuv.yuv.p_rgb8[j];
+                                mindist = dist + 128;
+                            }
+                        }
+                        i++;
+                    }
+                    i += 128-81;
+                }
+
+                break;
+            }
+        case 2:
+            p_vout->yuv.yuv.p_rgb16 = (u16 *)p_vout->yuv.p_base;
+            for( i_index = 0; i_index < RED_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
+                p_vout->yuv.yuv.p_rgb16[RED_OFFSET + 256 + i_index] =        RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 );
+            }
+            for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 );
+                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + 256 + i_index] =          RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 );
+            }
+            for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] );
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
+                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
+            }
+            break;
+        case 3:
+        case 4:
+            p_vout->yuv.yuv.p_rgb32 = (u32 *)p_vout->yuv.p_base;
+            for( i_index = 0; i_index < RED_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
+                p_vout->yuv.yuv.p_rgb32[RED_OFFSET + 256 + i_index] =        RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 );
+            }
+            for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 );
+                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + 256 + i_index] =          RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 );
+            }
+            for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] );
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
+                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
+            }
+            break;
+        }
+    }
+
+    /*
+     * Set functions pointers
+     */
+    if( p_vout->b_grayscale )
+    {
+        /* Grayscale */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            break;
+        case 2:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            break;
+        case 3:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            break;
+        case 4:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            break;
+        }
+    }
+    else
+    {
+        /* Color */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertYUV420RGB8;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertYUV422RGB8;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertYUV444RGB8;
+            break;
+        case 2:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB16;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB16;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB16;
+            break;
+        case 3:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB24;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB24;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB24;
+            break;
+        case 4:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB32;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB32;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB32;
+            break;
+        }
+    }
+}
+
+/*****************************************************************************
+ * SetOffset: build offset array for conversion functions
+ *****************************************************************************
+ * This function will build an offset array used in later conversion functions.
+ * It will also set horizontal and vertical scaling indicators.
+ *****************************************************************************/
+void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
+                boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset )
+{
+    int i_x;                                    /* x position in destination */
+    int i_scale_count;                                     /* modulo counter */
+
+    /*
+     * Prepare horizontal offset array
+     */
+    if( i_pic_width - i_width > 0 )
+    {
+        /* Prepare scaling array for horizontal extension */
+        *pb_h_scaling =  1;
+        i_scale_count =         i_pic_width;
+        for( i_x = i_width; i_x--; )
+        {
+            while( (i_scale_count -= i_width) > 0 )
+            {
+                *p_offset++ = 0;
+            }
+            *p_offset++ = 1;
+            i_scale_count += i_pic_width;
+        }
+    }
+    else if( i_pic_width - i_width < 0 )
+    {
+        /* Prepare scaling array for horizontal reduction */
+        *pb_h_scaling =  1;
+        i_scale_count =         i_pic_width;
+        for( i_x = i_pic_width; i_x--; )
+        {
+            *p_offset = 1;
+            while( (i_scale_count -= i_pic_width) >= 0 )
+            {
+                *p_offset += 1;
+            }
+            p_offset++;
+            i_scale_count += i_width;
+        }
+    }
+    else
+    {
+        /* No horizontal scaling: YUV conversion is done directly to picture */
+        *pb_h_scaling = 0;
+    }
+
+    /*
+     * Set vertical scaling indicator
+     */
+    if( i_pic_height - i_height > 0 )
+    {
+        *pi_v_scaling = 1;
+    }
+    else if( i_pic_height - i_height < 0 )
+    {
+        *pi_v_scaling = -1;
+    }
+    else
+    {
+        *pi_v_scaling = 0;
+    }
+}
+
diff --git a/plugins/yuv/video_yuv.h b/plugins/yuv/video_yuv.h
new file mode 100644 (file)
index 0000000..3d7feff
--- /dev/null
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * video_yuv.h: YUV transformation functions
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Constants
+ *****************************************************************************/
+
+/* Margins and offsets in conversion tables - Margins are used in case a RGB
+ * RGB conversion would give a value outside the 0-255 range. Offsets have been
+ * calculated to avoid using the same cache line for 2 tables. conversion tables
+ * are 2*MARGIN + 256 long and stores pixels.*/
+#define RED_MARGIN      178
+#define GREEN_MARGIN    135
+#define BLUE_MARGIN     224
+#define RED_OFFSET      1501                                 /* 1323 to 1935 */
+#define GREEN_OFFSET    135                                      /* 0 to 526 */
+#define BLUE_OFFSET     818                                   /* 594 to 1298 */
+#define RGB_TABLE_SIZE  1935                             /* total table size */
+
+#define GRAY_MARGIN     384
+#define GRAY_TABLE_SIZE 1024                             /* total table size */
+
+#define PALETTE_TABLE_SIZE 2176          /* YUV -> 8bpp palette lookup table */
+
+/* macros used for YUV pixel conversions */
+#define SHIFT 20
+#define U_GREEN_COEF    ((int)(-0.391 * (1<<SHIFT) / 1.164))
+#define U_BLUE_COEF     ((int)(2.018 * (1<<SHIFT) / 1.164))
+#define V_RED_COEF      ((int)(1.596 * (1<<SHIFT) / 1.164))
+#define V_GREEN_COEF    ((int)(-0.813 * (1<<SHIFT) / 1.164))
+
+/* argument lists for YUV functions */
+#define YUV_ARGS_8BPP p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+#define YUV_ARGS_16BPP p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+#define YUV_ARGS_24BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+#define YUV_ARGS_32BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+void SetGammaTable        ( int *pi_table, double f_gamma );
+void SetYUV               ( vout_thread_t *p_vout );
+void SetOffset            ( int i_width, int i_height, int i_pic_width,
+                            int i_pic_height, boolean_t *pb_h_scaling,
+                            int *pi_v_scaling, int *p_offset );
+
+void ConvertY4Gray8       ( YUV_ARGS_8BPP );
+void ConvertYUV420RGB8    ( YUV_ARGS_8BPP );
+void ConvertYUV422RGB8    ( YUV_ARGS_8BPP );
+void ConvertYUV444RGB8    ( YUV_ARGS_8BPP );
+
+void ConvertY4Gray16      ( YUV_ARGS_16BPP );
+void ConvertYUV420RGB16   ( YUV_ARGS_16BPP );
+void ConvertYUV422RGB16   ( YUV_ARGS_16BPP );
+void ConvertYUV444RGB16   ( YUV_ARGS_16BPP );
+
+void ConvertY4Gray24      ( YUV_ARGS_24BPP );
+void ConvertYUV420RGB24   ( YUV_ARGS_24BPP );
+void ConvertYUV422RGB24   ( YUV_ARGS_24BPP );
+void ConvertYUV444RGB24   ( YUV_ARGS_24BPP );
+
+void ConvertY4Gray32      ( YUV_ARGS_32BPP );
+void ConvertYUV420RGB32   ( YUV_ARGS_32BPP );
+void ConvertYUV422RGB32   ( YUV_ARGS_32BPP );
+void ConvertYUV444RGB32   ( YUV_ARGS_32BPP );
+
diff --git a/plugins/yuv/video_yuv15.c b/plugins/yuv/video_yuv15.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/plugins/yuv/video_yuv16.c b/plugins/yuv/video_yuv16.c
new file mode 100644 (file)
index 0000000..7fec511
--- /dev/null
@@ -0,0 +1,291 @@
+/*****************************************************************************
+ * video_yuv16.c: YUV transformation functions for 16bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+#include "video_yuv_macros.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray16: grayscale YUV 4:x:x to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertY4Gray16( YUV_ARGS_16BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_chroma_width;                    /* chroma width, not used */
+    u16 *       p_gray;                             /* base conversion table */
+    u16 *       p_pic_start;       /* beginning of the current line for copy */
+    u16 *       p_buffer_start;                   /* conversion buffer start */
+    u16 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    p_gray =            p_vout->yuv.yuv.p_gray16;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(400, 2);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV420RGB16( YUV_ARGS_16BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_uval, i_vval;                           /* U and V samples */
+    int         i_red, i_green, i_blue;          /* U and V modified samples */
+    int         i_chroma_width;                              /* chroma width */
+    u16 *       p_yuv;                              /* base conversion table */
+    u16 *       p_ybase;                     /* Y dependant conversion table */
+    u16 *       p_pic_start;       /* beginning of the current line for copy */
+    u16 *       p_buffer_start;                   /* conversion buffer start */
+    u16 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_yuv =             p_vout->yuv.yuv.p_rgb16;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(420, 2);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV422RGB16( YUV_ARGS_16BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_uval, i_vval;                           /* U and V samples */
+    int         i_red, i_green, i_blue;          /* U and V modified samples */
+    int         i_chroma_width;                              /* chroma width */
+    u16 *       p_yuv;                              /* base conversion table */
+    u16 *       p_ybase;                     /* Y dependant conversion table */
+    u16 *       p_pic_start;       /* beginning of the current line for copy */
+    u16 *       p_buffer_start;                   /* conversion buffer start */
+    u16 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_yuv =             p_vout->yuv.yuv.p_rgb16;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(422, 2);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV444RGB16( YUV_ARGS_16BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_uval, i_vval;                           /* U and V samples */
+    int         i_red, i_green, i_blue;          /* U and V modified samples */
+    int         i_chroma_width;                    /* chroma width, not used */
+    u16 *       p_yuv;                              /* base conversion table */
+    u16 *       p_ybase;                     /* Y dependant conversion table */
+    u16 *       p_pic_start;       /* beginning of the current line for copy */
+    u16 *       p_buffer_start;                   /* conversion buffer start */
+    u16 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    p_yuv =             p_vout->yuv.yuv.p_rgb16;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(444, 2);
+    }
+}
+
diff --git a/plugins/yuv/video_yuv24.c b/plugins/yuv/video_yuv24.c
new file mode 100644 (file)
index 0000000..7a77686
--- /dev/null
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * video_yuv24.c: YUV transformation functions for 24 bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+#include "video_yuv_macros.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray24: grayscale YUV 4:x:x to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertY4Gray24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, grayscale, bpp = 24\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV420RGB24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 420, bpp = 24\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB24: color YUV 4:2:2 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV422RGB24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 24\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB24: color YUV 4:4:4 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV444RGB24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 24\n" );
+}
+
diff --git a/plugins/yuv/video_yuv32.c b/plugins/yuv/video_yuv32.c
new file mode 100644 (file)
index 0000000..b63da92
--- /dev/null
@@ -0,0 +1,291 @@
+/*****************************************************************************
+ * video_yuv32.c: YUV transformation functions for 32 bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+#include "video_yuv_macros.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertY4Gray32( YUV_ARGS_32BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_chroma_width;                    /* chroma width, not used */
+    u32 *       p_gray;                             /* base conversion table */
+    u32 *       p_pic_start;       /* beginning of the current line for copy */
+    u32 *       p_buffer_start;                   /* conversion buffer start */
+    u32 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    p_gray =            p_vout->yuv.yuv.p_gray32;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(400, 4);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertYUV420RGB32( YUV_ARGS_32BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_uval, i_vval;                           /* U and V samples */
+    int         i_red, i_green, i_blue;          /* U and V modified samples */
+    int         i_chroma_width;                              /* chroma width */
+    u32 *       p_yuv;                              /* base conversion table */
+    u32 *       p_ybase;                     /* Y dependant conversion table */
+    u32 *       p_pic_start;       /* beginning of the current line for copy */
+    u32 *       p_buffer_start;                   /* conversion buffer start */
+    u32 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_yuv =             p_vout->yuv.yuv.p_rgb32;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(420, 4);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertYUV422RGB32( YUV_ARGS_32BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_uval, i_vval;                           /* U and V samples */
+    int         i_red, i_green, i_blue;          /* U and V modified samples */
+    int         i_chroma_width;                              /* chroma width */
+    u32 *       p_yuv;                              /* base conversion table */
+    u32 *       p_ybase;                     /* Y dependant conversion table */
+    u32 *       p_pic_start;       /* beginning of the current line for copy */
+    u32 *       p_buffer_start;                   /* conversion buffer start */
+    u32 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_yuv =             p_vout->yuv.yuv.p_rgb32;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(422, 4);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertYUV444RGB32( YUV_ARGS_32BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_uval, i_vval;                           /* U and V samples */
+    int         i_red, i_green, i_blue;          /* U and V modified samples */
+    int         i_chroma_width;                    /* chroma width, not used */
+    u32 *       p_yuv;                              /* base conversion table */
+    u32 *       p_ybase;                     /* Y dependant conversion table */
+    u32 *       p_pic_start;       /* beginning of the current line for copy */
+    u32 *       p_buffer_start;                   /* conversion buffer start */
+    u32 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    p_yuv =             p_vout->yuv.yuv.p_rgb32;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(444, 4);
+    }
+}
+
diff --git a/plugins/yuv/video_yuv8.c b/plugins/yuv/video_yuv8.c
new file mode 100644 (file)
index 0000000..15c6b8d
--- /dev/null
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * video_yuv8.c: YUV transformation functions for 8bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+#include "video_yuv_macros.h"
+#include "video_yuv_macros_8bpp.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray8: grayscale YUV 4:x:x to RGB 8 bpp
+ *****************************************************************************/
+void ConvertY4Gray8( YUV_ARGS_8BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_chroma_width;                    /* chroma width, not used */
+    u8 *        p_gray;                             /* base conversion table */
+    u8 *        p_pic_start;       /* beginning of the current line for copy */
+    u8 *        p_buffer_start;                   /* conversion buffer start */
+    u8 *        p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    p_gray =            p_vout->yuv.yuv.p_gray8;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        /* Do YUV conversion to buffer - YUV picture is always formed of 16
+         * pixels wide blocks */
+        for( i_x = i_width / 16; i_x--;  )
+        {
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
+        }
+
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH;
+        SCALE_HEIGHT(400, 1);
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB8: color YUV 4:2:0 to RGB 8 bpp
+ *****************************************************************************/
+void ConvertYUV420RGB8( YUV_ARGS_8BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         b_jump_uv;                       /* should we jump u and v ? */
+    int         i_real_y;                                           /* y % 4 */
+    u8 *        p_lookup;                                    /* lookup table */
+    int         i_chroma_width;                              /* chroma width */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /* 
+     * The dither matrices
+     */
+    int dither10[4] = {  0x0,  0x8,  0x2,  0xa };
+    int dither11[4] = {  0xc,  0x4,  0xe,  0x6 };
+    int dither12[4] = {  0x3,  0xb,  0x1,  0x9 };
+    int dither13[4] = {  0xf,  0x7,  0xd,  0x5 };
+
+    int dither20[4] = {  0x0, 0x10,  0x4, 0x14 };
+    int dither21[4] = { 0x18,  0x8, 0x1c,  0xc };
+    int dither22[4] = {  0x6, 0x16,  0x2, 0x12 };
+    int dither23[4] = { 0x1e,  0xe, 0x1a,  0xa };
+
+    return;
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_offset_start =    p_vout->yuv.p_offset;
+    p_lookup =          p_vout->yuv.p_base;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    i_real_y = 0;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Do horizontal and vertical scaling */
+        SCALE_WIDTH_DITHER( 420 );
+        SCALE_HEIGHT_DITHER( 420 );
+    }
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB8: color YUV 4:2:2 to RGB 8 bpp
+ *****************************************************************************/
+void ConvertYUV422RGB8( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 8\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB8: color YUV 4:4:4 to RGB 8 bpp
+ *****************************************************************************/
+void ConvertYUV444RGB8( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 8\n" );
+}
+
diff --git a/plugins/yuv/video_yuv_macros.h b/plugins/yuv/video_yuv_macros.h
new file mode 100644 (file)
index 0000000..d054adb
--- /dev/null
@@ -0,0 +1,161 @@
+/*****************************************************************************
+ * video_yuv_macros_truecolor.h: YUV transformation macros for truecolor
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * CONVERT_YUV_PIXEL, CONVERT_Y_PIXEL: pixel conversion blocks
+ *****************************************************************************
+ * These conversion routines are used by YUV conversion functions.
+ * conversion are made from p_y, p_u, p_v, which are modified, to p_buffer,
+ * which is also modified.
+ *****************************************************************************/
+#define CONVERT_Y_PIXEL( BPP )                                                \
+    /* Only Y sample is present */                                            \
+    p_ybase = p_yuv + *p_y++;                                                 \
+    *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128)>>SHIFT) + i_red] |     \
+        p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT)       \
+        + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128)>>SHIFT) + i_blue];
+
+#define CONVERT_YUV_PIXEL( BPP )                                              \
+    /* Y, U and V samples are present */                                      \
+    i_uval =    *p_u++;                                                       \
+    i_vval =    *p_v++;                                                       \
+    i_red =     (V_RED_COEF * i_vval) >> SHIFT;                               \
+    i_green =   (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT;     \
+    i_blue =    (U_BLUE_COEF * i_uval) >> SHIFT;                              \
+    CONVERT_Y_PIXEL( BPP )                                                    \
+
+/*****************************************************************************
+ * SCALE_WIDTH: scale a line horizontally
+ *****************************************************************************
+ * This macro scales a line using rendering buffer and offset array. It works
+ * for 1, 2 and 4 Bpp.
+ *****************************************************************************/
+#define SCALE_WIDTH                                                           \
+    if( b_horizontal_scaling )                                                \
+    {                                                                         \
+        /* Horizontal scaling, conversion has been done to buffer.            \
+         * Rewind buffer and offset, then copy and scale line */              \
+        p_buffer = p_buffer_start;                                            \
+        p_offset = p_offset_start;                                            \
+        for( i_x = i_pic_width / 16; i_x--; )                                 \
+        {                                                                     \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+        }                                                                     \
+        p_pic += i_pic_line_width;                                            \
+    }                                                                         \
+    else                                                                      \
+    {                                                                         \
+        /* No scaling, conversion has been done directly in picture memory.   \
+         * Increment of picture pointer to end of line is still needed */     \
+        p_pic += i_pic_width + i_pic_line_width;                              \
+    }                                                                         \
+
+/*****************************************************************************
+ * SCALE_HEIGHT: handle vertical scaling
+ *****************************************************************************
+ * This macro handle vertical scaling for a picture. CHROMA may be 420, 422 or
+ * 444 for RGB conversion, or 400 for gray conversion. It works for 1, 2, 3
+ * and 4 Bpp.
+ *****************************************************************************/
+#define SCALE_HEIGHT( CHROMA, BPP )                                           \
+    /* If line is odd, rewind 4:2:0 U and V samples */                        \
+    if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) )                \
+    {                                                                         \
+        p_u -= i_chroma_width;                                                \
+        p_v -= i_chroma_width;                                                \
+    }                                                                         \
+                                                                              \
+    /*                                                                        \
+     * Handle vertical scaling. The current line can be copied or next one    \
+     * can be ignored.                                                        \
+     */                                                                       \
+    switch( i_vertical_scaling )                                              \
+    {                                                                         \
+    case -1:                             /* vertical scaling factor is < 1 */ \
+        while( (i_scale_count -= i_pic_height) >= 0 )                         \
+        {                                                                     \
+            /* Height reduction: skip next source line */                     \
+            p_y += i_width;                                                   \
+            i_y++;                                                            \
+            if( (CHROMA == 420) || (CHROMA == 422) )                          \
+            {                                                                 \
+                if( i_y & 0x1 )                                               \
+                {                                                             \
+                    p_u += i_chroma_width;                                    \
+                    p_v += i_chroma_width;                                    \
+                }                                                             \
+            }                                                                 \
+            else if( CHROMA == 444 )                                          \
+            {                                                                 \
+                p_u += i_width;                                               \
+                p_v += i_width;                                               \
+            }                                                                 \
+        }                                                                     \
+        i_scale_count += i_height;                                            \
+        break;                                                                \
+    case 1:                              /* vertical scaling factor is > 1 */ \
+        while( (i_scale_count -= i_height) > 0 )                              \
+        {                                                                     \
+            /* Height increment: copy previous picture line */                \
+            for( i_x = i_pic_width / 16; i_x--; )                             \
+            {                                                                 \
+                *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );           \
+                *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );           \
+                if( BPP > 1 )                               /* 2, 3, 4 Bpp */ \
+                {                                                             \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                }                                                             \
+                if( BPP > 2 )                                  /* 3, 4 Bpp */ \
+                {                                                             \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                }                                                             \
+                if( BPP > 3 )                                     /* 4 Bpp */ \
+                {                                                             \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                }                                                             \
+            }                                                                 \
+            p_pic +=        i_pic_line_width;                                 \
+            p_pic_start +=  i_pic_line_width;                                 \
+        }                                                                     \
+        i_scale_count += i_pic_height;                                        \
+        break;                                                                \
+    }                                                                         \
+
diff --git a/plugins/yuv/video_yuv_macros_8bpp.h b/plugins/yuv/video_yuv_macros_8bpp.h
new file mode 100644 (file)
index 0000000..116f7ae
--- /dev/null
@@ -0,0 +1,175 @@
+/*****************************************************************************
+ * video_yuv_macros_8bpp.h: YUV transformation macros for 8bpp
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * CONVERT_4YUV_PIXELS: dither 4 pixels in 8 bpp
+ *****************************************************************************
+ * These macros dither 4 pixels in 8 bpp
+ *****************************************************************************/
+#define CONVERT_4YUV_PIXELS( CHROMA )                                         \
+    *p_pic++ = p_lookup[                                                      \
+        (((*p_y++ + dither10[i_real_y]) >> 4) << 7)                           \
+      + ((*p_u + dither20[i_real_y]) >> 5) * 9                                \
+      + ((*p_v + dither20[i_real_y]) >> 5) ];                                 \
+    *p_pic++ = p_lookup[                                                      \
+        (((*p_y++ + dither11[i_real_y]) >> 4) << 7)                           \
+      + ((*p_u++ + dither21[i_real_y]) >> 5) * 9                              \
+      + ((*p_v++ + dither21[i_real_y]) >> 5) ];                               \
+    *p_pic++ = p_lookup[                                                      \
+        (((*p_y++ + dither12[i_real_y]) >> 4) << 7)                           \
+      + ((*p_u + dither22[i_real_y]) >> 5) * 9                                \
+      + ((*p_v + dither22[i_real_y]) >> 5) ];                                 \
+    *p_pic++ = p_lookup[                                                      \
+        (((*p_y++ + dither13[i_real_y]) >> 4) << 7)                           \
+      + ((*p_u++ + dither23[i_real_y]) >> 5) * 9                              \
+      + ((*p_v++ + dither23[i_real_y]) >> 5) ];                               \
+
+/*****************************************************************************
+ * CONVERT_4YUV_PIXELS_SCALE: dither and scale 4 pixels in 8 bpp
+ *****************************************************************************
+ * These macros dither 4 pixels in 8 bpp, with horizontal scaling
+ *****************************************************************************/
+#define CONVERT_4YUV_PIXELS_SCALE( CHROMA )                                   \
+    *p_pic++ = p_lookup[                                                      \
+        ( ((*p_y + dither10[i_real_y]) >> 4) << 7)                            \
+        + ((*p_u + dither20[i_real_y]) >> 5) * 9                              \
+        + ((*p_v + dither20[i_real_y]) >> 5) ];                               \
+    b_jump_uv += *p_offset;                                                   \
+    p_y += *p_offset;                                                         \
+    p_u += *p_offset   & b_jump_uv;                                           \
+    p_v += *p_offset++ & b_jump_uv;                                           \
+    *p_pic++ = p_lookup[                                                      \
+        ( ((*p_y + dither11[i_real_y]) >> 4) << 7)                            \
+        + ((*p_u + dither21[i_real_y]) >> 5) * 9                              \
+        + ((*p_v + dither21[i_real_y]) >> 5) ];                               \
+    b_jump_uv += *p_offset;                                                   \
+    p_y += *p_offset;                                                         \
+    p_u += *p_offset   & b_jump_uv;                                           \
+    p_v += *p_offset++ & b_jump_uv;                                           \
+    *p_pic++ = p_lookup[                                                      \
+        ( ((*p_y + dither12[i_real_y]) >> 4) << 7)                            \
+        + ((*p_u + dither22[i_real_y]) >> 5) * 9                              \
+        + ((*p_v + dither22[i_real_y]) >> 5) ];                               \
+    b_jump_uv += *p_offset;                                                   \
+    p_y += *p_offset;                                                         \
+    p_u += *p_offset   & b_jump_uv;                                           \
+    p_v += *p_offset++ & b_jump_uv;                                           \
+    *p_pic++ = p_lookup[                                                      \
+        ( ((*p_y + dither13[i_real_y]) >> 4) << 7)                            \
+        + ((*p_u + dither23[i_real_y]) >> 5) * 9                              \
+        + ((*p_v + dither23[i_real_y]) >> 5) ];                               \
+    b_jump_uv += *p_offset;                                                   \
+    p_y += *p_offset;                                                         \
+    p_u += *p_offset   & b_jump_uv;                                           \
+    p_v += *p_offset++ & b_jump_uv;                                           \
+
+/*****************************************************************************
+ * SCALE_WIDTH_DITHER: scale a line horizontally for dithered 8 bpp
+ *****************************************************************************
+ * This macro scales a line using an offset array.
+ *****************************************************************************/
+#define SCALE_WIDTH_DITHER( CHROMA )                                          \
+    if( b_horizontal_scaling )                                                \
+    {                                                                         \
+        /* Horizontal scaling, but we can't use a buffer due to dither */     \
+        p_offset = p_offset_start;                                            \
+        b_jump_uv = 0;                                                        \
+        for( i_x = i_pic_width / 16; i_x--; )                                 \
+        {                                                                     \
+            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
+            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
+            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
+            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
+        }                                                                     \
+    }                                                                         \
+    else                                                                      \
+    {                                                                         \
+        for( i_x = i_width / 16; i_x--;  )                                    \
+        {                                                                     \
+            CONVERT_4YUV_PIXELS( CHROMA )                                     \
+            CONVERT_4YUV_PIXELS( CHROMA )                                     \
+            CONVERT_4YUV_PIXELS( CHROMA )                                     \
+            CONVERT_4YUV_PIXELS( CHROMA )                                     \
+        }                                                                     \
+    }                                                                         \
+    /* Increment of picture pointer to end of line is still needed */         \
+    p_pic += i_pic_line_width;                                                \
+    i_real_y = (i_real_y + 1) & 0x3;                                          \
+
+/*****************************************************************************
+ * SCALE_HEIGHT_DITHER: handle vertical scaling for dithered 8 bpp
+ *****************************************************************************
+ * This macro handles vertical scaling for a picture. CHROMA may be 420, 422 or
+ * 444 for RGB conversion, or 400 for gray conversion.
+ *****************************************************************************/
+#define SCALE_HEIGHT_DITHER( CHROMA )                                         \
+                                                                              \
+    /* If line is odd, rewind 4:2:0 U and V samples */                        \
+    if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) )                \
+    {                                                                         \
+        p_u -= i_chroma_width;                                                \
+        p_v -= i_chroma_width;                                                \
+    }                                                                         \
+                                                                              \
+    /*                                                                        \
+     * Handle vertical scaling. The current line can be copied or next one    \
+     * can be ignored.                                                        \
+     */                                                                       \
+                                                                              \
+    switch( i_vertical_scaling )                                              \
+    {                                                                         \
+    case -1:                             /* vertical scaling factor is < 1 */ \
+        while( (i_scale_count -= i_pic_height) >= 0 )                         \
+        {                                                                     \
+            /* Height reduction: skip next source line */                     \
+            p_y += i_width;                                                   \
+            i_y++;                                                            \
+            if( (CHROMA == 420) || (CHROMA == 422) )                          \
+            {                                                                 \
+                if( i_y & 0x1 )                                               \
+                {                                                             \
+                    p_u += i_chroma_width;                                    \
+                    p_v += i_chroma_width;                                    \
+                }                                                             \
+            }                                                                 \
+            else if( CHROMA == 444 )                                          \
+            {                                                                 \
+                p_u += i_width;                                               \
+                p_v += i_width;                                               \
+            }                                                                 \
+        }                                                                     \
+        i_scale_count += i_height;                                            \
+        break;                                                                \
+    case 1:                              /* vertical scaling factor is > 1 */ \
+        while( (i_scale_count -= i_height) > 0 )                              \
+        {                                                                     \
+            SCALE_WIDTH_DITHER( CHROMA );                                     \
+            p_y -= i_width;                                                   \
+            p_u -= i_chroma_width;                                            \
+            p_v -= i_chroma_width;                                            \
+            p_pic +=        i_pic_line_width;                                 \
+        }                                                                     \
+        i_scale_count += i_pic_height;                                        \
+        break;                                                                \
+    }                                                                         \
+
diff --git a/plugins/yuv/yuv.c b/plugins/yuv/yuv.c
new file mode 100644 (file)
index 0000000..e5350bf
--- /dev/null
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * yuv.c : C YUV functions for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void yuv_GetPlugin( p_vout_thread_t p_vout );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "C YUV to RGB transformations";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = NULL;
+    p_info->intf_GetPlugin = NULL;
+    p_info->yuv_GetPlugin  = yuv_GetPlugin;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void yuv_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_yuv_init   = yuv_SysInit;
+    p_vout->p_yuv_reset  = yuv_SysReset;
+    p_vout->p_yuv_end    = yuv_SysEnd;
+}
+
diff --git a/plugins/yuvmmx/video_yuv.c b/plugins/yuvmmx/video_yuv.c
new file mode 100644 (file)
index 0000000..20a43e2
--- /dev/null
@@ -0,0 +1,526 @@
+/*****************************************************************************
+ * video_yuv.c: YUV transformation functions
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * Constants
+ *****************************************************************************/
+
+int     yuv_SysInit     ( vout_thread_t *p_vout );
+int     yuv_SysReset    ( vout_thread_t *p_vout );
+void    yuv_SysEnd      ( vout_thread_t *p_vout );
+
+/*****************************************************************************
+ * vout_InitYUV: allocate and initialize translations tables
+ *****************************************************************************
+ * This function will allocate memory to store translation tables, depending
+ * of the screen depth.
+ *****************************************************************************/
+int yuv_SysInit( vout_thread_t *p_vout )
+{
+    size_t      tables_size;                        /* tables size, in bytes */
+
+    /* Computes tables size - 3 Bpp use 32 bits pixel entries in tables */
+    switch( p_vout->i_bytes_per_pixel )
+    {
+    case 1:
+        tables_size = sizeof( u8 )
+                * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : PALETTE_TABLE_SIZE);
+        break;
+    case 2:
+        tables_size = sizeof( u16 )
+                * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
+        break;
+    case 3:
+    case 4:
+    default:
+        tables_size = sizeof( u32 )
+                * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
+        break;
+    }
+
+    /* Allocate memory */
+    p_vout->yuv.p_base = malloc( tables_size );
+    if( p_vout->yuv.p_base == NULL )
+    {
+        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        return( 1 );
+    }
+
+    /* Allocate memory for conversion buffer and offset array */
+    p_vout->yuv.p_buffer = malloc( VOUT_MAX_WIDTH * p_vout->i_bytes_per_pixel );
+    if( p_vout->yuv.p_buffer == NULL )
+    {
+        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        free( p_vout->yuv.p_base );
+        return( 1 );
+    }
+    p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );
+    if( p_vout->yuv.p_offset == NULL )
+    {
+        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        free( p_vout->yuv.p_base );
+        free( p_vout->yuv.p_buffer );
+        return( 1 );
+    }
+
+    /* Initialize tables */
+    SetYUV( p_vout );
+    return( 0 );
+}
+
+/*****************************************************************************
+ * yuv_SysReset: re-initialize translations tables
+ *****************************************************************************
+ * This function will initialize the tables allocated by vout_CreateTables and
+ * set functions pointers.
+ *****************************************************************************/
+int yuv_SysReset( vout_thread_t *p_vout )
+{
+    yuv_SysEnd( p_vout );
+    return( yuv_SysInit( p_vout ) );
+}
+
+/*****************************************************************************
+ * yuv_SysEnd: destroy translations tables
+ *****************************************************************************
+ * Free memory allocated by yuv_SysCreate.
+ *****************************************************************************/
+void yuv_SysEnd( vout_thread_t *p_vout )
+{
+    free( p_vout->yuv.p_base );
+    free( p_vout->yuv.p_buffer );
+    free( p_vout->yuv.p_offset );
+}
+
+/* following functions are local */
+
+/*****************************************************************************
+ * SetGammaTable: return intensity table transformed by gamma curve.
+ *****************************************************************************
+ * pi_table is a table of 256 entries from 0 to 255.
+ *****************************************************************************/
+void SetGammaTable( int *pi_table, double f_gamma )
+{
+    int         i_y;                                       /* base intensity */
+
+    /* Use exp(gamma) instead of gamma */
+    f_gamma = exp( f_gamma );
+
+    /* Build gamma table */
+    for( i_y = 0; i_y < 256; i_y++ )
+    {
+        pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256;
+    }
+ }
+
+/*****************************************************************************
+ * SetYUV: compute tables and set function pointers
++ *****************************************************************************/
+void SetYUV( vout_thread_t *p_vout )
+{
+    int         pi_gamma[256];                                /* gamma table */
+    int         i_index;                                  /* index in tables */
+
+    /* Build gamma table */
+    SetGammaTable( pi_gamma, p_vout->f_gamma );
+
+    /*
+     * Set pointers and build YUV tables
+     */
+    if( p_vout->b_grayscale )
+    {
+        /* Grayscale: build gray table */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            {
+                u16 bright[256], transp[256];
+
+                p_vout->yuv.yuv.p_gray8 =  (u8 *)p_vout->yuv.p_base + GRAY_MARGIN;
+                for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
+                {
+                    p_vout->yuv.yuv.p_gray8[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
+                    p_vout->yuv.yuv.p_gray8[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
+                }
+                for( i_index = 0; i_index < 256; i_index++)
+                {
+                    p_vout->yuv.yuv.p_gray8[ i_index ] = pi_gamma[ i_index ];
+                    bright[ i_index ] = i_index << 8;
+                    transp[ i_index ] = 0;
+                }
+                /* the colors have been allocated, we can set the palette */
+                p_vout->p_set_palette( p_vout, bright, bright, bright, transp );
+                p_vout->i_white_pixel = 0xff;
+                p_vout->i_black_pixel = 0x00;
+                p_vout->i_gray_pixel = 0x44;
+                p_vout->i_blue_pixel = 0x3b;
+
+                break;
+            }
+        case 2:
+            p_vout->yuv.yuv.p_gray16 =  (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
+            for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_gray16[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
+                p_vout->yuv.yuv.p_gray16[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++)
+            {
+                p_vout->yuv.yuv.p_gray16[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
+            }
+            break;
+        case 3:
+        case 4:
+            p_vout->yuv.yuv.p_gray32 =  (u32 *)p_vout->yuv.p_base + GRAY_MARGIN;
+            for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_gray32[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
+                p_vout->yuv.yuv.p_gray32[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++)
+            {
+                p_vout->yuv.yuv.p_gray32[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
+            }
+            break;
+         }
+    }
+    else
+    {
+        /* Color: build red, green and blue tables */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            {
+                #define RGB_MIN 0
+                #define RGB_MAX 255
+                #define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 )
+
+                int y,u,v;
+                int r,g,b;
+                int uvr, uvg, uvb;
+                int i = 0, j = 0;
+                u16 red[256], green[256], blue[256], transp[256];
+                unsigned char lookup[PALETTE_TABLE_SIZE];
+
+                p_vout->yuv.yuv.p_rgb8 = (u8 *)p_vout->yuv.p_base;
+
+                /* this loop calculates the intersection of an YUV box
+                 * and the RGB cube. */
+                for ( y = 0; y <= 256; y += 16 )
+                {
+                    for ( u = 0; u <= 256; u += 32 )
+                    for ( v = 0; v <= 256; v += 32 )
+                    {
+                        uvr = (V_RED_COEF*(v-128)) >> SHIFT;
+                        uvg = (U_GREEN_COEF*(u-128) + V_GREEN_COEF*(v-128)) >> SHIFT;
+                        uvb = (U_BLUE_COEF*(u-128)) >> SHIFT;
+                        r = y + uvr;
+                        g = y + uvg;
+                        b = y + uvb;
+
+                        if( r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN
+                                && r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX )
+                        {
+                            /* this one should never happen unless someone fscked up my code */
+                            if(j == 256) { intf_ErrMsg( "vout error: no colors left to build palette\n" ); break; }
+
+                            /* clip the colors */
+                            red[j] = CLIP( r );
+                            green[j] = CLIP( g );
+                            blue[j] = CLIP( b );
+                            transp[j] = 0;
+
+                            /* allocate color */
+                            lookup[i] = 1;
+                            p_vout->yuv.yuv.p_rgb8[i++] = j;
+                            j++;
+                        }
+                        else
+                        {
+                            lookup[i] = 0;
+                            p_vout->yuv.yuv.p_rgb8[i++] = 0;
+                        }
+                    }
+                    i += 128-81;
+                }
+
+                /* the colors have been allocated, we can set the palette */
+                /* there will eventually be a way to know which colors
+                 * couldn't be allocated and try to find a replacement */
+                p_vout->p_set_palette( p_vout, red, green, blue, transp );
+
+                p_vout->i_white_pixel = 0xff;
+                p_vout->i_black_pixel = 0x00;
+                p_vout->i_gray_pixel = 0x44;
+                p_vout->i_blue_pixel = 0x3b;
+
+                i = 0;
+                /* this loop allocates colors that got outside
+                 * the RGB cube */
+                for ( y = 0; y <= 256; y += 16 )
+                {
+                    for ( u = 0; u <= 256; u += 32 )
+                    for ( v = 0; v <= 256; v += 32 )
+                    {
+                        int u2, v2;
+                        int dist, mindist = 100000000;
+
+                        if( lookup[i] || y==0)
+                        {
+                            i++;
+                            continue;
+                        }
+
+                        /* heavy. yeah. */
+                        for( u2 = 0; u2 <= 256; u2 += 32 )
+                        for( v2 = 0; v2 <= 256; v2 += 32 )
+                        {
+                            j = ((y>>4)<<7) + (u2>>5)*9 + (v2>>5);
+                            dist = (u-u2)*(u-u2) + (v-v2)*(v-v2);
+                            if( lookup[j] )
+                            /* find the nearest color */
+                            if( dist < mindist )
+                            {
+                                p_vout->yuv.yuv.p_rgb8[i] = p_vout->yuv.yuv.p_rgb8[j];
+                                mindist = dist;
+                            }
+                            j -= 128;
+                            if( lookup[j] )
+                            /* find the nearest color */
+                            if( dist + 128 < mindist )
+                            {
+                                p_vout->yuv.yuv.p_rgb8[i] = p_vout->yuv.yuv.p_rgb8[j];
+                                mindist = dist + 128;
+                            }
+                        }
+                        i++;
+                    }
+                    i += 128-81;
+                }
+
+                break;
+            }
+        case 2:
+            p_vout->yuv.yuv.p_rgb16 = (u16 *)p_vout->yuv.p_base;
+            for( i_index = 0; i_index < RED_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
+                p_vout->yuv.yuv.p_rgb16[RED_OFFSET + 256 + i_index] =        RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 );
+            }
+            for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 );
+                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + 256 + i_index] =          RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 );
+            }
+            for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] );
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb16[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
+                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
+            }
+            break;
+        case 3:
+        case 4:
+            p_vout->yuv.yuv.p_rgb32 = (u32 *)p_vout->yuv.p_base;
+            for( i_index = 0; i_index < RED_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
+                p_vout->yuv.yuv.p_rgb32[RED_OFFSET + 256 + i_index] =        RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 );
+            }
+            for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 );
+                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + 256 + i_index] =          RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 );
+            }
+            for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] );
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] );
+            }
+            for( i_index = 0; i_index < 256; i_index++ )
+            {
+                p_vout->yuv.yuv.p_rgb32[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
+                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
+            }
+            break;
+        }
+    }
+
+    /*
+     * Set functions pointers
+     */
+    if( p_vout->b_grayscale )
+    {
+        /* Grayscale */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            break;
+        case 2:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            break;
+        case 3:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            break;
+        case 4:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            break;
+        }
+    }
+    else
+    {
+        /* Color */
+        switch( p_vout->i_bytes_per_pixel )
+        {
+        case 1:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertYUV420RGB8;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertYUV422RGB8;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertYUV444RGB8;
+            break;
+        case 2:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB16;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB16;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB16;
+            break;
+        case 3:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB24;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB24;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB24;
+            break;
+        case 4:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB32;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB32;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB32;
+            break;
+        }
+    }
+}
+
+/*****************************************************************************
+ * SetOffset: build offset array for conversion functions
+ *****************************************************************************
+ * This function will build an offset array used in later conversion functions.
+ * It will also set horizontal and vertical scaling indicators.
+ *****************************************************************************/
+void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
+                boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset )
+{
+    int i_x;                                    /* x position in destination */
+    int i_scale_count;                                     /* modulo counter */
+
+    /*
+     * Prepare horizontal offset array
+     */
+    if( i_pic_width - i_width > 0 )
+    {
+        /* Prepare scaling array for horizontal extension */
+        *pb_h_scaling =  1;
+        i_scale_count =         i_pic_width;
+        for( i_x = i_width; i_x--; )
+        {
+            while( (i_scale_count -= i_width) > 0 )
+            {
+                *p_offset++ = 0;
+            }
+            *p_offset++ = 1;
+            i_scale_count += i_pic_width;
+        }
+    }
+    else if( i_pic_width - i_width < 0 )
+    {
+        /* Prepare scaling array for horizontal reduction */
+        *pb_h_scaling =  1;
+        i_scale_count =         i_pic_width;
+        for( i_x = i_pic_width; i_x--; )
+        {
+            *p_offset = 1;
+            while( (i_scale_count -= i_pic_width) >= 0 )
+            {
+                *p_offset += 1;
+            }
+            p_offset++;
+            i_scale_count += i_width;
+        }
+    }
+    else
+    {
+        /* No horizontal scaling: YUV conversion is done directly to picture */
+        *pb_h_scaling = 0;
+    }
+
+    /*
+     * Set vertical scaling indicator
+     */
+    if( i_pic_height - i_height > 0 )
+    {
+        *pi_v_scaling = 1;
+    }
+    else if( i_pic_height - i_height < 0 )
+    {
+        *pi_v_scaling = -1;
+    }
+    else
+    {
+        *pi_v_scaling = 0;
+    }
+}
+
diff --git a/plugins/yuvmmx/video_yuv.h b/plugins/yuvmmx/video_yuv.h
new file mode 100644 (file)
index 0000000..3d7feff
--- /dev/null
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * video_yuv.h: YUV transformation functions
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Constants
+ *****************************************************************************/
+
+/* Margins and offsets in conversion tables - Margins are used in case a RGB
+ * RGB conversion would give a value outside the 0-255 range. Offsets have been
+ * calculated to avoid using the same cache line for 2 tables. conversion tables
+ * are 2*MARGIN + 256 long and stores pixels.*/
+#define RED_MARGIN      178
+#define GREEN_MARGIN    135
+#define BLUE_MARGIN     224
+#define RED_OFFSET      1501                                 /* 1323 to 1935 */
+#define GREEN_OFFSET    135                                      /* 0 to 526 */
+#define BLUE_OFFSET     818                                   /* 594 to 1298 */
+#define RGB_TABLE_SIZE  1935                             /* total table size */
+
+#define GRAY_MARGIN     384
+#define GRAY_TABLE_SIZE 1024                             /* total table size */
+
+#define PALETTE_TABLE_SIZE 2176          /* YUV -> 8bpp palette lookup table */
+
+/* macros used for YUV pixel conversions */
+#define SHIFT 20
+#define U_GREEN_COEF    ((int)(-0.391 * (1<<SHIFT) / 1.164))
+#define U_BLUE_COEF     ((int)(2.018 * (1<<SHIFT) / 1.164))
+#define V_RED_COEF      ((int)(1.596 * (1<<SHIFT) / 1.164))
+#define V_GREEN_COEF    ((int)(-0.813 * (1<<SHIFT) / 1.164))
+
+/* argument lists for YUV functions */
+#define YUV_ARGS_8BPP p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+#define YUV_ARGS_16BPP p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+#define YUV_ARGS_24BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+#define YUV_ARGS_32BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
+yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
+int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+void SetGammaTable        ( int *pi_table, double f_gamma );
+void SetYUV               ( vout_thread_t *p_vout );
+void SetOffset            ( int i_width, int i_height, int i_pic_width,
+                            int i_pic_height, boolean_t *pb_h_scaling,
+                            int *pi_v_scaling, int *p_offset );
+
+void ConvertY4Gray8       ( YUV_ARGS_8BPP );
+void ConvertYUV420RGB8    ( YUV_ARGS_8BPP );
+void ConvertYUV422RGB8    ( YUV_ARGS_8BPP );
+void ConvertYUV444RGB8    ( YUV_ARGS_8BPP );
+
+void ConvertY4Gray16      ( YUV_ARGS_16BPP );
+void ConvertYUV420RGB16   ( YUV_ARGS_16BPP );
+void ConvertYUV422RGB16   ( YUV_ARGS_16BPP );
+void ConvertYUV444RGB16   ( YUV_ARGS_16BPP );
+
+void ConvertY4Gray24      ( YUV_ARGS_24BPP );
+void ConvertYUV420RGB24   ( YUV_ARGS_24BPP );
+void ConvertYUV422RGB24   ( YUV_ARGS_24BPP );
+void ConvertYUV444RGB24   ( YUV_ARGS_24BPP );
+
+void ConvertY4Gray32      ( YUV_ARGS_32BPP );
+void ConvertYUV420RGB32   ( YUV_ARGS_32BPP );
+void ConvertYUV422RGB32   ( YUV_ARGS_32BPP );
+void ConvertYUV444RGB32   ( YUV_ARGS_32BPP );
+
diff --git a/plugins/yuvmmx/video_yuv15.c b/plugins/yuvmmx/video_yuv15.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/plugins/yuvmmx/video_yuv16.c b/plugins/yuvmmx/video_yuv16.c
new file mode 100644 (file)
index 0000000..e23d2be
--- /dev/null
@@ -0,0 +1,132 @@
+/*****************************************************************************
+ * video_yuv16.c: YUV transformation functions for 16bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+#include "video_yuv_macros.h"
+#include "video_yuv_asm.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray16: color YUV 4:4:4 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertY4Gray16( YUV_ARGS_16BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 16\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV420RGB16( YUV_ARGS_16BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_chroma_width;                              /* chroma width */
+    u16 *       p_yuv;                              /* base conversion table */
+    u16 *       p_pic_start;       /* beginning of the current line for copy */
+    u16 *       p_buffer_start;                   /* conversion buffer start */
+    u16 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_yuv =             p_vout->yuv.yuv.p_rgb16;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        for ( i_x = i_width / 8; i_x--; )
+        {
+            __asm__( MMX_INIT_16
+                     : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
+
+            __asm__( ".align 8" MMX_YUV_MUL MMX_YUV_ADD MMX_UNPACK_16
+                     : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
+
+            p_y += 8;
+            p_u += 4;
+            p_v += 4;
+            p_buffer += 8;
+        }
+
+        SCALE_WIDTH;
+        SCALE_HEIGHT( 420, 2 );
+    }
+    __asm__( "emms" );
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV422RGB16( YUV_ARGS_16BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 16\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV444RGB16( YUV_ARGS_16BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 16\n" );
+}
+
diff --git a/plugins/yuvmmx/video_yuv24.c b/plugins/yuvmmx/video_yuv24.c
new file mode 100644 (file)
index 0000000..76c4572
--- /dev/null
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * video_yuv24.c: YUV transformation functions for 24 bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray24: grayscale YUV 4:x:x to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertY4Gray24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 24\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV420RGB24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 420, bpp = 24\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB24: color YUV 4:2:2 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV422RGB24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 24\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB24: color YUV 4:4:4 to RGB 2 Bpp
+ *****************************************************************************/
+void ConvertYUV444RGB24( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 24\n" );
+}
+
diff --git a/plugins/yuvmmx/video_yuv32.c b/plugins/yuvmmx/video_yuv32.c
new file mode 100644 (file)
index 0000000..6f70892
--- /dev/null
@@ -0,0 +1,132 @@
+/*****************************************************************************
+ * video_yuv32.c: YUV transformation functions for 32 bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+#include "video_yuv_macros.h"
+#include "video_yuv_asm.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertY4Gray32( YUV_ARGS_32BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 32\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertYUV420RGB32( YUV_ARGS_32BPP )
+{
+    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
+    int         i_vertical_scaling;                 /* vertical scaling type */
+    int         i_x, i_y;                 /* horizontal and vertical indexes */
+    int         i_scale_count;                       /* scale modulo counter */
+    int         i_chroma_width;                              /* chroma width */
+    u32 *       p_yuv;                              /* base conversion table */
+    u32 *       p_pic_start;       /* beginning of the current line for copy */
+    u32 *       p_buffer_start;                   /* conversion buffer start */
+    u32 *       p_buffer;                       /* conversion buffer pointer */
+    int *       p_offset_start;                        /* offset array start */
+    int *       p_offset;                            /* offset array pointer */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
+     */
+    i_pic_line_width -= i_pic_width;
+    i_chroma_width =    i_width / 2;
+    p_yuv =             p_vout->yuv.yuv.p_rgb32;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
+
+    /*
+     * Perform conversion
+     */
+    i_scale_count = i_pic_height;
+    for( i_y = 0; i_y < i_height; i_y++ )
+    {
+        /* Mark beginnning of line for possible later line copy, and initialize
+         * buffer */
+        p_pic_start =   p_pic;
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
+
+        for ( i_x = i_width / 8; i_x--; )
+        {
+            __asm__( ".align 8" MMX_INIT_32
+                     : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
+
+            __asm__( ".align 8" MMX_YUV_ADD MMX_YUV_MUL MMX_UNPACK_32
+                     : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
+
+            p_y += 8;
+            p_u += 4;
+            p_v += 4;
+            p_buffer += 8;
+        }
+
+        SCALE_WIDTH;
+        SCALE_HEIGHT( 420, 2 );
+    }
+    __asm__( "emms" );
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertYUV422RGB32( YUV_ARGS_32BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 32\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 Bpp
+ *****************************************************************************/
+void ConvertYUV444RGB32( YUV_ARGS_32BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 32\n" );
+}
+
diff --git a/plugins/yuvmmx/video_yuv8.c b/plugins/yuvmmx/video_yuv8.c
new file mode 100644 (file)
index 0000000..985b207
--- /dev/null
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * video_yuv8.c: YUV transformation functions for 8bpp
+ * Provides functions to perform the YUV conversion. The functions provided here
+ * are a complete and portable C implementation, and may be replaced in certain
+ * case by optimized functions.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+#include "video.h"
+#include "video_output.h"
+#include "video_yuv.h"
+
+#include "intf_msg.h"
+
+/*****************************************************************************
+ * ConvertY4Gray8: grayscale YUV 4:x:x to RGB 8 bpp
+ *****************************************************************************/
+void ConvertY4Gray8( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 8\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV420RGB8: color YUV 4:2:0 to RGB 8 bpp
+ *****************************************************************************/
+void ConvertYUV420RGB8( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 420, bpp = 8\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV422RGB8: color YUV 4:2:2 to RGB 8 bpp
+ *****************************************************************************/
+void ConvertYUV422RGB8( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 8\n" );
+}
+
+/*****************************************************************************
+ * ConvertYUV444RGB8: color YUV 4:4:4 to RGB 8 bpp
+ *****************************************************************************/
+void ConvertYUV444RGB8( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 8\n" );
+}
+
diff --git a/plugins/yuvmmx/video_yuv_asm.h b/plugins/yuvmmx/video_yuv_asm.h
new file mode 100644 (file)
index 0000000..f2c61f0
--- /dev/null
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ * video_yuv_asm.h: YUV transformation assembly
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ * Olie Lho <ollie@sis.com.tw>
+ *
+ * Adapted to VideoLAN by:
+ * Gaël Hendryckx <jimmy@via.ecp.fr>
+ * Samuel Hocevar <sam@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/* hope these constant values are cache line aligned */
+static unsigned long long mmx_80w     = 0x0080008000800080;
+static unsigned long long mmx_10w     = 0x1010101010101010;
+static unsigned long long mmx_00ffw   = 0x00ff00ff00ff00ff;
+static unsigned long long mmx_Y_coeff = 0x253f253f253f253f;
+
+static unsigned long long mmx_U_green = 0xf37df37df37df37d;
+static unsigned long long mmx_U_blue  = 0x4093409340934093;
+static unsigned long long mmx_V_red   = 0x3312331233123312;
+static unsigned long long mmx_V_green = 0xe5fce5fce5fce5fc;
+
+static unsigned long long mmx_redmask = 0xf8f8f8f8f8f8f8f8;
+static unsigned long long mmx_grnmask = 0xfcfcfcfcfcfcfcfc;
+static unsigned long long mmx_grnshift   = 0x03;
+static unsigned long long mmx_blueshift  = 0x03;
+
+#define MMX_INIT_16 "                                                       \n\
+                                                                            \n\
+movd      (%1), %%mm0       # Load 4 Cb       00 00 00 00 u3 u2 u1 u0       \n\
+movd      (%2), %%mm1       # Load 4 Cr       00 00 00 00 v3 v2 v1 v0       \n\
+pxor      %%mm4, %%mm4      # zero mm4                                      \n\
+movq      (%0), %%mm6       # Load 8 Y        Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0       \n\
+#movl      $0, (%3)         # cache preload for image                       \n\
+"
+
+#define MMX_INIT_32 "                                                       \n\
+                                                                            \n\
+movd      (%1), %%mm0       # Load 4 Cb       00 00 00 00 u3 u2 u1 u0       \n\
+movl      $0, (%3)          # cache preload for image                       \n\
+movd      (%2), %%mm1       # Load 4 Cr       00 00 00 00 v3 v2 v1 v0       \n\
+pxor      %%mm4, %%mm4      # zero mm4                                      \n\
+movq      (%0), %%mm6       # Load 8 Y        Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0       \n\
+"
+
+/*
+ * Do the multiply part of the conversion for even and odd pixels,
+ * register usage:
+ * mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
+ * mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd  pixels,
+ * mm6 -> Y even, mm7 -> Y odd
+ */
+
+#define MMX_YUV_MUL "                                                       \n\
+                                                                            \n\
+# convert the chroma part                                                   \n\
+punpcklbw %%mm4, %%mm0          # scatter 4 Cb    00 u3 00 u2 00 u1 00 u0   \n\
+punpcklbw %%mm4, %%mm1          # scatter 4 Cr    00 v3 00 v2 00 v1 00 v0   \n\
+psubsw    mmx_80w, %%mm0        # Cb -= 128                                 \n\
+psubsw    mmx_80w, %%mm1        # Cr -= 128                                 \n\
+psllw     $3, %%mm0             # Promote precision                         \n\
+psllw     $3, %%mm1             # Promote precision                         \n\
+movq      %%mm0, %%mm2          # Copy 4 Cb       00 u3 00 u2 00 u1 00 u0   \n\
+movq      %%mm1, %%mm3          # Copy 4 Cr       00 v3 00 v2 00 v1 00 v0   \n\
+pmulhw    mmx_U_green, %%mm2    # Mul Cb with green coeff -> Cb green       \n\
+pmulhw    mmx_V_green, %%mm3    # Mul Cr with green coeff -> Cr green       \n\
+pmulhw    mmx_U_blue, %%mm0     # Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0   \n\
+pmulhw    mmx_V_red, %%mm1      # Mul Cr -> Cred  00 r3 00 r2 00 r1 00      \n\
+paddsw    %%mm3, %%mm2          # Cb green + Cr green -> Cgreen             \n\
+                                                                            \n\
+# convert the luma part                                                     \n\
+psubusb   mmx_10w, %%mm6        # Y -= 16                                   \n\
+movq      %%mm6, %%mm7          # Copy 8 Y        Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0   \n\
+pand      mmx_00ffw, %%mm6      # get Y even      00 Y6 00 Y4 00 Y2 00 Y0   \n\
+psrlw     $8, %%mm7             # get Y odd       00 Y7 00 Y5 00 Y3 00 Y1   \n\
+psllw     $3, %%mm6             # Promote precision                         \n\
+psllw     $3, %%mm7             # Promote precision                         \n\
+pmulhw    mmx_Y_coeff, %%mm6    # Mul 4 Y even    00 y6 00 y4 00 y2 00 y0   \n\
+pmulhw    mmx_Y_coeff, %%mm7    # Mul 4 Y odd     00 y7 00 y5 00 y3 00 y1   \n\
+"
+
+/*
+ * Do the addition part of the conversion for even and odd pixels,
+ * register usage:
+ * mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
+ * mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd  pixels,
+ * mm6 -> Y even, mm7 -> Y odd
+ */
+
+#define MMX_YUV_ADD "                                                       \n\
+                                                                            \n\
+# Do horizontal and vertical scaling                                        \n\
+movq      %%mm0, %%mm3          # Copy Cblue                                \n\
+movq      %%mm1, %%mm4          # Copy Cred                                 \n\
+movq      %%mm2, %%mm5          # Copy Cgreen                               \n\
+paddsw    %%mm6, %%mm0          # Y even + Cblue  00 B6 00 B4 00 B2 00 B0   \n\
+paddsw    %%mm7, %%mm3          # Y odd  + Cblue  00 B7 00 B5 00 B3 00 B1   \n\
+paddsw    %%mm6, %%mm1          # Y even + Cred   00 R6 00 R4 00 R2 00 R0   \n\
+paddsw    %%mm7, %%mm4          # Y odd  + Cred   00 R7 00 R5 00 R3 00 R1   \n\
+paddsw    %%mm6, %%mm2          # Y even + Cgreen 00 G6 00 G4 00 G2 00 G0   \n\
+paddsw    %%mm7, %%mm5          # Y odd  + Cgreen 00 G7 00 G5 00 G3 00 G1   \n\
+                                                                            \n\
+# Limit RGB even to 0..255                                                  \n\
+packuswb  %%mm0, %%mm0          # B6 B4 B2 B0 | B6 B4 B2 B0                 \n\
+packuswb  %%mm1, %%mm1          # R6 R4 R2 R0 | R6 R4 R2 R0                 \n\
+packuswb  %%mm2, %%mm2          # G6 G4 G2 G0 | G6 G4 G2 G0                 \n\
+                                                                            \n\
+# Limit RGB odd to 0..255                                                   \n\
+packuswb  %%mm3, %%mm3          # B7 B5 B3 B1 | B7 B5 B3 B1                 \n\
+packuswb  %%mm4, %%mm4          # R7 R5 R3 R1 | R7 R5 R3 R1                 \n\
+packuswb  %%mm5, %%mm5          # G7 G5 G3 G1 | G7 G5 G3 G1                 \n\
+                                                                            \n\
+# Interleave RGB even and odd                                               \n\
+punpcklbw %%mm3, %%mm0          #                 B7 B6 B5 B4 B3 B2 B1 B0   \n\
+punpcklbw %%mm4, %%mm1          #                 R7 R6 R5 R4 R3 R2 R1 R0   \n\
+punpcklbw %%mm5, %%mm2          #                 G7 G6 G5 G4 G3 G2 G1 G0   \n\
+"
+
+#define MMX_UNPACK_16 "                                                     \n\
+                                                                            \n\
+# mask unneeded bits off                                                    \n\
+pand      mmx_redmask, %%mm0    # b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0       \n\
+pand      mmx_grnmask, %%mm2    # g7g6g5g4 g3g2_0_0 g7g6g5g4 g3g2_0_0       \n\
+pand      mmx_redmask, %%mm1    # r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0       \n\
+psrlw     mmx_blueshift,%%mm0   # 0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3       \n\
+pxor      %%mm4, %%mm4          # zero mm4                                  \n\
+movq      %%mm0, %%mm5          # Copy B7-B0                                \n\
+movq      %%mm2, %%mm7          # Copy G7-G0                                \n\
+                                                                            \n\
+# convert rgb24 plane to rgb16 pack for pixel 0-3                           \n\
+punpcklbw %%mm4, %%mm2          #  0_0_0_0  0_0_0_0 g7g6g5g4 g3g2_0_0       \n\
+punpcklbw %%mm1, %%mm0          # r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3       \n\
+psllw     mmx_blueshift,%%mm2   #  0_0_0_0 0_g7g6g5 g4g3g2_0  0_0_0_0       \n\
+por       %%mm2, %%mm0          # r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3       \n\
+movq      8(%0), %%mm6          # Load 8 Y        Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0   \n\
+movq      %%mm0, (%3)           # store pixel 0-3                           \n\
+                                                                            \n\
+# convert rgb24 plane to rgb16 pack for pixel 0-3                           \n\
+punpckhbw %%mm4, %%mm7          #  0_0_0_0  0_0_0_0 g7g6g5g4 g3g2_0_0       \n\
+punpckhbw %%mm1, %%mm5          # r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3       \n\
+psllw     mmx_blueshift,%%mm7   #  0_0_0_0 0_g7g6g5 g4g3g2_0  0_0_0_0       \n\
+movd      4(%1), %%mm0          # Load 4 Cb       00 00 00 00 u3 u2 u1 u0   \n\
+por       %%mm7, %%mm5          # r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3       \n\
+movd      4(%2), %%mm1          # Load 4 Cr       00 00 00 00 v3 v2 v1 v0   \n\
+movq      %%mm5, 8(%3)          # store pixel 4-7                           \n\
+"
+
+/*
+ * convert RGB plane to RGB packed format,
+ * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0,
+ * mm4 -> GB, mm5 -> AR pixel 4-7,
+ * mm6 -> GB, mm7 -> AR pixel 0-3
+ */
+
+#define MMX_UNPACK_32 "                                                     \n\
+                                                                            \n\
+pxor      %%mm3, %%mm3  # zero mm3                                          \n\
+movq      %%mm0, %%mm6  #                 B7 B6 B5 B4 B3 B2 B1 B0           \n\
+movq      %%mm1, %%mm7  #                 R7 R6 R5 R4 R3 R2 R1 R0           \n\
+movq      %%mm0, %%mm4  #                 B7 B6 B5 B4 B3 B2 B1 B0           \n\
+movq      %%mm1, %%mm5  #                 R7 R6 R5 R4 R3 R2 R1 R0           \n\
+punpcklbw %%mm2, %%mm6  #                 G3 B3 G2 B2 G1 B1 G0 B0           \n\
+punpcklbw %%mm3, %%mm7  #                 00 R3 00 R2 00 R1 00 R0           \n\
+punpcklwd %%mm7, %%mm6  #                 00 R1 B1 G1 00 R0 B0 G0           \n\
+movq      %%mm6, (%3)   # Store ARGB1 ARGB0                                 \n\
+movq      %%mm0, %%mm6  #                 B7 B6 B5 B4 B3 B2 B1 B0           \n\
+punpcklbw %%mm2, %%mm6  #                 G3 B3 G2 B2 G1 B1 G0 B0           \n\
+punpckhwd %%mm7, %%mm6  #                 00 R3 G3 B3 00 R2 B3 G2           \n\
+movq      %%mm6, 8(%3)  # Store ARGB3 ARGB2                                 \n\
+punpckhbw %%mm2, %%mm4  #                 G7 B7 G6 B6 G5 B5 G4 B4           \n\
+punpckhbw %%mm3, %%mm5  #                 00 R7 00 R6 00 R5 00 R4           \n\
+punpcklwd %%mm5, %%mm4  #                 00 R5 B5 G5 00 R4 B4 G4           \n\
+movq      %%mm4, 16(%3) # Store ARGB5 ARGB4                                 \n\
+movq      %%mm0, %%mm4  #                 B7 B6 B5 B4 B3 B2 B1 B0           \n\
+punpckhbw %%mm2, %%mm4  #                 G7 B7 G6 B6 G5 B5 G4 B4           \n\
+punpckhwd %%mm5, %%mm4  #                 00 R7 G7 B7 00 R6 B6 G6           \n\
+movq      %%mm4, 24(%3) # Store ARGB7 ARGB6                                 \n\
+movd      4(%1), %%mm0  # Load 4 Cb       00 00 00 00 u3 u2 u1 u0           \n\
+movd      4(%2), %%mm1  # Load 4 Cr       00 00 00 00 v3 v2 v1 v0           \n\
+pxor      %%mm4, %%mm4  # zero mm4                                          \n\
+movq      8(%0), %%mm6  # Load 8 Y        Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0           \n\
+"
+
diff --git a/plugins/yuvmmx/video_yuv_macros.h b/plugins/yuvmmx/video_yuv_macros.h
new file mode 100644 (file)
index 0000000..4a6c349
--- /dev/null
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * video_yuv_macros.h: YUV transformation macros
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * SCALE_WIDTH: scale a line horizontally
+ *****************************************************************************
+ * This macro scales a line using rendering buffer and offset array. It works
+ * for 1, 2 and 4 Bpp.
+ *****************************************************************************/
+#define SCALE_WIDTH                                                           \
+    if( b_horizontal_scaling )                                                \
+    {                                                                         \
+        /* Horizontal scaling, conversion has been done to buffer.            \
+         * Rewind buffer and offset, then copy and scale line */              \
+        p_buffer = p_buffer_start;                                            \
+        p_offset = p_offset_start;                                            \
+        for( i_x = i_pic_width / 16; i_x--; )                                 \
+        {                                                                     \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
+        }                                                                     \
+        p_pic += i_pic_line_width;                                            \
+    }                                                                         \
+    else                                                                      \
+    {                                                                         \
+        /* No scaling, conversion has been done directly in picture memory.   \
+         * Increment of picture pointer to end of line is still needed */     \
+        p_pic += i_pic_width + i_pic_line_width;                              \
+    }                                                                         \
+
+/*****************************************************************************
+ * SCALE_HEIGHT: handle vertical scaling
+ *****************************************************************************
+ * This macro handle vertical scaling for a picture. CHROMA may be 420, 422 or
+ * 444 for RGB conversion, or 400 for gray conversion. It works for 1, 2, 3
+ * and 4 Bpp.
+ *****************************************************************************/
+#define SCALE_HEIGHT( CHROMA, BPP )                                           \
+    /* If line is odd, rewind 4:2:0 U and V samples */                        \
+    if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) )                \
+    {                                                                         \
+        p_u -= i_chroma_width;                                                \
+        p_v -= i_chroma_width;                                                \
+    }                                                                         \
+                                                                              \
+    /*                                                                        \
+     * Handle vertical scaling. The current line can be copied or next one    \
+     * can be ignored.                                                        \
+     */                                                                       \
+    switch( i_vertical_scaling )                                              \
+    {                                                                         \
+    case -1:                             /* vertical scaling factor is < 1 */ \
+        while( (i_scale_count -= i_pic_height) >= 0 )                         \
+        {                                                                     \
+            /* Height reduction: skip next source line */                     \
+            p_y += i_width;                                                   \
+            i_y++;                                                            \
+            if( (CHROMA == 420) || (CHROMA == 422) )                          \
+            {                                                                 \
+                if( i_y & 0x1 )                                               \
+                {                                                             \
+                    p_u += i_chroma_width;                                    \
+                    p_v += i_chroma_width;                                    \
+                }                                                             \
+            }                                                                 \
+            else if( CHROMA == 444 )                                          \
+            {                                                                 \
+                p_u += i_width;                                               \
+                p_v += i_width;                                               \
+            }                                                                 \
+        }                                                                     \
+        i_scale_count += i_height;                                            \
+        break;                                                                \
+    case 1:                              /* vertical scaling factor is > 1 */ \
+        while( (i_scale_count -= i_height) > 0 )                              \
+        {                                                                     \
+            /* Height increment: copy previous picture line */                \
+            for( i_x = i_pic_width / 16; i_x--; )                             \
+            {                                                                 \
+                *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );           \
+                *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );           \
+                if( BPP > 1 )                               /* 2, 3, 4 Bpp */ \
+                {                                                             \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                }                                                             \
+                if( BPP > 2 )                                  /* 3, 4 Bpp */ \
+                {                                                             \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                }                                                             \
+                if( BPP > 3 )                                     /* 4 Bpp */ \
+                {                                                             \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
+                }                                                             \
+            }                                                                 \
+            p_pic +=        i_pic_line_width;                                 \
+            p_pic_start +=  i_pic_line_width;                                 \
+        }                                                                     \
+        i_scale_count += i_pic_height;                                        \
+        break;                                                                \
+    }                                                                         \
+
diff --git a/plugins/yuvmmx/yuvmmx.c b/plugins/yuvmmx/yuvmmx.c
new file mode 100644 (file)
index 0000000..19fbb21
--- /dev/null
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * yuvmmx.c : Accelerated MMX YUV functions for vlc
+ *****************************************************************************
+ * Copyright (C) 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include "config.h"
+#include "common.h"                                     /* boolean_t, byte_t */
+#include "threads.h"
+#include "mtime.h"
+#include "plugins.h"
+
+#include "interface.h"
+#include "audio_output.h"
+#include "video.h"
+#include "video_output.h"
+
+#include "plugins_export.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+void yuv_GetPlugin( p_vout_thread_t p_vout );
+
+/*****************************************************************************
+ * GetConfig: get the plugin structure and configuration
+ *****************************************************************************/
+plugin_info_t * GetConfig( void )
+{
+    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
+
+    p_info->psz_name    = "Accelerated MMX YUV to RGB transformations";
+    p_info->psz_version = VERSION;
+    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+
+    p_info->aout_GetPlugin = NULL;
+    p_info->vout_GetPlugin = NULL;
+    p_info->intf_GetPlugin = NULL;
+    p_info->yuv_GetPlugin  = yuv_GetPlugin;
+
+    return( p_info );
+}
+
+/*****************************************************************************
+ * Test: tests if the plugin can be launched
+ *****************************************************************************/
+int Test( void )
+{
+    return( 1 );
+}
+
+/*****************************************************************************
+ * Following functions are only called through the p_info structure
+ *****************************************************************************/
+
+void yuv_GetPlugin( p_vout_thread_t p_vout )
+{
+    p_vout->p_yuv_init   = yuv_SysInit;
+    p_vout->p_yuv_reset  = yuv_SysReset;
+    p_vout->p_yuv_end    = yuv_SysEnd;
+}
+
index bfaba845547233bc627fedecb9a011ceeafc0202..5d43aec35275e5681fdad49a476a93d89fa5fe1b 100644 (file)
@@ -76,11 +76,12 @@ ac3dec_thread_t * ac3dec_CreateThread (input_thread_t * p_input)
 {
     ac3dec_thread_t *   p_ac3dec;
 
-    intf_DbgMsg ("ac3dec debug: creating ac3 decoder thread\n");
+    intf_DbgMsg( "ac3dec debug: creating ac3 decoder thread\n" );
 
     /* Allocate the memory needed to store the thread's structure */
     if ((p_ac3dec = (ac3dec_thread_t *)malloc (sizeof(ac3dec_thread_t))) == NULL) {
-        intf_ErrMsg ("ac3dec error: not enough memory for ac3dec_CreateThread() to create the new thread\n");
+        intf_ErrMsg ( "ac3dec error: not enough memory "
+                      "for ac3dec_CreateThread() to create the new thread\n");
         return NULL;
     }
 
@@ -114,7 +115,7 @@ ac3dec_thread_t * ac3dec_CreateThread (input_thread_t * p_input)
 
     /* Spawn the ac3 decoder thread */
     if (vlc_thread_create(&p_ac3dec->thread_id, "ac3 decoder", (vlc_thread_func_t)RunThread, (void *)p_ac3dec)) {
-        intf_ErrMsg  ("ac3dec error: can't spawn ac3 decoder thread\n");
+        intf_ErrMsg( "ac3dec error: can't spawn ac3 decoder thread\n" );
         free (p_ac3dec);
         return NULL;
     }
@@ -168,9 +169,9 @@ static int InitThread (ac3dec_thread_t * p_ac3dec)
     p_ac3dec->p_ts = DECODER_FIFO_START (p_ac3dec->fifo)->p_first_ts;
     byte_stream = ac3_byte_stream (&p_ac3dec->ac3_decoder);
     byte_stream->p_byte =
-       p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_start;
+        p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_start;
     byte_stream->p_end =
-       p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_end;
+        p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_end;
     byte_stream->info = p_ac3dec;
     vlc_mutex_unlock (&p_ac3dec->fifo.data_lock);
 
@@ -211,64 +212,64 @@ static void RunThread (ac3dec_thread_t * p_ac3dec)
     /* ac3 decoder thread's main loop */
     /* FIXME : do we have enough room to store the decoded frames ?? */
     while ((!p_ac3dec->b_die) && (!p_ac3dec->b_error)) {
-       s16 * buffer;
-       ac3_sync_info_t sync_info;
+        s16 * buffer;
+        ac3_sync_info_t sync_info;
 
-       if (!sync) { /* have to find a synchro point */
-           int ptr;
-           ac3_byte_stream_t * p_byte_stream;
+        if (!sync) { /* have to find a synchro point */
+            int ptr;
+            ac3_byte_stream_t * p_byte_stream;
 
-           intf_Msg ("ac3dec: sync\n");
+            intf_Msg ("ac3dec: sync\n");
 
-           p_byte_stream = ac3_byte_stream (&p_ac3dec->ac3_decoder);
+            p_byte_stream = ac3_byte_stream (&p_ac3dec->ac3_decoder);
 
-           /* first read till next ac3 magic header */
-           do {
-               ac3_byte_stream_next (p_byte_stream);
-           } while ((!p_ac3dec->sync_ptr) &&
-                   (!p_ac3dec->b_die) &&
-                   (!p_ac3dec->b_error));
-           /* skip the specified number of bytes */
+            /* first read till next ac3 magic header */
+            do {
+                ac3_byte_stream_next (p_byte_stream);
+            } while ((!p_ac3dec->sync_ptr) &&
+                    (!p_ac3dec->b_die) &&
+                    (!p_ac3dec->b_error));
+            /* skip the specified number of bytes */
 
-           ptr = p_ac3dec->sync_ptr;
-           while (--ptr && (!p_ac3dec->b_die) && (!p_ac3dec->b_error)) {
-               if (p_byte_stream->p_byte >= p_byte_stream->p_end) {
-                   ac3_byte_stream_next (p_byte_stream);                   
-               }
-               p_byte_stream->p_byte++;
-           }
+            ptr = p_ac3dec->sync_ptr;
+            while (--ptr && (!p_ac3dec->b_die) && (!p_ac3dec->b_error)) {
+                if (p_byte_stream->p_byte >= p_byte_stream->p_end) {
+                    ac3_byte_stream_next (p_byte_stream);                    
+                }
+                p_byte_stream->p_byte++;
+            }
 
-           /* we are in sync now */
+            /* we are in sync now */
 
-           sync = 1;
-           p_ac3dec->sync_ptr = 0;
-       }
+            sync = 1;
+            p_ac3dec->sync_ptr = 0;
+        }
 
         if (DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts) {
-           p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts;
-           DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts = 0;
+            p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts;
+            DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts = 0;
         } else {
-           p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
+            p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
         }
 
         if (ac3_sync_frame (&p_ac3dec->ac3_decoder, &sync_info)) {
-           sync = 0;
-           goto bad_frame;
-       }
+            sync = 0;
+            goto bad_frame;
+        }
 
-       p_ac3dec->p_aout_fifo->l_rate = sync_info.sample_rate;
+        p_ac3dec->p_aout_fifo->l_rate = sync_info.sample_rate;
 
-       buffer = ((s16 *)p_ac3dec->p_aout_fifo->buffer) + (p_ac3dec->p_aout_fifo->l_end_frame * AC3DEC_FRAME_SIZE);
+        buffer = ((s16 *)p_ac3dec->p_aout_fifo->buffer) + (p_ac3dec->p_aout_fifo->l_end_frame * AC3DEC_FRAME_SIZE);
 
-       if (ac3_decode_frame (&p_ac3dec->ac3_decoder, buffer)) {
-           sync = 0;
-           goto bad_frame;
-       }
+        if (ac3_decode_frame (&p_ac3dec->ac3_decoder, buffer)) {
+            sync = 0;
+            goto bad_frame;
+        }
 
-       vlc_mutex_lock (&p_ac3dec->p_aout_fifo->data_lock);
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal (&p_ac3dec->p_aout_fifo->data_wait);
-       vlc_mutex_unlock (&p_ac3dec->p_aout_fifo->data_lock);
+        vlc_mutex_lock (&p_ac3dec->p_aout_fifo->data_lock);
+        p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
+        vlc_cond_signal (&p_ac3dec->p_aout_fifo->data_wait);
+        vlc_mutex_unlock (&p_ac3dec->p_aout_fifo->data_lock);
 
     bad_frame:
     }
@@ -337,62 +338,62 @@ void ac3_byte_stream_next (ac3_byte_stream_t * p_byte_stream)
     /* We are looking for the next TS packet that contains real data,
      * and not just a PES header */
     do {
-       /* We were reading the last TS packet of this PES packet... It's
-        * time to jump to the next PES packet */
-       if (p_ac3dec->p_ts->p_next_ts == NULL) {
-           int ptr;
-
-           /* We are going to read/write the start and end indexes of the 
-            * decoder fifo and to use the fifo's conditional variable, 
-            * that's why we need to take the lock before */ 
-           vlc_mutex_lock (&p_ac3dec->fifo.data_lock);
-           
-           /* Is the input thread dying ? */
-           if (p_ac3dec->p_input->b_die) {
-               vlc_mutex_unlock (&(p_ac3dec->fifo.data_lock));
-               return;
-           }
-
-           /* We should increase the start index of the decoder fifo, but
+        /* We were reading the last TS packet of this PES packet... It's
+         * time to jump to the next PES packet */
+        if (p_ac3dec->p_ts->p_next_ts == NULL) {
+            int ptr;
+
+            /* We are going to read/write the start and end indexes of the 
+             * decoder fifo and to use the fifo's conditional variable, 
+             * that's why we need to take the lock before */ 
+            vlc_mutex_lock (&p_ac3dec->fifo.data_lock);
+
+            /* Is the input thread dying ? */
+            if (p_ac3dec->p_input->b_die) {
+                vlc_mutex_unlock (&(p_ac3dec->fifo.data_lock));
+                return;
+            }
+
+            /* We should increase the start index of the decoder fifo, but
              * if we do this now, the input thread could overwrite the
              * pointer to the current PES packet, and we weren't able to
              * give it back to the netlist. That's why we free the PES
              * packet first. */
-           input_NetlistFreePES (p_ac3dec->p_input, DECODER_FIFO_START(p_ac3dec->fifo));
-
-           DECODER_FIFO_INCSTART (p_ac3dec->fifo);
-
-           while (DECODER_FIFO_ISEMPTY(p_ac3dec->fifo)) {
-               vlc_cond_wait (&p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock);
-
-               if (p_ac3dec->p_input->b_die) {
-                   vlc_mutex_unlock (&(p_ac3dec->fifo.data_lock));
-                   return;
-               }
-           }
-
-           /* The next byte could be found in the next PES packet */
-           p_ac3dec->p_ts = DECODER_FIFO_START (p_ac3dec->fifo)->p_first_ts;
-
-           /* parse ac3 magic header */
-           ptr = p_ac3dec->p_ts->buffer [p_ac3dec->p_ts->i_payload_start+2];
-           ptr <<= 8;
-           ptr |= p_ac3dec->p_ts->buffer [p_ac3dec->p_ts->i_payload_start+3];
-           p_ac3dec->sync_ptr = ptr;
-           p_ac3dec->p_ts->i_payload_start += 4;
-
-           /* We can release the fifo's data lock */
-           vlc_mutex_unlock (&p_ac3dec->fifo.data_lock);
-       }
-
-       /* Perhaps the next TS packet of the current PES packet contains 
-        * real data (ie its payload's size is greater than 0) */
-       else {
-           p_ac3dec->p_ts = p_ac3dec->p_ts->p_next_ts;
-       }
+            input_NetlistFreePES (p_ac3dec->p_input, DECODER_FIFO_START(p_ac3dec->fifo));
+
+            DECODER_FIFO_INCSTART (p_ac3dec->fifo);
+
+            while (DECODER_FIFO_ISEMPTY(p_ac3dec->fifo)) {
+                vlc_cond_wait (&p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock);
+
+                if (p_ac3dec->p_input->b_die) {
+                    vlc_mutex_unlock (&(p_ac3dec->fifo.data_lock));
+                    return;
+                }
+            }
+
+            /* The next byte could be found in the next PES packet */
+            p_ac3dec->p_ts = DECODER_FIFO_START (p_ac3dec->fifo)->p_first_ts;
+
+            /* parse ac3 magic header */
+            ptr = p_ac3dec->p_ts->buffer [p_ac3dec->p_ts->i_payload_start+2];
+            ptr <<= 8;
+            ptr |= p_ac3dec->p_ts->buffer [p_ac3dec->p_ts->i_payload_start+3];
+            p_ac3dec->sync_ptr = ptr;
+            p_ac3dec->p_ts->i_payload_start += 4;
+
+            /* We can release the fifo's data lock */
+            vlc_mutex_unlock (&p_ac3dec->fifo.data_lock);
+        }
+
+        /* Perhaps the next TS packet of the current PES packet contains 
+         * real data (ie its payload's size is greater than 0) */
+        else {
+            p_ac3dec->p_ts = p_ac3dec->p_ts->p_next_ts;
+        }
     } while (p_ac3dec->p_ts->i_payload_start == p_ac3dec->p_ts->i_payload_end);
     p_byte_stream->p_byte =
-       p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_start; 
+        p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_start; 
     p_byte_stream->p_end =
-       p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_end; 
+        p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_end; 
 }
index e3f6a0daab565c1677ae40c4f3041078dc5ed995..e31cda6747a65bdf304a1ac2a3aabbdee4c6ed9c 100644 (file)
 
 #include <stdio.h>                                           /* "intf_msg.h" */
 
-#include "int_types.h"
+#include "common.h"
+
 #include "ac3_decoder.h"
 #include "ac3_internal.h"
 #include "ac3_bit_stream.h"
 
+#include "intf_msg.h"
+
 #define Q0 ((-2 << 15) / 3.0)
 #define Q1 (0)
 #define Q2 ((2 << 15) / 3.0)
index 69813ca39bcf1691d8dccf8c54554d06ff150730..7f08657e796455cc0c0ed727213d3d5e9afb1a07 100644 (file)
@@ -80,7 +80,8 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
 aout_thread_t *aout_CreateThread( int *pi_status )
 {
     aout_thread_t * p_aout;                             /* thread descriptor */
-    char * psz_method;
+    typedef void    ( aout_getplugin_t ) ( aout_thread_t * p_aout );
+    int             i_index;
 #if 0
     int             i_status;                                 /* thread status */
 #endif
@@ -92,32 +93,27 @@ aout_thread_t *aout_CreateThread( int *pi_status )
         return( NULL );
     }
 
-    /* Request an interface plugin */
-    psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
-    
-    if( RequestPlugin( &p_aout->aout_plugin, psz_method ) )
+    /* Get a suitable audio plugin */
+    for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
     {
-        intf_ErrMsg( "error: could not open audio plugin %s.so\n", psz_method );
-        free( p_aout );
-        return( NULL );
+        /* If there's a plugin in p_info ... */
+        if( p_main->p_bank->p_info[ i_index ] != NULL )
+        {
+            /* ... and if this plugin provides the functions we want ... */
+            if( p_main->p_bank->p_info[ i_index ]->aout_GetPlugin != NULL )
+            {
+                /* ... then get these functions */
+                ( (aout_getplugin_t *)
+                  p_main->p_bank->p_info[ i_index ]->aout_GetPlugin )( p_aout );
+            }
+        }
     }
 
-    /* Get plugins */
-    p_aout->p_sys_open =         GetPluginFunction( p_aout->aout_plugin, "aout_SysOpen" );
-    p_aout->p_sys_reset =        GetPluginFunction( p_aout->aout_plugin, "aout_SysReset" );
-    p_aout->p_sys_setformat =    GetPluginFunction( p_aout->aout_plugin, "aout_SysSetFormat" );
-    p_aout->p_sys_setchannels =  GetPluginFunction( p_aout->aout_plugin, "aout_SysSetChannels" );
-    p_aout->p_sys_setrate =      GetPluginFunction( p_aout->aout_plugin, "aout_SysSetRate" );
-    p_aout->p_sys_getbufinfo =   GetPluginFunction( p_aout->aout_plugin, "aout_SysGetBufInfo" );
-    p_aout->p_sys_playsamples =  GetPluginFunction( p_aout->aout_plugin, "aout_SysPlaySamples" );
-    p_aout->p_sys_close =        GetPluginFunction( p_aout->aout_plugin, "aout_SysClose" );
-
     /*
      * Initialize audio device
      */
     if ( p_aout->p_sys_open( p_aout ) )
     {
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
@@ -128,28 +124,24 @@ aout_thread_t *aout_CreateThread( int *pi_status )
     if ( p_aout->p_sys_reset( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
     if ( p_aout->p_sys_setformat( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
     if ( p_aout->p_sys_setchannels( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
     if ( p_aout->p_sys_setrate( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
@@ -163,7 +155,6 @@ aout_thread_t *aout_CreateThread( int *pi_status )
     if( aout_SpawnThread( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
@@ -330,9 +321,6 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
     p_aout->p_sys_close( p_aout );
     intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device);
 
-    /* Close plugin */
-    TrashPlugin( p_aout->aout_plugin );
-
     /* Free structure */
     free( p_aout );
 }
@@ -746,7 +734,7 @@ void aout_Thread_U8_Mono( aout_thread_t * p_aout )
                             }
                         }
 #define SOUND 1
-#define DEBUG 0
+#define ADEBUG 0
 #define COEFF 2
                         if ( p_aout->fifo[i_fifo].l_units > l_units )
                         {
@@ -771,7 +759,7 @@ l_buffer++;
 */
 #endif
 
-#if DEBUG 
+#if ADEBUG 
 //intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 11 : %x (%d)",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] );
 intf_DbgMsg( "p_aout->fifo %ld\n",COEFF*p_aout->fifo[i_fifo].l_unit );
 intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) );
@@ -822,7 +810,7 @@ if( COEFF*p_aout->fifo[i_fifo].l_unit < 60000 )
 */
 #endif
 
-#if DEBUG
+#if ADEBUG
 //intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 21 : %x (%d)",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] );
 intf_DbgMsg( "p_aout->fifo %ld\n",COEFF*p_aout->fifo[i_fifo].l_unit );
 intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) );
index e91d3215114ac373dc0d977e888d8b4e8eaf9234..056a1bf04af792d3f3c4ee21dcc5a770cb31361f 100644 (file)
@@ -433,11 +433,7 @@ static void EndThread( input_thread_t * p_input )
         {
         case MPEG1_VIDEO_ES:
         case MPEG2_VIDEO_ES:
-#ifdef OLD_DECODER
-            vdec_DestroyThread( (vdec_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ );
-#else
             vpar_DestroyThread( (vpar_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ );
-#endif
             break;
         case MPEG1_AUDIO_ES:
         case MPEG2_AUDIO_ES:
@@ -1212,11 +1208,7 @@ static __inline__ void input_ParsePES( input_thread_t *p_input,
         {
             case MPEG1_VIDEO_ES:
             case MPEG2_VIDEO_ES:
-#ifdef OLD_DECODER
-                p_fifo = &(((vdec_thread_t*)(p_es_descriptor->p_dec))->fifo);
-#else
                 p_fifo = &(((vpar_thread_t*)(p_es_descriptor->p_dec))->fifo);
-#endif
                 break;
 
             case MPEG1_AUDIO_ES:
@@ -1225,8 +1217,6 @@ static __inline__ void input_ParsePES( input_thread_t *p_input,
                 break;
 
             case AC3_AUDIO_ES:
-                /* we skip 4 bytes at the beginning of the AC3 payload */
-                //p_ts->i_payload_start += 4;
                 p_fifo = &(((ac3dec_thread_t *)(p_es_descriptor->p_dec))->fifo);
                 break;
 
@@ -1293,8 +1283,9 @@ static __inline__ void input_ParsePES( input_thread_t *p_input,
 /*****************************************************************************
  * input_DemuxPSI:
  *****************************************************************************
- * Notice that current ES state has been locked by input_SortPacket. (No more true,
- * changed by benny - FIXME: See if it's ok, and definitely change the code ?? )
+ * Notice that current ES state has been locked by input_SortPacket.
+ * (No more true, changed by benny - FIXME: See if it's ok, and definitely
+ * change the code ?? )
  *****************************************************************************/
 static __inline__ void input_DemuxPSI( input_thread_t *p_input,
                                        ts_packet_t *p_ts_packet,
@@ -1303,7 +1294,7 @@ static __inline__ void input_DemuxPSI( input_thread_t *p_input,
 {
     int i_data_offset;    /* Offset of the interesting data in the TS packet */
     u16 i_data_length;                               /* Length of those data */
-    //boolean_t b_first_section; /* Was there another section in the TS packet ? */
+  //boolean_t b_first_section;         /* another section in the TS packet ? */
 
     ASSERT(p_input);
     ASSERT(p_ts_packet);
@@ -1322,13 +1313,14 @@ static __inline__ void input_DemuxPSI( input_thread_t *p_input,
        It will be set to a correct value if the data are not corrupted */
     i_data_offset = TS_PACKET_SIZE;
 
-    /* Has the reassembly of a section already began in a previous packet ? */
+    /* Has the reassembly of a section already begun in a previous packet ? */
     if( p_psi->b_running_section )
     {
         /* Was data lost since the last TS packet ? */
         if( b_packet_lost )
         {
-            /* Discard the packet and wait for the begining of a new one to resynch */
+            /* Discard the packet and wait for the begining of a new one
+             * to resynch */
             p_psi->b_running_section = 0;
             p_psi->i_current_position = 0;
             intf_DbgMsg( "PSI section(s) discarded due to packet loss\n" );
@@ -1350,35 +1342,36 @@ static __inline__ void input_DemuxPSI( input_thread_t *p_input,
         if( b_unit_start )
         {
             /* Get the offset at which the data for that section can be found
-               The offset is stored in the pointer_field since we are interested in
-               the first section of the TS packet. Note that the +1 is to bypass
-               the pointer field */
+               The offset is stored in the pointer_field since we are
+               interested in the first section of the TS packet. Note that
+               the +1 is to bypass the pointer field */
             i_data_offset = p_ts_packet->i_payload_start +
                             p_ts_packet->buffer[p_ts_packet->i_payload_start] + 1;
             //intf_DbgMsg( "New section beginning at offset %d in TS packet\n", i_data_offset );
         }
         else
         {
-            /* This may either mean that the TS is bad or that the packet contains
-               the end of a section that had been discarded in a previous loop:
-               trash the TS packet since we cannot do anything with those data: */
+            /* This may either mean that the TS is bad or that the packet
+             * contains the end of a section that had been discarded in a
+             * previous loop: trash the TS packet since we cannot do
+             * anything with those data: */
             p_psi->b_running_section = 0;
             p_psi->i_current_position = 0;
             intf_DbgMsg( "PSI packet discarded due to lack of synchronisation\n" );
         }
     }
 
-    /* The section we will deal with during the first iteration of the following
-       loop is the first one contained in the TS packet */
+    /* The section we will deal with during the first iteration of the
+     * following loop is the first one contained in the TS packet */
     //    b_first_section = 1;
 
-    /* Reassemble the pieces of sections contained in the TS packet and decode
-       the sections that could have been completed.
-       Stop when we reach the end of the packet or stuffing bytes */
+    /* Reassemble the pieces of sections contained in the TS packet and
+     * decode the sections that could have been completed.
+     * Stop when we reach the end of the packet or stuffing bytes */
     while( i_data_offset < TS_PACKET_SIZE && p_ts_packet->buffer[i_data_offset] != 0xFF )
     {
-        /* If the current section is a new one, reinit the data fields of the p_psi
-           struct to start its decoding */
+        /* If the current section is a new one, reinit the data fields of
+         * the p_psi struct to start its decoding */
         if( !p_psi->b_running_section )
         {
             /* Read the length of the new section */
@@ -1386,7 +1379,8 @@ static __inline__ void input_DemuxPSI( input_thread_t *p_input,
             //intf_DbgMsg( "Section length %d\n", p_psi->i_length );
             if( p_psi->i_length > PSI_SECTION_SIZE )
             {
-                /* The TS packet is corrupted, stop here to avoid possible a seg fault */
+                /* The TS packet is corrupted, stop here to avoid possible
+                 * a seg fault */
                 intf_DbgMsg( "PSI Section size is too big, aborting its reception\n" );
                 break;
             }
index c00afbbb7aa99cd1f93f39cd8669f0eaecd9c42b..694762dfa4fc0a9b89e234989e0b6297dd7fcedd 100644 (file)
@@ -126,7 +126,6 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
                 {
                     
                     case AC3_AUDIO_ES:
-                        intf_Msg( "Start an AC3 decoder\n" );
                         /* Spawn ac3 thread */
                         if ( ((ac3dec_thread_t *)(p_input->p_es[i_es_loop].p_dec) =
                             ac3dec_CreateThread(p_input)) == NULL )
@@ -139,11 +138,12 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
 
                             case LPCM_AUDIO_ES:
                         /* Spawn lpcm thread */
-                        intf_Msg ( "Start a LPCM decoder\n" );
-                        if ( ((lpcmdec_thread_t *)(p_input->p_es[i_es_loop].p_dec) =
-                            lpcmdec_CreateThread(p_input)) == NULL )
+                        if ( ((lpcmdec_thread_t *)
+                              (p_input->p_es[i_es_loop].p_dec) =
+                              lpcmdec_CreateThread(p_input)) == NULL )
                         {
-                            intf_ErrMsg( "LPCM Debug: Could not start lpcm decoder\n" );
+                            intf_ErrMsg( "LPCM Debug: Could not start "
+                                         "lpcm decoder\n" );
                             vlc_mutex_unlock( &p_input->es_lock );
                             return( -1 );
                         }
@@ -152,8 +152,9 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
 
                     case DVD_SPU_ES:
                         /* Spawn spu thread */
-                        if ( ((spudec_thread_t *)(p_input->p_es[i_es_loop].p_dec) =
-                            spudec_CreateThread(p_input)) == NULL )
+                        if ( ((spudec_thread_t *)
+                              (p_input->p_es[i_es_loop].p_dec) =
+                              spudec_CreateThread(p_input)) == NULL )
                         {
                             intf_ErrMsg( "Could not start spu decoder\n" );
                             vlc_mutex_unlock( &p_input->es_lock );
@@ -176,19 +177,10 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
                     case MPEG1_VIDEO_ES:
                     case MPEG2_VIDEO_ES:
                         /* Spawn video thread. */
-#ifdef OLD_DECODER
-                        if( ((vdec_thread_t*)(p_input->p_es[i_es_loop].p_dec) =
-                            vdec_CreateThread( p_input )) == NULL )
-#else
                         if( ((vpar_thread_t*)(p_input->p_es[i_es_loop].p_dec) =
                             vpar_CreateThread( p_input )) == NULL )
-#endif
                         {
-#ifdef OLD_DECODER
-                            intf_ErrMsg("Could not start video decoder\n");
-#else
                             intf_ErrMsg("Could not start video parser\n");
-#endif
                             vlc_mutex_unlock( &p_input->es_lock );
                             return( -1 );
                         }
@@ -196,7 +188,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
 
                     default:
                         /* That should never happen. */
-                        intf_DbgMsg("input error: unknown stream type (0x%.2x)\n",
+                        intf_DbgMsg( "input error: unknown stream (0x%.2x)\n",
                                     p_input->p_es[i_es_loop].i_type);
                         vlc_mutex_unlock( &p_input->es_lock );
                         return( -1 );
@@ -209,8 +201,10 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
                 p_input->p_es[i_es_loop].b_random = 0;
 
                 /* Mark stream to be demultiplexed. */
-                intf_DbgMsg("Stream %d added in %d\n", i_current_id, i_selected_es_loop);
-                p_input->pp_selected_es[i_selected_es_loop] = &p_input->p_es[i_es_loop];
+                intf_DbgMsg( "Stream %d added in %d\n",
+                             i_current_id, i_selected_es_loop);
+                p_input->pp_selected_es[i_selected_es_loop] =
+                                                 &p_input->p_es[i_es_loop];
                 vlc_mutex_unlock( &p_input->es_lock );
                 return( 0 );
             }
@@ -281,11 +275,7 @@ int input_DelPgrmElem( input_thread_t *p_input, int i_current_id )
 
                     case MPEG1_VIDEO_ES:
                     case MPEG2_VIDEO_ES:
-#ifdef OLD_DECODER
-                        vdec_DestroyThread( (vdec_thread_t*)(p_input->pp_selected_es[i_selected_es_loop]->p_dec) /*, NULL */ );
-#else
                         vpar_DestroyThread( (vpar_thread_t*)(p_input->pp_selected_es[i_selected_es_loop]->p_dec) /*, NULL */ );
-#endif
                         break;
                 }
 
index c9b393d087c3976f882a566d6d14b51e835647cc..d3d4016fbacface621d4941514e22fddf15c6d61 100644 (file)
@@ -39,6 +39,8 @@
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
+#include "plugins.h"
+#include "playlist.h"
 #include "intf_msg.h"
 
 #include "main.h"
 #define NO_SUBTITLES 255
 
 #define PS_BUFFER_SIZE 16384
-#define NO_PES 0
-#define AUDIO_PES 1
-#define VIDEO_PES 2
-#define AC3_PES 3
-#define SUBTITLE_PES 4
-#define LPCM_PES 5
-#define PRIVATE_PES 6
-#define UNKNOWN_PES 12
+
+#define NO_PES          0x00
+#define AUDIO_PES       0x01
+#define VIDEO_PES       0x02
+#define AC3_PES         0x03
+#define SUBTITLE_PES    0x04
+#define LPCM_PES        0x05
+#define PRIVATE_PES     0x06
+#define UNKNOWN_PES     0x12
 
 #define PCR_PID 0x20 /* 0x20 == first video stream
                       * 0x40 == first audio stream */
@@ -105,8 +108,6 @@ typedef struct options_s
     unsigned int pcr_pid;
     u8 i_file_type;
     int in; 
-    char **playlist;
-    int i_list_index;
 } options_t;
 
 typedef struct s_ps
@@ -279,15 +280,17 @@ static void adjust( input_file_t * p_if, file_ts_packet *ts )
 
 int file_next( options_t *options )
 {
-    /* the check for index == 0 should be done _before_ */
-    options->i_list_index--;
-    
+    p_playlist_t p_playlist = p_main->p_playlist;
+
+    /* the check for index == 0 has to be done _before_ */
+    p_playlist->i_index--;
+
     if( options->in != -1 )
     {
-            close( options->in );
+        close( options->in );
     }
 
-    if( !strcmp( options->playlist[options->i_list_index], "-" ) )
+    if( !strcmp( p_playlist->p_list[ p_playlist->i_index ], "-" ) )
     {
         /* read stdin */
         return ( options->in = 0 );
@@ -295,10 +298,14 @@ int file_next( options_t *options )
     else
     {
         /* read the actual file */
-        fprintf( stderr, "Playing file %s\n",
-                 options->playlist[options->i_list_index] );
-        return ( options->in = open( options->playlist[options->i_list_index],
-                                     O_RDONLY | O_NONBLOCK ) );
+        intf_Msg( "Playing file %s\n",
+                  p_playlist->p_list[ p_playlist->i_index ] );
+
+        options->in =
+            open( p_playlist->p_list[ p_playlist->i_index ],
+                  O_RDONLY | O_NONBLOCK );
+
+        return ( options->in );
     }
 }
 
@@ -320,7 +327,7 @@ ssize_t safe_read( options_t *options, unsigned char *buf, int count )
         if( ret == 0 )
         {
             /* zero means end of file */
-            if( options->i_list_index )
+            if( p_main->p_playlist->i_index )
             {
                 file_next( options );
             }
@@ -917,23 +924,24 @@ void ps_fill( input_file_t * p_if, boolean_t wait )
         
         /* read a whole UDP packet from the file */
         p_ps->ts_to_write = how_many;
-        if(ps_read(&p_if->options, p_ps, ts = (file_ts_packet *)(p_in_data->buf + p_in_data->end)) != how_many)
+        if( ps_read( &p_if->options, p_ps, ts = (file_ts_packet *)(p_in_data->buf + p_in_data->end) ) != how_many )
         {
             msleep( 50000 ); /* XXX we need an INPUT_IDLE */
             intf_ErrMsg( "input error: read() error\n" );
+            return;
         }
         
         /* Scan to mark TS packets containing a PCR */
-        for(i=0; i<how_many; i++, ts++)
+        for( i = 0 ; i < how_many ; i++ , ts++ )
         {
-            pcr_flag |= keep_pcr(p_ps->pcr_pid, ts);
+            pcr_flag |= keep_pcr( p_ps->pcr_pid, ts );
         }
         
-        vlc_mutex_lock(&p_in_data->lock);
+        vlc_mutex_lock( &p_in_data->lock );
         p_in_data->end++;
-        p_in_data->end %= BUF_SIZE+1;
-        vlc_cond_signal(&p_in_data->notempty);
-        vlc_mutex_unlock(&p_in_data->lock);
+        p_in_data->end %= BUF_SIZE + 1;
+        vlc_cond_signal( &p_in_data->notempty );
+        vlc_mutex_unlock( &p_in_data->lock );
     }
 }
 
@@ -962,19 +970,13 @@ int init_synchro( input_file_t * p_if )
         {
             vlc_cond_wait(&p_in_data->notempty, &p_in_data->lock);
         }
-        /*
-        if( p_in_data->end == p_in_data->start )
-        {
-            intf_ErrMsg( "input error: init_synchro error, not enough PCR found\n" );
-            return( -1 );
-        }
-        */
+
         vlc_mutex_unlock( &p_in_data->lock );
         
         ts = (file_ts_packet*)(p_in_data->buf + p_in_data->start);
         for( i=0 ; i < howmany ; i++, ts++ )
         {
-            if( ts  == p_own_pcr->buf[p_own_pcr->start] && !(((u8*)ts)[5] & 0x80) )
+            if( ts == p_own_pcr->buf[p_own_pcr->start] && !(((u8*)ts)[5] & 0x80) )
             {
                 p_synchro->last_pcr = ts;
                 p_synchro->last_pcr_time = ConvertPCRTime( ts );
@@ -1015,9 +1017,6 @@ int input_FileOpen( input_thread_t *p_input )
 
     p_options->in = -1;
 
-    p_options->playlist = (char **)p_input->p_source;
-    p_options->i_list_index = p_input->i_port;
-
     if( file_next( p_options ) < 0 )
     {
         intf_ErrMsg( "input error: cannot open the file %s", p_input->p_source );
index 9be288c9f2f099f515f672fb107e3c1455249564..7bbd22b57ea129d2020c217e005b504918fa72a6 100644 (file)
@@ -51,6 +51,7 @@
 #include "input_vlan.h"
 
 #include "intf_msg.h"
+#include "plugins.h"
 #include "main.h"
 
 /*****************************************************************************
index c2492302114f66ebcb4bca62d2ba9b726696dc36..eb6bb2737c41c137b9b2bf7cd0b685aaf734a9dc 100644 (file)
@@ -38,6 +38,7 @@
 #include "threads.h"
 #include "mtime.h"
 #include "intf_msg.h"
+#include "plugins.h"
 #include "debug.h"
 
 #include "input.h"
index 8e6facd8a8768388992ecbbd01ba2219438a32c3..4b511c5e7d3d0c556b5d1086d238f79240b8188f 100644 (file)
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
+#include "plugins.h"
 #include "netutils.h"
 #include "input_vlan.h"
 #include "intf_msg.h"
+
 #include "main.h"
 
 /*****************************************************************************
index a6ef8ba435ce3a70493ed6d6ab1565190d7eadf6..15ed2a7a6fa610028e47e0eff05dc96a0bb3ba3d 100644 (file)
@@ -39,6 +39,7 @@
 #include "threads.h"
 #include "mtime.h"
 #include "plugins.h"
+#include "playlist.h"
 #include "input.h"
 
 #include "audio_output.h"
@@ -89,8 +90,9 @@ static int      ParseChannel    ( intf_channel_t *p_channel, char *psz_str );
  *****************************************************************************/
 intf_thread_t* intf_Create( void )
 {
-    intf_thread_t *p_intf;
-    char * psz_method;
+    intf_thread_t * p_intf;
+    typedef void    ( intf_getplugin_t ) ( intf_thread_t * p_intf );
+    int             i_index;
 
     /* Allocate structure */
     p_intf = malloc( sizeof( intf_thread_t ) );
@@ -100,24 +102,22 @@ intf_thread_t* intf_Create( void )
         return( NULL );
     }
 
-    /* Request an interface plugin */
-    psz_method = main_GetPszVariable( VOUT_METHOD_VAR, VOUT_DEFAULT_METHOD );
-
-    if( RequestPlugin( &p_intf->intf_plugin, psz_method ) < 0 )
+    /* Get a suitable interface plugin */
+    for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
     {
-        intf_ErrMsg( "error: could not open interface plugin %s.so\n", psz_method );
-        free( p_intf );
-        return( NULL );
+        /* If there's a plugin in p_info ... */
+        if( p_main->p_bank->p_info[ i_index ] != NULL )
+        {
+            /* ... and if this plugin provides the functions we want ... */
+            if( p_main->p_bank->p_info[ i_index ]->intf_GetPlugin != NULL )
+            {
+                /* ... then get these functions */
+                ( (intf_getplugin_t *)
+                  p_main->p_bank->p_info[ i_index ]->intf_GetPlugin )( p_intf );
+            }
+        }
     }
 
-    /* Get plugins */
-    p_intf->p_sys_create
-            = GetPluginFunction( p_intf->intf_plugin, "intf_SysCreate" );
-    p_intf->p_sys_manage
-            = GetPluginFunction( p_intf->intf_plugin, "intf_SysManage" );
-    p_intf->p_sys_destroy
-            = GetPluginFunction( p_intf->intf_plugin, "intf_SysDestroy" );
-
     /* Initialize structure */
     p_intf->b_die =     0;
     p_intf->p_vout =    NULL;
@@ -133,7 +133,6 @@ intf_thread_t* intf_Create( void )
     if( p_intf->p_console == NULL )
     {
         intf_ErrMsg("error: can't create control console\n");
-        TrashPlugin( p_intf->intf_plugin );
         free( p_intf );
         return( NULL );
     }
@@ -141,7 +140,6 @@ intf_thread_t* intf_Create( void )
     {
         intf_ErrMsg("error: can't create interface\n");
         intf_ConsoleDestroy( p_intf->p_console );
-        TrashPlugin( p_intf->intf_plugin );
         free( p_intf );
         return( NULL );
     }
@@ -157,9 +155,9 @@ intf_thread_t* intf_Create( void )
  *****************************************************************************/
 void intf_Run( intf_thread_t *p_intf )
 {
-    if( p_intf->p_playlist )
+    if( p_main->p_playlist->p_list )
     {
-        p_intf->p_input = input_CreateThread( INPUT_METHOD_TS_FILE, (void *)p_intf->p_playlist, p_intf->i_list_index, 0, p_main->p_intf->p_vout, p_main->p_aout, NULL );
+        p_intf->p_input = input_CreateThread( INPUT_METHOD_TS_FILE, NULL, 0, 0, p_main->p_intf->p_vout, p_main->p_aout, NULL );
     }
     /* Execute the initialization script - if a positive number is returned,
      * the script could be executed but failed */
@@ -210,13 +208,6 @@ void intf_Destroy( intf_thread_t *p_intf )
     /* Unload channels */
     UnloadChannels( p_intf );
 
-    /* XXX: Close plugin - we don't do it because it makes the Gnome
-     * plugin segfaulting */
-    /*TrashPlugin( p_intf->intf_plugin );*/
-
-    /* Close plugin */
-    TrashPlugin( p_intf->intf_plugin );
-
     /* Free structure */
     free( p_intf );
 }
index e0f592cacc6562a672b3ab846a5024458d8d9299..5f89ce9563b5cca24b277ae2d5cee711a2c36dba 100644 (file)
@@ -165,7 +165,7 @@ int intf_ExecScript( char *psz_filename )
     p_file = fopen( psz_filename, "r" );
     if( p_file == NULL )
     {
-        intf_ErrMsg("warning: %s: %s\n", psz_filename, strerror(errno));
+        intf_DbgMsg("intf warning: %s: %s\n", psz_filename, strerror(errno));
         return( -1 );
     }
 
index 327a93779dc5f47dd9625d7a7b393b736f9c0da5..593787064797ed75abe98d6b3bface4b7742685a 100644 (file)
@@ -463,8 +463,6 @@ static int SpawnInput( int i_argc, intf_arg_t *p_argv )
     int                 i_port = 0;                        /* port parameter */
     int                 i_vlan = 0;                        /* vlan parameter */
 
-    fprintf( stderr, "spawn input\n" );
-
     /* Parse parameters - see command list above */
     for ( i_arg = 1; i_arg < i_argc; i_arg++ )
     {
@@ -535,10 +533,10 @@ static int Vlan( int i_argc, intf_arg_t *p_argv  )
 {
     int i_command;                                /* command argument number */
 
-    /* Do not try anything if vlans are desactivated */
+    /* Do not try anything if vlans are deactivated */
     if( !p_main->b_vlans )
     {
-        intf_IntfMsg("vlans are desactivated");
+        intf_IntfMsg("vlans are deactivated");
         return( INTF_OTHER_ERROR );
     }
 
index df32efe6ad942fbce7d6cbe779cf4d0ab265e665..b991a4e896ddd24c9ebf03de0aee48270dbfdeae 100644 (file)
@@ -40,6 +40,7 @@
 #include "threads.h"
 #include "mtime.h"
 #include "plugins.h"
+#include "playlist.h"
 #include "input_vlan.h"
 #include "input_ps.h"
 
@@ -132,7 +133,8 @@ main_t *p_main;
  * Local prototypes
  *****************************************************************************/
 static void SetDefaultConfiguration ( void );
-static int  GetConfiguration        ( int i_argc, char *ppsz_argv[], char *ppsz_env[] );
+static int  GetConfiguration        ( int i_argc, char *ppsz_argv[],
+                                      char *ppsz_env[] );
 static void Usage                   ( int i_fashion );
 static void Version                 ( void );
 
@@ -147,131 +149,152 @@ static int  TestMMX                 ( void );
  *****************************************************************************
  * Steps during program execution are:
  *      -configuration parsing and messages interface initialization
- *      -openning of audio output device and some global modules
+ *      -opening of audio output device and some global modules
  *      -execution of interface, which exit on error or on user request
  *      -closing of audio output device and some global modules
- * On error, the spawned threads are cancelled, and the open devices closed.
+ * On error, the spawned threads are canceled, and the open devices closed.
  *****************************************************************************/
 int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
 {
     main_t  main_data;                      /* root of all data - see main.h */
-    char **p_playlist;
-    int i_list_index;
 
     p_main = &main_data;                       /* set up the global variable */
 
+#ifdef SYS_BEOS
     /*
      * System specific initialization code
      */
-#ifdef SYS_BEOS
-    beos_Init();
+    beos_Create();
 #endif
 
+#ifdef HAVE_MMX
     /*
-     * Read configuration, initialize messages interface and set up program
+     * Test if our code is likely to run on this CPU 
      */
-#ifdef HAVE_MMX
     if( !TestMMX() )
     {
-        fprintf( stderr, "Sorry, this program needs an MMX processor. Please run the non-MMX version.\n" );
+        fprintf( stderr, "Sorry, this program needs an MMX processor. "
+                         "Please run the non-MMX version.\n" );
         return( 1 );
     }
 #endif
+
+    /*
+     * Initialize messages interface
+     */
     p_main->p_msg = intf_MsgCreate();
     if( !p_main->p_msg )                         /* start messages interface */
     {
-        fprintf( stderr, "critical error: can't initialize messages interface (%s)\n",
+        fprintf( stderr, "error: can't initialize messages interface (%s)\n",
                 strerror(errno) );
         return( errno );
     }
+
+    /*
+     * Read configuration
+     */
     if( GetConfiguration( i_argc, ppsz_argv, ppsz_env ) )  /* parse cmd line */
     {
         intf_MsgDestroy();
+        fprintf( stderr, "error: can't read configuration (%s)\n",
+                strerror(errno) );
         return( errno );
     }
 
-    /* get command line files */
-    i_list_index = 0;
-
-    if( optind < i_argc )
+    /*
+     * Initialize playlist and get commandline files
+     */
+    p_main->p_playlist = playlist_Create( );
+    if( !p_main->p_playlist )
     {
-        int i_index = 0;
-        p_playlist = malloc( (i_list_index = i_argc - optind)
-                                        * sizeof(int) );
-
-        while( i_argc - i_index > optind )
-        {
-            p_playlist[ i_index ] = ppsz_argv[ i_argc - i_index - 1];
-            i_index++;
-        }
+        intf_Msg( "Playlist initialization failed\n" );
+        intf_MsgDestroy();
+        return( errno );
     }
-    else
+    playlist_Init( p_main->p_playlist, optind );
+
+    /*
+     * Initialize plugin bank
+     */
+    p_main->p_bank = bank_Create( );
+    if( !p_main->p_bank )
     {
-        p_playlist = NULL;
+        intf_Msg( "Plugin bank initialization failed\n" );
+        playlist_Destroy( p_main->p_playlist );
+        intf_MsgDestroy();
+        return( errno );
     }
-
-    intf_MsgImm( COPYRIGHT_MESSAGE "\n" );          /* print welcome message */
+    bank_Init( p_main->p_bank );
 
     /*
      * Initialize shared resources and libraries
      */
-    if( main_data.b_vlans && input_VlanCreate() )
+    if( p_main->b_vlans && input_VlanCreate() )
     {
-        /* On error during vlans initialization, switch of vlans */
-        intf_Msg( "Virtual LANs initialization failed : vlans management is deactivated\n" );
-        main_data.b_vlans = 0;
+        /* On error during vlans initialization, switch off vlans */
+        intf_Msg( "Virtual LANs initialization failed : "
+                  "vlans management is deactivated\n" );
+        p_main->b_vlans = 0;
     }
 
     /*
      * Open audio device and start aout thread
      */
-    if( main_data.b_audio )
+    if( p_main->b_audio )
     {
-        main_data.p_aout = aout_CreateThread( NULL );
-        if( main_data.p_aout == NULL )
+        p_main->p_aout = aout_CreateThread( NULL );
+        if( p_main->p_aout == NULL )
         {
-            /* On error during audio initialization, switch of audio */
+            /* On error during audio initialization, switch off audio */
             intf_Msg( "Audio initialization failed : audio is deactivated\n" );
-            main_data.b_audio = 0;
+            p_main->b_audio = 0;
         }
     }
 
     /*
      * Run interface
      */
-    main_data.p_intf = intf_Create();
-    if( main_data.p_intf != NULL )
+    p_main->p_intf = intf_Create();
+    if( p_main->p_intf != NULL )
     {
-        main_data.p_intf->p_playlist = p_playlist;
-        main_data.p_intf->i_list_index = i_list_index;
-
         InitSignalHandler();             /* prepare signals for interception */
 
-        intf_Run( main_data.p_intf );
-        intf_Destroy( main_data.p_intf );
+        intf_Run( p_main->p_intf );
+
+        intf_Destroy( p_main->p_intf );
     }
 
     /*
      * Close audio device
      */
-    if( main_data.b_audio )
+    if( p_main->b_audio )
     {
-        aout_DestroyThread( main_data.p_aout, NULL );
+        aout_DestroyThread( p_main->p_aout, NULL );
     }
 
     /*
      * Free shared resources and libraries
      */
-    if( main_data.b_vlans )
+    if( p_main->b_vlans )
     {
         input_VlanDestroy();
     }
 
     /*
-     * System specific cleaning code
+     * Free plugin bank
      */
+    bank_Destroy( p_main->p_bank );
+
+    /*
+     * Free playlist
+     */
+    playlist_Destroy( p_main->p_playlist );
+
 #ifdef SYS_BEOS
-    beos_Clean();
+    /*
+     * System specific cleaning code
+     */
+    beos_Destroy();
 #endif
 
     /*
@@ -279,6 +302,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
      */
     intf_Msg( "Program terminated.\n" );
     intf_MsgDestroy();
+
     return( 0 );
 }
 
@@ -515,7 +539,7 @@ static int GetConfiguration( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
 static void Usage( int i_fashion )
 {
     /* Usage */
-    intf_Msg( "Usage: vlc [options] [parameters]\n" );
+    intf_Msg( "Usage: vlc [options] [parameters] [file]...\n" );
 
     if( i_fashion == USAGE )
     {
@@ -653,18 +677,18 @@ static void SignalHandler( int i_signal )
  * TestMMX: tests if the processor has MMX support.
  *****************************************************************************
  * This function is called if HAVE_MMX is enabled, to check whether the
- * cpu really supports MMX.
+ * CPU really supports MMX.
  *****************************************************************************/
 static int TestMMX( void )
 {
-/* FIXME: under beos, gcc does not support the foolowing inline assembly */ 
+/* FIXME: under beos, gcc does not support the following inline assembly */ 
 #ifdef SYS_BEOS
     return( 1 );
 #else
 
     int i_reg, i_dummy = 0;
 
-    /* test for a 386 cpu */
+    /* test for a 386 CPU */
     asm volatile ( "pushfl
                     popl %%eax
                     movl %%eax, %%ecx
@@ -680,7 +704,7 @@ static int TestMMX( void )
     if( !i_reg )
         return( 0 );
 
-    /* test for a 486 cpu */
+    /* test for a 486 CPU */
     asm volatile ( "movl %%ecx, %%eax
                     xorl $0x200000, %%eax
                     pushl %%eax
@@ -696,7 +720,7 @@ static int TestMMX( void )
     if( !i_reg )
         return( 0 );
 
-    /* the cpu supports the CPUID instruction - get its level */
+    /* the CPU supports the CPUID instruction - get its level */
     asm volatile ( "cpuid"
                  : "=a" ( i_reg ),
                    "=b" ( i_dummy ),
@@ -705,7 +729,7 @@ static int TestMMX( void )
                  : "a"  ( 0 ),       /* level 0 */
                    "b"  ( i_dummy ) ); /* buggy compiler shouldn't complain */
 
-    /* this shouldn't happen on a normal cpu */
+    /* this shouldn't happen on a normal CPU */
     if( !i_reg )
         return( 0 );
 
index e92b15af5f865d0143afc34bda2bbd8f0e115eda..e7639e3a0ac2234a322b529c9f2926ba5587a97b 100644 (file)
@@ -55,7 +55,7 @@ void beos_AppThread( void * args )
     delete BeApp;
 }
 
-void beos_Init( void )
+void beos_Create( void )
 {
     int i_lenght;
     BPath path;
@@ -78,7 +78,7 @@ void beos_Init( void )
     strcpy( psz_beos_program_path, path.Path() );
 }
 
-void beos_Clean( void )
+void beos_Destroy( void )
 {
     free( psz_beos_program_path ); /* XXX */
     be_app->PostMessage( B_QUIT_REQUESTED );
diff --git a/src/misc/playlist.c b/src/misc/playlist.c
new file mode 100644 (file)
index 0000000..162b421
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * playlist.c : Playlist management functions
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+#include "defs.h"
+
+#include "config.h"
+
+#include <stdlib.h>                                      /* free(), strtol() */
+#include <stdio.h>                                              /* sprintf() */
+#include <string.h>                                            /* strerror() */
+#include <errno.h>                                                 /* ENOMEM */
+
+#include "common.h"
+
+#include "intf_msg.h"
+#include "playlist.h"
+
+#include "main.h"
+
+/* Local prototypes */
+//int TestPlugin     ( plugin_id_t *p_plugin_id, char * psz_name );
+//int AllocatePlugin ( plugin_id_t plugin_id, plugin_bank_t * p_bank );
+
+playlist_t * playlist_Create ( void )
+{
+    playlist_t *p_playlist;
+
+    /* Allocate structure */
+    p_playlist = malloc( sizeof( playlist_t ) );
+    if( !p_playlist )
+    {
+        intf_ErrMsg("playlist error: %s\n", strerror( ENOMEM ) );
+        return( NULL );
+    }
+
+    p_playlist->i_index = 0;
+    p_playlist->p_list = NULL;
+
+    intf_Msg("Playlist initialized\n");
+    return( p_playlist );
+}
+
+void playlist_Init( playlist_t * p_playlist, int i_optind )
+{
+    int i_list_index = 0;
+    int i_index = 0;
+    int i_argc = p_main->i_argc;
+
+    if( i_optind < i_argc )
+    {
+        i_list_index = i_argc - i_optind;
+
+        p_playlist->p_list = malloc( i_list_index * sizeof( int ) );
+
+        while( i_argc - i_index > i_optind )
+        {
+            p_playlist->p_list[ i_index ] =
+                            p_main->ppsz_argv[ i_argc - i_index - 1];
+            i_index++;
+        }
+    }
+    else
+    {
+        /* if no file was asked, get stream from the network */
+        p_playlist->p_list = NULL;
+    }
+
+    p_main->p_playlist->i_index = i_list_index;
+}
+
+void playlist_Destroy( playlist_t * p_playlist )
+{
+    free( p_playlist );
+}
+
+/*
+ * Following functions are local
+ */
+
index 105adf4b59b7b41adde4dd13ab265a6ecc66e049..cf8c4de790f0e58f429622c2365c5452ac20da2a 100644 (file)
  *****************************************************************************/
 #include "defs.h"
 
+#include "config.h"
+
 #include <stdlib.h>                                      /* free(), strtol() */
 #include <stdio.h>                                              /* sprintf() */
+#include <string.h>                                            /* strerror() */
+#include <errno.h>                                                 /* ENOMEM */
 
 #if defined(HAVE_DLFCN_H)                                /* Linux, BSD, Hurd */
 #include <dlfcn.h>                           /* dlopen(), dlsym(), dlclose() */
 #include "beos_specific.h"
 #endif
 
+#include "common.h"
+
+#include "intf_msg.h"
 #include "plugins.h"
 
-#define PLUGIN_PATH_COUNT 3
+/* Local prototypes */
+char * TestPlugin     ( plugin_id_t *p_plugin_id, char * psz_name );
+int    AllocatePlugin ( plugin_id_t plugin_id, plugin_bank_t * p_bank,
+                        char * psz_filename );
+
+plugin_bank_t * bank_Create( void )
+{
+    plugin_bank_t *p_bank;
+    int i;
+
+    /* Allocate structure */
+    p_bank = malloc( sizeof( plugin_bank_t ) );
+    if( !p_bank )
+    {
+        intf_ErrMsg("plugin bank error: %s\n", strerror( ENOMEM ) );
+        return( NULL );
+    }
+
+    /* Initialize structure */
+    for( i = 0 ; i < MAX_PLUGIN_COUNT ; i++ )
+    {
+        p_bank->p_info[ i ] = NULL;
+    }
+    p_bank->i_plugin_count = MAX_PLUGIN_COUNT;
+
+    intf_Msg("Plugin bank initialized\n");
+    return( p_bank );
+}
+
+void bank_Init( plugin_bank_t * p_bank )
+{
+    plugin_id_t tmp;
+    char * psz_filename;
+
+    /* FIXME: we should browse all directories to get plugins */
+#define SEEK_PLUGIN( name ) \
+    psz_filename = TestPlugin( &tmp, name ); \
+    if( psz_filename ) AllocatePlugin( tmp, p_bank, psz_filename );
+
+    SEEK_PLUGIN( "beos" );
+    SEEK_PLUGIN( "x11" );
+    SEEK_PLUGIN( "dsp" );
+    SEEK_PLUGIN( "gnome" );
+    SEEK_PLUGIN( "ggi" );
+    SEEK_PLUGIN( "fb" );
+    SEEK_PLUGIN( "yuvmmx" );
+    SEEK_PLUGIN( "yuv" );
+    SEEK_PLUGIN( "dummy" );
+
+#undef SEEK_PLUGIN
+}
+
+void bank_Destroy( plugin_bank_t * p_bank )
+{
+    free( p_bank );
+}
+
+/*
+ * Following functions are local
+ */
+
+int AllocatePlugin( plugin_id_t plugin_id, plugin_bank_t * p_bank,
+                    char * psz_filename )
+{
+    typedef plugin_info_t * ( get_config_t ) ( void );
+    get_config_t * p_func;   
+    int i;
+
+    for( i = 0 ; i < p_bank->i_plugin_count ; i++ )
+    {
+        if( p_bank->p_info[ i ] == NULL )
+        {
+            break;
+        }
+    }
+
+    /* no room to store that plugin, quit */
+    if( i == p_bank->i_plugin_count )
+    {
+        intf_ErrMsg( "plugin bank error: reached max plugin count (%i), "
+                     "increase MAX_PLUGIN_COUNT\n", p_bank->i_plugin_count );
+        return( -1 );
+    }
+
+    /* system-specific dynamic symbol loading */
+    GET_PLUGIN( p_func, plugin_id, "GetConfig" );
+
+    /* if it failed, just quit */
+    if( !p_func )
+    {
+        return( -1 );
+    }
+
+    /* run the plugin function to initialize the structure */
+    p_bank->p_info[ i ]            = p_func( );
+    p_bank->p_info[ i ]->plugin_id = plugin_id;
+
+    /* Tell the world we found it */
+    intf_Msg( "Found plugin: %s (version %s)\n", p_bank->p_info[ i ]->psz_name,
+              p_bank->p_info[ i ]->psz_version );
+
+    /* return nicely */
+    return( 0 );
+}
 
-int RequestPlugin ( plugin_id_t * p_plugin, char * psz_name )
+
+char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name )
 {
     int i_count, i_length;
     char * psz_plugin;
-    char * psz_plugin_path[ PLUGIN_PATH_COUNT ] =
+    char * psz_plugin_path[ ] =
     {
         ".",
         "lib", /* this one should disappear */
-        PLUGIN_PATH
+        PLUGIN_PATH,
+        NULL
     };
 
     i_length = strlen( psz_name );
 
-    for ( i_count = 0 ; i_count < PLUGIN_PATH_COUNT ; i_count++ )
+    for ( i_count = 0 ; psz_plugin_path[ i_count ] ; i_count++ )
     {
 #ifdef SYS_BEOS
         char * psz_program_path;
@@ -66,48 +178,44 @@ int RequestPlugin ( plugin_id_t * p_plugin, char * psz_name )
         sprintf( psz_plugin, "%s/%s/%s.so", psz_program_path,
                  psz_plugin_path[i_count], psz_name );        
 
-        *p_plugin = load_add_on( psz_plugin );
+        *p_plugin_id = load_add_on( psz_plugin );
 #else
         psz_plugin = malloc( strlen(psz_plugin_path[i_count]) + i_length + 5 );
         sprintf( psz_plugin, "%s/%s.so", psz_plugin_path[i_count], psz_name );
 
-        *p_plugin = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL );
+        *p_plugin_id = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL );
 #endif
 
-        free( psz_plugin );
-
-#if defined(HAVE_DLFCN_H)
-       if( *p_plugin != NULL )
-#elif defined(HAVE_IMAGE_H)
-        if( *p_plugin >= 0 )
+#ifdef SYS_BEOS
+        if( *p_plugin_id >= 0 )
+#else
+       if( *p_plugin_id != NULL )
 #endif
         {
-            return( 0 );
+            /* plugin successfuly dlopened */
+            return( psz_plugin );
+        }
+#ifndef SYS_BEOS
+        else
+        {
+            intf_DbgMsg( "%s\n", dlerror() );
         }
+#endif
+
+        free( psz_plugin );
     }
 
-    return( -1 );
+    return( NULL );
 }
 
-void TrashPlugin ( plugin_id_t plugin )
+#if 0
+void TrashPlugin ( plugin_id_t plugin_id )
 {
-#if defined(HAVE_DLFCN_H)
-    dlclose( plugin );
-#elif defined(HAVE_IMAGE_H)
-    unload_add_on( plugin );
+#ifdef SYS_BEOS
+    unload_add_on( plugin_id );
+#else
+    dlclose( plugin_id );
 #endif
 }
-
-void * GetPluginFunction ( plugin_id_t plugin, char *psz_name )
-{
-#if defined(HAVE_DLFCN_H)
-    return( dlsym(plugin, psz_name) );
-#elif defined(HAVE_IMAGE_H)
-    void * p_func;   
-    if( get_image_symbol( plugin, psz_name, B_SYMBOL_TYPE_TEXT, &p_func ) )
-        return( NULL );
-    else
-        return( p_func );    
 #endif
-}
 
index e94ccd81e0ce50d5948e36ab4cf557165c82fb68..c64c01c22fbaabb53cffba3600c46054d8e2eb02 100644 (file)
@@ -126,7 +126,8 @@ spudec_thread_t * spudec_CreateThread( input_thread_t * p_input )
  *****************************************************************************/
 void spudec_DestroyThread( spudec_thread_t *p_spudec )
 {
-    intf_DbgMsg("spudec debug: requesting termination of spu decoder thread %p\n", p_spudec);
+    intf_DbgMsg( "spudec debug: requesting termination of "
+                 "spu decoder thread %p\n", p_spudec);
 
     /* Ask thread to kill itself */
     p_spudec->b_die = 1;
@@ -180,7 +181,7 @@ static int InitThread( spudec_thread_t *p_spudec )
 /*****************************************************************************
  * RunThread: spu decoder thread
  *****************************************************************************
- * spu decoder thread. This function does only return when the thread is
+ * spu decoder thread. This function only returns when the thread is
  * terminated.
  *****************************************************************************/
 static void RunThread( spudec_thread_t *p_spudec )
@@ -213,7 +214,7 @@ static void RunThread( spudec_thread_t *p_spudec )
         while( !DECODER_FIFO_ISEMPTY(p_spudec->fifo) )
         {
             /* wait for the next SPU ID.
-             * XXX: We trash 0xff bytes since they come from
+             * XXX: We trash 0xff bytes since they probably come from
              * an incomplete previous packet */
             do
             {
@@ -284,30 +285,30 @@ static void RunThread( spudec_thread_t *p_spudec )
 
                         switch( i_cmd )
                         {
-                            case 0x00:
+                            case SPU_CMD_FORCE_DISPLAY:
                                 /* 00 (force displaying) */
                                 break;
                             /* FIXME: here we have to calculate dates. It's
                              * around i_date * 12000 but I don't know
                              * how much exactly.
                              */
-                            case 0x01:
+                            case SPU_CMD_START_DISPLAY:
                                 /* 01 (start displaying) */
                                 p_spu->begin_date += ( i_date * 12000 );
                                 break;
-                            case 0x02:
+                            case SPU_CMD_STOP_DISPLAY:
                                 /* 02 (stop displaying) */
                                 p_spu->end_date += ( i_date * 12000 );
                                 break;
-                            case 0x03:
+                            case SPU_CMD_SET_PALETTE:
                                 /* 03xxxx (palette) */
                                 GetWord( i_word );
                                 break;
-                            case 0x04:
+                            case SPU_CMD_SET_ALPHACHANNEL:
                                 /* 04xxxx (alpha channel) */
                                 GetWord( i_word );
                                 break;
-                            case 0x05:
+                            case SPU_CMD_SET_COORDINATES:
                                 /* 05xxxyyyxxxyyy (coordinates) */
                                 i_word = GetByte( &p_spudec->bit_stream );
                                 p_spu->i_x = (i_word << 4)
@@ -327,26 +328,29 @@ static void RunThread( spudec_thread_t *p_spudec )
 
                                i_index += 6;
                                 break;
-                            case 0x06:
+                            case SPU_CMD_SET_OFFSETS:
                                 /* 06xxxxyyyy (byte offsets) */
                                 GetWord( i_word );
                                 p_spu->type.spu.i_offset[0] = i_word - 4;
                                 GetWord( i_word );
                                 p_spu->type.spu.i_offset[1] = i_word - 4;
                                 break;
-                            case 0xff:
+                            case SPU_CMD_END:
                                 /* ff (end) */
                                 break;
                             default:
                                 /* ?? (unknown command) */
+                                intf_ErrMsg( "spudec: unknown command 0x%.2x\n",
+                                             i_cmd );
                                 break;
                         }
                     }
-                    while( i_cmd != 0xff );
+                    while( i_cmd != SPU_CMD_END );
                 }
                 while( !b_finished );
 
-                /* SPU is finished - we can display it */
+                /* SPU is finished - we can tell the video output
+                 * to display it */
                 vout_DisplaySubPicture( p_spudec->p_vout, p_spu );
             }
             else 
index 3f4668fc9034b390686f3ea740120ab86f90404d..2d859f25200065d25ed0e47e73e85969c1b49a00 100644 (file)
@@ -121,6 +121,7 @@ __MotionComponents (8,16)   /* 422 */
            }                                                                \
        }                                                                    \
     }
+
 /*****************************************************************************
  * vdec_MotionComponent : last stage of motion compensation
  *****************************************************************************/
@@ -425,7 +426,7 @@ void vdec_MotionFieldField444( macroblock_t * p_mb )
 }
 
 /*****************************************************************************
- * vdec_MotionField16x8XXX?? : motion compensation for 16x8 motion type (field)
+ * vdec_MotionField16x8XXX: motion compensation for 16x8 motion type (field)
  *****************************************************************************/
 #define FIELD16X8( MOTION )                                             \
 {                                                                       \
index b97e742acfb062ea9889fd17cd79d9423fbbd47d..c46f26172976135eb0160891ce104d3e66d995bb 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * vdec_motion.c : motion compensation routines
+ * vdec_motion_inner.c : motion compensation inner routines
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
  *
index 2514f4d7f465e304909e81573d9587c12792d27d..5293f2e111320d6f5449bf82488f68802a31c733 100644 (file)
@@ -91,9 +91,9 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
                           int i_method, void *p_data )
 {
     vout_thread_t * p_vout;                             /* thread descriptor */
+    typedef void    ( vout_getplugin_t ) ( vout_thread_t * p_vout );
     int             i_status;                               /* thread status */
     int             i_index;               /* index for array initialization */
-    char *          psz_method;
 
     /* Allocate descriptor */
     intf_DbgMsg("\n");
@@ -104,30 +104,24 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
         return( NULL );
     }
 
-    /* Request an interface plugin */
-    psz_method = main_GetPszVariable( VOUT_METHOD_VAR, VOUT_DEFAULT_METHOD );
+    p_vout->p_set_palette       = SetPalette;
 
-    if( RequestPlugin( &p_vout->vout_plugin, psz_method ) < 0 )
+    /* Get a suitable video plugin */
+    for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
     {
-        intf_ErrMsg( "error: could not open video plugin %s.so\n", psz_method );
-        free( p_vout );
-        return( NULL );
+        /* If there's a plugin in p_info ... */
+        if( p_main->p_bank->p_info[ i_index ] != NULL )
+        {
+            /* ... and if this plugin provides the functions we want ... */
+            if( p_main->p_bank->p_info[ i_index ]->vout_GetPlugin != NULL )
+            {
+                /* ... then get these functions */
+                ( (vout_getplugin_t *)
+                  p_main->p_bank->p_info[ i_index ]->vout_GetPlugin )( p_vout );
+            }
+        }
     }
 
-    /* Get plugins */
-    p_vout->p_sys_create = 
-        GetPluginFunction( p_vout->vout_plugin, "vout_SysCreate" );
-    p_vout->p_sys_init =
-        GetPluginFunction( p_vout->vout_plugin, "vout_SysInit" );
-    p_vout->p_sys_end =
-        GetPluginFunction( p_vout->vout_plugin, "vout_SysEnd" );
-    p_vout->p_sys_destroy =
-        GetPluginFunction( p_vout->vout_plugin, "vout_SysDestroy" );
-    p_vout->p_sys_manage =
-        GetPluginFunction( p_vout->vout_plugin, "vout_SysManage" );
-    p_vout->p_sys_display =
-        GetPluginFunction( p_vout->vout_plugin, "vout_SysDisplay" );
-
     /* Initialize thread properties - thread id and locks will be initialized
      * later */
     p_vout->b_die               = 0;
@@ -136,8 +130,9 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
     p_vout->pi_status           = (pi_status != NULL) ? pi_status : &i_status;
     *p_vout->pi_status          = THREAD_CREATE;
 
-    /* Initialize some fields used by the system-dependant method - these fields will
-     * probably be modified by the method, and are only preferences */
+    /* Initialize some fields used by the system-dependant method - these
+     * fields will probably be modified by the method, and are only
+     * preferences */
     p_vout->i_changes           = 0;
     p_vout->i_width             = i_width;
     p_vout->i_height            = i_height;
@@ -152,8 +147,6 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
     p_vout->b_interface         = 0;
     p_vout->b_scale             = 0;
 
-    p_vout->p_set_palette       = SetPalette;
-
     intf_DbgMsg( "wished configuration: %dx%d, %d/%d bpp (%d Bpl)\n",
                  p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
                  p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
@@ -193,19 +186,23 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
      * own error messages */
     if( p_vout->p_sys_create( p_vout, psz_display, i_root_window, p_data ) )
     {
-        TrashPlugin( p_vout->vout_plugin );
         free( p_vout );
         return( NULL );
     }
-    intf_DbgMsg("actual configuration: %dx%d, %d/%d bpp (%d Bpl), masks: 0x%x/0x%x/0x%x\n",
-                p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
-                p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
-                p_vout->i_red_mask, p_vout->i_green_mask, p_vout->i_blue_mask );
+    intf_DbgMsg( "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
+                 "masks: 0x%x/0x%x/0x%x\n",
+                 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
+                 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
+                 p_vout->i_red_mask, p_vout->i_green_mask,
+                 p_vout->i_blue_mask );
 
     /* Calculate shifts from system-updated masks */
-    MaskToShift( &p_vout->i_red_lshift,   &p_vout->i_red_rshift,   p_vout->i_red_mask );
-    MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift, p_vout->i_green_mask );
-    MaskToShift( &p_vout->i_blue_lshift,  &p_vout->i_blue_rshift,  p_vout->i_blue_mask );
+    MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
+                 p_vout->i_red_mask );
+    MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
+                 p_vout->i_green_mask );
+    MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
+                 p_vout->i_blue_mask );
 
     /* Set some useful colors */
     p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
@@ -215,28 +212,28 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
 
     /* Load fonts - fonts must be initialized after the system method since
      * they may be dependant on screen depth and other thread properties */
-    p_vout->p_default_font      = vout_LoadFont( DATA_PATH "/" VOUT_DEFAULT_FONT );
+    p_vout->p_default_font = vout_LoadFont( DATA_PATH "/" VOUT_DEFAULT_FONT );
     if( p_vout->p_default_font == NULL )
     {
-        p_vout->p_default_font  = vout_LoadFont( "share/" VOUT_DEFAULT_FONT );
+        p_vout->p_default_font = vout_LoadFont( "share/" VOUT_DEFAULT_FONT );
     }
     if( p_vout->p_default_font == NULL )
     {
+        intf_ErrMsg( "vout error: could not load default font\n" );
         p_vout->p_sys_destroy( p_vout );
-        TrashPlugin( p_vout->vout_plugin );
         free( p_vout );
         return( NULL );
     }
-    p_vout->p_large_font        = vout_LoadFont( DATA_PATH "/" VOUT_LARGE_FONT );
+    p_vout->p_large_font = vout_LoadFont( DATA_PATH "/" VOUT_LARGE_FONT );
     if( p_vout->p_large_font == NULL )
     {
-        p_vout->p_large_font    = vout_LoadFont( "share/" VOUT_LARGE_FONT );
+        p_vout->p_large_font = vout_LoadFont( "share/" VOUT_LARGE_FONT );
     }
     if( p_vout->p_large_font == NULL )
     {
+        intf_ErrMsg( "vout error: could not load large font\n" );
         vout_UnloadFont( p_vout->p_default_font );
         p_vout->p_sys_destroy( p_vout );
-        TrashPlugin( p_vout->vout_plugin );
         free( p_vout );
         return( NULL );
     }
@@ -246,19 +243,20 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
     vlc_mutex_init( &p_vout->subpicture_lock );
     vlc_mutex_init( &p_vout->change_lock );
     vlc_mutex_lock( &p_vout->change_lock );
-    if( vlc_thread_create( &p_vout->thread_id, "video output", (void *) RunThread, (void *) p_vout) )
+    if( vlc_thread_create( &p_vout->thread_id, "video output",
+                           (void *) RunThread, (void *) p_vout) )
     {
         intf_ErrMsg("error: %s\n", strerror(ENOMEM));
         vout_UnloadFont( p_vout->p_default_font );
         vout_UnloadFont( p_vout->p_large_font );
         p_vout->p_sys_destroy( p_vout );
-        TrashPlugin( p_vout->vout_plugin );
         free( p_vout );
         return( NULL );
     }
 
-    intf_Msg("Video display initialized (%dx%d, %d/%d bpp)\n", p_vout->i_width,
-             p_vout->i_height, p_vout->i_screen_depth, p_vout->i_bytes_per_pixel * 8 );
+    intf_Msg( "Video display initialized (%dx%d, %d/%d bpp)\n", p_vout->i_width,
+              p_vout->i_height, p_vout->i_screen_depth,
+              p_vout->i_bytes_per_pixel * 8 );
 
     /* If status is NULL, wait until the thread is created */
     if( pi_status == NULL )
@@ -859,7 +857,7 @@ static int BinaryLog(u32 i)
     }
     if (i != ((u32)1 << i_log))
     {
-        intf_ErrMsg("internal error: binary log overflow\n");
+        intf_DbgMsg("internal error: binary log overflow\n");
     }
 
     return( i_log );
@@ -1257,9 +1255,6 @@ static void DestroyThread( vout_thread_t *p_vout, int i_status )
     vout_UnloadFont( p_vout->p_large_font );
     p_vout->p_sys_destroy( p_vout );
 
-    /* Close plugin */
-    TrashPlugin( p_vout->vout_plugin );
-
     /* Free structure */
     free( p_vout );
     *pi_status = i_status;
index 0bd898788331b85bab3e3962fb31db9733b46a77..4117c919333468dd3d2e7c2ccef4b13af6e259aa 100644 (file)
@@ -212,14 +212,14 @@ vout_font_t *vout_LoadFont( const char *psz_name )
     i_file = open( psz_name, O_RDONLY );
     if( i_file == -1 )
     {
-        intf_ErrMsg("error: can't open file '%s' (%s)\n", psz_name, strerror(errno));
+        intf_DbgMsg("vout: can't open file '%s' (%s)\n", psz_name, strerror(errno));
         return( NULL );
     }
 
     /* Read magick number */
     if( read( i_file, pi_buffer, 2 ) != 2 )
     {
-        intf_ErrMsg("error: unexpected end of file '%s'\n", psz_name );
+        intf_ErrMsg("vout error: unexpected end of file '%s'\n", psz_name );
         close( i_file );
         return( NULL );
     }
@@ -228,7 +228,7 @@ vout_font_t *vout_LoadFont( const char *psz_name )
     p_font = malloc( sizeof( vout_font_t ) );
     if( p_font == NULL )
     {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        intf_ErrMsg("vout error: %s\n", strerror(ENOMEM));
         close( i_file );
         return( NULL );
     }
@@ -239,7 +239,7 @@ vout_font_t *vout_LoadFont( const char *psz_name )
     case 0x3604:                                              /* .psf file */
         /*
          * PSF font: simple fixed font. Only the first 256 characters are read.
-         * Those fonts are always 1 byte width, and 256 or 512 characters long.
+         * Those fonts are always 1 byte wide, and 256 or 512 characters long.
          */
 
         /* Read font header - two bytes indicate the font properties */
@@ -320,7 +320,7 @@ vout_font_t *vout_LoadFont( const char *psz_name )
  *****************************************************************************/
 void vout_UnloadFont( vout_font_t *p_font )
 {
-    intf_DbgMsg( "font %p\n", p_font );
+    intf_DbgMsg( "vout: unloading font %p\n", p_font );
     free( p_font->p_data );
     free( p_font );
 }
index 2c3bc260427da5d22119db66316e960844707708..bd4483c8c5fa813884226c5a3358a1ce1b09c56d 100644 (file)
@@ -1,8 +1,6 @@
 /*****************************************************************************
  * video_yuv.c: YUV transformation functions
- * Provides functions to perform the YUV conversion. The functions provided here
- * are a complete and portable C implementation, and may be replaced in certain
- * case by optimized functions.
+ * These functions set up YUV tables for colorspace conversion
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
  *
 
 #include "intf_msg.h"
 
-/*****************************************************************************
- * Constants
- *****************************************************************************/
-
-/* Margins and offsets in conversion tables - Margins are used in case a RGB
- * RGB conversion would give a value outside the 0-255 range. Offsets have been
- * calculated to avoid using the same cache line for 2 tables. conversion tables
- * are 2*MARGIN + 256 long and stores pixels.*/
-#define RED_MARGIN      178
-#define GREEN_MARGIN    135
-#define BLUE_MARGIN     224
-#define RED_OFFSET      1501                                 /* 1323 to 1935 */
-#define GREEN_OFFSET    135                                      /* 0 to 526 */
-#define BLUE_OFFSET     818                                   /* 594 to 1298 */
-#define RGB_TABLE_SIZE  1935                             /* total table size */
-
-#define GRAY_MARGIN     384
-#define GRAY_TABLE_SIZE 1024                             /* total table size */
-
-#define PALETTE_TABLE_SIZE 2176          /* YUV -> 8bpp palette lookup table */
-
-/* macros used for YUV pixel conversions */
-#define SHIFT 20
-#define U_GREEN_COEF    ((int)(-0.391 * (1<<SHIFT) / 1.164))
-#define U_BLUE_COEF     ((int)(2.018 * (1<<SHIFT) / 1.164))
-#define V_RED_COEF      ((int)(1.596 * (1<<SHIFT) / 1.164))
-#define V_GREEN_COEF    ((int)(-0.813 * (1<<SHIFT) / 1.164))
-
-//#define NODITHER
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static void     SetGammaTable     ( int *pi_table, double f_gamma );
-static void     SetYUV            ( vout_thread_t *p_vout );
-static void     SetOffset         ( int i_width, int i_height, int i_pic_width, int i_pic_height,
-                                    boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset );
-
-static void     ConvertY4Gray8    ( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertY4Gray16   ( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertY4Gray24   ( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertY4Gray32   ( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV420RGB8 ( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV422RGB8 ( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV444RGB8 ( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV422RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV444RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV420RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV422RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV444RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV420RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV422RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-static void     ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                    int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                    int i_matrix_coefficients );
-
-/*****************************************************************************
- * CONVERT_YUV_PIXEL, CONVERT_Y_PIXEL: pixel conversion blocks
- *****************************************************************************
- * These conversion routines are used by YUV conversion functions.
- * conversion are made from p_y, p_u, p_v, which are modified, to p_buffer,
- * which is also modified.
- *****************************************************************************/
-#define CONVERT_Y_PIXEL( BPP )                                                \
-    /* Only Y sample is present */                                            \
-    p_ybase = p_yuv + *p_y++;                                                 \
-    *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128)>>SHIFT) + i_red] |     \
-        p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT)       \
-        + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128)>>SHIFT) + i_blue];
-
-#define CONVERT_YUV_PIXEL( BPP )                                              \
-    /* Y, U and V samples are present */                                      \
-    i_uval =    *p_u++;                                                       \
-    i_vval =    *p_v++;                                                       \
-    i_red =     (V_RED_COEF * i_vval) >> SHIFT;                               \
-    i_green =   (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT;     \
-    i_blue =    (U_BLUE_COEF * i_uval) >> SHIFT;                              \
-    CONVERT_Y_PIXEL( BPP )                                                    \
-
-/*****************************************************************************
- * CONVERT_4YUV_PIXELS, CONVERT_4YUV_PIXELS_SCALE: dither 4 pixels in 8 bpp
- *****************************************************************************
- * These macros dither 4 pixels in 8 bpp, with or without horiz. scaling
- *****************************************************************************/
-#define CONVERT_4YUV_PIXELS( CHROMA )                                         \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y++ + dither10[i_real_y]) >> 4) << 7)                           \
-      + ((*p_u + dither20[i_real_y]) >> 5) * 9                                \
-      + ((*p_v + dither20[i_real_y]) >> 5) ];                                 \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y++ + dither11[i_real_y]) >> 4) << 7)                           \
-      + ((*p_u++ + dither21[i_real_y]) >> 5) * 9                              \
-      + ((*p_v++ + dither21[i_real_y]) >> 5) ];                               \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y++ + dither12[i_real_y]) >> 4) << 7)                           \
-      + ((*p_u + dither22[i_real_y]) >> 5) * 9                                \
-      + ((*p_v + dither22[i_real_y]) >> 5) ];                                 \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y++ + dither13[i_real_y]) >> 4) << 7)                           \
-      + ((*p_u++ + dither23[i_real_y]) >> 5) * 9                              \
-      + ((*p_v++ + dither23[i_real_y]) >> 5) ];                               \
-
-#define CONVERT_4YUV_PIXELS_SCALE( CHROMA )                                   \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y + dither10[i_real_y]) >> 4) << 7)                             \
-        + ((*p_u + dither20[i_real_y])   >> 5) * 9                            \
-        + ((*p_v + dither20[i_real_y])   >> 5) ];                             \
-    b_jump_uv = (b_jump_uv + *p_offset) & 0x1;                                \
-    p_y += *p_offset;                                                         \
-    p_u += *p_offset   & b_jump_uv;                                           \
-    p_v += *p_offset++ & b_jump_uv;                                           \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y + dither11[i_real_y]) >> 4) << 7)                             \
-        + ((*p_u + dither21[i_real_y])   >> 5) * 9                            \
-        + ((*p_v + dither21[i_real_y])   >> 5) ];                             \
-    b_jump_uv = (b_jump_uv + *p_offset) & 0x1;                                \
-    p_y += *p_offset;                                                         \
-    p_u += *p_offset   & b_jump_uv;                                           \
-    p_v += *p_offset++ & b_jump_uv;                                           \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y + dither12[i_real_y]) >> 4) << 7)                             \
-        + ((*p_u + dither22[i_real_y])   >> 5) * 9                            \
-        + ((*p_v + dither22[i_real_y])   >> 5) ];                             \
-    b_jump_uv = (b_jump_uv + *p_offset) & 0x1;                                \
-    p_y += *p_offset;                                                         \
-    p_u += *p_offset   & b_jump_uv;                                           \
-    p_v += *p_offset++ & b_jump_uv;                                           \
-    *p_pic++ = p_lookup[                                                      \
-        (((*p_y + dither13[i_real_y]) >> 4) << 7)                             \
-        + ((*p_u + dither23[i_real_y])   >> 5) * 9                            \
-        + ((*p_v + dither23[i_real_y])   >> 5) ];                             \
-    b_jump_uv = (b_jump_uv + *p_offset) & 0x1;                                \
-    p_y += *p_offset;                                                         \
-    p_u += *p_offset   & b_jump_uv;                                           \
-    p_v += *p_offset++ & b_jump_uv;                                           \
-
-/*****************************************************************************
- * SCALE_WIDTH: scale a line horizontally
- *****************************************************************************
- * This macro scales a line using rendering buffer and offset array. It works
- * for 1, 2 and 4 Bpp.
- *****************************************************************************/
-#define SCALE_WIDTH                                                           \
-    if( b_horizontal_scaling )                                                \
-    {                                                                         \
-        /* Horizontal scaling, conversion has been done to buffer.            \
-         * Rewind buffer and offset, then copy and scale line */              \
-        p_buffer = p_buffer_start;                                            \
-        p_offset = p_offset_start;                                            \
-        for( i_x = i_pic_width / 16; i_x--; )                                 \
-        {                                                                     \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-            *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
-        }                                                                     \
-        p_pic += i_pic_line_width;                                            \
-    }                                                                         \
-    else                                                                      \
-    {                                                                         \
-        /* No scaling, conversion has been done directly in picture memory.   \
-         * Increment of picture pointer to end of line is still needed */     \
-        p_pic += i_pic_width + i_pic_line_width;                              \
-    }                                                                         \
-
-
-/*****************************************************************************
- * SCALE_WIDTH_DITHER: scale a line horizontally for dithered 8 bpp
- *****************************************************************************
- * This macro scales a line using an offset array.
- *****************************************************************************/
-#define SCALE_WIDTH_DITHER( CHROMA )                                          \
-    if( b_horizontal_scaling )                                                \
-    {                                                                         \
-        /* Horizontal scaling, but we can't use a buffer due to dither */     \
-        p_offset = p_offset_start;                                            \
-        b_jump_uv = 0;                                                        \
-        for( i_x = i_pic_width / 16; i_x--; )                                 \
-        {                                                                     \
-            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
-            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
-            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
-            CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
-        }                                                                     \
-    }                                                                         \
-    else                                                                      \
-    {                                                                         \
-        for( i_x = i_width / 16; i_x--;  )                                    \
-        {                                                                     \
-            CONVERT_4YUV_PIXELS( CHROMA )                                     \
-            CONVERT_4YUV_PIXELS( CHROMA )                                     \
-            CONVERT_4YUV_PIXELS( CHROMA )                                     \
-            CONVERT_4YUV_PIXELS( CHROMA )                                     \
-        }                                                                     \
-    }                                                                         \
-    /* Increment of picture pointer to end of line is still needed */         \
-    p_pic += i_pic_line_width;                                                \
-    i_real_y = (i_real_y + 1) & 0x3;                                          \
-
-/*****************************************************************************
- * SCALE_HEIGHT: handle vertical scaling
- *****************************************************************************
- * This macro handle vertical scaling for a picture. CHROMA may be 420, 422 or
- * 444 for RGB conversion, or 400 for gray conversion. It works for 1, 2, 3
- * and 4 Bpp.
- *****************************************************************************/
-#define SCALE_HEIGHT( CHROMA, BPP )                                           \
-    /* If line is odd, rewind 4:2:0 U and V samples */                        \
-    if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) )                \
-    {                                                                         \
-        p_u -= i_chroma_width;                                                \
-        p_v -= i_chroma_width;                                                \
-    }                                                                         \
-                                                                              \
-    /*                                                                        \
-     * Handle vertical scaling. The current line can be copied or next one    \
-     * can be ignored.                                                        \
-     */                                                                       \
-    switch( i_vertical_scaling )                                              \
-    {                                                                         \
-    case -1:                             /* vertical scaling factor is < 1 */ \
-        while( (i_scale_count -= i_pic_height) >= 0 )                         \
-        {                                                                     \
-            /* Height reduction: skip next source line */                     \
-            p_y += i_width;                                                   \
-            i_y++;                                                            \
-            if( (CHROMA == 420) || (CHROMA == 422) )                          \
-            {                                                                 \
-                if( i_y & 0x1 )                                               \
-                {                                                             \
-                    p_u += i_chroma_width;                                    \
-                    p_v += i_chroma_width;                                    \
-                }                                                             \
-            }                                                                 \
-            else if( CHROMA == 444 )                                          \
-            {                                                                 \
-                p_u += i_width;                                               \
-                p_v += i_width;                                               \
-            }                                                                 \
-        }                                                                     \
-        i_scale_count += i_height;                                            \
-        break;                                                                \
-    case 1:                              /* vertical scaling factor is > 1 */ \
-        while( (i_scale_count -= i_height) > 0 )                              \
-        {                                                                     \
-            /* Height increment: copy previous picture line */                \
-            for( i_x = i_pic_width / 16; i_x--; )                             \
-            {                                                                 \
-                *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );           \
-                *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );           \
-                if( BPP > 1 )                               /* 2, 3, 4 Bpp */ \
-                {                                                             \
-                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
-                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
-                }                                                             \
-                if( BPP > 2 )                                  /* 3, 4 Bpp */ \
-                {                                                             \
-                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
-                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
-                }                                                             \
-                if( BPP > 3 )                                     /* 4 Bpp */ \
-                {                                                             \
-                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
-                    *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );       \
-                }                                                             \
-            }                                                                 \
-            p_pic +=        i_pic_line_width;                                 \
-            p_pic_start +=  i_pic_line_width;                                 \
-        }                                                                     \
-        i_scale_count += i_pic_height;                                        \
-        break;                                                                \
-    }                                                                         \
-
-/*****************************************************************************
- * SCALE_HEIGHT_DITHER: handle vertical scaling for dithered 8 bpp
- *****************************************************************************
- * This macro handles vertical scaling for a picture. CHROMA may be 420, 422 or
- * 444 for RGB conversion, or 400 for gray conversion.
- *****************************************************************************/
-#define SCALE_HEIGHT_DITHER( CHROMA )                                         \
-                                                                              \
-    /* If line is odd, rewind 4:2:0 U and V samples */                        \
-    if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) )                \
-    {                                                                         \
-        p_u -= i_chroma_width;                                                \
-        p_v -= i_chroma_width;                                                \
-    }                                                                         \
-                                                                              \
-    /*                                                                        \
-     * Handle vertical scaling. The current line can be copied or next one    \
-     * can be ignored.                                                        \
-     */                                                                       \
-                                                                              \
-    switch( i_vertical_scaling )                                              \
-    {                                                                         \
-    case -1:                             /* vertical scaling factor is < 1 */ \
-        while( (i_scale_count -= i_pic_height) >= 0 )                         \
-        {                                                                     \
-            /* Height reduction: skip next source line */                     \
-            p_y += i_width;                                                   \
-            i_y++;                                                            \
-            if( (CHROMA == 420) || (CHROMA == 422) )                          \
-            {                                                                 \
-                if( i_y & 0x1 )                                               \
-                {                                                             \
-                    p_u += i_chroma_width;                                    \
-                    p_v += i_chroma_width;                                    \
-                }                                                             \
-            }                                                                 \
-            else if( CHROMA == 444 )                                          \
-            {                                                                 \
-                p_u += i_width;                                               \
-                p_v += i_width;                                               \
-            }                                                                 \
-        }                                                                     \
-        i_scale_count += i_height;                                            \
-        break;                                                                \
-    case 1:                              /* vertical scaling factor is > 1 */ \
-        while( (i_scale_count -= i_height) > 0 )                              \
-        {                                                                     \
-            SCALE_WIDTH_DITHER( CHROMA );                                     \
-            p_y -= i_width;                                                   \
-            p_u -= i_chroma_width;                                            \
-            p_v -= i_chroma_width;                                            \
-            p_pic +=        i_pic_line_width;                                 \
-        }                                                                     \
-        i_scale_count += i_pic_height;                                        \
-        break;                                                                \
-    }                                                                         \
+#include "main.h"
 
 /*****************************************************************************
  * vout_InitYUV: allocate and initialize translations tables
@@ -426,1463 +53,47 @@ static void     ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data
  *****************************************************************************/
 int vout_InitYUV( vout_thread_t *p_vout )
 {
-    size_t      tables_size;                        /* tables size, in bytes */
+    typedef void ( yuv_getplugin_t ) ( vout_thread_t * p_vout );
+    int          i_index;
 
-    /* Computes tables size - 3 Bpp use 32 bits pixel entries in tables */
-    switch( p_vout->i_bytes_per_pixel )
-    {
-    case 1:
-        tables_size = sizeof( u8 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : PALETTE_TABLE_SIZE);
-        break;
-    case 2:
-        tables_size = sizeof( u16 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
-        break;
-    case 3:
-    case 4:
-    default:
-        tables_size = sizeof( u32 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
-        break;
-    }
-
-    /* Allocate memory */
-    p_vout->yuv.p_base = malloc( tables_size );
-    if( p_vout->yuv.p_base == NULL )
-    {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
-        return( 1 );
-    }
-
-    /* Allocate memory for conversion buffer and offset array */
-    p_vout->yuv.p_buffer = malloc( VOUT_MAX_WIDTH * p_vout->i_bytes_per_pixel );
-    if( p_vout->yuv.p_buffer == NULL )
-    {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
-        free( p_vout->yuv.p_base );
-        return( 1 );
-    }
-    p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );
-    if( p_vout->yuv.p_offset == NULL )
+    /* Get a suitable YUV plugin */
+    for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
     {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
-        free( p_vout->yuv.p_base );
-        free( p_vout->yuv.p_buffer );
-        return( 1 );
+        /* If there's a plugin in p_info ... */
+        if( p_main->p_bank->p_info[ i_index ] != NULL )
+        {
+            /* ... and if this plugin provides the functions we want ... */
+            if( p_main->p_bank->p_info[ i_index ]->yuv_GetPlugin != NULL )
+            {
+                /* ... then get these functions */
+                ( (yuv_getplugin_t *)
+                  p_main->p_bank->p_info[ i_index ]->yuv_GetPlugin )( p_vout );
+            }
+        }
     }
 
-    /* Initialize tables */
-    SetYUV( p_vout );
-    return( 0 );
+    return p_vout->p_yuv_init( p_vout );
 }
 
 /*****************************************************************************
- * vout_ResetTables: re-initialize translations tables
+ * vout_ResetYUV: re-initialize translations tables
  *****************************************************************************
- * This function will initialize the tables allocated by vout_CreateTables and
+ * This function will initialize the tables allocated by vout_InitYUV and
  * set functions pointers.
  *****************************************************************************/
 int vout_ResetYUV( vout_thread_t *p_vout )
 {
-    vout_EndYUV( p_vout );
-    return( vout_InitYUV( p_vout ) );
+    p_vout->p_yuv_end( p_vout );
+    return( p_vout->p_yuv_init( p_vout ) );
 }
 
 /*****************************************************************************
  * vout_EndYUV: destroy translations tables
  *****************************************************************************
- * Free memory allocated by vout_CreateTables.
+ * Free memory allocated by vout_InitYUV
  *****************************************************************************/
 void vout_EndYUV( vout_thread_t *p_vout )
 {
-    free( p_vout->yuv.p_base );
-    free( p_vout->yuv.p_buffer );
-    free( p_vout->yuv.p_offset );
+    p_vout->p_yuv_end( p_vout );
 }
 
-/* following functions are local */
-
-/*****************************************************************************
- * SetGammaTable: return intensity table transformed by gamma curve.
- *****************************************************************************
- * pi_table is a table of 256 entries from 0 to 255.
- *****************************************************************************/
-static void SetGammaTable( int *pi_table, double f_gamma )
-{
-    int         i_y;                                       /* base intensity */
-
-    /* Use exp(gamma) instead of gamma */
-    f_gamma = exp( f_gamma );
-
-    /* Build gamma table */
-    for( i_y = 0; i_y < 256; i_y++ )
-    {
-        pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256;
-    }
- }
-
-/*****************************************************************************
- * SetYUV: compute tables and set function pointers
-+ *****************************************************************************/
-static void SetYUV( vout_thread_t *p_vout )
-{
-    int         pi_gamma[256];                                /* gamma table */
-    int         i_index;                                  /* index in tables */
-
-    /* Build gamma table */
-    SetGammaTable( pi_gamma, p_vout->f_gamma );
-
-    /*
-     * Set pointers and build YUV tables
-     */
-    if( p_vout->b_grayscale )
-    {
-        /* Grayscale: build gray table */
-        switch( p_vout->i_bytes_per_pixel )
-        {
-        case 1:
-            {
-                u16 bright[256], transp[256];
-
-                p_vout->yuv.yuv.p_gray8 =  (u8 *)p_vout->yuv.p_base + GRAY_MARGIN;
-                for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
-                {
-                    p_vout->yuv.yuv.p_gray8[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
-                    p_vout->yuv.yuv.p_gray8[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
-                }
-                for( i_index = 0; i_index < 256; i_index++)
-                {
-                    p_vout->yuv.yuv.p_gray8[ i_index ] = pi_gamma[ i_index ];
-                    bright[ i_index ] = i_index << 8;
-                    transp[ i_index ] = 0;
-                }
-                /* the colors have been allocated, we can set the palette */
-                p_vout->p_set_palette( p_vout, bright, bright, bright, transp );
-                p_vout->i_white_pixel = 0xff;
-                p_vout->i_black_pixel = 0x00;
-                p_vout->i_gray_pixel = 0x44;
-                p_vout->i_blue_pixel = 0x3b;
-
-                break;
-            }
-        case 2:
-            p_vout->yuv.yuv.p_gray16 =  (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
-            for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_gray16[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
-                p_vout->yuv.yuv.p_gray16[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
-            }
-            for( i_index = 0; i_index < 256; i_index++)
-            {
-                p_vout->yuv.yuv.p_gray16[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
-            }
-            break;
-        case 3:
-        case 4:
-            p_vout->yuv.yuv.p_gray32 =  (u32 *)p_vout->yuv.p_base + GRAY_MARGIN;
-            for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_gray32[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
-                p_vout->yuv.yuv.p_gray32[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
-            }
-            for( i_index = 0; i_index < 256; i_index++)
-            {
-                p_vout->yuv.yuv.p_gray32[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
-            }
-            break;
-         }
-    }
-    else
-    {
-        /* Color: build red, green and blue tables */
-        switch( p_vout->i_bytes_per_pixel )
-        {
-        case 1:
-            {
-                #define RGB_MIN 0
-                #define RGB_MAX 255
-                #define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 )
-
-                int y,u,v;
-                int r,g,b;
-                int uvr, uvg, uvb;
-                int i = 0, j = 0;
-                u16 red[256], green[256], blue[256], transp[256];
-                unsigned char lookup[PALETTE_TABLE_SIZE];
-
-                p_vout->yuv.yuv.p_rgb8 = (u8 *)p_vout->yuv.p_base;
-
-                /* this loop calculates the intersection of an YUV box
-                 * and the RGB cube. */
-                for ( y = 0; y <= 256; y += 16 )
-                {
-                    for ( u = 0; u <= 256; u += 32 )
-                    for ( v = 0; v <= 256; v += 32 )
-                    {
-                        uvr = (V_RED_COEF*(v-128)) >> SHIFT;
-                        uvg = (U_GREEN_COEF*(u-128) + V_GREEN_COEF*(v-128)) >> SHIFT;
-                        uvb = (U_BLUE_COEF*(u-128)) >> SHIFT;
-                        r = y + uvr;
-                        g = y + uvg;
-                        b = y + uvb;
-
-                        if( r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN
-                                && r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX )
-                        {
-                            /* this one should never happen unless someone fscked up my code */
-                            if(j == 256) { intf_ErrMsg( "vout error: no colors left to build palette\n" ); break; }
-
-                            /* clip the colors */
-                            red[j] = CLIP( r );
-                            green[j] = CLIP( g );
-                            blue[j] = CLIP( b );
-                            transp[j] = 0;
-
-                            /* allocate color */
-                            lookup[i] = 1;
-                            p_vout->yuv.yuv.p_rgb8[i++] = j;
-                            j++;
-                        }
-                        else
-                        {
-                            lookup[i] = 0;
-                            p_vout->yuv.yuv.p_rgb8[i++] = 0;
-                        }
-                    }
-                    i += 128-81;
-                }
-
-                /* the colors have been allocated, we can set the palette */
-                /* there will eventually be a way to know which colors
-                 * couldn't be allocated and try to find a replacement */
-                p_vout->p_set_palette( p_vout, red, green, blue, transp );
-
-                p_vout->i_white_pixel = 0xff;
-                p_vout->i_black_pixel = 0x00;
-                p_vout->i_gray_pixel = 0x44;
-                p_vout->i_blue_pixel = 0x3b;
-
-                i = 0;
-                /* this loop allocates colors that got outside
-                 * the RGB cube */
-                for ( y = 0; y <= 256; y += 16 )
-                {
-                    for ( u = 0; u <= 256; u += 32 )
-                    for ( v = 0; v <= 256; v += 32 )
-                    {
-                        int u2, v2;
-                        int dist, mindist = 100000000;
-
-                        if( lookup[i] || y==0)
-                        {
-                            i++;
-                            continue;
-                        }
-
-                        /* heavy. yeah. */
-                        for( u2 = 0; u2 <= 256; u2 += 32 )
-                        for( v2 = 0; v2 <= 256; v2 += 32 )
-                        {
-                            j = ((y>>4)<<7) + (u2>>5)*9 + (v2>>5);
-                            dist = (u-u2)*(u-u2) + (v-v2)*(v-v2);
-                            if( lookup[j] )
-                            /* find the nearest color */
-                            if( dist < mindist )
-                            {
-                                p_vout->yuv.yuv.p_rgb8[i] = p_vout->yuv.yuv.p_rgb8[j];
-                                mindist = dist;
-                            }
-                            j -= 128;
-                            if( lookup[j] )
-                            /* find the nearest color */
-                            if( dist + 128 < mindist )
-                            {
-                                p_vout->yuv.yuv.p_rgb8[i] = p_vout->yuv.yuv.p_rgb8[j];
-                                mindist = dist + 128;
-                            }
-                        }
-                        i++;
-                    }
-                    i += 128-81;
-                }
-
-                break;
-            }
-        case 2:
-            p_vout->yuv.yuv.p_rgb16 = (u16 *)p_vout->yuv.p_base;
-            for( i_index = 0; i_index < RED_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb16[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
-                p_vout->yuv.yuv.p_rgb16[RED_OFFSET + 256 + i_index] =        RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 );
-            }
-            for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 );
-                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + 256 + i_index] =          RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 );
-            }
-            for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] );
-                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] );
-            }
-            for( i_index = 0; i_index < 256; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb16[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
-                p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
-                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
-            }
-            break;
-        case 3:
-        case 4:
-            p_vout->yuv.yuv.p_rgb32 = (u32 *)p_vout->yuv.p_base;
-            for( i_index = 0; i_index < RED_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb32[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
-                p_vout->yuv.yuv.p_rgb32[RED_OFFSET + 256 + i_index] =        RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 );
-            }
-            for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 );
-                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + 256 + i_index] =          RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 );
-            }
-            for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] );
-                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] );
-            }
-            for( i_index = 0; i_index < 256; i_index++ )
-            {
-                p_vout->yuv.yuv.p_rgb32[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
-                p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
-                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
-            }
-            break;
-        }
-    }
-
-    /*
-     * Set functions pointers
-     */
-    if( p_vout->b_grayscale )
-    {
-        /* Grayscale */
-        switch( p_vout->i_bytes_per_pixel )
-        {
-        case 1:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray8;
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray8;
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray8;
-            break;
-        case 2:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray16;
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray16;
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray16;
-            break;
-        case 3:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray24;
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray24;
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray24;
-            break;
-        case 4:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray32;
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray32;
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray32;
-            break;
-        }
-    }
-    else
-    {
-        /* Color */
-        switch( p_vout->i_bytes_per_pixel )
-        {
-        case 1:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertYUV420RGB8;
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertYUV422RGB8;
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertYUV444RGB8;
-            break;
-        case 2:
-            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB16;
-            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB16;
-            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB16;
-            break;
-        case 3:
-            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB24;
-            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB24;
-            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB24;
-            break;
-        case 4:
-            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB32;
-            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB32;
-            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB32;
-            break;
-        }
-    }
-}
-
-/*****************************************************************************
- * SetOffset: build offset array for conversion functions
- *****************************************************************************
- * This function will build an offset array used in later conversion functions.
- * It will also set horizontal and vertical scaling indicators.
- *****************************************************************************/
-static void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
-                       boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset )
-{
-    int i_x;                                    /* x position in destination */
-    int i_scale_count;                                     /* modulo counter */
-
-    /*
-     * Prepare horizontal offset array
-     */
-    if( i_pic_width - i_width > 0 )
-    {
-        /* Prepare scaling array for horizontal extension */
-        *pb_h_scaling =  1;
-        i_scale_count =         i_pic_width;
-        for( i_x = i_width; i_x--; )
-        {
-            while( (i_scale_count -= i_width) > 0 )
-            {
-                *p_offset++ = 0;
-            }
-            *p_offset++ = 1;
-            i_scale_count += i_pic_width;
-        }
-    }
-    else if( i_pic_width - i_width < 0 )
-    {
-        /* Prepare scaling array for horizontal reduction */
-        *pb_h_scaling =  1;
-        i_scale_count =         i_pic_width;
-        for( i_x = i_pic_width; i_x--; )
-        {
-            *p_offset = 1;
-            while( (i_scale_count -= i_pic_width) >= 0 )
-            {
-                *p_offset += 1;
-            }
-            p_offset++;
-            i_scale_count += i_width;
-        }
-    }
-    else
-    {
-        /* No horizontal scaling: YUV conversion is done directly to picture */
-        *pb_h_scaling = 0;
-    }
-
-    /*
-     * Set vertical scaling indicator
-     */
-    if( i_pic_height - i_height > 0 )
-    {
-        *pi_v_scaling = 1;
-    }
-    else if( i_pic_height - i_height < 0 )
-    {
-        *pi_v_scaling = -1;
-    }
-    else
-    {
-        *pi_v_scaling = 0;
-    }
-}
-
-/*****************************************************************************
- * ConvertY4Gray8: grayscale YUV 4:x:x to RGB 8 bpp
- *****************************************************************************/
-static void ConvertY4Gray8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y,
-                            yuv_data_t *p_u, yuv_data_t *p_v, int i_width,
-                            int i_height, int i_pic_width, int i_pic_height,
-                            int i_pic_line_width, int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_chroma_width;                    /* chroma width, not used */
-    u8 *        p_gray;                             /* base conversion table */
-    u8 *        p_pic_start;       /* beginning of the current line for copy */
-    u8 *        p_buffer_start;                   /* conversion buffer start */
-    u8 *        p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    p_gray =            p_vout->yuv.yuv.p_gray8;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(400, 1);
-    }
-}
-
-/*****************************************************************************
- * ConvertY4Gray16: grayscale YUV 4:x:x to RGB 2 Bpp
- *****************************************************************************/
-static void ConvertY4Gray16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                             int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                             int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_chroma_width;                    /* chroma width, not used */
-    u16 *       p_gray;                             /* base conversion table */
-    u16 *       p_pic_start;       /* beginning of the current line for copy */
-    u16 *       p_buffer_start;                   /* conversion buffer start */
-    u16 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    p_gray =            p_vout->yuv.yuv.p_gray16;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(400, 2);
-    }
-}
-
-/*****************************************************************************
- * ConvertY4Gray24: grayscale YUV 4:x:x to RGB 3 Bpp
- *****************************************************************************/
-static void ConvertY4Gray24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                             int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                             int i_matrix_coefficients )
-{
-    /* XXX?? */
-}
-
-/*****************************************************************************
- * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 Bpp
- *****************************************************************************/
-static void ConvertY4Gray32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                             int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                             int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_chroma_width;                    /* chroma width, not used */
-    u32 *       p_gray;                             /* base conversion table */
-    u32 *       p_pic_start;       /* beginning of the current line for copy */
-    u32 *       p_buffer_start;                   /* conversion buffer start */
-    u32 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    p_gray =            p_vout->yuv.yuv.p_gray32;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-            *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(400, 4);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB8: color YUV 4:2:0 to RGB 8 bpp
- *****************************************************************************/
-static void ConvertYUV420RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         b_jump_uv;                       /* should we jump u and v ? */
-    int         i_real_y;                                           /* y % 4 */
-    u8 *        p_lookup;                                    /* lookup table */
-    int         i_chroma_width;                              /* chroma width */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-#ifdef NODITHER
-    int dither10[4] = {  0x7,  0x8,  0x7,  0x8 };
-    int dither11[4] = {  0x8,  0x7,  0x8,  0x7 };
-    int dither12[4] = {  0x7,  0x8,  0x7,  0x8 };
-    int dither13[4] = {  0x8,  0x7,  0x8,  0x7 };
-
-    int dither20[4] = {  0xf, 0x10,  0xf, 0x10 };
-    int dither21[4] = { 0x10,  0xf, 0x10,  0xf };
-    int dither22[4] = {  0xf, 0x10,  0xf, 0x10 };
-    int dither23[4] = { 0x10,  0xf, 0x10,  0xf };
-#else
-    int dither10[4] = {  0x0,  0x8,  0x2,  0xa };
-    int dither11[4] = {  0xc,  0x4,  0xe,  0x6 };
-    int dither12[4] = {  0x3,  0xb,  0x1,  0x9 };
-    int dither13[4] = {  0xf,  0x7,  0xd,  0x5 };
-
-    int dither20[4] = {  0x0, 0x10,  0x4, 0x14 };
-    int dither21[4] = { 0x18,  0x8, 0x1c,  0xc };
-    int dither22[4] = {  0x6, 0x16,  0x2, 0x12 };
-    int dither23[4] = { 0x1e,  0xe, 0x1a,  0xa };
-#endif
-
-    /* some other matrices that can be interesting, either for debugging
-     *  or for effects :
-     *  
-     * { { 0, 8, 2, 10 }, { 12, 4, 14, 16 }, { 3, 11, 1, 9}, {15, 7, 13, 5} }
-     * { { 7, 8, 0, 15 }, { 0, 15, 8, 7 }, { 7, 0, 15, 8 }, { 15, 7, 8, 0 } }
-     * { { 0, 15, 0, 15 }, { 15, 0, 15, 0 }, { 0, 15, 0, 15 }, { 15, 0, 15, 0 } }
-     * { { 15, 15, 0, 0 }, { 15, 15, 0, 0 }, { 0, 0, 15, 15 }, { 0, 0, 15, 15 } }
-     * { { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 } }
-     * { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } }
-     */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    i_chroma_width =    i_width / 2;
-    p_offset_start =    p_vout->yuv.p_offset;
-    p_lookup =          p_vout->yuv.p_base;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    i_real_y = 0;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH_DITHER( 420 );
-        SCALE_HEIGHT_DITHER( 420 );
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB8: color YUV 4:2:2 to RGB 8 bpp
- *****************************************************************************/
-static void ConvertYUV422RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                              /* chroma width */
-    u8 *        p_yuv;                              /* base conversion table */
-    u8 *        p_ybase;                     /* Y dependant conversion table */
-    u8 *        p_pic_start;       /* beginning of the current line for copy */
-    u8 *        p_buffer_start;                   /* conversion buffer start */
-    u8 *        p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    i_chroma_width =    i_width / 2;
-    p_yuv =             p_vout->yuv.yuv.p_rgb8;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(422, 1);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB8: color YUV 4:4:4 to RGB 8 bpp
- *****************************************************************************/
-static void ConvertYUV444RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                    /* chroma width, not used */
-    u8 *        p_yuv;                              /* base conversion table */
-    u8 *        p_ybase;                     /* Y dependant conversion table */
-    u8 *        p_pic_start;       /* beginning of the current line for copy */
-    u8 *        p_buffer_start;                   /* conversion buffer start */
-    u8 *        p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    p_yuv =             p_vout->yuv.yuv.p_rgb8;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-            CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(444, 1);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
- *****************************************************************************/
-static void ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-#if 0
-    /* MMX version */
-    int                 i_chroma_width, i_chroma_skip;      /* width and eol for chroma */
-
-    i_chroma_width =    i_width / 2;
-    i_chroma_skip =     i_skip / 2;
-    ConvertYUV420RGB16MMX( p_y, p_u, p_v, i_width, i_height,
-                           (i_width + i_skip) * sizeof( yuv_data_t ),
-                           (i_chroma_width + i_chroma_skip) * sizeof( yuv_data_t),
-                           i_scale, (u8 *)p_pic, 0, 0, (i_width + i_pic_eol) * sizeof( u16 ),
-                           p_vout->i_screen_depth == 15 );
-#endif
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                              /* chroma width */
-    u16 *       p_yuv;                              /* base conversion table */
-    u16 *       p_ybase;                     /* Y dependant conversion table */
-    u16 *       p_pic_start;       /* beginning of the current line for copy */
-    u16 *       p_buffer_start;                   /* conversion buffer start */
-    u16 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    i_chroma_width =    i_width / 2;
-    p_yuv =             p_vout->yuv.yuv.p_rgb16;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(420, 2);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
- *****************************************************************************/
-static void ConvertYUV422RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                              /* chroma width */
-    u16 *       p_yuv;                              /* base conversion table */
-    u16 *       p_ybase;                     /* Y dependant conversion table */
-    u16 *       p_pic_start;       /* beginning of the current line for copy */
-    u16 *       p_buffer_start;                   /* conversion buffer start */
-    u16 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    i_chroma_width =    i_width / 2;
-    p_yuv =             p_vout->yuv.yuv.p_rgb16;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(422, 2);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
- *****************************************************************************/
-static void ConvertYUV444RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                    /* chroma width, not used */
-    u16 *       p_yuv;                              /* base conversion table */
-    u16 *       p_ybase;                     /* Y dependant conversion table */
-    u16 *       p_pic_start;       /* beginning of the current line for copy */
-    u16 *       p_buffer_start;                   /* conversion buffer start */
-    u16 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    p_yuv =             p_vout->yuv.yuv.p_rgb16;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-            CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(444, 2);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 3 Bpp
- *****************************************************************************/
-static void ConvertYUV420RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    /* XXX?? */
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB24: color YUV 4:2:2 to RGB 3 Bpp
- *****************************************************************************/
-static void ConvertYUV422RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    /* XXX?? */
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB24: color YUV 4:4:4 to RGB 3 Bpp
- *****************************************************************************/
-static void ConvertYUV444RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    /* XXX?? */
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 4 Bpp
- *****************************************************************************/
-static void ConvertYUV420RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                              /* chroma width */
-    u32 *       p_yuv;                              /* base conversion table */
-    u32 *       p_ybase;                     /* Y dependant conversion table */
-    u32 *       p_pic_start;       /* beginning of the current line for copy */
-    u32 *       p_buffer_start;                   /* conversion buffer start */
-    u32 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    i_chroma_width =    i_width / 2;
-    p_yuv =             p_vout->yuv.yuv.p_rgb32;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(420, 4);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 Bpp
- *****************************************************************************/
-static void ConvertYUV422RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                              /* chroma width */
-    u32 *       p_yuv;                              /* base conversion table */
-    u32 *       p_ybase;                     /* Y dependant conversion table */
-    u32 *       p_pic_start;       /* beginning of the current line for copy */
-    u32 *       p_buffer_start;                   /* conversion buffer start */
-    u32 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    i_chroma_width =    i_width / 2;
-    p_yuv =             p_vout->yuv.yuv.p_rgb32;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(422, 4);
-    }
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 Bpp
- *****************************************************************************/
-static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
-                                int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
-                                int i_matrix_coefficients )
-{
-    boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
-    int         i_vertical_scaling;                 /* vertical scaling type */
-    int         i_x, i_y;                 /* horizontal and vertical indexes */
-    int         i_scale_count;                       /* scale modulo counter */
-    int         i_uval, i_vval;                           /* U and V samples */
-    int         i_red, i_green, i_blue;          /* U and V modified samples */
-    int         i_chroma_width;                    /* chroma width, not used */
-    u32 *       p_yuv;                              /* base conversion table */
-    u32 *       p_ybase;                     /* Y dependant conversion table */
-    u32 *       p_pic_start;       /* beginning of the current line for copy */
-    u32 *       p_buffer_start;                   /* conversion buffer start */
-    u32 *       p_buffer;                       /* conversion buffer pointer */
-    int *       p_offset_start;                        /* offset array start */
-    int *       p_offset;                            /* offset array pointer */
-
-    /*
-     * Initialize some values  - i_pic_line_width will store the line skip
-     */
-    i_pic_line_width -= i_pic_width;
-    p_yuv =             p_vout->yuv.yuv.p_rgb32;
-    p_buffer_start =    p_vout->yuv.p_buffer;
-    p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
-               &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
-    /*
-     * Perform conversion
-     */
-    i_scale_count = i_pic_height;
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        /* Mark beginnning of line for possible later line copy, and initialize
-         * buffer */
-        p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
-
-        /* Do YUV conversion to buffer - YUV picture is always formed of 16
-         * pixels wide blocks */
-        for( i_x = i_width / 16; i_x--;  )
-        {
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-            CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-        }
-
-        /* Do horizontal and vertical scaling */
-        SCALE_WIDTH;
-        SCALE_HEIGHT(444, 4);
-    }
-}
-
-/*-------------------- walken code follows ----------------------------------*/
-
-/*
- * YUV to RGB routines.
- *
- * these routines calculate r, g and b values from each pixel's y, u and v.
- * these r, g an b values are then passed thru a table lookup to take the
- * gamma curve into account and find the corresponding pixel value.
- *
- * the table must store more than 3*256 values because of the possibility
- * of overflow in the yuv->rgb calculation. actually the calculated r,g,b
- * values are in the following intervals :
- * -176 to 255+176 for red
- * -133 to 255+133 for green
- * -222 to 255+222 for blue
- *
- * If the input y,u,v values are right, the r,g,b results are not expected
- * to move out of the 0 to 255 interval but who knows what will happen in
- * real use...
- *
- * the red, green and blue conversion tables are stored in a single 1935-entry
- * array. The respective positions of each component in the array have been
- * calculated to minimize the cache interactions of the 3 tables.
- */
-
-#if 0
-/* XXX?? */
-static void yuvToRgb24 (unsigned char * Y,
-                        unsigned char * U, unsigned char * V,
-                        char * dest, int table[1935], int width)
-{
-    int i;
-    int u;
-    int v;
-    int uvRed;
-    int uvGreen;
-    int uvBlue;
-    int * tableY;
-    int tmp24;
-
-    i = width >> 3;
-    while (i--) {
-        u = *(U++);
-        v = *(V++);
-        uvRed = (V_RED_COEF*v) >> SHIFT;
-        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        u = *(U++);
-        v = *(V++);
-        uvRed = (V_RED_COEF*v) >> SHIFT;
-        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        u = *(U++);
-        v = *(V++);
-        uvRed = (V_RED_COEF*v) >> SHIFT;
-        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        u = *(U++);
-        v = *(V++);
-        uvRed = (V_RED_COEF*v) >> SHIFT;
-        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-    }
-
-    i = (width & 7) >> 1;
-    while (i--) {
-        u = *(U++);
-        v = *(V++);
-        uvRed = (V_RED_COEF*v) >> SHIFT;
-        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-    }
-
-    if (width & 1) {
-        u = *(U++);
-        v = *(V++);
-        uvRed = (V_RED_COEF*v) >> SHIFT;
-        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-        tableY = table + *(Y++);
-        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                        uvGreen] |
-                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-        *(dest++) = tmp24;
-        *(dest++) = tmp24 >> 8;
-        *(dest++) = tmp24 >> 16;
-    }
-}
-#endif
index 1d352d4d33e395ab32328d226d6b7cdc81385a1f..6a49c10deb28e8df56a45d0d5412b2813e283301 100644 (file)
@@ -1,7 +1,6 @@
 /*****************************************************************************
  * video_yuv.h: YUV transformation functions
- * Provides functions prototypes to perform the YUV conversion. The functions
- * may be implemented in one of the video_yuv_* files.
+ * These functions set up YUV tables for colorspace conversion
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
  *
@@ -29,25 +28,3 @@ int             vout_InitYUV      ( vout_thread_t *p_vout );
 int             vout_ResetYUV     ( vout_thread_t *p_vout );
 void            vout_EndYUV       ( vout_thread_t *p_vout );
 
-/*****************************************************************************
- * External prototypes
- *****************************************************************************/
-#ifdef HAVE_MMX
-
-/* YUV transformations for MMX - in video_yuv_mmx.S
- *      p_y, p_u, p_v:          Y U and V planes
- *      i_width, i_height:      frames dimensions (pixels)
- *      i_ypitch, i_vpitch:     Y and V lines sizes (bytes)
- *      i_aspect:               vertical aspect factor
- *      p_pic:                  RGB frame
- *      i_dci_offset:           XXX?? x offset for left image border
- *      i_offset_to_line_0:     XXX?? x offset for left image border
- *      i_pitch:                RGB line size (bytes)
- *      i_colortype:            0 for 565, 1 for 555 */
-void ConvertYUV420RGB16MMX( u8* p_y, u8* p_u, u8 *p_v,
-                            unsigned int i_width, unsigned int i_height,
-                            unsigned int i_ypitch, unsigned int i_vpitch,
-                            unsigned int i_aspect, u8 *p_pic,
-                            u32 i_dci_offset, u32 i_offset_to_line_0,
-                            int i_pitch, int i_colortype );
-#endif
index cdab31a801cacb244cfe220082be6f7996963cb8..45abb382d697b3cf399efe0550a65101b5f6cc62 100644 (file)
@@ -82,12 +82,13 @@ vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
 {
     vpar_thread_t *     p_vpar;
 
-    intf_DbgMsg("vpar debug: creating video parser thread\n");
+    intf_DbgMsg( "vpar debug: creating video parser thread\n" );
 
     /* Allocate the memory needed to store the thread's structure */
     if ( (p_vpar = (vpar_thread_t *)malloc( sizeof(vpar_thread_t) )) == NULL )
     {
-        intf_ErrMsg("vpar error: not enough memory for vpar_CreateThread() to create the new thread\n");
+        intf_ErrMsg( "vpar error: not enough memory "
+                     "for vpar_CreateThread() to create the new thread\n");
         return( NULL );
     }
 
@@ -100,8 +101,8 @@ vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
     /*
      * Initialize the input properties
      */
-    /* Initialize the decoder fifo's data lock and conditional variable and set
-     * its buffer as empty */
+    /* Initialize the decoder fifo's data lock and conditional variable
+     * and set its buffer as empty */
     vlc_mutex_init( &p_vpar->fifo.data_lock );
     vlc_cond_init( &p_vpar->fifo.data_wait );
     p_vpar->fifo.i_start = 0;
@@ -112,11 +113,12 @@ vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
     p_vpar->bit_stream.fifo.buffer = 0;
     p_vpar->bit_stream.fifo.i_available = 0;
 
-/* FIXME !!!!?? */
-p_vpar->p_vout = p_main->p_intf->p_vout;
+    /* FIXME !!!!?? */
+    p_vpar->p_vout = p_main->p_intf->p_vout;
 
     /* Spawn the video parser thread */
-    if ( vlc_thread_create(&p_vpar->thread_id, "video parser", (vlc_thread_func_t)RunThread, (void *)p_vpar) )
+    if ( vlc_thread_create( &p_vpar->thread_id, "video parser",
+                            (vlc_thread_func_t)RunThread, (void *)p_vpar ) )
     {
         intf_ErrMsg("vpar error: can't spawn video parser thread\n");
         free( p_vpar );
@@ -136,7 +138,8 @@ p_vpar->p_vout = p_main->p_intf->p_vout;
  *****************************************************************************/
 void vpar_DestroyThread( vpar_thread_t *p_vpar /*, int *pi_status */ )
 {
-    intf_DbgMsg("vpar debug: requesting termination of video parser thread %p\n", p_vpar);
+    intf_DbgMsg( "vpar debug: requesting termination of "
+                 "video parser thread %p\n", p_vpar);
 
     /* Ask thread to kill itself */
     p_vpar->b_die = 1;
@@ -180,10 +183,6 @@ static int InitThread( vpar_thread_t *p_vpar )
     int i_dummy;
 #endif
 
-#ifdef SAM_SYNCHRO
-    int i_dummy;
-#endif
-
     intf_DbgMsg("vpar debug: initializing video parser thread %p\n", p_vpar);
 
     /* Our first job is to initialize the bit stream structure with the
@@ -199,8 +198,10 @@ static int InitThread( vpar_thread_t *p_vpar )
         vlc_cond_wait( &p_vpar->fifo.data_wait, &p_vpar->fifo.data_lock );
     }
     p_vpar->bit_stream.p_ts = DECODER_FIFO_START( p_vpar->fifo )->p_first_ts;
-    p_vpar->bit_stream.p_byte = p_vpar->bit_stream.p_ts->buffer + p_vpar->bit_stream.p_ts->i_payload_start;
-    p_vpar->bit_stream.p_end = p_vpar->bit_stream.p_ts->buffer + p_vpar->bit_stream.p_ts->i_payload_end;
+    p_vpar->bit_stream.p_byte = p_vpar->bit_stream.p_ts->buffer
+                                + p_vpar->bit_stream.p_ts->i_payload_start;
+    p_vpar->bit_stream.p_end = p_vpar->bit_stream.p_ts->buffer
+                               + p_vpar->bit_stream.p_ts->i_payload_end;
     vlc_mutex_unlock( &p_vpar->fifo.data_lock );
 
     /* Initialize parsing data */
@@ -251,8 +252,8 @@ static int InitThread( vpar_thread_t *p_vpar )
     }
 #else
     /* Fake a video_decoder thread */
-    if( (p_vpar->pp_vdec[0] = (vdec_thread_t *)malloc(sizeof( vdec_thread_t ))) == NULL
-        || vdec_InitThread( p_vpar->pp_vdec[0] ) )
+    if( (p_vpar->pp_vdec[0] = (vdec_thread_t *)malloc(sizeof( vdec_thread_t )))
+         == NULL || vdec_InitThread( p_vpar->pp_vdec[0] ) )
     {
         return( 1 );
     }
@@ -276,41 +277,28 @@ static int InitThread( vpar_thread_t *p_vpar )
      * Initialize the synchro properties
      */
 #ifdef SAM_SYNCHRO
-    p_vpar->synchro.i_last_decode_pts = 0;
-    p_vpar->synchro.i_last_display_pts = 0;
-    p_vpar->synchro.i_images_since_pts = 0;
+    p_vpar->synchro.i_last_pts = 0;
+
     /* for i frames */
-    p_vpar->synchro.i_last_i_pts = 0;
-    p_vpar->synchro.theorical_fps = 25;
-    p_vpar->synchro.i_last_nondropped_i_pts = 0;
-    p_vpar->synchro.actual_fps = 20;
+    p_vpar->synchro.i_last_seen_I_pts = 0;
+    p_vpar->synchro.i_last_kept_I_pts = 0;
+
     /* the fifo */
-    p_vpar->synchro.i_fifo_start = 0;
-    p_vpar->synchro.i_fifo_stop = 0;
-    /* the counter */
-    p_vpar->synchro.modulo = 0;
+    p_vpar->synchro.i_start  = 0;
+    p_vpar->synchro.i_stop   = 0;
+
     /* mean decoding time - at least 200 ms for a slow machine */
-    p_vpar->synchro.i_mean_decode_time = 200000;
+    p_vpar->synchro.i_delay            = 200000;
+    p_vpar->synchro.i_theorical_delay  = 40000; /* 25 fps */
     /* assume we can display all Is and 2 Ps */
-    p_vpar->synchro.can_display_i = 1;
-    p_vpar->synchro.can_display_p = 0;
+    p_vpar->synchro.b_all_I = 1;
+    p_vpar->synchro.b_all_P = 0;
     p_vpar->synchro.displayable_p = 2;
-    p_vpar->synchro.can_display_b = 0;
+    p_vpar->synchro.b_all_B = 0;
     p_vpar->synchro.displayable_b = 0;
     /* assume there were about 3 P and 6 B images between I's */
-    p_vpar->synchro.current_p_count = 1;
-    p_vpar->synchro.nondropped_p_count = 1;
-    p_vpar->synchro.p_count_predict = 3;
-    p_vpar->synchro.current_b_count = 1;
-    p_vpar->synchro.nondropped_b_count = 1;
-    p_vpar->synchro.b_count_predict = 6;
-    for( i_dummy = 0; i_dummy < 6; i_dummy++)
-    {
-        p_vpar->synchro.tab_p[i_dummy].mean = 3;
-        p_vpar->synchro.tab_p[i_dummy].deviation = .5;
-        p_vpar->synchro.tab_b[i_dummy].mean = 6;
-        p_vpar->synchro.tab_b[i_dummy].deviation = .5;
-    }
+    p_vpar->synchro.i_P_seen = p_vpar->synchro.i_P_kept = 1;
+    p_vpar->synchro.i_B_seen = p_vpar->synchro.i_B_kept = 1;
 #endif
 
 #ifdef MEUUH_SYNCHRO
@@ -411,7 +399,8 @@ static void ErrorThread( vpar_thread_t *p_vpar )
         /* Trash all received PES packets */
         while( !DECODER_FIFO_ISEMPTY(p_vpar->fifo) )
         {
-            input_NetlistFreePES( p_vpar->bit_stream.p_input, DECODER_FIFO_START(p_vpar->fifo) );
+            input_NetlistFreePES( p_vpar->bit_stream.p_input,
+                                  DECODER_FIFO_START(p_vpar->fifo) );
             DECODER_FIFO_INCSTART( p_vpar->fifo );
         }
 
index 13043db0b41a251a6518c3a89123b7bf951e9040..764b718142b39fa0cfef73ee07220a133c113fe3 100644 (file)
  */
 
 #ifdef SAM_SYNCHRO
-/*****************************************************************************
- * vpar_SynchroUpdateTab : Update a mean table in the synchro structure
- *****************************************************************************/
-float vpar_SynchroUpdateTab( video_synchro_tab_t * tab, int count )
-{
-
-    tab->mean = ( tab->mean + MAX_COUNT * count ) / ( MAX_COUNT + 1 );
-    tab->deviation = ( tab->deviation + MAX_COUNT * abs (tab->mean - count) )
-                        / ( MAX_COUNT + 1 );
-
-    return tab->deviation;
-}
 
 /*****************************************************************************
  * vpar_SynchroUpdateStructures : Update the synchro structures
  *****************************************************************************/
 void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
-                                   int i_coding_type, int dropped )
+                                   int i_coding_type, boolean_t b_kept )
 {
-    float candidate_deviation;
-    float optimal_deviation;
-    float predict;
-    mtime_t i_current_pts;
-    mtime_t i_delay;
-    mtime_t i_displaydate;
-    decoder_fifo_t * decoder_fifo = p_vpar->bit_stream.p_decoder_fifo;
-
-    /* interpolate the current _decode_ PTS */
-    i_current_pts = decoder_fifo->buffer[decoder_fifo->i_start]->b_has_pts ?
-                    decoder_fifo->buffer[decoder_fifo->i_start]->i_pts :
-                    0;
-    if( !i_current_pts )
+    mtime_t         i_delay;
+    mtime_t         i_pts;
+    pes_packet_t *  p_pes = p_vpar->bit_stream.p_decoder_fifo->buffer[ 
+                               p_vpar->bit_stream.p_decoder_fifo->i_start ];
+
+    /* try to guess the current DTS and PTS */
+    if( p_pes->b_has_pts )
     {
-        i_current_pts = p_vpar->synchro.i_last_decode_pts
-                       + 1000000.0 / (1 + p_vpar->synchro.actual_fps);
-    }
-    p_vpar->synchro.i_last_decode_pts = i_current_pts;
+        i_pts = p_pes->i_pts;
 
-    /* see if the current image has a pts - if not, set to 0 */
-    p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_pts
-            = i_current_pts;
+        /* if the image is I type, then the presentation timestamp is
+         * the PTS of the PES. Otherwise, we calculate it with the
+         * theorical framerate value */
+        if( i_coding_type == I_CODING_TYPE )
+        {
+            p_vpar->synchro.i_last_pts = p_pes->i_pts;
+        }
+        else
+        {
+            p_vpar->synchro.i_last_pts += p_vpar->synchro.i_theorical_delay;
+        }
 
-    /* update display time */
-    i_displaydate = decoder_fifo->buffer[decoder_fifo->i_start]->b_has_pts ?
-                    decoder_fifo->buffer[decoder_fifo->i_start]->i_pts :
-                    0;
-    if( !i_displaydate || i_coding_type != I_CODING_TYPE )
+        p_pes->b_has_pts = 0;
+    }
+    else
     {
-        if (!p_vpar->synchro.i_images_since_pts )
-            p_vpar->synchro.i_images_since_pts = 10;
-
-        i_displaydate = p_vpar->synchro.i_last_display_pts
-                       + 1000000.0 / (p_vpar->synchro.theorical_fps);
+        p_vpar->synchro.i_last_pts += p_vpar->synchro.i_theorical_delay;
+        i_pts = p_vpar->synchro.i_last_pts;
     }
 
-    decoder_fifo->buffer[decoder_fifo->i_start]->b_has_pts = 0;
-
-    p_vpar->synchro.i_images_since_pts--;
-    p_vpar->synchro.i_last_display_pts = i_displaydate;
-
-
-
     /* update structures */
     switch(i_coding_type)
     {
         case P_CODING_TYPE:
 
-            p_vpar->synchro.current_p_count++;
-            if( !dropped ) p_vpar->synchro.nondropped_p_count++;
+            p_vpar->synchro.i_P_seen++;
+            if( b_kept ) p_vpar->synchro.i_P_kept++;
             break;
 
         case B_CODING_TYPE:
-            p_vpar->synchro.current_b_count++;
-            if( !dropped ) p_vpar->synchro.nondropped_b_count++;
+            p_vpar->synchro.i_B_seen++;
+            if( b_kept ) p_vpar->synchro.i_B_kept++;
             break;
 
         case I_CODING_TYPE:
 
-            /* update information about images we can decode */
-            if (i_current_pts != p_vpar->synchro.i_last_i_pts)
-            {
-                if ( p_vpar->synchro.i_last_i_pts && i_current_pts != p_vpar->synchro.i_last_i_pts)
-                {
-                    p_vpar->synchro.theorical_fps = (p_vpar->synchro.theorical_fps + 1000000.0 * (1 + p_vpar->synchro.current_b_count + p_vpar->synchro.current_p_count) / (i_current_pts - p_vpar->synchro.i_last_i_pts)) / 2;
-                }
-                p_vpar->synchro.i_last_i_pts = i_current_pts;
-            }
-
-            if( !dropped )
+            /* update the last I PTS we have, we need it to
+             * calculate the theorical framerate */
+            if (i_pts != p_vpar->synchro.i_last_seen_I_pts)
             {
-                if ( p_vpar->synchro.i_last_nondropped_i_pts && i_current_pts != p_vpar->synchro.i_last_nondropped_i_pts)
+                if ( p_vpar->synchro.i_last_seen_I_pts )
                 {
-                    p_vpar->synchro.actual_fps = (p_vpar->synchro.actual_fps + 1000000.0 * (1 + p_vpar->synchro.nondropped_b_count + p_vpar->synchro.nondropped_p_count) / (i_current_pts - p_vpar->synchro.i_last_nondropped_i_pts)) / 2;
+                    p_vpar->synchro.i_theorical_delay =
+                            ( i_pts - p_vpar->synchro.i_last_seen_I_pts )
+                          / ( 1 + p_vpar->synchro.i_B_seen
+                                + p_vpar->synchro.i_P_seen);
                 }
-
-            }
-
-
-            /* update all the structures for P images */
-
-            /* period == 1 */
-            optimal_deviation = vpar_SynchroUpdateTab(
-                            &p_vpar->synchro.tab_p[0],
-                            p_vpar->synchro.current_p_count);
-            predict = p_vpar->synchro.tab_p[0].mean;
-
-            /* period == 2 */
-            candidate_deviation = vpar_SynchroUpdateTab(
-                            &p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo & 0x1)],
-                            p_vpar->synchro.current_p_count);
-            if (candidate_deviation < optimal_deviation)
-            {
-                optimal_deviation = candidate_deviation;
-                predict = p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo & 0x1)].mean;
-            }
-
-            /* period == 3 */
-            candidate_deviation = vpar_SynchroUpdateTab(
-                            &p_vpar->synchro.tab_p[3 + (p_vpar->synchro.modulo % 3)],
-                            p_vpar->synchro.current_p_count);
-            if (candidate_deviation < optimal_deviation)
-            {
-                optimal_deviation = candidate_deviation;
-                predict = p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo % 3)].mean;
+                p_vpar->synchro.i_last_seen_I_pts = i_pts;
             }
 
-            p_vpar->synchro.p_count_predict = predict;
-            p_vpar->synchro.current_p_count = 0;
-
-
-            /* update all the structures for B images */
-
-            /* period == 1 */
-            optimal_deviation = vpar_SynchroUpdateTab(
-                            &p_vpar->synchro.tab_b[0],
-                            p_vpar->synchro.current_b_count);
-            predict = p_vpar->synchro.tab_b[0].mean;
-
-            /* period == 2 */
-            candidate_deviation = vpar_SynchroUpdateTab(
-                            &p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo & 0x1)],
-                            p_vpar->synchro.current_b_count);
-            if (candidate_deviation < optimal_deviation)
-            {
-                optimal_deviation = candidate_deviation;
-                predict = p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo & 0x1)].mean;
-            }
-
-            /* period == 3 */
-            candidate_deviation = vpar_SynchroUpdateTab(
-                            &p_vpar->synchro.tab_b[3 + (p_vpar->synchro.modulo % 3)],
-                            p_vpar->synchro.current_b_count);
-            if (candidate_deviation < optimal_deviation)
-            {
-                optimal_deviation = candidate_deviation;
-                predict = p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo % 3)].mean;
-            }
-
-            p_vpar->synchro.b_count_predict = predict;
-            p_vpar->synchro.current_b_count = 0;
-
             /* now we calculated all statistics, it's time to
              * decide what we have the time to display
              */
-            i_delay = i_current_pts - p_vpar->synchro.i_last_nondropped_i_pts;
+            i_delay = i_pts - p_vpar->synchro.i_last_kept_I_pts;
 
-            p_vpar->synchro.can_display_i
-                = ( p_vpar->synchro.i_mean_decode_time < i_delay );
+            p_vpar->synchro.b_all_I
+                = ( p_vpar->synchro.i_delay < i_delay );
 
-            p_vpar->synchro.can_display_p
-                    = ( p_vpar->synchro.i_mean_decode_time
-                    * (1 + p_vpar->synchro.p_count_predict) < i_delay );
+            p_vpar->synchro.b_all_P
+                    = ( p_vpar->synchro.i_delay
+                    * (1 + p_vpar->synchro.i_P_seen) < i_delay );
 
-            if( !p_vpar->synchro.can_display_p )
+            if( !p_vpar->synchro.b_all_P )
             {
                 p_vpar->synchro.displayable_p
-                    = -1 + i_delay / p_vpar->synchro.i_mean_decode_time;
+                    //= -1.0 + (float)i_delay / (float)p_vpar->synchro.i_delay;
+                    = (-1.0 + (float)p_vpar->synchro.displayable_p + (float)i_delay / (float)p_vpar->synchro.i_delay) / 2.0;
                 if( p_vpar->synchro.displayable_p < 0 )
                     p_vpar->synchro.displayable_p = 0;
+
+                p_vpar->synchro.b_all_B = 0;
+                p_vpar->synchro.displayable_b = 0;
             }
             else
-                p_vpar->synchro.displayable_p = 0;
-
-            if( p_vpar->synchro.can_display_p
-                && !(p_vpar->synchro.can_display_b
-                    = ( p_vpar->synchro.i_mean_decode_time
-                    * (1 + p_vpar->synchro.b_count_predict
-                        + p_vpar->synchro.p_count_predict)) < i_delay) )
             {
-                p_vpar->synchro.displayable_b
-                    = -2.0 + i_delay / p_vpar->synchro.i_mean_decode_time
-                        - p_vpar->synchro.can_display_p;
+                p_vpar->synchro.displayable_p = p_vpar->synchro.i_P_seen;
+
+                if( !(p_vpar->synchro.b_all_B
+                        = ( p_vpar->synchro.i_delay
+                        * (1 + p_vpar->synchro.i_B_seen
+                            + p_vpar->synchro.i_P_seen)) < i_delay) )
+                {
+                    p_vpar->synchro.displayable_b
+                        //= -2.0 + i_delay / p_vpar->synchro.i_delay - p_vpar->synchro.b_all_P;
+                        = ( -2.0 + (float)p_vpar->synchro.displayable_b + (float)i_delay / (float)p_vpar->synchro.i_delay - (float)p_vpar->synchro.b_all_P) / 2.0;
+                }
+                else
+                {
+                    p_vpar->synchro.displayable_b = p_vpar->synchro.i_B_seen;
+                }
             }
-            else
-                p_vpar->synchro.displayable_b = 0;
 
-#if 0
-            intf_DbgMsg( "I %i  P %i (%f)  B %i (%f)\n",
-                p_vpar->synchro.can_display_i,
-                p_vpar->synchro.can_display_p,
-                p_vpar->synchro.displayable_p,
-                p_vpar->synchro.can_display_b,
-                p_vpar->synchro.displayable_b );
+#if 1
+            if( p_vpar->synchro.b_all_I )
+                intf_ErrMsg( "I: all  " );
+            if( p_vpar->synchro.b_all_P )
+                intf_ErrMsg( "P: all  " );
+            else if( p_vpar->synchro.displayable_p > 0 )
+                intf_ErrMsg( "P: %f  ", p_vpar->synchro.displayable_p );
+            if( p_vpar->synchro.b_all_B )
+                intf_ErrMsg( "B: all" );
+            else if( p_vpar->synchro.displayable_b > 0 )
+                intf_ErrMsg( "B: %f", p_vpar->synchro.displayable_b );
+            intf_ErrMsg( "\n" );
 #endif
+            p_vpar->synchro.i_P_seen = 0;
+            p_vpar->synchro.i_B_seen = 0;
 
             /* update some values */
-            if( !dropped )
+            if( b_kept )
             {
-                p_vpar->synchro.i_last_nondropped_i_pts = i_current_pts;
-                p_vpar->synchro.nondropped_p_count = 0;
-                p_vpar->synchro.nondropped_b_count = 0;
+                p_vpar->synchro.i_last_kept_I_pts = i_pts;
+                p_vpar->synchro.i_P_kept = 0;
+                p_vpar->synchro.i_B_kept = 0;
             }
 
             break;
-
     }
-
-    p_vpar->synchro.modulo++;
-
 }
 
 /*****************************************************************************
@@ -285,45 +201,56 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
 boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
                               int i_structure )
 {
-    mtime_t i_delay = p_vpar->synchro.i_last_decode_pts - mdate();
+    mtime_t i_delay = p_vpar->synchro.i_last_pts - mdate();
 
     switch( i_coding_type )
     {
         case I_CODING_TYPE:
 
-            return( p_vpar->synchro.can_display_i );
+            //intf_ErrMsg( " I %f      %f\nI ", 1000000.0 / p_vpar->synchro.i_theorical_delay, 1000000.0 / p_vpar->synchro.i_delay );
+            return( p_vpar->synchro.b_all_I );
 
         case P_CODING_TYPE:
 
-            if( p_vpar->synchro.can_display_p )
+            if( p_vpar->synchro.b_all_P )
+            {
+                //intf_ErrMsg( " p  " );
                 return( 1 );
+            }
 
             if( p_vpar->synchro.displayable_p * i_delay
-                < p_vpar->synchro.i_mean_decode_time )
+                < p_vpar->synchro.i_delay )
             {
-                //intf_ErrMsg( "trashed a P\n" );
+                //intf_ErrMsg( " -  " );
                 return( 0 );
             }
 
             p_vpar->synchro.displayable_p--;
+            //intf_ErrMsg( " p> " );
             return( 1 );
 
         case B_CODING_TYPE:
 
-            if( p_vpar->synchro.can_display_b )
+            if( p_vpar->synchro.b_all_B )
+            {
+                //intf_ErrMsg( "b " );
                 return( 1 );
+            }
 
-            /* modulo & 0x3 is here to add some randomness */
-            if( i_delay < (1 + (p_vpar->synchro.modulo & 0x3))
-                * p_vpar->synchro.i_mean_decode_time )
+            if( p_vpar->synchro.displayable_b <= 0 )
             {
-                //intf_ErrMsg( "trashed a B\n" );
+                //intf_ErrMsg( "  " );
                 return( 0 );
             }
 
-            if( p_vpar->synchro.displayable_b <= 0 )
+            if( i_delay < 0 )
+            {
+                //intf_ErrMsg( "· " );
+                p_vpar->synchro.displayable_b -= 0.5;
                 return( 0 );
+            }
 
+            //intf_ErrMsg( "b " );
             p_vpar->synchro.displayable_b--;
             return( 1 );
     }
@@ -338,7 +265,7 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
 void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
                         int i_structure )
 {
-    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, 1);
+    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, 0);
 
 }
 
@@ -348,13 +275,11 @@ void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
 void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
                             int i_structure )
 {
-    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, 0);
+    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, 1);
 
-    p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_decode_date = mdate();
-    p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_image_type
-        = i_coding_type;
+    p_vpar->synchro.i_date_fifo[p_vpar->synchro.i_stop] = mdate();
 
-    p_vpar->synchro.i_fifo_stop = (p_vpar->synchro.i_fifo_stop + 1) & 0xf;
+    FIFO_INCREMENT( i_stop );
 
 }
 
@@ -363,20 +288,29 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
  *****************************************************************************/
 void vpar_SynchroEnd( vpar_thread_t * p_vpar )
 {
-    mtime_t i_decode_time;
-
-    i_decode_time = (mdate() -
-            p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date)
-        / ( (p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start) & 0x0f);
+    if( p_vpar->synchro.i_stop != p_vpar->synchro.i_start )
+    {
+        mtime_t i_delay;
 
-    p_vpar->synchro.i_mean_decode_time =
-        ( 7 * p_vpar->synchro.i_mean_decode_time + i_decode_time ) / 8;
+        i_delay = ( mdate() -
+            p_vpar->synchro.i_date_fifo[p_vpar->synchro.i_start] )
+              / ( (p_vpar->synchro.i_stop - p_vpar->synchro.i_start) & 0x0f );
 
-    /* intf_ErrMsg( "decoding time was %lli\n",
-        p_vpar->synchro.i_mean_decode_time ); */
+        p_vpar->synchro.i_delay =
+            ( 7 * p_vpar->synchro.i_delay + i_delay ) >> 3;
 
-    p_vpar->synchro.i_fifo_start = (p_vpar->synchro.i_fifo_start + 1) & 0xf;
+#if 0
+        intf_ErrMsg( "decode %lli (mean %lli, theorical %lli)\n",
+                     i_delay, p_vpar->synchro.i_delay,
+                     p_vpar->synchro.i_theorical_delay );
+#endif
+    }
+    else
+    {
+        intf_ErrMsg( "vpar error: critical ! fifo full\n" );
+    }
 
+    FIFO_INCREMENT( i_start );
 }
 
 /*****************************************************************************
@@ -384,23 +318,27 @@ void vpar_SynchroEnd( vpar_thread_t * p_vpar )
  *****************************************************************************/
 mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
 {
-    mtime_t i_displaydate = p_vpar->synchro.i_last_display_pts;
-
 #if 0
+
+    mtime_t i_displaydate = p_vpar->synchro.i_last_pts;
+
     static mtime_t i_delta = 0;
 
-    intf_ErrMsg( "displaying type %i with delay %lli and delta %lli\n",
-        p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type,
+    intf_ErrMsg( "displaying image with delay %lli and delta %lli\n",
         i_displaydate - mdate(),
         i_displaydate - i_delta );
 
     intf_ErrMsg ( "theorical fps: %f - actual fps: %f \n",
-        p_vpar->synchro.theorical_fps, p_vpar->synchro.actual_fps );
+        1000000.0 / p_vpar->synchro.i_theorical_delay, 1000000.0 / p_vpar->synchro.i_delay );
 
     i_delta = i_displaydate;
-#endif
 
     return i_displaydate;
+#else
+
+    return p_vpar->synchro.i_last_pts;
+
+#endif
 }
 
 #endif
index 36092648fee833acc30a2d0dddcdfda9ba73940b..4de9d66f9cb3be78b2e268d7a7ff72cb9d71b80f 100644 (file)
--- a/vlc.spec
+++ b/vlc.spec
@@ -4,14 +4,17 @@ Release: 1
 Copyright: GPL
 Url: http://www.videolan.org/
 Group: X11/Applications/Graphics
-Source0: http://www.videolan.org/packages/0.1.99c/vlc-0.1.99c.tar.gz
-Packager: Eric Doutreleau <Eric.doutreleau@int-evry.fr>
+Source0: http://www.videolan.org/packages/0.1.99d/vlc-0.1.99d.tar.gz
+Packager: Samuel Hocevar <sam@via.ecp.fr>
 
 Buildroot: /tmp/vlc-build
 Summary: VideoLAN Client.
 
 %changelog
-* Thu Jun 15 2000 Eric Doutreleau < Eric.Doutreleau@int-evry.fr>
+* Sun Jun 18 2000 Samuel Hocevar <sam@via.ecp.fr>
+Took over the package
+
+* Thu Jun 15 2000 Eric Doutreleau <Eric.Doutreleau@int-evry.fr>
 Initial package
 
 %description
@@ -25,7 +28,7 @@ a free network-aware MPEG and DVD player
 %setup 
 
 %build
-./configure --prefix=/usr --enable-ppro --enable-mmx --enable-gnome
+./configure --prefix=/usr --enable-mmx --enable-gnome
 make
 %install
 mkdir -p $RPM_BUILD_ROOT/usr/lib