| View previous topic :: View next topic |
| Author |
Message |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 18, 2006 4:31 am Post subject: sceAudiocodec anyone ? |
|
|
I noticed that this driver (which purpose is to decode atrac3 datas into PCM, which could prove to be most useful as it operates on the media engine) is available within gta via the atrac3plus library but as the library itself is loaded in user space (0x8E65500 on 2.6) it may be overwritten so i thought about using the driver directly, the relevant syscalls used by gta are (+ some others for streaming from the umd):
sceAudiocodec_9d3f790c located at: 0x08E68CE4 (8 bytes)
sceAudiocodecInit located at: 0x08E68CEC (8 bytes)
sceAudiocodecDecode located at: 0x08E68CF4 (8 bytes)
sceAudiocodecGetEDRAM located at: 0x08E68CFC (8 bytes)
sceAudiocodecReleaseEDRAM located at: 0x08E68D04 (8 bytes)
I've started to disassemble both the library and the driver and found out a way to use sceAudiocodec_9d3f790c, sceAudiocodecGetEDRAM & sceAudiocodecInit by using them with like that:
| Code: |
// These two first ones are called during sceAtracStartEntry
ret = sceAudiocodec_9d3f790c(At3_Buffer, 0x1001);
ret = sceAudiocodecGetEDRAM(At3_Buffer, 0x1001);
ret = sceAudiocodecInit(At3_Buffer, 0x1001);
|
At3_Buffer is a 328 bytes buffer (probably a structure).
0x1001 is the type of stream to decode (0x1001 = AT3 / 0x1000 = AT3+).
Everything goes fine until and each function return a 0 value (maybe they shouldn't ?) but sceAudiocodecDecode doesn't work and returns 0x807f0002 error value), i looked in the memory dump to see how the atrac3 library initialized that At3_Buffer but no matter what i tried it still doesn't work.
The first thing i can't figure out yet is where to pass the addresses of the at3 block to decode and where it'll be decoded.
From what i've seen, there is 4 blocks used by the attrac3 grouped by 2 depending on the passed ID (prolly 2 for the atrac3 & 2 for the atrac3plus which seem to be different formats).
Most probably At3_Buffer must be filled by hand with some values but i don't know which ones yet.
The functions themselves write datas to the buffer:
sceAudiocodec_9d3f790c:
05012801 at offset 0
00003de0 at offset 0x10
sceAudiocodecGetEDRAM:
001dfbc0 at offset 0xc
001dfb94 at offset 0x68
sceAudiocodecInit:
0000ac44 at offset 0x2c
00001000 at offset 0x30
Anyone have some experience with this one or is interested to work on it too ? |
|
| Back to top |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Sun Jun 18, 2006 9:40 pm Post subject: |
|
|
| maybe you want to take a look at this topic ? |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 18, 2006 10:02 pm Post subject: |
|
|
I'm well aware of this thread but i'm talking about playing atrac3 file in USER mode which isn't what moonlight's example is doing afaik (it doesn't work on my 2.6 at least).
You see, i plan to release stuff for that little black box and leaving it's second processor sitting there and doing nothing is totally unacceptable to me and as a bottom condition it must be compatible with 2.01+ & 1.5 otherwise there's no point in releasing anything. |
|
| Back to top |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Sun Jun 18, 2006 10:34 pm Post subject: |
|
|
actually i already have some code (thx tyr) that should load the modules and fix the imports in usermode.
just haven't found the time and a volunteer (with fw 2.x and gta) to test it. wanna volunteer? ;) |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 18, 2006 10:36 pm Post subject: |
|
|
| Sure. |
|
| Back to top |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Sun Jun 18, 2006 11:05 pm Post subject: |
|
|
| thx, you got pm. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 18, 2006 11:14 pm Post subject: |
|
|
| Nothing reached the box yet. |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Jun 19, 2006 1:30 am Post subject: |
|
|
| weak wrote: | actually i already have some code (thx tyr) that should load the modules and fix the imports in usermode.
just haven't found the time and a volunteer (with fw 2.x and gta) to test it. wanna volunteer? ;) |
GTA should have the to have the atrac3 library loaded like all games do (you know, in user mode you can load almost everything from a disc). So there must be a way without using the sceAudioCodec, although it would be educational to find how to use it.
EDIT: ok i didn't read all the first message. You say that the library could be overwritten. But maybe it can be loaded twice like it's possible with some modules. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Mon Jun 19, 2006 1:57 am Post subject: |
|
|
I didn't try to use the atrac3 which is in memory because this lib uses Kernel_Library which is loaded in user space and is apparently overwritten.
Also i don't know how to load and start modules files from the umd (the method used in your atrac3 example doesn't work even when i tried to load them from the umd),
i'm not even sure that gta does load these two prx because libatrac3plus & audiocodec are already present in the firmware so they may just be loaded at startup by the vsh or something (it may load sc_sascore.prx tho as it doesn't seem to be included in the fw).
+ libatrac3 eats memory. |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Jun 19, 2006 2:18 am Post subject: |
|
|
| No, the atrac3 libraries and the rest of prx's in a game are always loaded from the disc. I don't know if they use the SceKernelLMOption structure, but for sure that you can load those modules from a disc in user mode. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Mon Jun 19, 2006 6:00 am Post subject: |
|
|
Ok here we go, this is the way the prx are loaded in GTA:
| Code: |
SceKernelLMOption Load_Option;
SceKernelSMOption Start_Option;
SceUID hModule_ID;
SceUID hModule;
SceUID hFile;
int Status;
// Located at 0x229980
memset(&Load_Option, 0, sizeof(SceKernelLMOption));
Load_Option.size = sizeof(SceKernelLMOption);
Load_Option.mpidtext = PSP_MEMORY_PARTITION_USER;
Load_Option.mpiddata = PSP_MEMORY_PARTITION_USER;
Load_Option.access = 1; // ???
// Located at 0x229BCC
memset(&Start_Option, 0, sizeof(SceKernelSMOption));
Start_Option.size = sizeof(SceKernelSMOption);
Start_Option.stacksize = 16 * 1024;
Start_Option.priority = 32;
hModule_ID = sceIoOpen("disc0:/PSP_GAME/USRDIR/PRX2_0_0/MOD/LIBATRAC3PLUS.PRX", PSP_O_RDONLY, 0);
hModule = sceKernelLoadModuleByID(hModule_ID, 0, &Load_Option);
int ret = sceKernelStartModule(hModule, 0, NULL, &Status, &Start_Option);
|
And this doesn't work, sceKernelLoadModuleByID returns error 80020139 (the only reference to this error i could find on the web is: 80020139 - exclusive load).
I guess the modules can't be opened twice but apparently i can't stop / unload them anyway so this bring me back to the start of this topic. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Tue Jun 20, 2006 3:46 am Post subject: |
|
|
| Oki, i found out how to replay atrac3 files on 2.6, so never mind, thanks for the help. |
|
| Back to top |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Tue Jun 20, 2006 5:22 am Post subject: |
|
|
| hitchhikr wrote: | | Oki, i found out how to replay atrac3 files on 2.6, so never mind, thanks for the help. |
would be nice if you could tell us how exactly :) |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Tue Jun 20, 2006 9:55 am Post subject: |
|
|
There you have it:
http://perso.orange.fr/franck.charlet/temp/AT3_Replay.zip
I reproduce here the content of the readme.txt in extenso:
ATRAC3 files replay preview for firwmware 1.5 & GTA
Written by hitchhikr/Neural.
It's only a preview (so DON'T use it yet !),
I don't know if it works on 1.5 yet (tell me if it does or not).
It does some dirty hacks to obtain sceAudioCodec NIDs that should be fixed in fanjita's eloader.
Notice that this won't work if run from the menu, the emenu--.pbp need to be replaced with our file
as it erases the atrac3 library before we could retrieve the syscalls of the sceAudioCodec.
So:
- pspAudioCodec_Lib/libpspAudioCodec.a should be copied in your \pspdev\psp\sdk\lib.
- When running under GTA \AT3_Replay\AT3_Replay\EBOOT.PBP should replace the emenu--.pbp (or whatever it is called).
located on the memory stick in \PSP\eloader.
- "Makke - Artura.at3" must copied in ms0:/
It must be used like this:
--------------------------------------------
#include "AT3.h"
#include "AT3.c"
#define FILENAME "ms0:/Makke - Artura.at3"
#define FILENAME_LENGTH 2288712
unsigned char Tune[FILENAME_LENGTH] __attribute__((aligned(16)));
// Load the file & init the replay
SceUID handle = sceIoOpen(FILENAME, PSP_O_RDONLY, 0);
sceIoRead(handle, Tune, FILENAME_LENGTH);
sceIoClose(handle);
AT3_Init(Tune, FILENAME_LENGTH, 1);
// Start replaying
AT3_Play(1);
// Free the resources
AT3_Stop();
--------------------------------------------
Makke - Artura.at3 (atrac3 132 kbps).
Copyright (c) 2005 Marcus Nilsson (http://makke.c64.org/).
I'd like to know if this is working on 1.5 and with GTA too, of course (if it doesn't within your GTA, things should be resolved as soon as the nids are implemented in the eloader, i think). |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Tue Jun 20, 2006 10:31 am Post subject: |
|
|
hey thanx very much that is very cool how you
can play at3 in usermode ....very good indeed
just tested on 1.5 ...and no it dont work ...simply
the sceAudioCodec NIDs are not the same for 1.5
this can be easily fixed ...but you do not include main.c
source file so please do post that soon :)
and Makefile ....libpspAudioCodec you provide is excellent _________________ 10011011 00101010 11010111 10001001 10111010 |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Tue Jun 20, 2006 10:51 am Post subject: |
|
|
Yeah i noticed there's trouble on 1.5, what do you mean the nids are differents ? Shouldn't the vsh fix the syscalls from the nids when loading the pbp or does it need the driver to be loadded & started manually ?
I think the problem may come from somewhere else.
Actually, you can easily recreate a main.c. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Wed Jun 21, 2006 5:14 am Post subject: |
|
|
| Uploaded a new version, hopefully this one will work a little bit better. (also i added the main.c) |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Wed Jun 21, 2006 5:44 am Post subject: |
|
|
| Good job!! Very educative :) |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Wed Jun 21, 2006 7:55 am Post subject: |
|
|
indeed
great :) _________________ 10011011 00101010 11010111 10001001 10111010 |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Sun Jun 25, 2006 3:12 am Post subject: Re: sceAudiocodec anyone ? |
|
|
| hitchhikr wrote: |
At3_Buffer is a 328 bytes buffer (probably a structure).
0x1001 is the type of stream to decode (0x1001 = AT3 / 0x1000 = AT3+).
|
0x1002 = MP3
It seems that it may be possible to decode MP3 through hardware :) |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Sun Jun 25, 2006 3:39 am Post subject: |
|
|
| That would be kick-ass :) |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 25, 2006 12:32 pm Post subject: |
|
|
| Quote: |
0x1002 = MP3
It seems that it may be possible to decode MP3 through hardware :)
|
There seem to be some handling for a 0x1004 type too, so assuming the xmb is using the audiocodec.prx to decode all audio files when replaying them that type may be for WMA, the structure passed to the driver is surely different, tho.
Notice that GTA loads videocodec.prx, mpegbase.prx & mpeg.prx (the later one isn't present in the firmware and i don't know how to access the first two but gta probably accesses to them via mpeg.prx (sceMpeg)).
I released a new version of the replay available here:
http://perso.orange.fr/franck.charlet/AT3_Replay.zip
I modified the datas passed to the audiocodec driver to match those produced by the libatrac3plus, hopefully it'll be more compatible now.
I'd like to know if this one work on other psp than mine (2.6),
thanks. |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Sun Jun 25, 2006 1:45 pm Post subject: |
|
|
| hitchhikr wrote: |
I released a new version of the replay available here:
http://perso.orange.fr/franck.charlet/AT3_Replay.zip
I modified the datas passed to the audiocodec driver to match those produced by the libatrac3plus, hopefully it'll be more compatible now.
I'd like to know if this one work on other psp than mine (2.6),
thanks. |
Still no go on 1.5 for me.
I'd really like to see the ability to play back at3 on all firmwares. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 25, 2006 3:12 pm Post subject: |
|
|
It would help to know what's going on with the 1.5, like is there something displayed or moving on the screen ?
What are the return values of sceAudiocodec_9d3f790c, sceAudiocodecGetEDRAM, sceAudiocodecInit & sceAudiocodecDecode ?
Also it would be good to know if audiocodec.prx is really loaded as excepted. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Sun Jun 25, 2006 7:25 pm Post subject: |
|
|
| Never mind, i think i figured out the problem. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
|
| Back to top |
|
 |
Gizmo
Joined: 05 Feb 2005 Posts: 14
|
Posted: Mon Jun 26, 2006 11:45 am Post subject: |
|
|
Tryed this on 1.5 (copied the eboot folders into GAME and the at3 in the MS root). All I get is a black screen, no sound - no reaction to any button. Doesn't shut down automatically so I have to hold the power button for a while.
:-( |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Jun 26, 2006 3:03 pm Post subject: |
|
|
| Quote: |
IMPORT_FUNC "sceAudioCodec",0xDEADBEEF,sceAudiocodec_9d3f790c
|
? |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Mon Jun 26, 2006 6:38 pm Post subject: |
|
|
| moonlight wrote: | | Quote: |
IMPORT_FUNC "sceAudioCodec",0xDEADBEEF,sceAudiocodec_9d3f790c
|
? |
It's just used as a place holder to avoid confusing the search routine. The stategy is to load the audiocodec.prx first then libatrac3plus.prx, let the kernel to fix the syscalls then search for them in the atrac3 library loaded in user mode & retrieve them (they're already loaded in gta). While it works perfectly on 2.6, it doesn't on 1.5 because apparently i need kernel access to load the prx but i can't use them in such mode and need an user app to do so, i think moving the replay code into an user mode prx will work fine, i didn't know that & that's wicked shit IMHO. |
|
| Back to top |
|
 |
hitchhikr
Joined: 04 Feb 2006 Posts: 83
|
Posted: Tue Jun 27, 2006 7:30 pm Post subject: |
|
|
http://perso.orange.fr/franck.charlet/AT3_Replay.zip
Both the .at3 and the prx must be copied in ms0:/
If it doesn't work on 1.5 i'd really really really like someone skilled enough to tell me what's happening with this bloody firmware. |
|
| Back to top |
|
 |
|