From 51ed8fe6f2ea9892e905e81cf5bad3960537eb40 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Fri, 19 Feb 2010 17:18:42 +0000 Subject: Challenge MOD r7 alpha based on Ultrastar Deluxe v1.0.1a for changes read Changelog.txt in folder Game git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2107 b956fd51-792f-4845-bead-9b4dfca2ff2c --- .../JEDI-SDLv1.0/smpeg/Demos/GLMovie/glmovie.dpr | 434 +++++++++++++++++++ .../JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Campus.jpg | Bin 0 -> 4836 bytes .../smpeg/Demos/MpegPlayer/MPEGPlay.dpr | 26 ++ .../JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.dfm | Bin 0 -> 1314 bytes .../JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.pas | 91 ++++ .../JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.xfm | 106 +++++ .../JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/README.1ST | 21 + .../smpeg/Demos/MpegPlayer/sdlmpegpanel.pas | 149 +++++++ .../smpeg/Demos/MpegPlayer/video40.dpk | 33 ++ .../smpeg/Demos/MpegPlayer/video50.dpk | 33 ++ .../smpeg/Demos/MpegPlayer/video60.dpk | 35 ++ .../smpeg/Demos/SMpegPlayer/SMpegPlayer.cfg | 38 ++ .../smpeg/Demos/SMpegPlayer/SMpegPlayer.dof | 136 ++++++ .../smpeg/Demos/SMpegPlayer/SMpegPlayer.dpr | 278 ++++++++++++ Game/Code/lib/JEDI-SDLv1.0/smpeg/Pas/smpeg.pas | 465 +++++++++++++++++++++ 15 files changed, 1845 insertions(+) create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/GLMovie/glmovie.dpr create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Campus.jpg create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/MPEGPlay.dpr create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.dfm create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.pas create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.xfm create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/README.1ST create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/sdlmpegpanel.pas create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video40.dpk create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video50.dpk create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video60.dpk create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.cfg create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dof create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dpr create mode 100644 Game/Code/lib/JEDI-SDLv1.0/smpeg/Pas/smpeg.pas (limited to 'Game/Code/lib/JEDI-SDLv1.0/smpeg') diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/GLMovie/glmovie.dpr b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/GLMovie/glmovie.dpr new file mode 100644 index 00000000..375e0b79 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/GLMovie/glmovie.dpr @@ -0,0 +1,434 @@ +program glmovie; +{******************************************************************} +{ } +{ Object Pascal Example of using smpeg with OpenGL } +{ Conversion of the glmovie Demo } +{ } +{ Portions created by Sam Lantinga , are } +{ Copyright (C) 1998 Sam Lantinga. } +{ All Rights Reserved. } +{ } +{ The original files are : glmovie.c } +{ } +{ The original Pascal code is : glmovie.dpr } +{ The initial developer of the Pascal code is : } +{ Dominique Louis } +{ } +{ Portions created by Dominique Louis are } +{ Copyright (C) 2001 Dominique Louis. } +{ } +{ Contributor(s) } +{ -------------- } +{ Romi Kuntsman } +{ } +{ Obtained through: } +{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } +{ } +{ You may retrieve the latest version of this file at the Project } +{ JEDI home page, located at http://delphi-jedi.org } +{ } +{ The contents of this file are used with permission, subject to } +{ the Mozilla Public License Version 1.1 (the "License"); you may } +{ not use this file except in compliance with the License. You may } +{ obtain a copy of the License at } +{ http://www.mozilla.org/NPL/NPL-1_1Final.html } +{ } +{ Software distributed under the License is distributed on an } +{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } +{ implied. See the License for the specific language governing } +{ rights and limitations under the License. } +{ } +{ Description } +{ ----------- } +{ GLMovie : Shows how to load and play an Mpeg file using OpenGL } +{ } +{ } +{ Requires } +{ -------- } +{ SDL runtime libary for SDL, smpeg and OpenGL somewhere } +{ in your path . } +{ The Latest SDL runtimes can be found on http://www.libsdl.org } +{ } +{ Programming Notes } +{ ----------------- } +{ This demo shows how to load and play an mpeg file using smpeg } +{ with OpenGLv } +{ You will need Smpeg libraris and OpenGL in order for this demo } +{ } +{ Revision History } +{ ---------------- } +{ December 02 2001 - DL : Initial translation. } +{ June 21 2002 - RK : Fixed DL's silly mistakes } +{ } +{ } +{******************************************************************} + +uses + SysUtils, + gl, + glu, + smpeg, + sdl, + logger; + +type + { Some data is redundant at this stage. } + PGLMovieTexture = ^TGLMovieTexture; + TGLMovieTexture = record + id : GLuint; (* OpenGL texture id. *) + poly_width : GLuint; (* Quad width for tile. *) + poly_height : GLuint; (* Quad height for tile. *) + movie_width : GLuint; (* Width of movie inside tile. *) + movie_height : GLuint; (* Height of movie inside tile. *) + skip_rows : GLuint; (* Number of rows of movie to skip *) + skip_pixels : GLuint; (* Number of columns of movie to skip *) + row : GLuint; (* Row number of tile in scheme. *) + col : GLuint; (* Column number of tile in scheme. *) + end; + +type + TGLuintArray = array of GLuint; + PGLuintArray = ^TGLuintArray; + TGLMovieTextureArray = array of TGLMovieTexture; + PGLMovieTextureArray = ^TGLMovieTextureArray; + +var + (* Our evil maximum texture size. Boo 3Dfxnot *) + texture_size : GLuint = 256; (* Keep this around for easy freeing later. *) + texture_ids : TGLuintArray; (* Our main data. *) + textures : TGLMovieTextureArray; + num_texture_rows : GLuint = 0; + num_texture_cols : GLuint = 0; (* Width and height of all tiling. *) + tiled_width : GLuint = 0; + tiled_height : GLuint = 0; (* Width and height of entire movie. *) + movie_width : GLuint = 0; + movie_height : GLuint = 0; + + (* + * Draw the frame data. + * + * Parameters: + * frame: Actual RGBA frame data + *) + +procedure glmovie_draw( frame : PGLubyte ); +var + i : GLuint; + shift : GLdouble; +begin + glClear( GL_COLOR_BUFFER_BIT ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity; + shift := 1 / ( texture_size ); + for i := 0 to num_texture_rows * num_texture_cols - 1 do + begin + glBindTexture( GL_TEXTURE_2D, textures[ i ].id ); + glPixelStorei( GL_UNPACK_ROW_LENGTH, movie_width ); + glPixelStorei( GL_UNPACK_SKIP_ROWS, textures[ i ].skip_rows ); + glPixelStorei( GL_UNPACK_SKIP_PIXELS, textures[ i ].skip_pixels ); + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, (* offset_x *) 0, (* offset_y *) textures[ i ].movie_width + 2, textures[ i ].movie_height + 2, GL_RGBA, GL_UNSIGNED_BYTE, frame ); + glBegin( GL_QUADS ); + glTexCoord2f( shift, shift ); + glVertex2i( textures[ i ].col * texture_size, textures[ i ].row * texture_size ); + glTexCoord2f( shift, shift + ( textures[ i ].movie_height ) / ( texture_size ) ); + glVertex2i( textures[ i ].col * texture_size, ( textures[ i ].row + 1 ) * texture_size ); + glTexCoord2f( shift + ( textures[ i ].movie_width ) / ( texture_size ), shift + ( textures[ i ].movie_height ) / ( texture_size ) ); + glVertex2i( ( textures[ i ].col + 1 ) * texture_size, ( textures[ i ].row + 1 ) * texture_size ); + glTexCoord2f( shift + ( textures[ i ].movie_width ) / ( texture_size ), shift ); + glVertex2i( ( textures[ i ].col + 1 ) * texture_size, textures[ i ].row * texture_size ); + glEnd; + end; +end; + +{* + * Calculates the next power of 2 given a particular value. + * Useful for calculating proper texture sizes for non power-of-2 + * aligned texures. + * Parameters: + * seed: Value to begin from + * Returns: + * Next power of 2 beginning from 'seed' + *} + +function glmovie_next_power_of_2( seed : GLuint ) : GLuint; +var + i : GLuint; +begin + i := 1; + while ( i < seed ) do + begin + i := i * 2; + end; + + result := i; +end; + +(* + * Initialize the movie player subsystem with the width and height + * of the *movie data* (as opposed to the window). + * + * Parameters: + * width: Width of movie in pixels + * height: Height of movie in pixels + * result :=s: + * GL_NO_ERROR on success + * Any of the enumerated GL errors on failure + *) + +function glmovie_init( Width : GLuint; Height : GLuint ) : GLenum; +type + PGLubyteArray = ^TGLubyteArray; + TGLubyteArray = array of GLubyte; +var + (* Initial black texels. *) + pixels : TGLubyteArray; + (* Absolute offsets from within tiled frame. *) + //offset_x: GLuint; + //offset_y: GLuint; + skip_rows : GLuint; + skip_pixels : GLuint; + i, j, current : GLuint; +begin + skip_rows := 0; + current := 0; + (* Save original movie dimensions. *) + movie_width := width; + movie_height := height; + (* Get the power of 2 dimensions. *) + tiled_width := glmovie_next_power_of_2( width ); + tiled_height := glmovie_next_power_of_2( height ); + while ( ( texture_size > tiled_width ) or ( texture_size > tiled_height ) ) do + begin + texture_size := texture_size div 2; + end; + (* Now break it up into quads. *) + num_texture_rows := tiled_height div texture_size; + num_texture_cols := tiled_width div texture_size; + (* Time for fun with data type = record *) + glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + glEnable( GL_TEXTURE_2D ); + glEnable( GL_DITHER ); + + SetLength( texture_ids, num_texture_rows * num_texture_cols ); + if ( texture_ids = nil ) then + begin + result := GL_OUT_OF_MEMORY; + exit; + end; + + glGenTextures( num_texture_rows * num_texture_cols, @texture_ids[0] ); + SetLength( textures, num_texture_rows * num_texture_cols ); + + if ( textures = nil ) then + begin + glDeleteTextures( num_texture_rows * num_texture_cols, @texture_ids[0] ); + SetLength( texture_ids, 0 ); + result := GL_OUT_OF_MEMORY; + exit; + end; + + for i := 0 to num_texture_rows - 1 do + begin + skip_pixels := 0; + for j := 0 to num_texture_cols - 1 do + begin + current := i * num_texture_cols + j; + (* Setup texture. *) + textures[ current ].id := texture_ids[ current ]; + textures[ current ].poly_width := texture_size; + textures[ current ].poly_height := texture_size; + textures[ current ].movie_width := ( movie_width - 2 ) * ( j + 1 ) div num_texture_cols - skip_pixels; + textures[ current ].movie_height := ( movie_height - 2 ) * ( i + 1 ) div num_texture_rows - skip_rows; + textures[ current ].row := i; + textures[ current ].col := j; + textures[ current ].skip_pixels := skip_pixels; + textures[ current ].skip_rows := skip_rows; + skip_pixels := skip_pixels + textures[ current ].movie_width; + + SetLength( pixels, textures[ current ].poly_width * textures[ current ].poly_height * 4 ); + if ( pixels = nil ) then + begin + glDeleteTextures( num_texture_rows * num_texture_cols, @texture_ids[0] ); + SetLength( texture_ids, 0 ); + SetLength( textures, 0 ); + result := GL_OUT_OF_MEMORY; + exit; + end; + //FillChar( pixels^, textures[ current ].poly_width * textures[ current ].poly_height * 4, 0 ); + + (* Do all of our useful binding. *) + glBindTexture( GL_TEXTURE_2D, textures[ current ].id ); + glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + (* Specify our 256x256 black texture. *) + glTexImage2D( GL_TEXTURE_2D, + 0, + GL_RGB, + textures[ current ].poly_width, + textures[ current ].poly_height, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + @pixels[0] ); + SetLength( pixels, 0 ); + end; + skip_rows := skip_rows + textures[ current ].movie_height; + end; + (* Simple state setup at the end. *) + glClearColor( 0.0, 0.0, 0.0, 0.0 ); + result := glGetError( ); +end; + +//******************* glmpeg_update ************************* + +procedure glmpeg_update( surface : PSDL_Surface; x : Sint32; y : Sint32; w : Uint32; + h : Uint32 ); cdecl; +var + error : GLenum; +begin + glmovie_draw( PGLubyte( surface.pixels ) ); + error := glGetError( ); + if ( error <> GL_NO_ERROR ) then + begin + Log.LogError( Format( 'glmovie: GL error: %s', [ gluErrorString( error ) ] ), + 'glmpeg_update' ); + Exit; + end; + SDL_GL_SwapBuffers; +end; + +{* + * Here we need to center the OpenGL viewport within the + * window size that we are given. + * + * Parameters: + * width: Width of the window in pixels + * height: Height of the window in pixels + *} + +procedure glmovie_resize( width : GLuint; height : GLuint ); +begin + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity; + gluOrtho2D( 0, tiled_width, tiled_height, 0 ); +end; + +{* + * Free any resources associated with the movie player. + *} + +procedure glmovie_quit; +begin + glDeleteTextures( num_texture_rows * num_texture_cols, @texture_ids ); + SetLength( texture_ids, 0 ); + SetLength( textures, 0 ); +end; + +var + mpeg : PSMPEG; + mpeg_info : TSMPEG_Info; + screen : PSDL_Surface; + surface : PSDL_Surface; + event : TSDL_Event; +begin + if ( ParamCount < 1 ) then + begin + Log.LogError( Format( 'Usage: %s file.mpg', [ ParamStr( 0 ) ] ), 'Main' ); + Exit; + end; + + if ( SDL_Init( SDL_INIT_VIDEO or SDL_INIT_AUDIO ) < 0 ) then + begin + Log.LogError( 'glmovie: I couldn''t initizlize SDL(shrug)', 'Main' ); + Exit; + end; + + mpeg := SMPEG_new( PChar( ParamStr( 1 ) ), @mpeg_info, 1 ); + if ( mpeg = nil ) then + begin + Log.LogError( Format( 'glmovie: I''m not so sure about this %s file...', + [ ParamStr( 1 ) ] ), 'Main' ); + SDL_Quit; + Exit; + end; + (* Grab the mouse and input and set the video mode *) + SDL_ShowCursor( 0 ); + SDL_WM_GrabInput( SDL_GRAB_ON ); + + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + + // Set the title bar in environments that support it + SDL_WM_SetCaption('SDL GLMovie Demo using JEDI-SDL', nil + ); + + screen := SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL { or SDL_FULLSCREEN } ); + if ( Screen = nil ) then + begin + Log.LogError( Format( 'glmovie: Couldn''t set 640 x 480 GL video mode : %s', + [ SDL_GetError ] ), 'Main' ); + SDL_Quit; + Exit; + end; + + (* Everything needs to be in RGB for GL, but needs to be 32-bit for SMPEG. *) + surface := SDL_AllocSurface( SDL_SWSURFACE, + mpeg_info.width, + mpeg_info.height, + 32, + $000000FF, + $0000FF00, + $00FF0000, + $FF000000 ); + + if ( surface = nil ) then + begin + Log.LogError( 'glmovie: I couldn''t make a surface(boo hoo)', 'Main' ); + SDL_Quit; + Exit; + end; + + (* *Initialize* with mpeg size. *) + if ( glmovie_init( mpeg_info.width, mpeg_info.height ) <> GL_NO_ERROR ) then + begin + Log.LogError( 'glmovie: glmovie_init failed ', 'Main' ); + SDL_Quit; + Exit; + end; + + (* *Resize* with window size. *) + glmovie_resize( screen.w, screen.h ); + SMPEG_setdisplay( mpeg, surface, nil, @glmpeg_update ); + SMPEG_play( mpeg ); + + while ( SMPEG_status( mpeg ) = STATUS_SMPEG_PLAYING ) do + begin + + while ( SDL_PollEvent( @event ) <> 0 ) do + begin + case ( event.type_ ) of + SDL_KEYDOWN : + begin + if ( event.key.keysym.sym = SDLK_ESCAPE ) then + begin + SMPEG_stop( mpeg ); + end; + end; + SDL_MOUSEBUTTONDOWN, SDL_QUITEV : + SMPEG_stop( mpeg ); + end; + SDL_Delay( 100 ); + end; + end; + + glmovie_quit; + SDL_Quit; +end. + diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Campus.jpg b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Campus.jpg new file mode 100644 index 00000000..366d7e91 Binary files /dev/null and b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Campus.jpg differ diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/MPEGPlay.dpr b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/MPEGPlay.dpr new file mode 100644 index 00000000..a0687f4e --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/MPEGPlay.dpr @@ -0,0 +1,26 @@ +program MPEGPlay; + +{$IFDEF VER140} +{$DEFINE CLX} +{$ELSE} +{$DEFINE VCL} +{$ENDIF} + +uses + +{$IFDEF CLX} + QForms, +{$ENDIF} +{$IFDEF VCL} + Forms, +{$ENDIF} + Main in 'Main.pas' {Form1}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm( TForm1, Form1 ); + Application.Run; +end. + diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.dfm b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.dfm new file mode 100644 index 00000000..f881f626 Binary files /dev/null and b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.dfm differ diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.pas b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.pas new file mode 100644 index 00000000..5c2bd4f5 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.pas @@ -0,0 +1,91 @@ +unit Main; + +interface + +{$IFDEF UNIX} +{$DEFINE CLX} +{$ELSE} +{$DEFINE VCL} +{$ENDIF} + +uses + SysUtils, + Classes, +{$IFDEF CLX} + Types, + QGraphics, + QControls, + QForms, + QDialogs, + QExtCtrls, + QStdCtrls, +{$ENDIF} +{$IFDEF VCL} + Forms, + Graphics, + Dialogs, + StdCtrls, + Controls, + ExtCtrls, +{$ENDIF} + sdlmpegpanel; + +type + TForm1 = class( TForm ) + Panel1 : TPanel; + Panel2 : TPanel; + Button1 : TButton; + Button2 : TButton; + Button3 : TButton; + Panel3 : TPanel; + CheckBox1 : TCheckBox; + OpenDialog: TOpenDialog; + SDLMPEGPanel: TSDLMPEGPanel; + procedure Button1Click( Sender : TObject ); + procedure Button2Click( Sender : TObject ); + procedure Button3Click( Sender : TObject ); + private + { Private declarations } + public + { Public declarations } + end; + +var + Form1 : TForm1; + +implementation + +{$IFDEF WIN32} +{$R *.dfm} +{$ENDIF} + +{$IFDEF UNIX} +{$R *.xfm} +{$ENDIF} + +procedure TForm1.Button1Click( Sender : TObject ); +begin + with OpenDialog do + begin + if Execute then + begin + SDLMPEGPanel.MPEGFile := FileName; + SDLMPEGPanel.Sound := CheckBox1.Checked; + SDLMPEGPanel.Play; + end; + end; +end; + +procedure TForm1.Button2Click( Sender : TObject ); +begin + SDLMPEGPanel.Pause; +end; + +procedure TForm1.Button3Click( Sender : TObject ); +begin + SDLMPEGPanel.Stop; +end; + +end. + + \ No newline at end of file diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.xfm b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.xfm new file mode 100644 index 00000000..6b581787 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/Main.xfm @@ -0,0 +1,106 @@ +object Form1: TForm1 + Left = 377 + Top = 273 + Width = 351 + Height = 308 + VertScrollBar.Range = 44 + ActiveControl = Button1 + AutoScroll = False + Caption = 'The Tube' + Color = clBackground + Font.Color = clText + Font.Height = 11 + Font.Name = 'MS Sans Serif' + Font.Pitch = fpVariable + Font.Style = [] + ParentFont = False + Position = poScreenCenter + PixelsPerInch = 96 + TextHeight = 18 + TextWidth = 5 + object Panel1: TPanel + Left = 0 + Top = 264 + Width = 351 + Height = 44 + Align = alBottom + TabOrder = 0 + object Panel2: TPanel + Left = 1 + Top = 1 + Width = 282 + Height = 42 + Align = alClient + BevelOuter = bvNone + TabOrder = 0 + object Button1: TButton + Left = 5 + Top = 21 + Width = 48 + Height = 16 + Caption = 'Play' + TabOrder = 0 + OnClick = Button1Click + end + object Button2: TButton + Left = 57 + Top = 21 + Width = 48 + Height = 16 + Caption = 'Pause' + TabOrder = 1 + OnClick = Button2Click + end + object Button3: TButton + Left = 109 + Top = 21 + Width = 48 + Height = 16 + Caption = 'Stop' + TabOrder = 2 + OnClick = Button3Click + end + object CheckBox1: TCheckBox + Left = 5 + Top = 0 + Width = 65 + Height = 20 + Caption = 'Sound' + Checked = True + State = cbChecked + TabOrder = 3 + end + end + object Panel3: TPanel + Left = 283 + Top = 1 + Width = 67 + Height = 42 + Align = alRight + Anchors = [akLeft, akTop, akRight, akBottom] + BevelOuter = bvNone + TabOrder = 1 + end + end + object SDLMPEGPanel: TSDLMPEGPanel + Left = 0 + Top = 0 + Width = 351 + Height = 264 + Align = alClient + BevelInner = bvRaised + BevelOuter = bvLowered + Caption = 'You Movie should play here...' + TabOrder = 1 + Sound = False + end + object OpenDialog: TOpenDialog + Filter = 'MPEGs|*.mpeg;*.mpg|All Files|*.*' + FilterIndex = 0 + Height = 0 + Title = 'Open' + Width = 0 + Left = 40 + Top = 32 + end +end diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/README.1ST b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/README.1ST new file mode 100644 index 00000000..07e09117 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/README.1ST @@ -0,0 +1,21 @@ +0. This demo app makes use of SDL Beta 4 from the JEDI group. + Their full library is on this companion CD as well. + +1. You need to install libSDL-1.2 - www.libsdl.org if it is not already + installed on your system + +2. You need to install smpeg 0.4.4 - www.lokigames.com if it is not already + installed on your system. + Once smpeg is installed, navigate to your /usr/lib/ directory via a commandline and + create a symbolic link from libsmpeg-0.4.so.0 to libsmpeg.so. This is done + with the following command ( assuming you are in /usr/lib/ )... + ln -s libsmpeg-0.4.so.0 libsmpeg.so + + +3. Then compile using: + dcc video60.dpk - Kylix or D6, video40.dpk - D4, video50 - D5 + dcc MPEGPlay.dpr + +4. Run the app and play some MPEGs. + + diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/sdlmpegpanel.pas b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/sdlmpegpanel.pas new file mode 100644 index 00000000..6e7e87de --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/sdlmpegpanel.pas @@ -0,0 +1,149 @@ +unit sdlmpegpanel; + +interface + +{$IFDEF UNIX} +{$DEFINE CLX} +{$ELSE} +{$DEFINE VCL} +{$ENDIF} + +uses + SysUtils, + Classes, +{$IFDEF VCL} + Graphics, + Controls, + Forms, + Dialogs, + ExtCtrls, +{$ENDIF} +{$IFDEF CLX} + Types, + QGraphics, + QControls, + QForms, + QDialogs, + QExtCtrls, +{$ENDIF} + sdl, + smpeg; + +type + TSDLMPEGPanel = class( TPanel ) + private + { Private declarations } + FSurface : PSDL_Surface; + FSMPEGHandle : PSMPEG; + FMPEGFile : TFileName; + FMPEGInfo : TSMPEG_Info; + FPlaying : Boolean; + FSound : Integer; + function GetSound : Boolean; + procedure SetSound( const Value : Boolean ); + protected + { Protected declarations } + public + { Public declarations } + procedure Play; + procedure Stop; + procedure Pause; + published + { Published declarations } + property MPEGFile : TFileName read FMPEGFile write FMPEGFile; + property Sound : Boolean read GetSound write SetSound; + end; + +procedure Register; + +implementation + +{$IFDEF CLX} +uses + Libc, + Qt; +{$ENDIF} + +procedure TSDLMPEGPanel.Play; +var + EnvVal : string; +begin + if FPlaying then + Exit; + FPlaying := True; + + if SDL_getenv( 'SDL_WINDOWID' ) = '' then + begin + {$IFDEF VCL} + SDL_putenv( 'SDL_VIDEODRIVER=windib' ); + EnvVal := 'SDL_WINDOWID=' + inttostr( Integer( Handle ) ); + {$ENDIF} + + {$IFDEF CLX} + EnvVal := 'SDL_WINDOWID=' + inttostr( QWidget_WinId( ChildHandle ) ); + {$ENDIF} + + SDL_putenv( PChar( EnvVal ) ); + end; + + if SDL_getenv( 'SDL_VIDEO_YUV_HWACCEL' ) = '' then + SDL_putenv( 'SDL_VIDEO_YUV_HWACCEL=0' ); + + if SDL_Init( SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE ) < 0 then + raise Exception.Create( 'SDL_Init failed' ); + {$IFDEF VCL} + FSurface := SDL_SetVideoMode( Width, Height, 16, SDL_SWSURFACE ); + {$ENDIF} + {$IFDEF CLX} + FSurface := SDL_SetVideoMode( Width, Height, QPixmap_depth( Bitmap.Handle ), SDL_SWSURFACE ); + {$ENDIF} + if FSurface = nil then + raise Exception.Create( 'SDL_SetVideoMode failed' ); + + FSMPEGHandle := SMPEG_new( PChar( FMPEGFile ), @FMPEGInfo, FSound ); + if FSMPEGHandle = nil then + raise Exception.Create( 'Cannot create MPEG stream' ); + + if FSound = 0 then + SMPEG_enableaudio( FSMPEGHandle, 0 ); + + SMPEG_scaleXY( FSMPEGHandle, Width, Height ); + SMPEG_setdisplay( FSMPEGHandle, FSurface, nil, nil ); + + SMPEG_play( FSMPEGHandle ); +end; + +procedure TSDLMPEGPanel.Stop; +begin + if not FPlaying then + Exit; + FPlaying := False; + SMPEG_stop( FSMPEGHandle ); + SMPEG_delete( FSMPEGHandle ); + SDL_Quit; +end; + +procedure TSDLMPEGPanel.Pause; +begin + if FPlaying then + SMPEG_pause( FSMPEGHandle ); +end; + +function TSDLMPEGPanel.GetSound : Boolean; +begin + Result := Boolean( FSound ); +end; + +procedure TSDLMPEGPanel.SetSound( const Value : Boolean ); +begin + FSound := Integer( Value ); +end; + +procedure Register; +begin + RegisterComponents( 'SDL', [ TSDLMPEGPanel ] ); +end; + +end. + + diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video40.dpk b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video40.dpk new file mode 100644 index 00000000..5af28450 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video40.dpk @@ -0,0 +1,33 @@ +package video40; + +{$R *.RES} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$IMPLICITBUILD OFF} + +requires + Vcl40; + +contains + SDLMPEGPanel in 'SDLMPEGPanel.pas'; + +end. diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video50.dpk b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video50.dpk new file mode 100644 index 00000000..9c5612e4 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video50.dpk @@ -0,0 +1,33 @@ +package video50; + +{$R *.RES} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$IMPLICITBUILD OFF} + +requires + Vcl50; + +contains + SDLMPEGPanel in 'SDLMPEGPanel.pas'; + +end. diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video60.dpk b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video60.dpk new file mode 100644 index 00000000..9af38841 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/MpegPlayer/video60.dpk @@ -0,0 +1,35 @@ +package video60; + +{$R *.res} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$IMPLICITBUILD OFF} +requires + rtl, + visualclx; + +contains + SDLMPEGPanel in 'SDLMPEGPanel.pas'; + + + +end. \ No newline at end of file diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.cfg b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.cfg new file mode 100644 index 00000000..9d13f677 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.cfg @@ -0,0 +1,38 @@ +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J- +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-LE"c:\program files\borland\delphi7\Projects\Bpl" +-LN"c:\program files\borland\delphi7\Projects\Bpl" +-w-UNSAFE_TYPE +-w-UNSAFE_CODE +-w-UNSAFE_CAST diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dof b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dof new file mode 100644 index 00000000..96b3fada --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dof @@ -0,0 +1,136 @@ +[FileVersion] +Version=7.0 +[Compiler] +A=8 +B=0 +C=1 +D=1 +E=0 +F=0 +G=1 +H=1 +I=1 +J=0 +K=0 +L=1 +M=0 +N=1 +O=1 +P=1 +Q=0 +R=0 +S=0 +T=0 +U=0 +V=1 +W=0 +X=1 +Y=1 +Z=1 +ShowHints=1 +ShowWarnings=1 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +NamespacePrefix= +SymbolDeprecated=1 +SymbolLibrary=1 +SymbolPlatform=1 +UnitLibrary=1 +UnitPlatform=1 +UnitDeprecated=1 +HResultCompat=1 +HidingMember=1 +HiddenVirtual=1 +Garbage=1 +BoundsError=1 +ZeroNilCompat=1 +StringConstTruncated=1 +ForLoopVarVarPar=1 +TypedConstVarPar=1 +AsgToTypedConst=1 +CaseLabelRange=1 +ForVariable=1 +ConstructingAbstract=1 +ComparisonFalse=1 +ComparisonTrue=1 +ComparingSignedUnsigned=1 +CombiningSignedUnsigned=1 +UnsupportedConstruct=1 +FileOpen=1 +FileOpenUnitSrc=1 +BadGlobalSymbol=1 +DuplicateConstructorDestructor=1 +InvalidDirective=1 +PackageNoLink=1 +PackageThreadVar=1 +ImplicitImport=1 +HPPEMITIgnored=1 +NoRetVal=1 +UseBeforeDef=1 +ForLoopVarUndef=1 +UnitNameMismatch=1 +NoCFGFileFound=1 +MessageDirective=1 +ImplicitVariants=1 +UnicodeToLocale=1 +LocaleToUnicode=1 +ImagebaseMultiple=1 +SuspiciousTypecast=1 +PrivatePropAccessor=1 +UnsafeType=0 +UnsafeCode=0 +UnsafeCast=0 +[Linker] +MapFile=0 +OutputObjs=0 +ConsoleApp=1 +DebugInfo=0 +RemoteSymbols=0 +MinStackSize=16384 +MaxStackSize=1048576 +ImageBase=4194304 +ExeDescription= +[Directories] +OutputDir= +UnitOutputDir= +PackageDLLOutputDir= +PackageDCPOutputDir= +SearchPath= +Packages= +Conditionals= +DebugSourceDirs= +UsePackages=0 +[Parameters] +RunParams= +HostApplication= +Launcher= +UseLauncher=0 +DebugCWD= +[Language] +ActiveLang= +ProjectLang= +RootDir= +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=2057 +CodePage=1252 +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dpr b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dpr new file mode 100644 index 00000000..c88c0eb6 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Demos/SMpegPlayer/SMpegPlayer.dpr @@ -0,0 +1,278 @@ +program SMpegPlayer; +{******************************************************************} +{ } +{ Object Pascal Example of using smpeg and SDL_Mixer } +{ Conversion of Console Smpeg player } +{ } +{ } +{ The original files are : Found on internet } +{ } +{ The original Pascal code is : SMpegPlayer.dpr } +{ The initial developer of the Pascal code is : } +{ Dominique Louis } +{ } +{ Portions created by Dominique Louis are } +{ Copyright (C) 2001 Dominique Louis. } +{ } +{ Contributor(s) } +{ -------------- } +{ } +{ } +{ Obtained through: } +{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } +{ } +{ You may retrieve the latest version of this file at the Project } +{ JEDI home page, located at http://delphi-jedi.org } +{ } +{ The contents of this file are used with permission, subject to } +{ the Mozilla Public License Version 1.1 (the "License"); you may } +{ not use this file except in compliance with the License. You may } +{ obtain a copy of the License at } +{ http://www.mozilla.org/NPL/NPL-1_1Final.html } +{ } +{ Software distributed under the License is distributed on an } +{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } +{ implied. See the License for the specific language governing } +{ rights and limitations under the License. } +{ } +{ Description } +{ ----------- } +{ SMpegPlayer : Shows how to load and play an Mpeg file using } +{ smpeg and SDL_Mixer for the sound } +{ } +{ Requires } +{ -------- } +{ SDL runtime libary for SDL, smpeg and OpenGL somewhere } +{ in your path . } +{ The Latest SDL runtimes can be found on http://www.libsdl.org } +{ } +{ Programming Notes } +{ ----------------- } +{ This demo shows how to load and play an mpeg file using smpeg } +{ with SDL_Mixer } +{ You will need Smpeg and SDL_Mixer libraris order for this demo } +{ } +{ Revision History } +{ ---------------- } +{ July 02 2001 - DL : Initial translation. } +{ } +{ November 23 2002 - DL : Fix PollMPeg as suggested by } +{ } +{ } +{******************************************************************} + +uses + SysUtils, + sdl, + sdl_mixer, + smpeg; + +const + SCREEN_WIDTH = 800; + SCREEN_HEIGHT = 600; + BPP = 0; + + TITLE = 'JEDI-SDL Console MpegPlayer'; + +var + // Screen Surface + screen : PSDL_Surface; + + // Audio Specs + aspec : TSDL_AudioSpec; + format : Uint16; + freq, chan : integer; + Islooping : Boolean; + +function OpenMpeg( FileName : string ) : PSMPEG; +var + Handle : PSMPEG; +begin + // Create a new Mpeg + handle := SMPEG_new( PChar( fileName ), nil, 0 ); + if handle = nil then + begin + //Display Error + Halt; + end; + + // Disable Audio + SMPEG_enableaudio( handle, 0 ); + + // Query Mixer + Mix_QuerySpec( freq, format, chan ); + aspec.freq := freq; + aspec.format := format; + aspec.channels := chan; + + // Tell Smpeg what we want + Smpeg_actualSpec( handle, @aspec ); + + // Hook the mixer audio playing function + Mix_HookMusic( @SMPeg_PlayAudioSDL, handle ); + + // Reenable Audio + SMPEG_enableaudio( handle, 1 ); + + // Set Max Volume + SMPEG_setvolume( handle, 100 ); + + //Set up a video surface to display MPeg in + SMPEG_setdisplay( Handle, Screen, nil, nil ); + + // Reenable Video + SMPEG_enablevideo( handle, 1 ); + + // Retuen the handle in case we need it somewhere else + Result := handle; +end; + +// Free Mpeg + +procedure FreeMPeg( handle : PSMPEG ); +begin + SMPEG_delete( handle ); +end; + +// Loop Mpeg + +procedure LoopMpeg( handle : PSMPEG ); +begin + if IsLooping then + begin + SMPEG_loop( handle, 1 ); + isLooping := true; + end + else + begin + SMPEG_loop( handle, 0 ); + isLooping := false; + end; +end; + +// Play Mpeg + +procedure PlayMpeg( handle : PSMPEG ); +begin + SMpeg_play( handle ); +end; + +// Stop Mpeg + +procedure StopMpeg( handle : PSMPEG ); +begin + SMpeg_stop( handle ); +end; + +function PollMPeg( handle : PSMPEG ) : TSMpegStatus; +begin + Result := SMPEG_status( handle ); +end; + +function WaitMpeg( interval : Uint32; param : pointer ) : Uint32; +var + e : TSDL_Event; + handle : PSMPEG; +begin + handle := PSMPEG( param ); + + // Has it stopped? If so, throw a User Event + if PollMPeg( handle ) = STATUS_SMPEG_STOPPED then + begin + e.type_ := SDL_USEREVENT; + e.user.code := 1; + e.user.data1 := nil; + e.user.data2 := nil; + SDL_PushEvent( @e ); + end; + + result := interval; +end; + +procedure RunIntro( fileName : string ); +var + e : TSDL_Event; + handle : PSMPEG; + td : PSDL_TimerID; + done : Boolean; +begin + done := false; + // Create a Movie + handle := OpenMpeg( fileName ); + + // Play the Movie + PlayMPeg( Handle ); + + // Create a timer to see if the Movie has stopped + td := SDL_AddTimer( 1000, @WaitMPeg, handle ); + + // wait for Movie to finish + while not done do + begin + // wiat for out event to happen + SDL_WaitEvent( @e ); + case e.type_ of + // Check to see if user want to skip the movie + SDL_KEYDOWN : + begin + if e.key.keysym.sym = SDLK_ESCAPE then + Done := true; + end; + + SDL_USEREVENT : + begin + if PollMpeg( handle ) = STATUS_SMPEG_STOPPED then + Done := true; + end + + end; + end; + + // Stop the movie + StopMpeg( handle ); + + // Remove WaitMpegTimer + SDL_RemoveTimer( td ); + + // Unhook mixer audio playback function + Mix_HookMusic( nil, nil ); + + // Free out MPEG + FreeMPeg( handle ); +end; + +begin + // Make sure we at least have a parameter + if ParamCount <> 1 then + begin + Halt( 1 ); + end; + + // Initialize SDL + if SDL_Init( SDL_INIT_VIDEO or SDL_INIT_AUDIO or SDL_INIT_TIMER ) < 0 then + begin + // Display and error + Halt( 1 ); + end; + + // Open the Mixer before SDL_SetVideo to avoid the poping sound + Mix_OpenAudio( 22050, AUDIO_S16, 2, 1024 ); + + SDL_WM_SetCaption( TITLE, nil ); + + // Set the video Mode + screen := SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, BPP, SDL_DOUBLEBUF or + SDL_ANYFORMAT ); + if screen = nil then + begin + // Display and error + Halt( 1 ); + end; + + RunIntro( ParamStr( 1 ) ); + + Mix_CloseAudio; + + SDL_Quit; +end. + diff --git a/Game/Code/lib/JEDI-SDLv1.0/smpeg/Pas/smpeg.pas b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Pas/smpeg.pas new file mode 100644 index 00000000..c32c1904 --- /dev/null +++ b/Game/Code/lib/JEDI-SDLv1.0/smpeg/Pas/smpeg.pas @@ -0,0 +1,465 @@ +unit smpeg; +{******************************************************************************} +{ + $Id: smpeg.pas,v 1.12 2007/12/05 22:54:30 savage Exp $ + +} +{ } +{ Borland Delphi SMPEG - SDL MPEG Player Library } +{ Conversion of the SMPEG - SDL MPEG Player Library } +{ } +{ Portions created by Sam Lantinga are } +{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga } +{ 5635-34 Springhouse Dr. } +{ Pleasanton, CA 94588 (USA) } +{ } +{ All Rights Reserved. } +{ } +{ The original files are : smpeg.h } +{ } +{ The initial developer of this Pascal code was : } +{ Matthias Thoma } +{ } +{ Portions created by Matthias Thoma are } +{ Copyright (C) 2000 - 2001 Matthias Thoma. } +{ } +{ } +{ Contributor(s) } +{ -------------- } +{ Tom Jones His Project inspired this conversion } +{ Matthias Thoma } +{ } +{ Obtained through: } +{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } +{ } +{ You may retrieve the latest version of this file at the Project } +{ JEDI home page, located at http://delphi-jedi.org } +{ } +{ The contents of this file are used with permission, subject to } +{ the Mozilla Public License Version 1.1 (the "License"); you may } +{ not use this file except in compliance with the License. You may } +{ obtain a copy of the License at } +{ http://www.mozilla.org/MPL/MPL-1.1.html } +{ } +{ Software distributed under the License is distributed on an } +{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } +{ implied. See the License for the specific language governing } +{ rights and limitations under the License. } +{ } +{ Description } +{ ----------- } +{ } +{ } +{ } +{ } +{ } +{ } +{ } +{ Requires } +{ -------- } +{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0 } +{ They are available from... } +{ http://www.libsdl.org . } +{ } +{ Programming Notes } +{ ----------------- } +{ } +{ } +{ } +{ } +{ Revision History } +{ ---------------- } +{ May 08 2001 - MT : Initial conversion } +{ } +{ October 12 2001 - DA : Various changes as suggested by David Acklam } +{ } +{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more } +{ Pascal compilers. Initial support is now included } +{ for GnuPascal, VirtualPascal, TMT and obviously } +{ continue support for Delphi Kylix and FreePascal. } +{ } +{ April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support } +{ Fixed all invalid calls to DLL. } +{ Changed constant names to: } +{ const } +{ STATUS_SMPEG_ERROR = -1; } +{ STATUS_SMPEG_STOPPED = 0; } +{ STATUS_SMPEG_PLAYING = 1; } +{ because SMPEG_ERROR is a function (_SMPEG_error } +{ isn't correct), and cannot be two elements with the } +{ same name } +{ } +{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added} +{ better TMT Pascal support and under instruction } +{ from Prof. Abimbola Olowofoyeku (The African Chief),} +{ I have added better Gnu Pascal support } +{ } +{ April 30 2003 - DL : under instruction from David Mears AKA } +{ Jason Siletto, I have added FPC Linux support. } +{ This was compiled with fpc 1.1, so remember to set } +{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* } +{ } +{ + $Log: smpeg.pas,v $ + Revision 1.12 2007/12/05 22:54:30 savage + Better Mac OS X support for Frameworks. + + Revision 1.11 2007/05/20 20:32:45 savage + Initial Changes to Handle 64 Bits + + Revision 1.10 2005/04/10 11:48:33 savage + Changes as suggested by Michalis, thanks. + + Revision 1.9 2005/01/05 01:47:15 savage + Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. + + Revision 1.8 2005/01/04 23:14:59 savage + Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. + + Revision 1.7 2004/08/14 22:54:30 savage + Updated so that Library name defines are correctly defined for MacOS X. + + Revision 1.6 2004/05/10 14:10:04 savage + Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). + + Revision 1.5 2004/04/13 09:32:08 savage + Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. + + Revision 1.4 2004/04/02 10:40:55 savage + Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. + + Revision 1.3 2004/03/31 22:20:02 savage + Windows unit not used in this file, so it was removed to keep the code tidy. + + Revision 1.2 2004/03/30 20:23:28 savage + Tidied up use of UNIX compiler directive. + + Revision 1.1 2004/02/14 23:35:42 savage + version 1 of sdl_image, sdl_mixer and smpeg. + + +} +{******************************************************************************} + +{$I jedi-sdl.inc} + +// Linux and Windows C-Compilers use different byte-allignment +{$IFDEF UNIX} + {$ALIGN 4} // Linux uses DWORD alignment +{$ENDIF} +{$IFDEF WINDOWS} + {$IFDEF VER140} + {$ALIGN 8} // Windows uses Quad-Word alignment + {$ENDIF} +{$ENDIF} + +interface + +uses +{$IFDEF __GPC__} + gpc, +{$ENDIF} + + sdl; + +const +{$IFDEF WINDOWS} + SmpegLibName = 'smpeg.dll'; +{$ENDIF} + +{$IFDEF UNIX} +{$IFDEF DARWIN} + SmpegLibName = 'libsmpeg-0.4.0.dylib'; +{$ELSE} + {$IFDEF FPC} + SmpegLibName = 'libsmpeg.so'; + {$ELSE} + SmpegLibName = 'libsmpeg-0.4.so.0'; + {$ENDIF} +{$ENDIF} +{$ENDIF} + +{$IFDEF MACOS} + SmpegLibName = 'smpeg'; + {$linklib libsmpeg} +{$ENDIF} + +//------------------------------------------------------------------------------ +// MPEGFilter.h +//------------------------------------------------------------------------------ +{ SMPEG filter info flags } +const + SMPEG_FILTER_INFO_MB_ERROR = 1; + SMPEG_FILTER_INFO_PIXEL_ERROR = 2; + +{ Filter info from SMPEG } +type + SMPEG_FilterInfo = record + yuv_mb_square_error: PUint16; + yuv_pixel_square_error: PUint16; + end; + TSMPEG_FilterInfo = SMPEG_FilterInfo; + PSMPEG_FilterInfo = ^SMPEG_FilterInfo; + +{ MPEG filter definition } + PSMPEG_Filter = ^TSMPEG_Filter; + +{ Callback functions for the filter } + {$IFNDEF __GPC__} + TSMPEG_FilterCallback = function( dest, source: PSDL_Overlay; region: PSDL_Rect; filter_info: PSMPEG_FilterInfo; data: Pointer ): Pointer; cdecl; + {$ELSE} + TSMPEG_FilterCallback = function( dest, source: PSDL_Overlay; region: PSDL_Rect; filter_info: PSMPEG_FilterInfo; data: Pointer ): Pointer; + {$ENDIF} + + {$IFNDEF __GPC__} + TSMPEG_FilterDestroy = function( Filter: PSMPEG_Filter ): Pointer; cdecl; + {$ELSE} + TSMPEG_FilterDestroy = function( Filter: PSMPEG_Filter ): Pointer; + {$ENDIF} + +{ The filter definition itself } + TSMPEG_Filter = record + flags: Uint32; + data: Pointer; + callback: TSMPEG_FilterCallback; + destroy: TSMPEG_FilterDestroy; + end; + +{ The null filter (default). It simply copies the source rectangle to the video overlay. } +function SMPEGfilter_null: PSMPEG_Filter; +cdecl; external {$IFDEF __GPC__}name 'SMPEGfilter_null'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ The bilinear filter. A basic low-pass filter that will produce a smoother image. } +function SMPEGfilter_bilinear: PSMPEG_Filter; +cdecl; external {$IFDEF __GPC__}name 'SMPEGfilter_bilinear'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness } +function SMPEGfilter_deblocking: PSMPEG_Filter; +cdecl; external {$IFDEF __GPC__}name 'SMPEGfilter_deblocking'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +//------------------------------------------------------------------------------ +// SMPEG.h +//------------------------------------------------------------------------------ +const + SMPEG_MAJOR_VERSION = 0; + SMPEG_MINOR_VERSION = 4; + SMPEG_PATCHLEVEL = 2; + +type + SMPEG_version = record + major: UInt8; + minor: UInt8; + patch: UInt8; + end; + TSMPEG_version = SMPEG_version; + PSMPEG_version = ^TSMPEG_version; + + // This is the actual SMPEG object + _SMPEG = record + //obj: PMPEG; + end; + TSMPEG = _SMPEG; + PSMPEG = ^_SMPEG; + + { Used to get information about the SMPEG object } + __SMPEG_Info = record + has_audio: Integer; + has_video: Integer; + width: Integer; + height: Integer; + current_frame: Integer; + current_fps: double; + audio_string: array[0..79] of char; + audio_current_frame: Integer; + current_offset: UInt32; + total_size: UInt32; + current_time: double; + total_time: double; + end; + _SMPEG_Info = __SMPEG_Info; + SMPEG_Info = _SMPEG_Info; + TSMPEG_Info = _SMPEG_Info; + PSMPEG_Info = ^_SMPEG_Info; + +{ Possible MPEG status codes } +const + STATUS_SMPEG_ERROR = -1; + STATUS_SMPEG_STOPPED = 0; + STATUS_SMPEG_PLAYING = 1; + +type + SMPEGstatus = Integer; + TSMPEGstatus = Integer; + PSMPEGstatus = ^Integer; + + { Matches the declaration of SDL_UpdateRect() } + {$IFNDEF __GPC__} + TSMPEG_DisplayCallback = function( dst: PSDL_Surface; x, y: Integer; w, h: Cardinal ): Pointer; cdecl; + {$ELSE} + TSMPEG_DisplayCallback = function( dst: PSDL_Surface; x, y: Integer; w, h: Cardinal ): Pointer; + {$ENDIF} + + +{ Create a new SMPEG object from an MPEG file. + On return, if 'info' is not NULL, it will be filled with information + about the MPEG object. + This function returns a new SMPEG object. Use SMPEG_error() to find out + whether or not there was a problem building the MPEG stream. + The sdl_audio parameter indicates if SMPEG should initialize the SDL audio + subsystem. If not, you will have to use the SMPEG_playaudio() function below + to extract the decoded data. } +function SMPEG_new(const _file: PChar; info: PSMPEG_Info; sdl_audio: Integer): PSMPEG; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_new'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ The same as above for a file descriptor } +function SMPEG_new_descr(_file: Integer; info: PSMPEG_Info; sdl_audio: Integer): PSMPEG; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_new_descr'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ The same as above but for a raw chunk of data. SMPEG makes a copy of the + data, so the application is free to delete after a successful call to this + function. } +function SMPEG_new_data(data: Pointer; size: Integer; info: PSMPEG_Info; sdl_audio: Integer): PSMPEG; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_new_data'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Get current information about an SMPEG object } +procedure SMPEG_getinfo(mpeg: PSMPEG; info: PSMPEG_Info); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_getinfo'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +//procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer); +//cdecl; external {$IFDEF __GPC__}name 'SMPEG_getinfo'{$ELSE} SmpegLibName{$ENDIF __GPC__}; +{ Enable or disable audio playback in MPEG stream } +procedure SMPEG_enableaudio(mpeg: PSMPEG; enable: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_enableaudio'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Enable or disable video playback in MPEG stream } +procedure SMPEG_enablevideo(mpeg: PSMPEG; enable: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_enablevideo'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Delete an SMPEG object } +procedure SMPEG_delete(mpeg: PSMPEG); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_delete'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Get the current status of an SMPEG object } +function SMPEG_status(mpeg: PSMPEG): TSMPEGstatus; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_status'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + // status +{ Set the audio volume of an MPEG stream, in the range 0-100 } +procedure SMPEG_setvolume(mpeg: PSMPEG; volume: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_setvolume'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Set the destination surface for MPEG video playback + 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL. + 'callback' is a function called when an area of 'dst' needs to be updated. + If 'callback' is NULL, the default function (SDL_UpdateRect) will be used. } +procedure SMPEG_setdisplay(mpeg: PSMPEG; dst: PSDL_Surface; surfLock: PSDL_mutex; callback: TSMPEG_DisplayCallback); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_setdisplay'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Set or clear looping play on an SMPEG object } +procedure SMPEG_loop(mpeg: PSMPEG; _repeat: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_loop'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Scale pixel display on an SMPEG object } +procedure SMPEG_scaleXY(mpeg: PSMPEG; width, height: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_scaleXY'{$ELSE} SmpegLibName{$ENDIF __GPC__}; +procedure SMPEG_scale(mpeg: PSMPEG; scale: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_scale'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +procedure SMPEG_Double(mpeg : PSMPEG; doubleit : Boolean ); + +{ Move the video display area within the destination surface } +procedure SMPEG_move(mpeg: PSMPEG; x, y: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_move'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Set the region of the video to be shown } +procedure SMPEG_setdisplayregion(mpeg: PSMPEG; x, y, w, h: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_setdisplayregion'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Play an SMPEG object } +procedure SMPEG_play(mpeg: PSMPEG); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_play'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Pause/Resume playback of an SMPEG object} +procedure SMPEG_pause(mpeg: PSMPEG); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_pause'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Stop playback of an SMPEG object } +procedure SMPEG_stop(mpeg: PSMPEG); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_stop'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Rewind the play position of an SMPEG object to the beginning of the MPEG } +procedure SMPEG_rewind(mpeg: PSMPEG); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_rewind'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Seek 'bytes' bytes in the MPEG stream } +procedure SMPEG_seek(mpeg: PSMPEG; bytes: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_seek'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Skip 'seconds' seconds in the MPEG stream } +procedure SMPEG_skip(mpeg: PSMPEG; seconds: single); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_skip'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Render a particular frame in the MPEG video + API CHANGE: This function no longer takes a target surface and position. + Use SMPEG_setdisplay() and SMPEG_move() to set this information. } +procedure SMPEG_renderFrame(mpeg: PSMPEG; framenum: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_renderFrame'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Render the last frame of an MPEG video } +procedure SMPEG_renderFinal(mpeg: PSMPEG; dst: PSDL_Surface; x, y: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_renderFinal'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Set video filter } +function SMPEG_filter(mpeg: PSMPEG; filter: PSMPEG_Filter): PSMPEG_Filter; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_filter'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Return NULL if there is no error in the MPEG stream, or an error message + if there was a fatal error in the MPEG stream for the SMPEG object. } +function SMPEG_error(mpeg: PSMPEG): PChar; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_error'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Exported callback function for audio playback. + The function takes a buffer and the amount of data to fill, and returns + the amount of data in bytes that was actually written. This will be the + amount requested unless the MPEG audio has finished. +} +function SMPEG_playAudio(mpeg: PSMPEG; stream: PUInt8; len: Integer): Integer; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_playAudio'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer } +procedure SMPEG_playAudioSDL(mpeg: Pointer; stream: PUInt8; len: Integer); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_playAudioSDL'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Get the best SDL audio spec for the audio stream } +function SMPEG_wantedSpec(mpeg: PSMPEG; wanted: PSDL_AudioSpec): Integer; +cdecl; external {$IFDEF __GPC__}name 'SMPEG_wantedSpec'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ Inform SMPEG of the actual SDL audio spec used for sound playback } +procedure SMPEG_actualSpec(mpeg: PSMPEG; spec: PSDL_AudioSpec); +cdecl; external {$IFDEF __GPC__}name 'SMPEG_actualSpec'{$ELSE} SmpegLibName{$ENDIF __GPC__}; + +{ This macro can be used to fill a version structure with the compile-time + version of the SDL library. } +procedure SMPEG_GETVERSION( var X : TSMPEG_version ); + +implementation + +{$IFDEF __GPC__} + {$L 'smpeg'} { link smpeg.dll.a or libsmpeg.so or libsmpeg.a } +{$ENDIF} + +procedure SMPEG_double(mpeg : PSMPEG; doubleit : Boolean ); +begin + if doubleit then + SMPEG_scale( mpeg, 2 ) + else + SMPEG_scale( mpeg, 1 ); +end; + +procedure SMPEG_GETVERSION( var X : TSMPEG_version ); +begin + X.major := SMPEG_MAJOR_VERSION; + X.minor := SMPEG_MINOR_VERSION; + X.patch := SMPEG_PATCHLEVEL; +end; + +end. -- cgit v1.2.3