I am starting to work with 10-bit color (10 bits each red, green, blue, no alpha. I have written two procedures to encode r, g and b values into packed and unpacked 64-bit quads.
Could somebody please check my code? Does anyone have a faster, more efficient way of doing this?
Here are the pixel formats:
https://www.1stvision.com/cameras/IDS/I ... rmats.html
Thank you.
Code: Select all
;RGB10, BGR10, RGB12, BGR12, RGBa10, BGRa10, RGBa12, BGRa12
;Color pixel formats With a bit depth of 10 Or 12 bit need two bytes For each color value ("R", "G", "B", "a"), leaving 6 Or 4 bits of every second byte unused. With RGB10, BGR10, RGB12 Or BGR12 a pixel needs 6 byte = 48 bit in total. Adding an alpha channel, the size of RGBa10, BGRa10, RGBa12 And BGRa12 the pixel's size increases to 8 byte = 64 bit.
;The second pixel row starts With byte 6n Or 8n respectively.
;RGB10p32, BGR10p32
;With the packed 10 bit formats RGB10p32 And BGR10p32, the unused bits are reduced To only 2 out of 32 total bits. This means the Data is much denser packed but the alignment gets lost. RGB10p32 And BGR10p32 need 4 byte = 32 bits For each pixel.
;The second pixel row starts With byte 4n.
;https://www.1stvision.com/cameras/IDS/IDS-manuals/en/basics-color-pixel-formats.html
red1.q = 1023
green1.q = 1023
blue1.q = 1023
red2.q = 1023
green2.q = 1023
blue2.q =1023
;RGB10p32
Procedure RGB10p32 (red1, green1, blue1, red2, green2, blue2)
sampleP.q = 0 ;64 bits RGB10p32 - INITIALIZE TO ZERO
blue1 << 52
green1 << 42
red1 << 32
blue2 << 20
green2 << 10
sampleP | red2 | green2 | blue2 | red1 | green1 | blue1
ProcedureReturn sampleP
EndProcedure
Procedure rgb10 ()
sample.q = 0
red1 << 48
blue2 << 32
green2 << 16
sample | red2 | green2 | blue2 | red1 | green1 | blue1
ProcedureReturn sample
EndProcedure