Make 'Ys I & II Eternal Story' playable.
Posted on 2006-01-20 00:00:00
Been working on the decoding of the blocks. I added the inverse scan processing and added a temporary IDCT step.

But after testing a bit more, I found a little problem with the decoding an "escape" DCT coefficient VLC code. The MPEG-2 ISO standard says the 6-bits following this code shall be the value for "run" and and next 12-bits the value for "level". But that didn't fit quite well with the bit stream I was testing my code with. After some search I found out that my bit stream was not an MPEG-2 compilant stream but rather an MPEG-1 one. The definition of "escape" is different with this standard (8-bits for "level" instead of 12-bits). There's supposedly a 16-bits variant of this, but I wasn't able to find much information about it. The 8-bits version works fine with the stream I've tested.

I'll need to add some bit stream version detection later on, because the standards are incompatible on this precise thing and maybe more. A major difference between an MPEG-1 and MPEG-2 stream is that the MPEG-2 stream is required to have a "sequence_extension" block while the MPEG-1 mustn't have one. I'll be using this difference to detect which type of bit stream it is. The MPEG decoder library running on the PS2 probably uses this too to set the MP1 bit of the IPU_CTRL register properly.

After some other minor fixes with the coefficient decoding, my experimental MPEG-2 decoder can succesfully decode all the blocks present in this small test MPEG-1 bit stream. I've tested the movie being played in the game too (which is also an MPEG-1 bit stream), but this one uses some B-pictures with motion vectors, which I haven't bothered to touch yet, and won't work properly.

I'm going to leave the experimental decoder for a while and try to add the BDEC command emulation in the the emulator. I didn't do much yet though... Just added the function skeleton of the function that will do the block decoding and added the DC predictor reset functionality. I'll try to get the decoding of DCT coefficients of an intra macroblock working tomorrow. I'll add the post-processing of the block (dequantise, inverse scan, IDCT) afterwards.

The test bit stream I've been using is available here.