video with smpeg problem

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
wing64
Posts: 15
Joined: Sun Apr 09, 2006 5:21 pm

video with smpeg problem

Post by wing64 »

Hello
I use smpeg for load video mpeg1 and found problems.
If run by network with ps2link program can display video mpeg1 correct but when change prorgam run from memorycard or burn to cd-rom then video mpeg1 not display on screen
is show black screen. Why program run by ps2link can display video correct but run from memorycard or cd-rom it not work ? Please suggest me.
best regards
wing64

file .elf here http://www.geocities.com/web13c/s200.zip

sourcecode here

Code: Select all

#include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>
#include <iopheap.h>
#include <loadfile.h>
#include <iopcontrol.h>
#include <cdvd_rpc.h>
#include <fileio.h>
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include "SDL.h"
#include "smpeg.h"
#include "pak.h"
#include "romfs.h"
#include "romfs_io.h"

extern u8 *cdvd_irx;
extern int size_cdvd_irx;
extern u8 *fileXio_irx;
extern int size_fileXio_irx;
extern u8 *iomanX_irx;
extern int size_iomanX_irx;
extern u8 *ps2dev9_irx;
extern int size_ps2dev9_irx;
extern u8 *ps2fs_irx;
extern int size_ps2fs_irx;

extern u8 *ioptrap_irx;
extern int size_ioptrap_irx;
extern u8 *poweroff_irx;
extern int size_poweroff_irx;

int	have_cdvd     = 0;

SDL_Surface *screen;

void loadCdModules&#40;void&#41;
&#123;
	int ret;
	
	if	&#40;!have_cdvd&#41;
	&#123;	SifExecModuleBuffer&#40;&cdvd_irx, size_cdvd_irx, 0, NULL, &ret&#41;;
		CDVD_Init&#40;&#41;;
		have_cdvd = 1;
	&#125;

	SifExecModuleBuffer&#40;&fileXio_irx, size_fileXio_irx, 0, NULL, &ret&#41;;
	SifExecModuleBuffer&#40;&iomanX_irx, size_iomanX_irx, 0, NULL, &ret&#41;;
	SifExecModuleBuffer&#40;&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &ret&#41;;
	SifExecModuleBuffer&#40;&ps2fs_irx, size_ps2fs_irx, 0, NULL, &ret&#41;;

	SifExecModuleBuffer&#40;&ioptrap_irx, size_ioptrap_irx, 0, NULL, &ret&#41;;
	SifExecModuleBuffer&#40;&poweroff_irx, size_poweroff_irx, 0, NULL, &ret&#41;;

&#125;

void loadBasicModules&#40;void&#41;
&#123;
	//if	&#40;!have_sio2man&#41;
	&#123;	SifLoadModule&#40;"rom0&#58;SIO2MAN", 0, NULL&#41;;
		//have_sio2man = 1;
	&#125;
	//if	&#40;!have_mcman&#41;
	&#123;	SifLoadModule&#40;"rom0&#58;MCMAN", 0, NULL&#41;;
		//have_mcman = 1;
	&#125;
	//if	&#40;!have_mcserv&#41;
	&#123;	SifLoadModule&#40;"rom0&#58;MCSERV", 0, NULL&#41;;
		//have_mcserv = 1;
	&#125;
	//if	&#40;!have_padman&#41;
	&#123;	SifLoadModule&#40;"rom0&#58;PADMAN", 0, NULL&#41;;
		//have_padman = 1;
	&#125;
&#125;
//------------------------------
//endfunc loadBasicModules
//--------------------------------------------------------------

void update&#40;SDL_Surface *cscreen, Sint32 x, Sint32 y, Uint32 w, Uint32 h&#41;
&#123;
    if &#40; screen->flags & SDL_DOUBLEBUF &#41; 
	&#123;
		printf&#40; "" &#41;;
        SDL_Flip&#40;screen&#41;;
		
    &#125;
&#125;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	SMPEG_Info movinfo;
	SMPEG*	mov;
	char *bootPath;

	loadBasicModules&#40; &#41;;
	loadCdModules&#40; &#41;;

    /* Initialize the SDL library */
    if&#40; SDL_Init&#40;SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER&#41; < 0 &#41; &#123;
        fprintf&#40;stderr,
                "Couldn't initialize SDL&#58; %s\n", SDL_GetError&#40;&#41;&#41;;
        exit&#40;1&#41;;
    &#125;

    /* Clean up on exit */
    atexit&#40;SDL_Quit&#41;;

  
    /*
     * Initialize the display in a 640x480 8-bit palettized mode,
     * requesting a software surface
     */
    screen = SDL_SetVideoMode&#40;320, 240, 16, SDL_FULLSCREEN | SDL_SWSURFACE &#41;;
    if &#40; screen == NULL &#41; &#123;
        fprintf&#40;stderr, "Couldn't set 640x480x8 video mode&#58; %s\n",
                        SDL_GetError&#40;&#41;&#41;;
        exit&#40;1&#41;;
    &#125;

	extern unsigned char romdisk_start&#91;&#93;; 
	char *ptr; //ptr on datastruc file 
	SDL_RWops *context;

  	romdisk_mount&#40;romdisk_start&#41;;
  	rfs_init&#40;&#41;;

	rfs_open&#40; "all2.mpg" &#41;;
	ptr = &#40;char *&#41;malloc&#40;sizeof&#40;char&#41;*&#40;rfs_size&#40;&#41;+1&#41;&#41;;
	rfs_read&#40;ptr,rfs_size&#40;&#41;&#41;;
	context = SDL_RWFromMem&#40;ptr,rfs_size&#40;&#41;&#41;;
	mov = SMPEG_new_rwops&#40; context, &movinfo, 0&#41;;
	if&#40; !mov &#41;
	&#123;
		printf&#40; "error all2.mpg...\n" &#41;;
		return -1;
	&#125;

	SMPEG_setdisplay&#40;mov, screen, NULL,NULL&#41;;
    SMPEG_enableaudio&#40;mov, 0&#41;;
    SMPEG_enablevideo&#40;mov, 1&#41;;
	SMPEG_loop&#40; mov, 1 &#41;;
	SMPEG_play&#40; mov &#41;;

	while&#40; 1 &#41;
	&#123;
		printf&#40; "" &#41;;
		SDL_Event event;
		while &#40; SDL_PollEvent&#40;&event&#41; &#41; 
		&#123;
            switch &#40;event.type&#41; &#123;
              case SDL_KEYDOWN&#58;
                if &#40; event.key.keysym.sym == SDLK_ESCAPE &#41; &#123;
                    SMPEG_stop&#40; mov &#41;;
                &#125;
                break;
              case SDL_MOUSEBUTTONDOWN&#58;
              case SDL_QUIT&#58;
                SMPEG_stop&#40; mov &#41;;
                break;
            &#125;
		&#125;
		SDL_Flip&#40; screen &#41;;
	&#125;

	SMPEG_delete&#40; mov &#41;;
	SDL_FreeSurface&#40; screen &#41;;

	return 0;
&#125;
kjdflkdfdfsdf
Post Reply