a MIPS Assembly Language question

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

a MIPS Assembly Language question

Post by cooleyes »

what this code mean?
I can't find any information about ins instructions . :(

Code: Select all

ins        $v0, $zr, 0, 4
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Re: a MIPS Assembly Language question

Post by crazyc »

cooleyes wrote:what this code mean?
I can't find any information about ins instructions . :(

Code: Select all

ins        $v0, $zr, 0, 4
Insert into $v0 starting at bit 0 the lowest 4 bits of $zr.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

here it is equivalent to : v0 = v0 & -16; // that is bits 0..3 of v0 are set to 0.


INS rt, rs, bpos, blen : bit insertion
---------------------------------------
ins Rt, Rs, bpos, blen <=> Rt.bits[blen+bpos-1..bpos] = Rs.bits[blen-1..0] <=> Rt = (Rt & -((2^blen) << bpos)) | ((Rs & (2^blen - 1)) << bpos)

EXT rt, rs, bpos, blen : bit extraction
---------------------------------------
ext Rt, Rs, bpos, blen <=> Rt = Rs.bits[blen+bpos-1..bpos] <=> Rt = (Rs >> bpos) & (2^blen - 1)


those instructions are mainly used for bitfields in struct :

Code: Select all

typedef union &#123; int word; struct &#123; int bf4 &#58; 4; &#125; &#125; bit4_t;
...
bit4_t f&#40;bit4 x&#41;
&#123;
  bit4_t res;
  ...
  printf&#40;"%d", x.bf4&#41;; // EXT $a1, $a0, 0, 4
  ...
  res.bf4 = 0; // INS $v0, $zr, 0, 4
  ...
  return res;
&#125;
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

oh, thanks
:)
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

on PSP, "shift" and "or" operations are a little overhead compared with "ins" instructions :

Code: Select all

#define COLOR565&#40; r, g, b &#41; \
 &#40;&#123; unsigned short c = r>>3; asm volatile &#40; "ins %0, %2, 5, 6; ins %0, %3, 11, 5" &#58; "+r"&#40;c&#41; &#58; "r"&#40;g>>2&#41;, "r"&#40;b>>3&#41; &#41;; c; &#125;&#41;
#define COLOR5551&#40; r, g, b, a &#41; \
 &#40;&#123; unsigned short c = r>>3; asm volatile &#40; "ins %0, %2, 5, 6; ins %0, %3, 11, 5; ins %0, %4, 15, 1" &#58; "+r"&#40;c&#41; &#58; "r"&#40;g>>3&#41;, "r"&#40;b>>3&#41;, "r"&#40;a>>7&#41; &#41;; c; &#125;&#41;
as you can see there is no need for "or" instructions.

Normally using :

Code: Select all

union rgb565_t &#123; unsigned short c; struct &#123; unsigned short r &#58; 5, g &#58; 6, b &#58; 5; &#125; &#125;
#define COLOR565&#40; r, g, b &#41; &#40;&#123; union rgb565_t res; res.c = r >> 3; res.g = g >> 2; res.b = b >> 3; res.c; &#125;&#41;
should give a similar code on PSP, since "ins"/"ext" instructions were specially designed for access to/from bit fields in struct.

if you are not convinced :
  • 1) unsigned short COLOR565_c(int r,int g,int b ) // 9 insns
    { return (((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0)); }
    2) unsigned short COLOR565_asm(int r,int g,int b ) // 7 insns
    { unsigned short c = r>>3; asm volatile ( "ins %0, %1, 5, 6; ins %0, %2, 11, 5" : "+r"(c) : "r"(g>>2), "r"(b>>3) ); return c; }
    3) unsigned short COLOR565_union(int r,int g,int b ) // 7 insns
    { union rgb565_t { unsigned short c; struct { unsigned short r : 5, g : 6, b : 5; }; } res; res.c = r >> 3; res.g = g >> 2; res.b = b >> 3; return res.c; }

Code: Select all

1&#41;
00000000 <COLOR565_c>&#58;
   0&#58;	000410c3 	sra	v0,a0,0x3
   4&#58;	00052883 	sra	a1,a1,0x2
   8&#58;	00052940 	sll	a1,a1,0x5
   c&#58;	000212c0 	sll	v0,v0,0xb
  10&#58;	00451025 	or	v0,v0,a1
  14&#58;	000630c3 	sra	a2,a2,0x3
  18&#58;	00461025 	or	v0,v0,a2
  1c&#58;	03e00008 	jr	ra
  20&#58;	3042ffff 	andi	v0,v0,0xffff

2&#41;
00000024 <COLOR565_asm>&#58;
  24&#58;	7c8278c0 	ext	v0,a0,0x3,0x10
  28&#58;	00052883 	sra	a1,a1,0x2
  2c&#58;	000630c3 	sra	a2,a2,0x3
  30&#58;	7ca25144 	ins	v0,a1,0x5,0x6
  34&#58;	7cc27ac4 	ins	v0,a2,0xb,0x5
  38&#58;	03e00008 	jr	ra
  3c&#58;	3042ffff 	andi	v0,v0,0xffff

3&#41;
00000040 <COLOR565_union>&#58;
  40&#58;	000410c2 	srl	v0,a0,0x3
  44&#58;	00052883 	sra	a1,a1,0x2
  48&#58;	7ca25144 	ins	v0,a1,0x5,0x6
  4c&#58;	000630c3 	sra	a2,a2,0x3
  50&#58;	7cc27ac4 	ins	v0,a2,0xb,0x5
  54&#58;	03e00008 	jr	ra
  58&#58;	3042ffff 	andi	v0,v0,0xffff
Note that COLOR565_asm and COLOR565_union are quite similar.
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

hlide wrote:on PSP, "shift" and "or" operations are a little overhead compared with "ins" instructions :

Code: Select all

#define COLOR565&#40; r, g, b &#41; \
 &#40;&#123; unsigned short c = r>>3; asm volatile &#40; "ins %0, %2, 5, 6; ins %0, %3, 11, 5" &#58; "+r"&#40;c&#41; &#58; "r"&#40;g>>2&#41;, "r"&#40;b>>3&#41; &#41;; c; &#125;&#41;
#define COLOR5551&#40; r, g, b, a &#41; \
 &#40;&#123; unsigned short c = r>>3; asm volatile &#40; "ins %0, %2, 5, 6; ins %0, %3, 11, 5; ins %0, %4, 15, 1" &#58; "+r"&#40;c&#41; &#58; "r"&#40;g>>3&#41;, "r"&#40;b>>3&#41;, "r"&#40;a>>7&#41; &#41;; c; &#125;&#41;
as you can see there is no need for "or" instructions.

Normally using :

Code: Select all

union rgb565_t &#123; unsigned short c; struct &#123; unsigned short r &#58; 5, g &#58; 6, b &#58; 5; &#125; &#125;
#define COLOR565&#40; r, g, b &#41; &#40;&#123; union rgb565_t res; res.c = r >> 3; res.g = g >> 2; res.b = b >> 3; res.c; &#125;&#41;
should give a similar code on PSP, since "ins"/"ext" instructions were specially designed for access to/from bit fields in struct.

if you are not convinced :
  • 1) unsigned short COLOR565_c(int r,int g,int b ) // 9 insns
    { return (((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0)); }
    2) unsigned short COLOR565_asm(int r,int g,int b ) // 7 insns
    { unsigned short c = r>>3; asm volatile ( "ins %0, %1, 5, 6; ins %0, %2, 11, 5" : "+r"(c) : "r"(g>>2), "r"(b>>3) ); return c; }
    3) unsigned short COLOR565_union(int r,int g,int b ) // 7 insns
    { union rgb565_t { unsigned short c; struct { unsigned short r : 5, g : 6, b : 5; }; } res; res.c = r >> 3; res.g = g >> 2; res.b = b >> 3; return res.c; }

Code: Select all

1&#41;
00000000 <COLOR565_c>&#58;
   0&#58;	000410c3 	sra	v0,a0,0x3
   4&#58;	00052883 	sra	a1,a1,0x2
   8&#58;	00052940 	sll	a1,a1,0x5
   c&#58;	000212c0 	sll	v0,v0,0xb
  10&#58;	00451025 	or	v0,v0,a1
  14&#58;	000630c3 	sra	a2,a2,0x3
  18&#58;	00461025 	or	v0,v0,a2
  1c&#58;	03e00008 	jr	ra
  20&#58;	3042ffff 	andi	v0,v0,0xffff

2&#41;
00000024 <COLOR565_asm>&#58;
  24&#58;	7c8278c0 	ext	v0,a0,0x3,0x10
  28&#58;	00052883 	sra	a1,a1,0x2
  2c&#58;	000630c3 	sra	a2,a2,0x3
  30&#58;	7ca25144 	ins	v0,a1,0x5,0x6
  34&#58;	7cc27ac4 	ins	v0,a2,0xb,0x5
  38&#58;	03e00008 	jr	ra
  3c&#58;	3042ffff 	andi	v0,v0,0xffff

3&#41;
00000040 <COLOR565_union>&#58;
  40&#58;	000410c2 	srl	v0,a0,0x3
  44&#58;	00052883 	sra	a1,a1,0x2
  48&#58;	7ca25144 	ins	v0,a1,0x5,0x6
  4c&#58;	000630c3 	sra	a2,a2,0x3
  50&#58;	7cc27ac4 	ins	v0,a2,0xb,0x5
  54&#58;	03e00008 	jr	ra
  58&#58;	3042ffff 	andi	v0,v0,0xffff
Note that COLOR565_asm and COLOR565_union are quite similar.

hehe, thanks for your code

I am trying to use videocodec.prx to decode xvid and avc.

I had found out how to decode xvid frame,
and I am finding how to use sceMpegBaseYCrCbCopyVme to copy the decoded data in ME ram.
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

here is my test code

it can decode the xvid frame data in "Test.dat"( just a frame)
but when I use "sceMpegBaseYCrCbCopyVme", it crash. :(

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <psppower.h>
#include <stdio.h>
#include <stdlib.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <psppower.h>
#include <pspdebug.h>
#include <psprtc.h>
#include <pspsdk.h>
#include <pspaudiocodec.h>
#include <pspaudio.h>
#include <string.h>
#include <malloc.h>
#include <pspmpeg.h>
#include "pspvideocodec.h"

int SetupCallbacks&#40;&#41;;

PSP_MODULE_INFO&#40;"videocodec test", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

__attribute__ &#40;&#40;constructor&#41;&#41;
void loaderInit&#40;&#41;&#123;
	pspKernelSetKernelPC&#40;&#41;;
	pspSdkInstallNoDeviceCheckPatch&#40;&#41;;
	pspSdkInstallNoPlainModuleCheckPatch&#40;&#41;;
	pspSdkInstallKernelLoadModulePatch&#40;&#41;;
&#125;

SceCtrlData input;

unsigned long Video_Codec_BufferMP4V&#91;96&#93; __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;
unsigned long Video_Codec_BufferAVC1&#91;96&#93; __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;
unsigned long Video_YUVCodec_BufferMP4V&#91;12&#93;  __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;
unsigned char YUVBuffer&#91;512*512*3&#93;  __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;


int main&#40;void&#41;
&#123;
	SetupCallbacks&#40;&#41;;
	
	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenSetXY&#40;0, 2&#41;;
	//scePowerSetClockFrequency&#40;120,120,60&#41;;
	//scePowerSetCpuClockFrequency&#40;120&#41;;
	//scePowerSetBusClockFrequency&#40;60&#41;;
	u32 cpu = scePowerGetCpuClockFrequency&#40;&#41;;
	u32 bus = scePowerGetBusClockFrequency&#40;&#41;;
	
	pspDebugScreenPrintf&#40;"cpu=%d, bus=%d\n", cpu, bus&#41;;
	
	pspDebugScreenPrintf&#40;"Press any key to exit.\n"&#41;;
	
	int result;
	
	result = pspSdkLoadStartModule&#40;"flash0&#58;/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;result < 0 &#41; goto wait;
	
	result = pspSdkLoadStartModule&#40;"flash0&#58;/kd/videocodec.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;result < 0 &#41; goto wait;
	
	result = pspSdkLoadStartModule&#40;"flash0&#58;/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;result < 0 &#41; goto wait;
	
	result = pspSdkLoadStartModule&#40;"flash0&#58;/kd/mpegbase.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;result < 0 &#41; goto wait;
	
	result = pspSdkLoadStartModule&#40;"flash0&#58;/kd/mpeg_vsh.prx", PSP_MEMORY_PARTITION_USER&#41;;
	if &#40;result < 0 &#41; goto wait;
	
	pspSdkFixupImports&#40;result&#41;;
	
	sceMpegInit&#40;&#41;;
	
	FILE* fp = fopen&#40;"ms0&#58;/Test.dat", "rb"&#41;;
	fseek&#40;fp, 0, PSP_SEEK_END&#41;;
	long fsize = ftell&#40;fp&#41;;
	long buffer_size = fsize;
	int mod_64 = buffer_size & 0x3f;
	if &#40;mod_64 != 0&#41; buffer_size += 64 - mod_64;
	unsigned char* file_buffer = memalign&#40;64, buffer_size&#41;;
	fseek&#40;fp, 0, PSP_SEEK_SET&#41;;
	fread&#40;file_buffer, fsize, 1, fp&#41;;
	fclose&#40;fp&#41;;

	
	memset&#40;Video_Codec_BufferMP4V, 0, sizeof&#40;Video_Codec_BufferMP4V&#41;&#41;;
	
	int res ;
	int i;
	
	//---------------------------------------------------------------------------------//
	Video_Codec_BufferMP4V&#91;4&#93; = &#40;unsigned long&#41;&#40;&#40;&#40;void*&#41;Video_Codec_BufferMP4V&#41; + 128 &#41;;
	Video_Codec_BufferMP4V&#91;11&#93; = 512;
	Video_Codec_BufferMP4V&#91;12&#93; = 512;
	Video_Codec_BufferMP4V&#91;13&#93; = 512*512;
	
	fp = fopen&#40;"ms0&#58;/sceVideocodecOpen&#40;mp4v&#41;.dat", "wb"&#41;;
	for&#40;i=0;i<96;i++&#41; &#123;
		fwrite&#40; &Video_Codec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	fclose&#40;fp&#41;;
	if &#40; &#40;res = sceVideocodecOpen&#40;Video_Codec_BufferMP4V, 0x1&#41;&#41; < 0 &#41; &#123;
		pspDebugScreenPrintf&#40;"sceVideocodecOpen=0x%08X\n", res&#41;;
		goto wait;
	&#125;
	pspDebugScreenPrintf&#40;"sceVideocodecOpen=0x%08X\n", res&#41;;
	
	//---------------------------------------------------------------------------------//
	Video_Codec_BufferMP4V&#91;7&#93; = 16384;
	
	fp = fopen&#40;"ms0&#58;/sceVideocodecGetEDRAM&#40;mp4v&#41;.dat", "wb"&#41;;
	for&#40;i=0;i<96;i++&#41; &#123;
		fwrite&#40; &Video_Codec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	fclose&#40;fp&#41;;
	if &#40; &#40;res = sceVideocodecGetEDRAM&#40;Video_Codec_BufferMP4V, 0x1&#41;&#41; < 0 &#41; &#123;
		pspDebugScreenPrintf&#40;"sceVideocodecGetEDRAM=0x%08X\n", res&#41;;
		goto wait;
	&#125;
	pspDebugScreenPrintf&#40;"sceVideocodecGetEDRAM=0x%08X\n", res&#41;;
	
	//---------------------------------------------------------------------------------//
	fp = fopen&#40;"ms0&#58;/sceVideocodecInit&#40;mp4v&#41;.dat", "wb"&#41;;
	for&#40;i=0;i<96;i++&#41; &#123;
		fwrite&#40; &Video_Codec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	fclose&#40;fp&#41;;
	if &#40; &#40;res = sceVideocodecInit&#40;Video_Codec_BufferMP4V, 0x1&#41;&#41; < 0 &#41; &#123;
		pspDebugScreenPrintf&#40;"sceVideocodecInit=0x%08X\n", res&#41;;
		goto wait;
	&#125;
	pspDebugScreenPrintf&#40;"sceVideocodecInit=0x%08X\n", res&#41;;
	
	//---------------------------------------------------------------------------------//
	Video_Codec_BufferMP4V&#91;34&#93; = 7;
	Video_Codec_BufferMP4V&#91;36&#93; = 0;
	
	fp = fopen&#40;"ms0&#58;/sceVideocodecStop&#40;mp4v&#41;.dat", "wb"&#41;;
	for&#40;i=0;i<96;i++&#41; &#123;
		fwrite&#40; &Video_Codec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	fclose&#40;fp&#41;;
	if &#40; &#40;res = sceVideocodecStop&#40;Video_Codec_BufferMP4V, 0x1&#41;&#41; < 0 &#41; &#123;
		pspDebugScreenPrintf&#40;"sceVideocodecStop=0x%08X\n", res&#41;;
		goto wait;
	&#125;
	pspDebugScreenPrintf&#40;"sceVideocodecStop=0x%08X\n", res&#41;;
	
	//---------------------------------------------------------------------------------//
	Video_Codec_BufferMP4V&#91;9&#93; = file_buffer;
	Video_Codec_BufferMP4V&#91;10&#93; = fsize;
	Video_Codec_BufferMP4V&#91;14&#93; = 7;
	
	fp = fopen&#40;"ms0&#58;/sceVideocodecDecode&#40;mp4v&#41;.dat", "wb"&#41;;
	for&#40;i=0;i<96;i++&#41; &#123;
		fwrite&#40; &Video_Codec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	fclose&#40;fp&#41;;
	if &#40; &#40;res = sceVideocodecDecode&#40;Video_Codec_BufferMP4V, 0x1&#41;&#41; < 0 &#41; &#123;
		pspDebugScreenPrintf&#40;"sceVideocodecDecode=0x%08X\n", res&#41;;
		goto wait;
	&#125;
	pspDebugScreenPrintf&#40;"sceVideocodecDecode=0x%08X\n", res&#41;;
	
	Video_YUVCodec_BufferMP4V&#91;0&#93; = &#40;Video_Codec_BufferMP4V&#91;45&#93;+15&#41; & 0xFFFFFFF0;
	Video_YUVCodec_BufferMP4V&#91;1&#93; = &#40;Video_Codec_BufferMP4V&#91;44&#93;+15&#41; & 0xFFFFFFF0;
	Video_YUVCodec_BufferMP4V&#91;2&#93; = 0;
	Video_YUVCodec_BufferMP4V&#91;3&#93; = 1;
	Video_YUVCodec_BufferMP4V&#91;4&#93; = Video_Codec_BufferMP4V&#91;53&#93;;
	Video_YUVCodec_BufferMP4V&#91;5&#93; = Video_YUVCodec_BufferMP4V&#91;4&#93; + &#40;Video_Codec_BufferMP4V&#91;56&#93; * &#40;Video_YUVCodec_BufferMP4V&#91;0&#93;/2&#41;&#41;; 
	Video_YUVCodec_BufferMP4V&#91;6&#93; = Video_Codec_BufferMP4V&#91;54&#93;;
	Video_YUVCodec_BufferMP4V&#91;7&#93; = Video_Codec_BufferMP4V&#91;55&#93;;
	Video_YUVCodec_BufferMP4V&#91;8&#93; = Video_YUVCodec_BufferMP4V&#91;6&#93; + &#40;Video_Codec_BufferMP4V&#91;57&#93; * &#40;Video_YUVCodec_BufferMP4V&#91;0&#93;/4&#41;&#41;;
	Video_YUVCodec_BufferMP4V&#91;9&#93; = Video_YUVCodec_BufferMP4V&#91;7&#93; + &#40;Video_Codec_BufferMP4V&#91;57&#93; * &#40;Video_YUVCodec_BufferMP4V&#91;0&#93;/4&#41;&#41;;
	Video_YUVCodec_BufferMP4V&#91;10&#93; = 0;
	Video_YUVCodec_BufferMP4V&#91;11&#93; = 0;
	
	fp = fopen&#40;"ms0&#58;/sceMpegBaseYCrCbCopyVme&#40;mp4v&#41;.dat", "wb"&#41;;
	for&#40;i=0;i<12;i++&#41; &#123;
		fwrite&#40; &Video_YUVCodec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	fclose&#40;fp&#41;;
	
	res = sceMpegBaseYCrCbCopyVme&#40;YUVBuffer, Video_YUVCodec_BufferMP4V, 3&#41;;
	pspDebugScreenPrintf&#40;"sceMpegBaseYCrCbCopyVme=0x%08X\n", res&#41;;
	
	fp = fopen&#40;"ms0&#58;/YUVBuffer&#40;mp4v&#41;.dat", "wb"&#41;;
	fwrite&#40; YUVBuffer, sizeof&#40;unsigned char&#41;, 512*512*3, fp&#41;;
	fclose&#40;fp&#41;;
	
	//---------------------------------------------------------------------------------//	
	sceCtrlReadBufferPositive&#40;&input, 1&#41;;
	while&#40;!&#40;input.Buttons & PSP_CTRL_TRIANGLE&#41;&#41;
	&#123;
		sceKernelDelayThread&#40;10000&#41;;	// wait 10 milliseconds
		sceCtrlReadBufferPositive&#40;&input, 1&#41;;
	&#125;
	
	fp = fopen&#40;"ms0&#58;/mp4vend.dat", "wb"&#41;;
	for&#40;i=0;i<96;i++&#41; &#123;
		pspDebugScreenPrintf&#40;"0x%08X ", Video_Codec_BufferMP4V&#91;i&#93;&#41;;
		fwrite&#40; &Video_Codec_BufferMP4V&#91;i&#93;, sizeof&#40;unsigned int&#41;, 1, fp&#41;;
	&#125;
	pspDebugScreenPrintf&#40;"\n"&#41;;
	fclose&#40;fp&#41;;

wait&#58;
	sceCtrlReadBufferPositive&#40;&input, 1&#41;;
	while&#40;!&#40;input.Buttons & PSP_CTRL_TRIANGLE&#41;&#41;
	&#123;
		sceKernelDelayThread&#40;10000&#41;;	// wait 10 milliseconds
		sceCtrlReadBufferPositive&#40;&input, 1&#41;;
	&#125;
	
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;


/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;


/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;

	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;


/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

Code: Select all

/*
 * PSP Software Development Kit - http&#58;//www.pspdev.org
 * -----------------------------------------------------------------------
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
 *
 * pspvideocodec.h - Prototypes for the sceVideocodec library.
 *
 * Copyright &#40;c&#41; 2007 cooleyes
 *
 */

#ifdef __cplusplus
extern "C" &#123;
#endif

int sceVideocodecOpen&#40;unsigned long *Buffer, int Type&#41;;
int sceVideocodecGetEDRAM&#40;unsigned long *Buffer, int Type&#41;;
int sceVideocodecInit&#40;unsigned long *Buffer, int Type&#41;;
int sceVideocodecDecode&#40;unsigned long *Buffer, int Type&#41;;
int sceVideocodecReleaseEDRAM&#40;unsigned long *Buffer&#41;;
int sceMpegBaseYCrCbCopyVme&#40;void* YUVBuffer, unsigned long *Buffer, int Type&#41;;

#ifdef __cplusplus
&#125;
#endif
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

fp = fopen("ms0:/sceVideocodecStop(mp4v).dat", "wb");

you do this alot ...why?
10011011 00101010 11010111 10001001 10111010
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

dot_blank wrote:fp = fopen("ms0:/sceVideocodecStop(mp4v).dat", "wb");

you do this alot ...why?
just to save the codecbuffer to a file after a function call.
Post Reply