12-bit (and 10-bit) RAW video development discussion

Started by d, May 22, 2013, 10:58:34 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

d

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 raw_rec.mo file I'm posting an assembled rawc.o file that can be linked with a compiled raw_rec.o into raw_rec.mo. 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 http://shoutingroomonly.com/rawc.zip

AnotherDave

I wonder if implementing something like this on the 5D3 would make it easier to shoot at higher resolutions in crop mode?

Does anyone have the numbers on what the theoretical MB/frame would be at 3.6k 10bit?

Andy600

This could be the magic bullet to go with the magic lantern  8)
Colorist working with Davinci Resolve, Baselight, Nuke, After Effects & Premier Pro. Occasional Sunday afternoon DOP. Developer of Cinelog-C Colorspace Management and LUTs - www.cinelogdcp.com

Hazer

5D2 with both Lexar and Komputerbay 1000x cards and happy to test.  However my gcc-fu is a little rusty and I'd be better off trusting you to upload a functioning module.  If you can do that, count me (and probably a bunch of others) in.

g3gg0

did you made some speed tests?
as you are working on uncached memories, the performance wouldnt be good enough imo.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

d

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.

g3gg0

... wow.. cannot believe that.
can you post the asm code?
memcpy using 4 registers could not get more than 2-3 fps when testing around with YUV.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

Andy600

@g3gg0 - was that bang I just heard you falling off your chair?  ;D
Colorist working with Davinci Resolve, Baselight, Nuke, After Effects & Premier Pro. Occasional Sunday afternoon DOP. Developer of Cinelog-C Colorspace Management and LUTs - www.cinelogdcp.com

g3gg0

yeah..
well, i implemented an memcpy using LDMIA/STMIA for LV buffer copying and this was a dead end.
so i tried to get EDMAC working.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

ch_d

so d. if this is true and working - u r a hero to me. count me in for testing.
5D MII

Grunf

Are there any vector-ish OP's on this implementation of ARM that can do shifts on multiple 16-bit integers packed into 64 or 128-bit registers?

nanomad

I've removed the download. Call it an excess of safety but I don't want random code running on cameras especially of it doesn't have a source code attached.
I've sent the link to g3gg0 so he can review it and re-enable it if it's good
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

Greg

Quote from: nanomad on May 23, 2013, 12:37:13 AM
I've removed the download. Call it an excess of safety but I don't want random code running on cameras especially of it doesn't have a source code attached.
I've sent the link to g3gg0 so he can review it and re-enable it if it's good
Good idea, the safety of our cameras is important.

Kunibert

Quote from: Grunf on May 23, 2013, 12:37:07 AM
Are there any vector-ish OP's on this implementation of ARM that can do shifts on multiple 16-bit integers packed into 64 or 128-bit registers?
As far as i know the Digic 5+ is a modification of this core:
http://www.arm.com/products/processors/classic/arm9/arm946.php?tab=Specifications

Alia5

Thanks! Now i don't trust the Devs anymore when they say that somethign would be impossible!
No serious, awesome job!

g3gg0

here the removed link:
http://shoutingroomonly.com/rawc.zip

the CPU in digic is an ARM946, thats right.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

1%

This would be a HUGE win for SD cameras that can't record even close to CF.

Audionut

And those of us looking for highest resolution at 48-60fps.

The bottom 2 bits are pretty much just noise anyway.

Andy600

Quote from: 1% on May 23, 2013, 01:29:03 AM
This would be a HUGE win for SD cameras that can't record even close to CF.

Are you gonna try with TL2 or is that a stupid question?  ;D
Colorist working with Davinci Resolve, Baselight, Nuke, After Effects & Premier Pro. Occasional Sunday afternoon DOP. Developer of Cinelog-C Colorspace Management and LUTs - www.cinelogdcp.com

1%

I'll try to download it and just run it I guess... I'm not worried about this dude putting his blood sweat and tears in just to break my camera.

silvertonesx24

Am I correct in assuming that 10-bit and 12-bit will look no different than 14-bit (in real-world application of this camera)?

1%

I've linked as follows:

MODULE_OBJS=raw_rec.o rawc.o


When I boot up I get this laughing skull and then camera starts smoking.....


Actually not sure if its working, will have to open the raws it produced. Not sure if I'm getting speed increase... looks like its doing something. Maybe have to add the modifications?

Alia5

Quote from: silvertonesx24 on May 23, 2013, 01:42:14 AM
Am I correct in assuming that 10-bit and 12-bit will look no different than 14-bit (in real-world application of this camera)?

Reading this: http://francoismalan.com/2011/10/raw-12bit-or-14bit-lossy-or-lossless/
... i guess that it would only make a very very slight difference!

If this is really working... I just dont have words for how awesome this is...

Andy600

Quote from: 1% on May 23, 2013, 01:38:12 AM
I'll try to download it and just run it I guess... I'm not worried about this dude putting his blood sweat and tears in just to break my camera.

I'll be a guinea pig if needed. Got my 50d yesterday and I'm willing to risk my 600 for something important like this. (Disclaimer. OK, the wife thinks the 600 is now hers but...)  ;)
Colorist working with Davinci Resolve, Baselight, Nuke, After Effects & Premier Pro. Occasional Sunday afternoon DOP. Developer of Cinelog-C Colorspace Management and LUTs - www.cinelogdcp.com

Andy600

Quote from: 1% on May 23, 2013, 01:46:48 AM
I've linked as follows:

MODULE_OBJS=raw_rec.o rawc.o


When I boot up I get this laughing skull and then camera starts smoking.....


Actually not sure if its working, will have to open the raws it produced. Not sure if I'm getting speed increase... looks like its doing something. Maybe have to add the modifications?

I was half-expecting you to have been rickrolled by it :D
Colorist working with Davinci Resolve, Baselight, Nuke, After Effects & Premier Pro. Occasional Sunday afternoon DOP. Developer of Cinelog-C Colorspace Management and LUTs - www.cinelogdcp.com