Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - d

It looks like I accidentally uploaded an old, broken version of rawc.o. The correct, working version is now at the same URL. If you downloaded it before this reply went up you will need to re-download and and re-link it. Sorry about that.

Also, I noticed a mistake in the example raw_get_pixel posted earlier. The correct shifts for pixels C and F are:

raw->c_lo | (raw->c_hi << 4);
raw->f_lo | (raw->f_hi << 8);
Quote from: g3gg0 on May 22, 2013, 11:33:53 PM
did you made some speed tests?
as you are working on uncached memories, the performance wouldnt be good enough imo.

It's fast enough for continuous 12-bit 1280x720 on a 5D2 (6x 24MB buffers), and this is real world performance with actual recordings on an actual camera. I don't have any other cameras (or faster cards) to test with.
I've spent the last couple of days working on optimized 14-to-12-bit and 14-to-10-bit RAW conversion routines in native ARM assembly in hopes that 1) in spite of conventional wisdom the camera was in fact fast enough to do rudimentary "compression", and 2) the reduction in bitrate (15% and 29% respectively) would be a step towards making the 5D2 more viable for RAW recording at resolutions higher than 1280x720. There was only a limited amount of testing I could do with my very slow (40MB/s) cards but at 1280x720 on my 5D2 the conversion is fast enough for continuous "compressed" recording. I'd like to make the routines available to some people with faster cards and different cameras to see the extent to which this is viable at higher resolutions (10-bit 1880x1080 should theoretically be possible within the 5D2's apparent 60MB/s hardware limits).

Right now this should be treated as something highly experimental. Rather than posting a pre-built file I'm posting an assembled rawc.o file that can be linked with a compiled raw_rec.o into The edits that need to be made to raw_rec.c (keep in mind that I'm working off the May 14th version so things have probably moved around) are:

New external functions:

extern void raw14_to_raw12(void *buffer, int size);
extern void raw14_to_raw10(void *buffer, int size);

New variable:

static int buffer_size_compressed = 0;

Inside the main recording loop after if (saving_buffer_index != capturing_buffer_index), add:

buffer_size_compressed = (buffer_size_used * 12) / 14;
raw14_to_raw12(buffers[saving_buffer_index], buffer_size_used);

for 12-bit, or:

buffer_size_compressed = (buffer_size_used * 10) / 14;
raw14_to_raw10(buffers[saving_buffer_index], buffer_size_used);

for 10-bit. Change every instance of buffer_size_used later in the function to buffer_size_compressed.

The native 14-bit RAW data is packed into halfwords, but it gets repacked into words in the conversion routines, so the C struct for getting at the 12-bit data in C looks like this:

struct raw12_pixblock
        unsigned int c_hi: 8;
        unsigned int b: 12;
        unsigned int a: 12;
        unsigned int f_hi: 4;
        unsigned int e: 12;
        unsigned int d: 12;
        unsigned int c_lo: 4;
        unsigned int h: 12;
        unsigned int g: 12;
        unsigned int f_lo: 8;
} __attribute__((packed));

Same deal with 10-bit data, but it's 32 bits shorter (and has 10-bit pixels obviously).

You can download the .o file at
Here's a complete zip file for the 5D2. Extracting this to a bootable card should be all you need to do (assuming you've got your camera already set up to boot from cards).
I managed to build the nightly for my 5D2 and 1280x720 raw video is as lovely as expected, but it doesn't seem to want to let me record at 1920x1080 or higher. Is this a limitation of the 5D2 versus the newer cameras?

(Yes, 1280 is the right height; I'm a sucker for 3:2)