jPSXdec is a cross-platform PlayStation 1 media decoder/converter.
Get the latest version here.

Sunday, January 20, 2008

PSX YCbCr to yuv4mpeg2

PSX YCbCr

Given Y, Cb, and Cr color range of [-128, 127].
                              PSX
[ 1 0 1.402 ] [ Y + 128 ] [ r ]
[ 1 -0.3437 -0.7143 ] * [ Cb ] = [ g ]
[ 1 1.772 0 ] [ Cr ] [ b ]

yuv4mpeg2 (i.e. Rec.601) YCbCr

Given Y color range of [16, 235] and Cb,Cr color range of [16, 240].
                              Rec.601
[ 1.164 0 1.59 ] [ Y - 16 ] [ r ]
[ 1.164 -0.391 -0.813 ] * [ Cb - 128 ] = [ g ]
[ 1.164 2.018 0 ] [ Cr - 128 ] [ b ]

To convert a PSX YCbCr color to a Rec.601 YCbCr color:

[ 1 -3415973/13224846875 1242172/13224846875 ]
[ 0 105814197/105798775 -5608/105798775 ]
[ 0 19492/105798775 105791687/105798775 ]


Answer: yuv4mpeg2^-1 * PSX =
[ 1 3415973/13225888625 -1242172/13225888625 ]
[ 0 105791687/105807109 5608/105807109 ]
[ 0 -19492/105807109 105814197/105807109 ]


Rec601_YCbCr =
PSX
[Y + 128] [ 16]
Rec601_Matrix^-1 * PSX_Matrix * [Cb ] + [128]
[Cr ] [128]
Where
Rec601_Matrix^-1 * PSX_Matrix =

[250/291 -488509/2660418030 -82738/1330209015]
[0 4014411/4571165 164/4571165]
[0 3673/27426990 8031459/9142330]

Thanks to toruvinn for refreshing me on matrix math, and this site and Maxima for saving me from lots of raw calculations.

Update 27Feb2010: Fixed.
Update 23Mar2010: Really fixed.

Sunday, January 6, 2008

HATSUHINODE

Hope all had a pleasant new year. As we enter 2008, it is interesting to note that this year marks the 10th anniversary of the Serial Experiments Lain anime series, along with the Playstation game.

Now that holidays are over, I finally managed to release the latest compiled executable on the download page. No changes to the program interface (same wonderful command-line that you're used to ;), but it has all the latest internal goodness that I hope actually works--most notable is it now [edit] mostly supports FF8 (it would help to fully test it before making such calims :P).