Helper to decode RGB gains from HD108 header bytes
| 43 | |
| 44 | /// Helper to decode RGB gains from HD108 header bytes |
| 45 | void decodeGains(u8 f0, u8 f1, u8* r_gain, u8* g_gain, u8* b_gain) { |
| 46 | // f0: [1][RRRRR][GG] - marker bit, 5-bit R gain, 2 MSBs of G gain |
| 47 | *r_gain = (f0 >> 2) & 0x1F; |
| 48 | u8 g_msb = f0 & 0x03; |
| 49 | |
| 50 | // f1: [GGG][BBBBB] - 3 LSBs of G gain, 5-bit B gain |
| 51 | u8 g_lsb = (f1 >> 5) & 0x07; |
| 52 | *g_gain = (g_msb << 3) | g_lsb; |
| 53 | *b_gain = f1 & 0x1F; |
| 54 | } |
| 55 | |
| 56 | /// Helper to verify header bytes match expected RGB gains |
| 57 | void checkHeaderBytes(u8 f0, u8 f1, u8 expected_r, u8 expected_g, u8 expected_b) { |