diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-01-08 01:36:05 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-01-08 01:36:05 +0200 |
commit | b390b9b28fa6280f355eeef4811b6cfc02dea01a (patch) | |
tree | ef67be7ab1b189f5818fb8a273fa10f19d19aec6 | |
parent | efe742e3fa08f007ab41f1d666fd1f1c3bf0d63a (diff) | |
parent | 8e778e501948b67b1f8cd889e68242d1a1eb6041 (diff) | |
download | mpv-b390b9b28fa6280f355eeef4811b6cfc02dea01a.tar.bz2 mpv-b390b9b28fa6280f355eeef4811b6cfc02dea01a.tar.xz |
Merge svn changes up to r30185
-rw-r--r-- | DOCS/man/en/mplayer.1 | 27 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rwxr-xr-x | configure | 85 | ||||
-rw-r--r-- | libao2/ao_sdl.c | 4 | ||||
-rw-r--r-- | libmpcodecs/vf_screenshot.c | 1 | ||||
-rw-r--r-- | libvo/aclib.c | 2 | ||||
-rw-r--r-- | libvo/aclib_template.c | 16 | ||||
-rw-r--r-- | libvo/gl_common.c | 22 | ||||
-rw-r--r-- | libvo/gl_common.h | 11 | ||||
-rw-r--r-- | libvo/matrixview.c | 378 | ||||
-rw-r--r-- | libvo/matrixview.h | 12 | ||||
-rw-r--r-- | libvo/matrixview_font.h | 588 | ||||
-rw-r--r-- | libvo/video_out.c | 4 | ||||
-rw-r--r-- | libvo/vo_matrixview.c | 325 | ||||
-rw-r--r-- | libvo/vo_sdl.c | 4 | ||||
-rw-r--r-- | mplayer.c | 4 |
16 files changed, 1456 insertions, 28 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 434f12c348..e801048a64 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -3860,6 +3860,18 @@ Provides brightness, contrast, saturation, hue and gamma control. Gamma can also be set independently for red, green and blue. Speed depends more on GPU memory bandwidth than other methods. .RE +.IPs colorspace +Select the color space for YUV to RGB conversion. +.RSss +.IPs 0 +Use the formula used normally by MPlayer (default) +.IPs 1 +Use ITU-R BT.601 color space. +.IPs 2 +Use ITU-R BT.709 color space. +.IPs 3 +Use SMPTE-240M color space. +.RE .IPs lscale=<n> Select the scaling function to use for luminance scaling. Only valid for yuv modes 2, 3, 4 and 6. @@ -3958,6 +3970,21 @@ Apart from this the values have the same meaning as for \-vo gl. .REss . .TP +.B matrixview +OpenGL based renderer creating a Matrix-like running-text effect. +.PD 0 +.RSs +.IPs cols=<n> +Number of text columns to display. +Very low values (< 16) will probably fail due to scaler limitations. +Values not divisible be 16 may cause issues as well. +.IPs rows=<n> +Number of text rows to display. +Very low values (< 16) will probably fail due to scaler limitations. +Values not divisible be 16 may cause issues as well. +.REss +. +.TP .B "null\ \ \ " Produces no video output. Useful for benchmarking. @@ -541,6 +541,7 @@ SRCS_MPLAYER-$(GIF) += libvo/vo_gif89a.c SRCS_MPLAYER-$(GL) += libvo/gl_common.c libvo/vo_gl.c libvo/vo_gl2.c libvo/csputils.c SRCS_MPLAYER-$(GL_WIN32) += libvo/w32_common.c SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c +SRCS_MPLAYER-$(MATRIXVIEW) += libvo/vo_matrixview.c libvo/matrixview.c SRCS_MPLAYER-$(IVTV) += libao2/ao_ivtv.c libvo/vo_ivtv.c SRCS_MPLAYER-$(JACK) += libao2/ao_jack.c @@ -334,6 +334,7 @@ Video output: --enable-dhahelper enable VIDIX dhahelper support --enable-svgalib_helper enable VIDIX svgalib_helper support --enable-gl enable OpenGL video output [autodetect] + --disable-matrixview disable OpenGL MatrixView video output [autodetect] --enable-dga2 enable DGA 2 support [autodetect] --enable-dga1 enable DGA 1 support [autodetect] --enable-vesa enable VESA video output [autodetect] @@ -537,6 +538,7 @@ _md5sum=yes _yuv4mpeg=yes _gif=auto _gl=auto +matrixview=yes _ggi=auto _ggiwmh=auto _aa=auto @@ -890,6 +892,8 @@ for ac_option do --disable-gif) _gif=no ;; --enable-gl) _gl=yes ;; --disable-gl) _gl=no ;; + --enable-matrixview) matrixview=yes ;; + --disable-matrixview) matrixview=no ;; --enable-ggi) _ggi=yes ;; --disable-ggi) _ggi=no ;; --enable-ggiwmh) _ggiwmh=yes ;; @@ -4488,6 +4492,19 @@ else _novomodules="xvidix $_novomodules" fi +echocheck "MatrixView" +if test "$_gl" = no ; then + matrixview=no +fi +if test "$matrixview" = yes ; then + _vomodules="matrixview $_vomodules" + def_matrixview='#define CONFIG_MATRIXVIEW 1' +else + _novomodules="matrixview $_novomodules" + def_matrixview='#undef CONFIG_MATRIXVIEW' +fi +echores "$matrixview" + echocheck "GGI" if test "$_ggi" = auto ; then cat > $TMPC << EOF @@ -5039,6 +5056,9 @@ echores "$_vesa" echocheck "SDL" +_inc_tmp="" +_ld_tmp="" +def_sdl_sdl_h="#undef CONFIG_SDL_SDL_H" if test -z "$_sdlconfig" ; then if ( sdl-config --version ) >>"$TMPLOG" 2>&1 ; then _sdlconfig="sdl-config" @@ -5050,15 +5070,40 @@ if test -z "$_sdlconfig" ; then fi if test "$_sdl" = auto || test "$_sdl" = yes ; then cat > $TMPC << EOF +#ifdef CONFIG_SDL_SDL_H +#include <SDL/SDL.h> +#else #include <SDL.h> +#endif +#ifndef __APPLE__ +// we allow SDL hacking our main() only on OSX +#undef main +#endif int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE); return 0; } EOF _sdl=no - if "$_sdlconfig" --version >>"$TMPLOG" 2>&1 ; then - if cc_check $($_sdlconfig --cflags) $($_sdlconfig --libs) >>"$TMPLOG" 2>&1 ; then + for _ld_tmp in "-lSDL" "-lSDL -lpthread" "-lSDL -lwinmm -lgdi32" ; do + if cc_check -DCONFIG_SDL_SDL_H $_inc_tmp $_ld_tmp ; then + _sdl=yes + def_sdl_sdl_h="#define CONFIG_SDL_SDL_H 1" + break + fi + done + if test "$_sdl" = no && "$_sdlconfig" --version >>"$TMPLOG" 2>&1 ; then + if cygwin ; then + _inc_tmp="$($_sdlconfig --cflags | cut -d " " -f 1,5,6 | sed s/no-cygwin/cygwin/)" + _ld_tmp="$($_sdlconfig --libs | cut -d " " -f 1,4,6 | sed s/no-cygwin/cygwin/)" + elif mingw32 ; then + _inc_tmp=$($_sdlconfig --cflags | sed s/-Dmain=SDL_main//) + _ld_tmp=$($_sdlconfig --libs | sed -e s/-mwindows// -e s/-lmingw32//) + else + _inc_tmp="$($_sdlconfig --cflags)" + _ld_tmp="$($_sdlconfig --libs)" + fi + if cc_check $_inc_tmp $_ld_tmp >>"$TMPLOG" 2>&1 ; then _sdlversion=$($_sdlconfig --version | sed 's/[^0-9]//g') if test "$_sdlversion" -gt 116 ; then if test "$_sdlversion" -lt 121 ; then @@ -5073,16 +5118,8 @@ EOF fi if test "$_sdl" = yes ; then def_sdl='#define CONFIG_SDL 1' - if cygwin ; then - libs_mplayer="$libs_mplayer $($_sdlconfig --libs | cut -d " " -f 1,4,6 | sed s/no-cygwin/cygwin/)" - extra_cflags="$extra_cflags $($_sdlconfig --cflags | cut -d " " -f 1,5,6 | sed s/no-cygwin/cygwin/)" - elif mingw32 ; then - libs_mplayer="$libs_mplayer $($_sdlconfig --libs | sed -e s/-mwindows// -e s/-lmingw32//)" - extra_cflags="$extra_cflags $($_sdlconfig --cflags | sed s/-Dmain=SDL_main//)" - else - libs_mplayer="$libs_mplayer $($_sdlconfig --libs)" - extra_cflags="$extra_cflags $($_sdlconfig --cflags | sed s/-D_GNU_SOURCE=1//)" - fi + extra_cflags="$extra_cflags $_inc_tmp" + libs_mplayer="$libs_mplayer $_ld_tmp" _vomodules="sdl $_vomodules" _aomodules="sdl $_aomodules" _res_comment="using $_sdlconfig" @@ -6017,7 +6054,7 @@ int main(void) { } EOF _fontconfig=no - for _ld_tmp in "" "-lexpat -lfreetype" "-lexpat -lfreetype -lz" ; do + for _ld_tmp in "" "-lexpat -lfreetype" "-lexpat -lfreetype -lz" "-lexpat -lfreetype -lz -liconv" ; do _ld_tmp="-lfontconfig $_ld_tmp" cc_check $_ld_tmp && _fontconfig=yes && extra_ldflags="$extra_ldflags $_ld_tmp" && break done @@ -6054,8 +6091,9 @@ echores "$_ass" echocheck "fribidi with charsets" +_inc_tmp="" +_ld_tmp="" if test "$_fribidi" = auto ; then - if ( $_fribidiconfig --version ) >/dev/null 2>&1 ; then cat > $TMPC << EOF #include <stdio.h> /* workaround for fribidi 0.10.4 and below */ @@ -6070,15 +6108,19 @@ int main(void) { } EOF _fribidi=no - cc_check $($_fribidiconfig --cflags) $($_fribidiconfig --libs) && _fribidi=yes - else - _fribidi=no - fi + _inc_tmp="" + _ld_tmp="-lfribidi" + cc_check $_inc_tmp $_ld_tmp && _fribidi=yes + if test "$_fribidi" = no ; then + _inc_tmp="$($_fribidiconfig --cflags)" + _ld_tmp="$($_fribidiconfig --libs)" + cc_check $_inc_tmp $_ld_tmp && _fribidi=yes + fi fi if test "$_fribidi" = yes ; then def_fribidi='#define CONFIG_FRIBIDI 1' - extra_cflags="$extra_cflags $($_fribidiconfig --cflags)" - extra_ldflags="$extra_ldflags $($_fribidiconfig --libs)" + extra_cflags="$extra_cflags $_inc_tmp" + extra_ldflags="$extra_ldflags $_ld_tmp" else def_fribidi='#undef CONFIG_FRIBIDI' fi @@ -7841,6 +7883,7 @@ GGI = $_ggi GL = $_gl GL_WIN32 = $_gl_win32 GL_X11 = $_gl_x11 +MATRIXVIEW = $matrixview HAVE_POSIX_SELECT = $_posix_select HAVE_SYS_MMAN_H = $_mman IVTV = $_ivtv @@ -8314,6 +8357,7 @@ $def_gif_tvt_hack $def_gl $def_gl_win32 $def_gl_x11 +$def_matrixview $def_ivtv $def_jpeg $def_kva @@ -8325,6 +8369,7 @@ $def_pnm $def_quartz $def_s3fb $def_sdl +$def_sdl_sdl_h $def_sdlbuggy $def_svga $def_tdfxfb diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c index 47a05ef2fa..0cef28c913 100644 --- a/libao2/ao_sdl.c +++ b/libao2/ao_sdl.c @@ -31,7 +31,11 @@ #include "audio_out.h" #include "audio_out_internal.h" #include "libaf/af_format.h" +#ifdef CONFIG_SDL_SDL_H +#include <SDL/SDL.h> +#else #include <SDL.h> +#endif #include "osdep/timer.h" #include "libavutil/fifo.h" diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c index 1fb37a623b..0176eddfbd 100644 --- a/libmpcodecs/vf_screenshot.c +++ b/libmpcodecs/vf_screenshot.c @@ -256,6 +256,7 @@ static int query_format(struct vf_instance* vf, unsigned int fmt) static void uninit(vf_instance_t *vf) { + avcodec_close(vf->priv->avctx); av_freep(&vf->priv->avctx); if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); if (vf->priv->buffer) free(vf->priv->buffer); diff --git a/libvo/aclib.c b/libvo/aclib.c index 4fbd36d10e..7328de794a 100644 --- a/libvo/aclib.c +++ b/libvo/aclib.c @@ -23,9 +23,11 @@ #include "config.h" #include <stddef.h> +#include <stdint.h> #include <string.h> #include "cpudetect.h" #include "fastmemcpy.h" +#include "ffmpeg_files/x86_cpu.h" #undef memcpy #define BLOCK_SIZE 4096 diff --git a/libvo/aclib_template.c b/libvo/aclib_template.c index d7b2201944..db3015ae66 100644 --- a/libvo/aclib_template.c +++ b/libvo/aclib_template.c @@ -100,7 +100,7 @@ If you have questions please contact with me: Nick Kurshev: nickols_k@mail.ru. /* for small memory blocks (<256 bytes) this version is faster */ #define small_memcpy(to,from,n)\ {\ -register unsigned long int dummy;\ +register x86_reg dummy;\ __asm__ volatile(\ "rep; movsb"\ :"=&D"(to), "=&S"(from), "=&c"(dummy)\ @@ -180,9 +180,9 @@ static void * RENAME(fast_memcpy)(void * to, const void * from, size_t len) #endif if(len >= MIN_LEN) { - register unsigned long int delta; + register x86_reg delta; /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)to)&(MMREG_SIZE-1); + delta = ((intptr_t)to)&(MMREG_SIZE-1); if(delta) { delta=MMREG_SIZE-delta; @@ -201,7 +201,7 @@ static void * RENAME(fast_memcpy)(void * to, const void * from, size_t len) processor's decoders, but it's not always possible. */ #if HAVE_SSE /* Only P3 (may be Cyrix3) */ - if(((unsigned long)from) & 15) + if(((intptr_t)from) & 15) /* if SRC is misaligned */ for(; i>0; i--) { @@ -243,7 +243,7 @@ static void * RENAME(fast_memcpy)(void * to, const void * from, size_t len) } #else // Align destination at BLOCK_SIZE boundary - for(; ((int)to & (BLOCK_SIZE-1)) && i>0; i--) + for(; ((intptr_t)to & (BLOCK_SIZE-1)) && i>0; i--) { __asm__ volatile ( #ifndef HAVE_ONLY_MMX1 @@ -328,7 +328,7 @@ static void * RENAME(fast_memcpy)(void * to, const void * from, size_t len) "cmp %4, %2 \n\t" " jae 1b \n\t" : "+r" (from), "+r" (to), "+r" (i) - : "r" ((long)BLOCK_SIZE), "i" (BLOCK_SIZE/64), "i" ((long)CONFUSION_FACTOR) + : "r" ((x86_reg)BLOCK_SIZE), "i" (BLOCK_SIZE/64), "i" ((x86_reg)CONFUSION_FACTOR) : "%"REG_a, "%ecx" ); @@ -400,9 +400,9 @@ static void * RENAME(mem2agpcpy)(void * to, const void * from, size_t len) #endif if(len >= MIN_LEN) { - register unsigned long int delta; + register x86_reg delta; /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)to)&7; + delta = ((intptr_t)to)&7; if(delta) { delta=8-delta; diff --git a/libvo/gl_common.c b/libvo/gl_common.c index b6bef7f1b7..a411c00eb2 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -41,8 +41,10 @@ void (GLAPIENTRY *End)(void); void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei); void (GLAPIENTRY *MatrixMode)(GLenum); void (GLAPIENTRY *LoadIdentity)(void); +void (GLAPIENTRY *Translated)(double, double, double); void (GLAPIENTRY *Scaled)(double, double, double); void (GLAPIENTRY *Ortho)(double, double, double, double, double, double); +void (GLAPIENTRY *Frustum)(double, double, double, double, double, double); void (GLAPIENTRY *PushMatrix)(void); void (GLAPIENTRY *PopMatrix)(void); void (GLAPIENTRY *Clear)(GLbitfield); @@ -54,10 +56,14 @@ void (GLAPIENTRY *CallList)(GLuint); void (GLAPIENTRY *CallLists)(GLsizei, GLenum, const GLvoid *); void (GLAPIENTRY *GenTextures)(GLsizei, GLuint *); void (GLAPIENTRY *DeleteTextures)(GLsizei, const GLuint *); +void (GLAPIENTRY *TexEnvf)(GLenum, GLenum, GLfloat); void (GLAPIENTRY *TexEnvi)(GLenum, GLenum, GLint); void (GLAPIENTRY *Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte); void (GLAPIENTRY *Color3f)(GLfloat, GLfloat, GLfloat); +void (GLAPIENTRY *Color4f)(GLfloat, GLfloat, GLfloat, GLfloat); void (GLAPIENTRY *ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); +void (GLAPIENTRY *ClearDepth)(GLclampd); +void (GLAPIENTRY *DepthFunc)(GLenum); void (GLAPIENTRY *Enable)(GLenum); void (GLAPIENTRY *Disable)(GLenum); const GLubyte *(GLAPIENTRY *GetString)(GLenum); @@ -75,6 +81,11 @@ void (GLAPIENTRY *TexParameterf)(GLenum, GLenum, GLfloat); void (GLAPIENTRY *TexParameterfv)(GLenum, GLenum, const GLfloat *); void (GLAPIENTRY *TexCoord2f)(GLfloat, GLfloat); void (GLAPIENTRY *Vertex2f)(GLfloat, GLfloat); +void (GLAPIENTRY *Vertex3f)(GLfloat, GLfloat, GLfloat); +void (GLAPIENTRY *Normal3f)(GLfloat, GLfloat, GLfloat); +void (GLAPIENTRY *Lightfv)(GLenum, GLenum, const GLfloat *); +void (GLAPIENTRY *ColorMaterial)(GLenum, GLenum); +void (GLAPIENTRY *ShadeModel)(GLenum); void (GLAPIENTRY *GetIntegerv)(GLenum, GLint *); /** @@ -359,8 +370,10 @@ static const extfunc_desc_t extfuncs[] = { DEF_FUNC_DESC(Viewport), DEF_FUNC_DESC(MatrixMode), DEF_FUNC_DESC(LoadIdentity), + DEF_FUNC_DESC(Translated), DEF_FUNC_DESC(Scaled), DEF_FUNC_DESC(Ortho), + DEF_FUNC_DESC(Frustum), DEF_FUNC_DESC(PushMatrix), DEF_FUNC_DESC(PopMatrix), DEF_FUNC_DESC(Clear), @@ -372,10 +385,14 @@ static const extfunc_desc_t extfuncs[] = { DEF_FUNC_DESC(CallLists), DEF_FUNC_DESC(GenTextures), DEF_FUNC_DESC(DeleteTextures), + DEF_FUNC_DESC(TexEnvf), DEF_FUNC_DESC(TexEnvi), DEF_FUNC_DESC(Color4ub), DEF_FUNC_DESC(Color3f), + DEF_FUNC_DESC(Color4f), DEF_FUNC_DESC(ClearColor), + DEF_FUNC_DESC(ClearDepth), + DEF_FUNC_DESC(DepthFunc), DEF_FUNC_DESC(Enable), DEF_FUNC_DESC(Disable), DEF_FUNC_DESC(DrawBuffer), @@ -392,6 +409,11 @@ static const extfunc_desc_t extfuncs[] = { DEF_FUNC_DESC(TexParameterfv), DEF_FUNC_DESC(TexCoord2f), DEF_FUNC_DESC(Vertex2f), + DEF_FUNC_DESC(Vertex3f), + DEF_FUNC_DESC(Normal3f), + DEF_FUNC_DESC(Lightfv), + DEF_FUNC_DESC(ColorMaterial), + DEF_FUNC_DESC(ShadeModel), DEF_FUNC_DESC(GetIntegerv), // here start the real extensions diff --git a/libvo/gl_common.h b/libvo/gl_common.h index db20ebbc65..0be98cf6ed 100644 --- a/libvo/gl_common.h +++ b/libvo/gl_common.h @@ -395,8 +395,10 @@ extern void (GLAPIENTRY *End)(void); extern void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei); extern void (GLAPIENTRY *MatrixMode)(GLenum); extern void (GLAPIENTRY *LoadIdentity)(void); +extern void (GLAPIENTRY *Translated)(double, double, double); extern void (GLAPIENTRY *Scaled)(double, double, double); extern void (GLAPIENTRY *Ortho)(double, double, double, double, double, double); +extern void (GLAPIENTRY *Frustum)(double, double, double, double, double, double); extern void (GLAPIENTRY *PushMatrix)(void); extern void (GLAPIENTRY *PopMatrix)(void); extern void (GLAPIENTRY *Clear)(GLbitfield); @@ -408,10 +410,14 @@ extern void (GLAPIENTRY *CallList)(GLuint); extern void (GLAPIENTRY *CallLists)(GLsizei, GLenum, const GLvoid *); extern void (GLAPIENTRY *GenTextures)(GLsizei, GLuint *); extern void (GLAPIENTRY *DeleteTextures)(GLsizei, const GLuint *); +extern void (GLAPIENTRY *TexEnvf)(GLenum, GLenum, GLfloat); extern void (GLAPIENTRY *TexEnvi)(GLenum, GLenum, GLint); extern void (GLAPIENTRY *Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte); extern void (GLAPIENTRY *Color3f)(GLfloat, GLfloat, GLfloat); +extern void (GLAPIENTRY *Color4f)(GLfloat, GLfloat, GLfloat, GLfloat); extern void (GLAPIENTRY *ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); +extern void (GLAPIENTRY *ClearDepth)(GLclampd); +extern void (GLAPIENTRY *DepthFunc)(GLenum); extern void (GLAPIENTRY *Enable)(GLenum); extern void (GLAPIENTRY *Disable)(GLenum); extern const GLubyte *(GLAPIENTRY *GetString)(GLenum); @@ -429,6 +435,11 @@ extern void (GLAPIENTRY *TexParameterf)(GLenum, GLenum, GLfloat); extern void (GLAPIENTRY *TexParameterfv)(GLenum, GLenum, const GLfloat *); extern void (GLAPIENTRY *TexCoord2f)(GLfloat, GLfloat); extern void (GLAPIENTRY *Vertex2f)(GLfloat, GLfloat); +extern void (GLAPIENTRY *Vertex3f)(GLfloat, GLfloat, GLfloat); +extern void (GLAPIENTRY *Normal3f)(GLfloat, GLfloat, GLfloat); +extern void (GLAPIENTRY *Lightfv)(GLenum, GLenum, const GLfloat *); +extern void (GLAPIENTRY *ColorMaterial)(GLenum, GLenum); +extern void (GLAPIENTRY *ShadeModel)(GLenum); extern void (GLAPIENTRY *GetIntegerv)(GLenum, GLint *); extern void (GLAPIENTRY *GenBuffers)(GLsizei, GLuint *); diff --git a/libvo/matrixview.c b/libvo/matrixview.c new file mode 100644 index 0000000000..287ff2d497 --- /dev/null +++ b/libvo/matrixview.c @@ -0,0 +1,378 @@ +/* + * Copyright (C) 2003 Alex Zolotov <nightradio@knoppix.ru> + * Mucked with by Tugrul Galatali <tugrul@galatali.com> + * + * MatrixView is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * MatrixView 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 MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * Ported to an MPlayer video out plugin by Pigeon <pigeon at pigeond.net> + * August 2006 + */ + +#include <math.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include "gl_common.h" +#include "matrixview.h" +#include "matrixview_font.h" + +static float matrix_contrast = 1.5; +static float matrix_brightness = 1.0; + +// Settings for our light. Try playing with these (or add more lights). +static float Light_Ambient[] = { 0.1f, 0.1f, 0.1f, 1.0f }; +static float Light_Diffuse[] = { 1.2f, 1.2f, 1.2f, 1.0f }; +static float Light_Position[] = { 2.0f, 2.0f, 0.0f, 1.0f }; + +static const uint8_t flare[4][4] = { + { 0, 0, 0, 0}, + { 0, 180, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0} +}; + +#define MAX_TEXT_X 0x4000 +#define MAX_TEXT_Y 0x4000 +static int text_x = 0; +static int text_y = 0; +#define _text_x text_x/2 +#define _text_y text_y/2 + +// Scene position +#define Z_Off -128.0f +#define Z_Depth 8 + +static uint8_t *speed; +static uint8_t *text; +static uint8_t *text_light; +static float *text_depth; + +static float *bump_pic; + +static void draw_char(int num, float light, float x, float y, float z) +{ + float tx, ty; + int num2, num3; + + num &= 63; + //light = light / 255; //light=7-light;num+=(light*60); + light = light / 255 * matrix_brightness; + num2 = num / 10; + num3 = num - (num2 * 10); + ty = (float)num2 / 7; + tx = (float)num3 / 10; + Normal3f(0.0f, 0.0f, 1.0f); // Needed for lighting + Color4f(0.0, 1.0, 0.0, light); // Basic polygon color + + TexCoord2f(tx, ty); + Vertex3f(x, y, z); + TexCoord2f(tx + 0.1, ty); + Vertex3f(x + 1, y, z); + TexCoord2f(tx + 0.1, ty + 0.166); + Vertex3f(x + 1, y - 1, z); + TexCoord2f(tx, ty + 0.166); + Vertex3f(x, y - 1, z); +} + +static void draw_illuminatedchar(int num, float x, float y, float z) +{ + float tx, ty; + int num2, num3; + + num2 = num / 10; + num3 = num - (num2 * 10); + ty = (float)num2 / 7; + tx = (float)num3 / 10; + Normal3f(0.0f, 0.0f, 1.0f); // Needed for lighting + Color4f(1.0, 1.0, 1.0, .5); // Basic polygon color + + TexCoord2f(tx, ty); + Vertex3f(x, y, z); + TexCoord2f(tx + 0.1, ty); + Vertex3f(x + 1, y, z); + TexCoord2f(tx + 0.1, ty + 0.166); + Vertex3f(x + 1, y - 1, z); + TexCoord2f(tx, ty + 0.166); + Vertex3f(x, y - 1, z); +} + +static void draw_flare(float x, float y, float z) //flare +{ + Normal3f(0.0f, 0.0f, 1.0f); // Needed for lighting + Color4f(1.0, 1.0, 1.0, .8); // Basic polygon color + + TexCoord2f(0, 0); + Vertex3f(x - 1, y + 1, z); + TexCoord2f(0.75, 0); + Vertex3f(x + 2, y + 1, z); + TexCoord2f(0.75, 0.75); + Vertex3f(x + 2, y - 2, z); + TexCoord2f(0, 0.75); + Vertex3f(x - 1, y - 2, z); +} + +static void draw_text(uint8_t *pic) +{ + int x, y; + int p = 0; + int c, c_pic; + int pic_fade = 255; + + for (y = _text_y; y > -_text_y; y--) { + for (x = -_text_x; x < _text_x; x++) { + c = text_light[p] - (text[p] >> 1); + c += pic_fade; + if (c > 255) + c = 255; + + if (pic) { + // Original code + //c_pic = pic[p] * matrix_contrast - (255 - pic_fade); + + c_pic = (255 - pic[p]) * matrix_contrast - (255 - pic_fade); + + if (c_pic < 0) + c_pic = 0; + + c -= c_pic; + + if (c < 0) + c = 0; + + bump_pic[p] = (255.0f - c_pic) / (256 / Z_Depth); + } else { + bump_pic[p] = Z_Depth; + } + + if (text[p] && c > 10) + draw_char(text[p] + 1, c, x, y, text_depth[p] + bump_pic[p]); + + if (text_depth[p] < 0.1) + text_depth[p] = 0; + else + text_depth[p] /= 1.1; + + if (text_light[p] > 128 && text_light[p + text_x] < 10) + draw_illuminatedchar(text[p] + 1, x, y, text_depth[p] + bump_pic[p]); + + p++; + } + } +} + +static void draw_flares(void) +{ + float x, y; + int p = 0; + + for (y = _text_y; y > -_text_y; y--) { + for (x = -_text_x; x < _text_x; x++) { + if (text_light[p] > 128 && text_light[p + text_x] < 10) + draw_flare(x, y, text_depth[p] + bump_pic[p]); + p++; + } + } +} + +static void scroll(double dCurrentTime) +{ + int a, s, polovina; + //static double dLastCycle = -1; + static double dLastMove = -1; + + if (dCurrentTime - dLastMove > 1.0 / (text_y / 1.5)) { + dLastMove = dCurrentTime; + + polovina = text_x * text_y / 2; + s = 0; + for (a = text_x * text_y + text_x - 1; a >= text_x; a--) { + if (speed[s]) + text_light[a] = text_light[a - text_x]; //scroll light table down + s++; + if (s >= text_x) + s = 0; + } + memmove(text_light + text_x, text_light, text_x * text_y); + memset(text_light, 253, text_x); + + s = 0; + for (a = polovina; a < text_x * text_y; a++) { + if (text_light[a] == 255) + text_light[s] = text_light[s + text_x] >> 1; //make black bugs in top line + + s++; + + if (s >= text_x) + s = 0; + } + } +} + +static void make_change(double dCurrentTime) +{ + int r = rand() % text_x * text_y; + + text[r] += 133; //random bugs + + r = rand() % (4 * text_x); + if (r < text_x && text_light[r]) + text_light[r] = 255; //white bugs + + scroll (dCurrentTime); +} + + +static void make_text(void) +{ + int a; + + for (a = 0; a < text_x * text_y; a++) + text[a] = rand() >> 8; // avoid the lowest bits of rand() + + for (a = 0; a < text_x; a++) + speed[a] = rand() >= RAND_MAX / 2; +} + +static void ourBuildTextures(void) +{ + TexImage2D(GL_TEXTURE_2D, 0, 1, 128, 64, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, font_texture); + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + BindTexture(GL_TEXTURE_2D, 1); + TexImage2D(GL_TEXTURE_2D, 0, 1, 4, 4, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, flare); + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + // Some pretty standard settings for wrapping and filtering. + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + BindTexture(GL_TEXTURE_2D, 0); +} + +void matrixview_init(int w, int h) +{ + make_text(); + + ourBuildTextures(); + + // Color to clear color buffer to. + ClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + // Depth to clear depth buffer to; type of test. + ClearDepth(1.0); + DepthFunc(GL_LESS); + + // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. + ShadeModel(GL_SMOOTH); + + // Set up a light, turn it on. + Lightfv(GL_LIGHT1, GL_POSITION, Light_Position); + Lightfv(GL_LIGHT1, GL_AMBIENT, Light_Ambient); + Lightfv(GL_LIGHT1, GL_DIFFUSE, Light_Diffuse); + Enable(GL_LIGHT1); + + // A handy trick -- have surface material mirror the color. + ColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + Enable(GL_COLOR_MATERIAL); + + // Allow adjusting of texture color via glColor + TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + matrixview_reshape(w, h); +} + + +void matrixview_reshape(int w, int h) +{ + Viewport(0, 0, w, h); + + MatrixMode(GL_PROJECTION); + LoadIdentity(); + Frustum(-_text_x, _text_x, -_text_y, _text_y, -Z_Off - Z_Depth, -Z_Off); + + MatrixMode(GL_MODELVIEW); +} + + +void matrixview_draw(int w, int h, double currentTime, float frameTime, uint8_t *data) +{ + Enable(GL_BLEND); + Enable(GL_TEXTURE_2D); + + Disable(GL_LIGHTING); + BlendFunc(GL_SRC_ALPHA, GL_ONE); + Disable(GL_DEPTH_TEST); + + MatrixMode(GL_MODELVIEW); + LoadIdentity(); + Translated(0.0f, 0.0f, Z_Off); + + // Clear the color and depth buffers. + Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + // OK, let's start drawing our planer quads. + Begin(GL_QUADS); + draw_text(data); + End(); + + BindTexture(GL_TEXTURE_2D, 1); + Begin(GL_QUADS); + draw_flares(); + End(); + BindTexture(GL_TEXTURE_2D, 0); + + make_change(currentTime); + + LoadIdentity(); + MatrixMode(GL_PROJECTION); +} + +void matrixview_contrast_set(float contrast) +{ + matrix_contrast = contrast; +} + +void matrixview_brightness_set(float brightness) +{ + matrix_brightness = brightness; +} + + +void matrixview_matrix_resize(int w, int h) +{ + int elems; + free(speed); + speed = NULL; + free(text); + text = NULL; + free(text_light); + text_light = NULL; + free(text_depth); + text_depth = NULL; + if (w > MAX_TEXT_X || h > MAX_TEXT_Y) + return; + elems = w * (h + 1); + speed = calloc(w, sizeof(*speed)); + text = calloc(elems, sizeof(*text)); + text_light = calloc(elems, sizeof(*text_light)); + text_depth = calloc(elems, sizeof(*text_depth)); + bump_pic = calloc(elems, sizeof(*bump_pic)); + text_x = w; + text_y = h; + make_text(); +} diff --git a/libvo/matrixview.h b/libvo/matrixview.h new file mode 100644 index 0000000000..db76729906 --- /dev/null +++ b/libvo/matrixview.h @@ -0,0 +1,12 @@ +#ifndef MPLAYER_MATRIXVIEW_H +#define MPLAYER_MATRIXVIEW_H + +#include <stdint.h> +void matrixview_init (int w, int h); +void matrixview_reshape (int w, int h); +void matrixview_draw (int w, int h, double currentTime, float frameTime, uint8_t *data); +void matrixview_matrix_resize(int w, int h); +void matrixview_contrast_set(float contrast); +void matrixview_brightness_set(float brightness); + +#endif /* MPLAYER_MATRIXVIEW_H */ diff --git a/libvo/matrixview_font.h b/libvo/matrixview_font.h new file mode 100644 index 0000000000..753e9344a2 --- /dev/null +++ b/libvo/matrixview_font.h @@ -0,0 +1,588 @@ +#ifndef MPLAYER_MATRIXVIEW_FONT_H +#define MPLAYER_MATRIXVIEW_FONT_H + +#include <stdint.h> + +#define FONT_TEXTURE_W 128 +#define FONT_TEXTURE_H 64 +static const uint8_t font_texture[FONT_TEXTURE_H][FONT_TEXTURE_W] = { + { + 2, 2, 2, 2, 5, 20, 52, 77, 13, 2, 2, 2, 2, 2, 2, 3, + 13, 42, 67, 71, 66, 34, 7, 2, 2, 2, 2, 4, 36, 69, 71, 71, + 71, 71, 70, 35, 4, 3, 2, 2, 2, 2, 2, 3, 2, 29, 70, 71, + 39, 3, 2, 3, 3, 44, 71, 71, 71, 72, 71, 71, 71, 65, 13, 2, + 3, 2, 3, 5, 30, 64, 72, 71, 45, 13, 3, 2, 2, 2, 29, 71, + 71, 71, 71, 71, 71, 71, 71, 47, 2, 2, 2, 2, 2, 5, 26, 58, + 63, 36, 7, 2, 2, 2, 2, 2, 2, 12, 58, 71, 71, 71, 71, 61, + 15, 2, 2, 2, 2, 3, 2, 3, 2, 2, 2, 2, 3, 2, 3, 5 + |