tirsdag 17. februar 2009

H.264 at 1080p with NVIDIA's VDPAU on Linux

NVIDIA released support for their Video Decode and Presentation API for Unix with version 180.06 of their video and OpenGL driver for Xorg. They have also released patches to MPlayer so we can actually use it. I have tried getting it to work on my Gentoo GNU/Linux x86_64, but with the earliest drivers I got a green video window followed by a Xorg freeze with my graphics card. I had to SSH into the computer and kill MPlayer and Xorg. One of the versions even froze the kernel up completely. Version 180.27 actually didn't freeze my computer, put instead of the decoded video I got a random mosaic of colors.

With version 180.29 it did function properly with my XFX GeForce 280 GTX XXX graphics card. It's working great, and I can play H.264 1080p video with MPlayer using only 3% of a single CPU core!

To get VDPAU working you need, as I mentioned, a recent driver and at least version 180.06. Also you need a patched MPlayer, witch you can obtain the sources for here. Get the header files under "include" as well, and unpack the tarball and run the script checkout-patch-build.sh to retrieve MPlayer sources, patches and compile it all. As it is now (version 3482714), the VDPAU patches need additional patching to be able to play H.264 video above level 4.1:


--- libvo/vo_vdpau.c.orig 2009-02-17 15:03:25.936006847 +0100
+++ libvo/vo_vdpau.c 2009-02-17 18:43:43.995005259 +0100
@@ -90,7 +90,7 @@
/* Numbers of video and ouput Surfaces */
#define NUM_OUTPUT_SURFACES 3
#define NUM_VIDEO_SURFACES_MPEG2 3 // (1 frame being decoded, 2 reference)
-#define NUM_VIDEO_SURFACES_H264 17 // (1 frame being decoded, up to 16 references)
+#define NUM_VIDEO_SURFACES_H264 18 // (1 frame being decoded, 16 reference frames, plus b_frames and b_pyramid)
#define NUM_VIDEO_SURFACES_VC1 3 // (same as MPEG-2)
#define NUM_VIDEO_SURFACES_NON_ACCEL_YUV 1 // surfaces for YV12 etc.
#define NUM_VIDEO_SURFACES_NON_ACCEL_RGB 0 // surfaces for RGB or YUV4:4:4
@@ -701,10 +701,7 @@
uint32_t round_width = (vid_width + 15) & ~15;
uint32_t round_height = (vid_height + 15) & ~15;
uint32_t surf_size = (round_width * round_height * 3) / 2;
- max_references = (12 * 1024 * 1024) / surf_size;
- if (max_references > 16) {
- max_references = 16;
- }
+ max_references = 16; // Support for H.264 Level 5.1
}
break;
default:

mandag 16. februar 2009

CueCat USB barcode scanner hacked!

Last week I ordered a CueCat USB barcode scanner from LibraryThing. Today I gave it a first try, on my new book Pragmatic Version Control Using Git. Eager to try my new toy that I had envisioned to ease the process of adding my books to a database I plugged it in, observed that it was recognised as a HID, tried to scan the barcode, and out came this gibberish: .C3nZC3nZC3n2C3P3DxP6DxnY.fHmc.E3zXDhv1C3nYDNzY.

Quite disappointed, I realized that this thing might not be easily used with Linux after all. I searched on Google for CueCat, and soon realized that the stupid scanner outputs a serial number unique to this scanner, followed by the type of barcode and finally the barcode number, and all this is encrypted with CueCat's sophisticated "XOR with C"-cipher:
#!/usr/bin/perl -n 
# Copyright: Larry Wall
printf "Serial: %s Type: %s Code: %s\n",
map {
tr/a-zA-Z0-9+-/ -_/;
$_ = unpack 'u', chr(32 + length()*3/4) . $_;
s/\0+$//;
$_ ^= "C" x length;
} /\.([^.]+)/g;


So I foresaw that this dongle was going to be a pain to use. But after some more reading, I came across this page that shows me how to hack the CueCat and disable the encryption alltogether. So disassembled the device and cut pin number 5, like this:


After reassembling the scanner, I tried it on my book again. And lo and behold, there was the real ISBN number I had been looking for: 9781934356159!

lørdag 14. februar 2009

BuyPass switces to Java to interface with SmartCard

BuyPass is switching to using a Java implementation to interface with their BuyPass SmartCards. This is good news for everyone using a 64-bit Linux operating system. Their current access library called jnipcsc is only available for 32-bit architectures, and even then it's a pain to get working. They estimate that the new version of the BuyPass Java applet is ready for release in march 2009.