Update of /cvsroot/freevo/freevo/contrib/rpm
In directory sc8-pr-cvs1:/tmp/cvs-serv29591

Added Files:
        SDL-1.2.6-dxr3-ffmpeg.patch SDL-1.2.6-gcc3.patch 
Log Message:
Added dxr3 patches for SDL 1.2.6


--- NEW FILE: SDL-1.2.6-dxr3-ffmpeg.patch ---
--- /usr/local/SDL-1.2.5/configure.in   2002-10-06 13:34:53.000000000 -0700
+++ SDL-1.2.5/configure.in      2002-12-29 06:58:58.000000000 -0800
@@ -1000,6 +1002,25 @@
     fi
 }
 
+dnl Set up the Dxr3 video driver.
+CheckDxr3Video()
+{
+    AC_ARG_ENABLE(video-dxr3,
+[  --enable-video-dxr3    use dxr3 video driver [default=yes]],
+                  , enable_video_dxr3=yes)
+    if test x$enable_video_dxr3 = xyes; then
+      CFLAGS="$CFLAGS -DENABLE_DXR3VIDEO"
+      VIDEO_SUBDIRS="$VIDEO_SUBDIRS dxr3"
+      VIDEO_DRIVERS="$VIDEO_DRIVERS dxr3/libvideo_dxr3.la"
+
+      DXR3_CFLAGS="-I/usr/include/ffmpeg"
+      DXR3_LIBS="-lavcodec"
+
+      AC_SUBST(DXR3_CFLAGS)
+      AC_SUBST(DXR3_LIBS)
+    fi
+}
+
 dnl Check to see if OpenGL support is desired
 AC_ARG_ENABLE(video-opengl,
 [  --enable-video-opengl   include OpenGL context creation [default=yes]],
@@ -1680,6 +1701,7 @@
 case "$target" in
     *-*-linux*)
         ARCH=linux
+        CheckDxr3Video
         CheckDummyVideo
         CheckDiskAudio
         CheckDLOPEN
@@ -2700,6 +2707,7 @@
 src/video/dga/Makefile
 src/video/directfb/Makefile
 src/video/dummy/Makefile
+src/video/dxr3/Makefile
 src/video/epoc/Makefile
 src/video/fbcon/Makefile
 src/video/gem/Makefile

--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/Makefile.am        2002-12-29 06:58:58.000000000 -0800
@@ -0,0 +1,18 @@
+
+## Makefile.am for SDL using the dxr3 video driver
+
+CFLAGS = @CFLAGS@ $(DXR3_CFLAGS)
+
+noinst_LTLIBRARIES = libvideo_dxr3.la
+libvideo_dxr3_la_SOURCES = $(DXR3_SRCS)
+libvideo_dxr3_la_LIBADD  = $(DXR3_LIBS)
+
+# The SDL null video driver sources
+DXR3_SRCS =                    \
+       SDL_dxr3video.h         \
+       SDL_dxr3events.c        \
+       SDL_dxr3events_c.h      \
+       SDL_dxr3mouse.c         \
+       SDL_dxr3mouse_c.h       \
+       SDL_dxr3video.c
+
--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/SDL_dxr3events.c   2002-12-29 09:10:13.000000000 -0800
@@ -0,0 +1,234 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    [EMAIL PROTECTED]
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL-1.2.6-dxr3-ffmpeg.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $";
+#endif
+
+/* Being a dxr3 driver, there's no event stream. We just define stubs for
+   most of the API. */
+
+#include "SDL.h"
+#include "SDL_sysevents.h"
+#include "SDL_keysym.h"
+#include "SDL_events_c.h"
+#include "SDL_dxr3video.h"
+#include "SDL_dxr3events_c.h"
+
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+int DXR3_OpenKeyboard(SDL_VideoDevice *vdev)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+       struct termios tio_new;
+
+//     fprintf(stderr,"DXR3_OpenKeyboard() called.\n");
+
+       ioctl(0,TCGETS,&data->tio_orig);
+
+       memcpy(&tio_new,&data->tio_orig,sizeof(struct termios));
+       tio_new.c_lflag &= ~(ICANON|ECHO); /* Clear ICANON and ECHO. */
+       tio_new.c_cc[VMIN] = 1;
+       tio_new.c_cc[VTIME] = 0;
+
+       ioctl(0,TCSETS,&tio_new);
+
+       return 0;
+}      
+
+void DXR3_CloseKeyboard(SDL_VideoDevice *vdev)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+
+//     fprintf(stderr,"DXR3_CloseKeyboard() called.\n");
+
+       ioctl(0,TCSETS,&data->tio_orig);
+
+       if ( data->fd_keyboard >= 0 ) {
+               /* not necessary... */
+               /* close(data->fd_keyboard); */
+       }
+       data->fd_keyboard = -1;
+}
+
+#ifdef axa
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+//     fprintf(stderr,"TranslateKey() called.\n");
+       /* Set the keysym information */
+       keysym->scancode = scancode;
+       keysym->sym = scancode; // keymap[scancode];
+       keysym->mod = KMOD_NONE;
+
+       /* If UNICODE is on, get the UNICODE value for the key */
+       keysym->unicode = 0;
+       if ( SDL_TranslateUNICODE ) {
+               int map;
+               SDLMod modstate;
+
+               modstate = SDL_GetModState();
+               map = 0;
+               if ( modstate & KMOD_SHIFT ) {
+                       map |= (1<<KG_SHIFT);
+               }
+               if ( modstate & KMOD_CTRL ) {
+                       map |= (1<<KG_CTRL);
+               }
+               if ( modstate & KMOD_ALT ) {
+                       map |= (1<<KG_ALT);
+               }
+               if ( modstate & KMOD_MODE ) {
+                       map |= (1<<KG_ALTGR);
+               }
+               if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) {
+                       if ( modstate & KMOD_CAPS ) {
+                               map ^= (1<<KG_SHIFT);
+                       }
+               }
+               if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) {
+                       if ( modstate & KMOD_NUM ) {
+                               keysym->unicode=KVAL(vga_keymap[map][scancode]);
+                       }
+               } else {
+                       keysym->unicode = KVAL(vga_keymap[map][scancode]);
+               }
+       }
+       return(keysym);
+}
+#endif
+
+static void handle_keyboard(SDL_VideoDevice *vdev)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+
+       unsigned char keybuf[BUFSIZ];
+       int i, nread;
+       SDL_keysym keysym;
+
+       struct timespec ts;
+       ts.tv_sec = 0;
+       ts.tv_nsec = 50*1000;
+
+//     fprintf(stderr,"handle_keyboard() in.\n");
+
+       nread = read(data->fd_keyboard, keybuf, BUFSIZ);
+       i = 0;
+       while( i < nread) {
+
+
+               memset(&keysym, 0, sizeof(keysym));
+               keysym.mod = KMOD_NONE;
+               keysym.unicode = 0;
+
+               if( (nread-i) >= 3 ) {
+                       if(keybuf[i] == 27 && keybuf[i+1] == 91) {
+                               switch( keybuf[i+2] ) {
+                               case 68: {
+                                       keysym.sym = SDLK_LEFT;
+                                       break;
+                               }
+                               case 67: {
+                                       keysym.sym = SDLK_RIGHT;
+                                       break;
+                               }
+                               case 65: {
+                                       keysym.sym = SDLK_UP;
+                                       break;
+                               }
+                               case 66: {
+                                       keysym.sym = SDLK_DOWN;
+                                       break;
+                               }
+                               default: {
+                                       printf("unknow key: %d\n",keybuf[i+2]);
+                                       break;
+                               }
+                               }
+                       data->posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
+                       data->posted += SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
+                       i += 3;
+                       continue;
+                       }       
+               }
+               switch( keybuf[i] ) {
+                       case 10:
+                               keysym.sym = SDLK_RETURN;
+                               break;
+                       default: 
+                               keysym.sym = keybuf[i]; 
+                               break;
+                       
+               }
+//             printf("key pressed: %d\n",keysym.sym);
+               
+               i += 1;
+               data->posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
+               data->posted += SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
+//             nanosleep(&ts,NULL);
+       }
+
+//     fprintf(stderr,"handle_keyboard() out.\n");
+}
+
+void DXR3_PumpEvents(SDL_VideoDevice *vdev)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+
+       fd_set fdset;
+       int max_fd;
+       static struct timeval zero;
+
+//     fprintf(stderr,"DXR3_PumpEvents() in.\n");
+
+       do {
+               data->posted = 0;
+
+               FD_ZERO(&fdset);
+               max_fd = 0;
+               if ( data->fd_keyboard >= 0 ) {
+                       FD_SET(data->fd_keyboard, &fdset);
+                       if ( max_fd < data->fd_keyboard ) {
+                               max_fd = data->fd_keyboard;
+                       }
+               }
+               if ( select(max_fd+1, &fdset, NULL, NULL, &zero) > 0 ) {
+                       if ( data->fd_keyboard >= 0 ) {
+                               if ( FD_ISSET(data->fd_keyboard, &fdset) ) {
+                                       handle_keyboard(vdev);
+                               }
+                       }
+               }
+       } while ( data->posted );
+//     fprintf(stderr,"DXR3_PumpEvents() out.\n");
+}
+
+void DXR3_InitOSKeymap(SDL_VideoDevice *vdev)
+{
+       /* do nothing. */
+}
+
+/* end of SDL_dxr3events.c ... */
+
--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/SDL_dxr3events_c.h 2002-12-29 09:10:59.000000000 -0800
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    [EMAIL PROTECTED]
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL-1.2.6-dxr3-ffmpeg.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $";
+#endif
+
+#include "SDL_dxr3video.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+extern void DXR3_InitOSKeymap(SDL_VideoDevice *vdev);
+extern void DXR3_PumpEvents(SDL_VideoDevice *vdev);
+extern int  DXR3_OpenKeyboard(SDL_VideoDevice *vdev);
+extern void DXR3_CloseKeyboard(SDL_VideoDevice *vdev);
+
+/* end of SDL_dxr3events_c.h ... */
+
--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/SDL_dxr3mouse.c    2002-12-29 06:58:58.000000000 -0800
@@ -0,0 +1,40 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    [EMAIL PROTECTED]
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL-1.2.6-dxr3-ffmpeg.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+
+#include "SDL_dxr3mouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+       int unused;
+};
--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/SDL_dxr3mouse_c.h  2002-12-29 06:58:58.000000000 -0800
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    [EMAIL PROTECTED]
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL-1.2.6-dxr3-ffmpeg.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $";
+#endif
+
+#include "SDL_dxr3video.h"
+
+/* Functions to be exported */
--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/SDL_dxr3video.c    2002-12-29 10:32:16.000000000 -0800
@@ -0,0 +1,433 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    [EMAIL PROTECTED]
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL-1.2.6-dxr3-ffmpeg.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <linux/em8300.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+
+#include "SDL_dxr3video.h"
+#include "SDL_dxr3events_c.h"
+#include "SDL_dxr3mouse_c.h"
+
+#define DXR3VID_DRIVER_NAME "dxr3"
+
+/* Initialization/Query functions */
+static int DXR3_VideoInit(SDL_VideoDevice *vdev, SDL_PixelFormat *vformat);
+static SDL_Rect **DXR3_ListModes(SDL_VideoDevice *vdev, SDL_PixelFormat *format, 
Uint32 flags);
+static SDL_Surface *DXR3_SetVideoMode(SDL_VideoDevice *vdev, SDL_Surface *current, 
int width, int height, int bpp, Uint32 flags);
+static int DXR3_SetColors(SDL_VideoDevice *vdev, int firstcolor, int ncolors, 
SDL_Color *colors);
+static void DXR3_VideoQuit(SDL_VideoDevice *vdev);
+
+/* Hardware surface functions */
+static int DXR3_AllocHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface);
+static int DXR3_LockHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface);
+static void DXR3_UnlockHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface);
+static void DXR3_FreeHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface);
+
+/* etc. */
+static void DXR3_UpdateRects(SDL_VideoDevice *vdev, int numrects, SDL_Rect *rects);
+
+
+const char *devname_v = "/dev/em8300_mv-0";
+const char *devname_c = "/dev/em8300-0";
+
+#define OUTBUF_SIZE 300000
+
+#define MAX_WIDTH 720
+#define MAX_HEIGHT 576
+
+/* DXR3 driver bootstrap functions */
+
+static int DXR3_Available(void)
+{
+       const char *envr = getenv("SDL_VIDEODRIVER");
+
+       if (envr && !strcmp(envr, DXR3VID_DRIVER_NAME))
+               return 1;
+
+       return 0;
+}
+
+static void DXR3_DeleteDevice(SDL_VideoDevice *device)
+{
+       free(device->hidden);
+       device->hidden = NULL;
+       free(device);
+}
+
+static SDL_VideoDevice *DXR3_CreateDevice(int devindex)
+{
+       SDL_VideoDevice *device;
+
+       /* Initialize all variables that we clean on shutdown */
+       device = malloc(sizeof(SDL_VideoDevice));
+       if (!device)
+               return NULL;
+       memset(device, 0, sizeof(*device));
+
+       device->hidden = malloc((sizeof(*device->hidden)));
+       if (!device->hidden) {
+               free(device);
+               return NULL;
+       }
+       memset(device->hidden, 0, sizeof(*device->hidden));
+
+       /* Set the function pointers */
+       device->VideoInit = DXR3_VideoInit;
+       device->ListModes = DXR3_ListModes;
+       device->SetVideoMode = DXR3_SetVideoMode;
+       device->CreateYUVOverlay = NULL;
+       device->SetColors = DXR3_SetColors;
+       device->UpdateRects = DXR3_UpdateRects;
+       device->VideoQuit = DXR3_VideoQuit;
+       device->AllocHWSurface = DXR3_AllocHWSurface;
+       device->CheckHWBlit = NULL;
+       device->FillHWRect = NULL;
+       device->SetHWColorKey = NULL;
+       device->SetHWAlpha = NULL;
+       device->LockHWSurface = DXR3_LockHWSurface;
+       device->UnlockHWSurface = DXR3_UnlockHWSurface;
+       device->FlipHWSurface = NULL;
+       device->FreeHWSurface = DXR3_FreeHWSurface;
+       device->SetCaption = NULL;
+       device->SetIcon = NULL;
+       device->IconifyWindow = NULL;
+       device->GrabInput = NULL;
+       device->GetWMInfo = NULL;
+       device->InitOSKeymap = DXR3_InitOSKeymap;
+       device->PumpEvents = DXR3_PumpEvents;
+
+       device->free = DXR3_DeleteDevice;
+
+       return device;
+}
+
+VideoBootStrap DXR3_bootstrap = {
+       DXR3VID_DRIVER_NAME,
+       "SDL dxr3 video driver",
+       DXR3_Available,
+       DXR3_CreateDevice
+};
+
+
+int DXR3_VideoInit(SDL_VideoDevice *vdev, SDL_PixelFormat *vformat)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+
+       fprintf(stderr, "WARNING: You are using the SDL dxr3 video driver!\n");
+
+       /* Determine the screen depth (use default 8-bit depth) */
+       /* we change this during the SDL_SetVideoMode implementation... */
+       vformat->BitsPerPixel = 8;
+       vformat->BytesPerPixel = 1;
+
+       /* fixme: 0 means stdin */
+       data->fd_keyboard = 0;
+
+       if (DXR3_OpenKeyboard(vdev) < 0) {
+               DXR3_VideoQuit(vdev);
+               return -1;
+       }
+
+       /* We're done! */
+       return 0;
+}
+
+SDL_Rect **DXR3_ListModes(SDL_VideoDevice *vdev, SDL_PixelFormat *format,
+                         Uint32 flags)
+{
+        return (SDL_Rect **) -1;
+}
+
+SDL_Surface *DXR3_SetVideoMode(SDL_VideoDevice *vdev, SDL_Surface *current,
+                              int width, int height, int bpp, Uint32 flags)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+       em8300_register_t reg;
+       int ioval = 0;
+       int tmp1, tmp2;
+
+       if (vdev->hidden->buffer)
+               free(vdev->hidden->buffer);
+
+       vdev->hidden->buffer = malloc(width * height * (bpp / 8));
+       if (!vdev->hidden->buffer) {
+               SDL_SetError("Couldn't allocate buffer for requested mode");
+               return NULL;
+       }
+
+       memset(vdev->hidden->buffer, 0, width * height * (bpp / 8));
+
+       /* Allocate the new pixel format for the screen */
+       if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) {
+               SDL_SetError("Couldn't allocate new pixel format for requested mode");
+               goto err_buffer;
+       }
+
+       /* Set up the new mode framebuffer */
+       current->flags = flags & SDL_FULLSCREEN;
+       current->w = width;
+       current->h = height;
+
+       /* quick hack */
+       if (width > MAX_WIDTH) {
+               fprintf(stderr, "WARNING: width (%d) out of bounds. cropping to %d 
pixels!\n", width, MAX_WIDTH);
+               width = MAX_WIDTH;
+       }
+       if (height > MAX_HEIGHT ) {
+               fprintf(stderr, "WARNING: height (%d) out of bounds. cropping to %d 
pixels!\n", height, MAX_HEIGHT);
+               height = MAX_HEIGHT;
+       }
+
+       vdev->hidden->w = width;
+       vdev->hidden->h = height;
+       current->pitch = width * (bpp / 8);
+       current->pixels = vdev->hidden->buffer;
+
+       /* Open and set up the dxr3 */
+       data->fd_video = open(devname_v, O_WRONLY | O_NONBLOCK);
+       if (data->fd_video < 0) {
+               SDL_SetError("Couldn't open video part of dxr3.");
+               goto err_buffer;
+       }
+
+       data->fd_control = open(devname_c, O_WRONLY | O_NONBLOCK);
+       if (data->fd_control < 0) {
+               SDL_SetError("Couldn't open control part of dxr3.");
+               goto err_control;
+       }
+
+       /* Set the playmode to play (just in case another app has set it to something 
else) */
+       ioval = EM8300_PLAYMODE_PLAY;
+       if (ioctl(data->fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
+               SDL_SetError("Couldn't set playmode of dxr3.");
+               goto err_set_play;
+       }
+
+       /* Start em8300 prebuffering and sync engine */
+       reg.microcode_register = 1;
+       reg.reg = 0;
+       reg.val = MVCOMMAND_SYNC;
+       if (ioctl(data->fd_control, EM8300_IOCTL_WRITEREG, &reg)) {
+               SDL_SetError("Couldn't EM8300_IOCTL_WRITEREG (dxr3).");
+               goto err_set_play;
+       }
+       
+       /* Clean buffer by syncing it */
+       ioval = EM8300_SUBDEVICE_VIDEO;
+       ioctl(data->fd_control, EM8300_IOCTL_FLUSH, &ioval);
+       ioval = EM8300_SUBDEVICE_AUDIO;
+       ioctl(data->fd_control, EM8300_IOCTL_FLUSH, &ioval);
+
+       fsync(data->fd_video);
+
+       tmp1 = abs(height - ((width / 4) * 3));
+       tmp2 = abs(height - (int)(width / 2.35));
+       if (tmp1 < tmp2)
+               ioval = EM8300_ASPECTRATIO_4_3;
+       else
+               ioval = EM8300_ASPECTRATIO_16_9;
+       ioctl(data->fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval);
+
+       data->outbuf = malloc(OUTBUF_SIZE);
+       if (!data->outbuf) {
+               SDL_SetError("malloc() failed (dxr3).");
+               goto err_set_play;
+       }
+
+       data->picture_yuv = malloc((width * height * 3) / 2);
+       if (!data->picture_yuv) {
+               SDL_SetError("malloc() failed (dxr3).");
+               goto err_outbuf;
+       }
+
+       avcodec_init();
+       avcodec_register_all();
+
+       /* fix me: error handling */
+       data->codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
+       if (!data->codec)
+               goto err_outbuf;
+
+       data->c = avcodec_alloc_context();
+       if (!data->c)
+               goto err_outbuf;
+
+       data->picture = avcodec_alloc_frame();
+       if (!data->picture)
+               goto err_alloc_frame;
+
+       data->c->bit_rate = 1000000;
+       data->c->width = width;
+       data->c->height = height;
+       
+       data->c->frame_rate = 25 * FRAME_RATE_BASE;
+       data->c->gop_size = 1;
+       data->c->flags = CODEC_FLAG_QSCALE;
+       
+       if (avcodec_open(data->c, data->codec) < 0)
+               goto err_avc_open;
+       
+       data->picture->data[0] = data->picture_yuv;
+       data->picture->data[1] = data->picture->data[0] + width * height;
+       data->picture->data[2] = data->picture->data[1] + (width * height / 4);
+
+       data->picture->linesize[0] = width;
+       data->picture->linesize[1] = width / 2;
+       data->picture->linesize[2] = width / 2;
+
+       data->picture->quality = 2;
+
+       /* We're done */  
+       return current;
+
+err_avc_open:
+       free(data->picture);
+       data->picture = NULL;
+err_alloc_frame:
+       free(data->c);
+       data->c = NULL;
+err_outbuf:
+       free(data->outbuf);
+       data->outbuf = NULL;
+err_set_play:
+       close(data->fd_control);
+       data->fd_control = -1;
+err_control:
+       close(data->fd_video);
+       data->fd_video = -1;
+err_buffer:
+       free(vdev->hidden->buffer);
+       vdev->hidden->buffer = NULL;
+       return NULL;
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int DXR3_AllocHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface)
+{
+       return -1;
+}
+
+static void DXR3_FreeHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface)
+{
+}
+
+/* We need to wait for vertical retrace on page flipped displays */
+static int DXR3_LockHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface)
+{
+       return 0;
+}
+
+static void DXR3_UnlockHWSurface(SDL_VideoDevice *vdev, SDL_Surface *surface)
+{
+}
+
+static void DXR3_UpdateRects(SDL_VideoDevice *vdev, int numrects,
+                            SDL_Rect *rects)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+       AVPicture dst, src;
+       int size;
+
+       if (data->picture_yuv) {
+               dst.data[0] = data->picture->data[0];
+               dst.data[1] = data->picture->data[1];
+               dst.data[2] = data->picture->data[2];
+               src.data[0] = data->buffer;
+               img_convert(&dst, PIX_FMT_YUV420P, &src, PIX_FMT_BGRA32, 
data->c->width, data->c->height);
+
+               size = avcodec_encode_video(data->c, data->outbuf, OUTBUF_SIZE, 
data->picture);
+               if (data->outbuf[size - 1] != 0xb7) {
+                       /* add sequence end code */
+                       data->outbuf[size] = 0x00;
+                       data->outbuf[size + 1] = 0x00;
+                       data->outbuf[size + 2] = 0x01;
+                       data->outbuf[size + 3] = 0xb7;
+                       size += 4;
+               }
+
+               write(data->fd_video, data->outbuf, size);
+       }
+}
+
+int DXR3_SetColors(SDL_VideoDevice *vdev, int firstcolor, int ncolors,
+                  SDL_Color *colors)
+{
+       /* do nothing of note. */
+       return 1;
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+void DXR3_VideoQuit(SDL_VideoDevice *vdev)
+{
+       struct SDL_PrivateVideoData *data = vdev->hidden;
+
+       if (vdev->screen->pixels) {
+               free(vdev->screen->pixels);
+               vdev->screen->pixels = NULL;
+       }
+
+       /* DXR3 cleanup */
+       if (data->fd_video != -1) {
+               close(data->fd_video);
+               data->fd_video = -1;
+       }
+       if (data->fd_control != -1) {
+               close(data->fd_control);
+               data->fd_control = -1;
+       }
+       
+       /* avcodec clean up */
+       if (data->picture_yuv) {
+               free(data->picture_yuv);
+               data->picture_yuv = 0;
+       }
+       if (data->outbuf) {
+               free(data->outbuf);
+               data->outbuf = 0;
+       }
+       
+       DXR3_CloseKeyboard(vdev);
+}
--- /dev/null   2002-11-18 10:54:08.000000000 -0800
+++ SDL-1.2.5/src/video/dxr3/SDL_dxr3video.h    2002-12-29 09:09:01.000000000 -0800
@@ -0,0 +1,61 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    [EMAIL PROTECTED]
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL-1.2.6-dxr3-ffmpeg.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $";
+#endif
+
+#ifndef _SDL_dxr3video_h
+#define _SDL_dxr3video_h
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+
+#include <avcodec.h>
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_mutex.h"
+
+/* Private display data */
+
+struct SDL_PrivateVideoData {
+    int w, h;
+    UINT8 *buffer;
+
+    AVCodec *codec;
+    AVCodecContext *c;
+    AVFrame *picture;
+    UINT8 *picture_yuv;
+    UINT8 *outbuf;
+
+    int fd_video;
+    int fd_control;
+    struct termios tio_orig;
+    int fd_keyboard;
+    int posted;
+};
+
+#endif /* _SDL_dxr3video_h */
--- /usr/local/SDL-1.2.5/src/video/Makefile.am  2002-10-06 11:47:20.000000000 -0700
+++ SDL-1.2.5/src/video/Makefile.am     2002-12-29 06:58:58.000000000 -0800
@@ -5,7 +5,7 @@
 
 # Define which subdirectories need to be built
 SUBDIRS = @VIDEO_SUBDIRS@
-DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
+DIST_SUBDIRS = dxr3 dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
                wincommon windib windx5 \
                maccommon macdsp macrom quartz \
                bwindow ps2gs photon cybergfx epoc picogui \
--- /usr/local/SDL-1.2.5/src/video/SDL_sysvideo.h       2002-10-05 09:50:56.000000000 
-0700
+++ SDL-1.2.5/src/video/SDL_sysvideo.h  2002-12-29 06:58:58.000000000 -0800
@@ -394,6 +394,9 @@
 #ifdef ENABLE_DUMMYVIDEO
 extern VideoBootStrap DUMMY_bootstrap;
 #endif
+#ifdef ENABLE_DXR3VIDEO
+extern VideoBootStrap DXR3_bootstrap;
+#endif
 #ifdef ENABLE_XBIOS
 extern VideoBootStrap XBIOS_bootstrap;
 #endif
--- /usr/local/SDL-1.2.5/src/video/SDL_video.c  2002-10-05 09:50:56.000000000 -0700
+++ SDL-1.2.5/src/video/SDL_video.c     2002-12-29 06:58:58.000000000 -0800
@@ -105,6 +105,9 @@
 #ifdef ENABLE_DUMMYVIDEO
        &DUMMY_bootstrap,
 #endif
+#ifdef ENABLE_DXR3VIDEO
+       &DXR3_bootstrap,
+#endif
 #ifdef ENABLE_XBIOS
        &XBIOS_bootstrap,
 #endif

--- NEW FILE: SDL-1.2.6-gcc3.patch ---
##################################################################################
$Id: SDL-1.2.6-gcc3.patch,v 1.1 2004/01/06 07:53:09 tcwan Exp $
##################################################################################

                             SDL PATCH REPORT
                             ================

SDL-Release: 1.2.5
Patch-ID: SDL-giffordj-001

Patch by       :    [EMAIL PROTECTED]

Problem-Description: Fixes for GCC 3.3 Errors

This patch is a based of suggested patches posted found on the web. This
is not an offical patch for SDL. But it works for me.

Patch:

diff -uNr SDL-1.2.5.orig/src/video/SDL_stretch.c SDL-1.2.5/src/video/SDL_stretch.c
--- SDL-1.2.5.orig/src/video/SDL_stretch.c      2002-03-06 03:23:03.000000000 -0800
+++ SDL-1.2.5/src/video/SDL_stretch.c   2003-05-16 17:15:17.000000000 -0700
@@ -261,9 +261,8 @@
                        break;
                    default:
 #ifdef __GNUC__
-                       __asm__ __volatile__ ("
-                               call _copy_row
-                       "
+                       __asm__ __volatile__ (
+                       "call _copy_row"
                        : "=&D" (u1), "=&S" (u2)
                        : "0" (dstp), "1" (srcp)
                        : "memory" );




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to