Author Topic: 12-bit (and 10-bit) RAW video development discussion  (Read 188633 times)

d

  • New to the forum
  • *
  • Posts: 6
12-bit (and 10-bit) RAW video development discussion
« on: May 22, 2013, 10:58:34 PM »
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:

Code: [Select]
extern void raw14_to_raw12(void *buffer, int size);
extern void raw14_to_raw10(void *buffer, int size);

New variable:

Code: [Select]
static int buffer_size_compressed = 0;
Inside the main recording loop after if (saving_buffer_index != capturing_buffer_index), add:

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

for 12-bit, or:

Code: [Select]
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:

Code: [Select]
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

  • Senior
  • ****
  • Posts: 348
Re: 12-bit (and 10-bit) RAW video
« Reply #1 on: May 22, 2013, 11:07:53 PM »
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

  • Hero Member
  • *****
  • Posts: 1785
  • Have you tried turning it off and on again?
Re: 12-bit (and 10-bit) RAW video
« Reply #2 on: May 22, 2013, 11:20:40 PM »
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

  • Freshman
  • **
  • Posts: 56
Re: 12-bit (and 10-bit) RAW video
« Reply #3 on: May 22, 2013, 11:22:55 PM »
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.


d

  • New to the forum
  • *
  • Posts: 6
Re: 12-bit (and 10-bit) RAW video
« Reply #5 on: May 22, 2013, 11:56:12 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.


Andy600

  • Hero Member
  • *****
  • Posts: 1785
  • Have you tried turning it off and on again?
Re: 12-bit (and 10-bit) RAW video
« Reply #7 on: May 23, 2013, 12:12:47 AM »
@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


ch_d

  • Freshman
  • **
  • Posts: 90
  • 5D MII
Re: 12-bit (and 10-bit) RAW video
« Reply #9 on: May 23, 2013, 12:33:44 AM »
so d. if this is true and working - u r a hero to me. count me in for testing.
5D MII

Grunf

  • New to the forum
  • *
  • Posts: 43
Re: 12-bit (and 10-bit) RAW video
« Reply #10 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?

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: 12-bit (and 10-bit) RAW video
« Reply #11 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
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

  • Hero Member
  • *****
  • Posts: 525
Re: 12-bit (and 10-bit) RAW video
« Reply #12 on: May 23, 2013, 12:40:32 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

  • New to the forum
  • *
  • Posts: 7
Re: 12-bit (and 10-bit) RAW video
« Reply #13 on: May 23, 2013, 01:05:01 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

  • Freshman
  • **
  • Posts: 99
  • 600D
Re: 12-bit (and 10-bit) RAW video
« Reply #14 on: May 23, 2013, 01:13:08 AM »
Thanks! Now i don't trust the Devs anymore when they say that somethign would be impossible!
No serious, awesome job!


1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: 12-bit (and 10-bit) RAW video
« Reply #16 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.

Audionut

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3366
  • I have a 1Dx, I'm awesome.
Re: 12-bit (and 10-bit) RAW video
« Reply #17 on: May 23, 2013, 01:33:22 AM »
And those of us looking for highest resolution at 48-60fps.

The bottom 2 bits are pretty much just noise anyway.

Andy600

  • Hero Member
  • *****
  • Posts: 1785
  • Have you tried turning it off and on again?
Re: 12-bit (and 10-bit) RAW video
« Reply #18 on: May 23, 2013, 01:33:52 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%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: 12-bit (and 10-bit) RAW video
« Reply #19 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.

silvertonesx24

  • Freshman
  • **
  • Posts: 73
  • 5Dii
Re: 12-bit (and 10-bit) RAW video
« Reply #20 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)?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: 12-bit (and 10-bit) RAW video
« Reply #21 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?

Alia5

  • Freshman
  • **
  • Posts: 99
  • 600D
Re: 12-bit (and 10-bit) RAW video
« Reply #22 on: May 23, 2013, 01:48:30 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

  • Hero Member
  • *****
  • Posts: 1785
  • Have you tried turning it off and on again?
Re: 12-bit (and 10-bit) RAW video
« Reply #23 on: May 23, 2013, 01:48:49 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

  • Hero Member
  • *****
  • Posts: 1785
  • Have you tried turning it off and on again?
Re: 12-bit (and 10-bit) RAW video
« Reply #24 on: May 23, 2013, 01:50:15 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