Author Topic: PA, PB, PC, ...  (Read 2622 times)

escho

  • Contributor
  • Hero Member
  • *****
  • Posts: 563
PA, PB, PC, ...
« on: February 21, 2014, 09:15:24 PM »
Please help me understanding the code from raw2dng a bit better:

Code: [Select]
#define PA ((int)(p->a))
#define PB ((int)(p->b_lo | (p->b_hi << 12)))
#define PC ((int)(p->c_lo | (p->c_hi << 10)))
#define PD ((int)(p->d_lo | (p->d_hi << 8)))
#define PE ((int)(p->e_lo | (p->e_hi << 6)))
#define PF ((int)(p->f_lo | (p->f_hi << 4)))
#define PG ((int)(p->g_lo | (p->g_hi << 2)))
#define PH ((int)(p->h))

For what is PA standing, for a red or for a green pixel?

Edgar
https://sternenkarten.com/
600D, 6D, openSUSE Tumbleweed

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: PA, PB, PC, ...
« Reply #1 on: February 21, 2014, 09:21:14 PM »
A struct raw_pixblock contains 8 pixels packed into 14 bytes (each pixel has 14 bits). To read these 8 pixels, you can use PA ... PH. To write them, you can use the setter macros (SET_PA ... SET_PH).

When your struct raw_pixblock is on even lines (first line being 0), PA is red. When it's on odd lines, it's green. I always force the image to begin with a red pixel in order to simplify the coding (though the DNG spec and the CHDK guys like to do things a little more complicated by allowing the image to begin with any color).

There is a generic routine (raw_get_pixel), which is a little slower, but easier to use.

escho

  • Contributor
  • Hero Member
  • *****
  • Posts: 563
Re: PA, PB, PC, ...
« Reply #2 on: February 21, 2014, 09:29:10 PM »
Ahh, I understand. PA is the first pixel of this 8 pixel-block. And dependant of the line, it´s  red or green.
Thanks

Edgar
https://sternenkarten.com/
600D, 6D, openSUSE Tumbleweed