jPSXdec is a cross-platform PlayStation 1 media decoder/converter.
Get the latest version here.
Showing posts with label Playstation. Show all posts
Showing posts with label Playstation. Show all posts

Monday, September 6, 2010

PlayStation Video Decoders:
The Final Showdown

Updated from the previous comparison with the lastest versions, and three new decoders!

Most importantly, I finally captured what it ACTUALLY looks like on PlayStation hardware (in the dead center).

Those on top get it (more) correct, those on the bottom get it (more) wrong (and ffmpeg and Q-gears are just weird).

Naturally jPSXdec dominates in quality and accuracy. :)

The lineup:See the download for all the jucy (and technical) details.

Saturday, October 24, 2009

PSX Video Converter Deathmatch


UPDATE: This comparison has been superseded by a newer one

I took 8 different video converters and lined them up for the showdown of the decade!
Ok, so it's not really that dramatic. Some points of interest:
  • PCSX shows the most amount of blocky artifacts, which is understandable because its converter was designed for speed over quality.
  • PsxMC, PSmplay, PsxTulz, and PCSX all show very similar coloring. PsxMC and PSmplay are especially similar; however, they are not pixel exact matches.
  • Q-gears seems to have the darkest and warmest colors of them all, while ffmpeg is the brightest.
  • jPSXdec seems to produce softer images than the others, and its colors are quite similar to PSXPlay.
The differences may not seem very apparent side-by-side, but if you align the images on top of each other (like layers) then toggle the top image's visibility, the differences really stand out.

Now which is the most accurate? That depends on your definition of accurate.
  1. Do you want the exact values the PlayStation 1 hardware produces?
  2. Do you want it to match how you see it on the television?
  3. Do you want it to more closely resemble what the original designer created?
  4. Do you want a more mathematically precise conversion?
I don't have modded PlayStation hardware, and I don't have any way to very accurately capture composite video output, so I can't investigate #1 or #2.

You need to have the official Sony PlayStation 1 movie converter tool to investigate #3. If some shifty soul wanted to convert this video to STR and send it to me, I could investigate further. ;)

I made my best effort to ensure jPSXdec is very mathematically accurate, so I can at least recommend jPSXdec if you want #4.

Download all the converted images, along with more details (including some source code) on how I did all the conversions.

25Oct2009: updated download with corrections and included convertible test STR.

23Nov2009: updated download with better PsxTulz screenshot (thanks T_chan!).

Wednesday, September 24, 2008

How to encode quality PlayStation 1 video

Recently I've run across a couple of groups trying to replace the video of a Playstation 1 game. As we have to do the same thing with S.E. Lain, I thought I would share some insight as to how it might be done with the highest quality output.

Since there are many things that go into encoding mpeg video, that step is best left to programs that know how to juggle those options, such as ffmpeg. It also allows you to tweak those options, and use its advanced features to get the best results.

So here is how you do it, broken down into 6 ridiculously complicated steps.

  1. Convert your video into 4:2:0 yuv4mpeg2, but using the PSX specific rgb->yuv conversion.
  2. Feed the yuv4mpeg2 video into ffmpeg at an allowed fps and create a mpeg1 movie with only I-frames (-intra). This should be done at a variety of different quality levels (-qscale from 1 to n).
  3. Parse the I-frames out of the movie and parse their macro-blocks
  4. Convert the mpeg1 VLCs to PSX VLCs
  5. Do this for every mpeg1 quality and pick the one that fits best within the amount of space available to the frame
  6. Multiplex the frames and construct all the sectors

If the new video is mostly just the old video with some changes (e.g. subtitles) then quality can improved tremendously with this variation.

  1. Use some method to determine which macro blocks to replace (manually picking them, or performing a diff on lossless video data, or a fuzzy diff on lossy video data)
  2. Only replace those macro blocks with new ones of the same qscale
  3. If the replaced data makes the frame too big, then either replace the entire frame with an ffmpeg created frame that will fit (qscale will probably be bigger), or remove some quality in the frame to make it smaller
  4. Multiplex the frames and construct all the sectors

Alternatively have ffmpeg write an AVI using MJPG codec and parse the JPEG frames and convert the JPEG VLCs to PSX VLCs (I'm not sure how to get ffmpeg to produce quality variations with the MJPG codec).

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.

Thursday, October 18, 2007

Links

Numerous links were followed during the development of this program. All of these were valid at the time I followed them. I'm just throwing these in here for now. I'll clean it up later.

PSX Tools
http://hitmen.c02.at/html/psx_tools.html
http://members.fortunecity.com/zlasher/files/toolz.html
http://www.psxforum.com/utilities.php
http://www.geocities.com/anapan8/cv/

Decoding links
http://jcatki.no-ip.org/cdxa/
http://www.momentaryfascinations.com/technology/the.spyro.soundtracks.html
http://forums.qhimm.com/index.php?topic=6473.0
http://forums.qhimm.com/index.php?topic=6140.0
http://q-gears.svn.sourceforge.net/viewvc/q-gears/trunk/src/common/movie/decoders/
http://wiki.multimedia.cx/index.php?title=PlayStation_Motion_Decoder
http://osdir.com/ml/video.xine.devel/2003-02/msg00179.html
http://osdir.com/ml/video.xine.devel/2003-02/msg00186.html
http://samples.mplayerhq.hu/game-formats/psx-str/
http://www.koders.com/c/fidF23C1EAFCEAF84CA539927A01093D37D9695722A.aspx

MPEG1 links
http://bmrc.berkeley.edu/research/mpeg/faq/mpeggeneral.html
http://www.chiariglione.org/ride/inside_MPEG-1/inside_MPEG-1.htm
http://www.andrewduncan.ws/MPEG/MPEG-1_Picts.html
http://www.geocities.com/xhelmboyx/quicktime/formats/mpeg-layout.txt
http://www.faqs.org/faqs/mpeg-faq/
http://www.wotsit.org/list.asp?search=mpeg
http://guru.multimedia.cx/the-mpeg124-and-h26123-idct/
http://www.uow.edu.au/~nabg/MPEG/IDCT.html

Other Info
http://forum.digital-digest.com/showthread.php?t=17898
http://www.greenspun.com/bboard/q-and-a-fetch-msg.tcl?msg_id=000tS4
http://groups.google.com/group/alt.games.sony-playstation/browse_thread/thread/3bb9cc7ce10bbb58/02098464ed19f81a?hl=ened19f81a
http://www.megagames.com/psx/psx_copy_patch_linux.shtml
http://rpgd.emulationworld.com/klarth/