
Stefan Seefeld wrote:
...IPP provides a heterogenous 16-bit RGB type with 5 bits red, 6 bits green, and 5 bits blue. I wonder whether that could be mapped to GIL, and how.
Although we don't have an existing model, I believe it is possible. You will need to make a heterogeneous pixel (i.e. pixel whose channels are of different type). Its channels will have proxy references. Here is how I would go about doing it. First, you need a class that can modify a given range of bits in a given type. This will be the channel proxy reference: // Manipulates bits [StartBit..StartBit+NumBits] of Data template <typename Data, int StartBit, int NumBits> struct subbyte_channel_reference { Data& _data; typedef Data value_type; subbyte_channel_reference(Data& data); subbyte_channel_reference& operator=(int value); }; typedef subbyte_channel_reference<int16_t,0,5> red_565_chan_ref_t; typedef subbyte_channel_reference<int16_t,6,6> green_565_chan_ref_t; typedef subbyte_channel_reference<int16_t,11,5> blue_565_chan_ref_t; You need to also make traits for it indicating that its reference type is proxy: template <> struct channel_traits<red_565_chan_ref_t> { typedef red_565_chan_ref_t::value_type value_type; typedef red_565_chan_ref_t reference; ... }; Then create your own model of HeterogeneousPixelConcept that returns the corresponding references: struct rgb565_pixel { typedef rgb_t color_space_t; template <int K> struct kth_channel_t; template <int K> typename kth_channel_t<K>::reference channel() { return typename kth_channel_t<K>::reference(_data); } int16_t _data; // this stores the 5+6+5 bits }; template <> struct rgb565_pixel::kth_channel_t<0> { typedef red_565_chan_ref_t reference; }; template <> struct rgb565_pixel::kth_channel_t<1> { typedef green_565_chan_ref_t reference; }; template <> struct rgb565_pixel::kth_channel_t<2> { typedef blue_565_chan_ref_t reference; }; You don't have to worry about planar representation here, as 565 pixels are always interleaved as far as I know. In theory GIL shouldn't have to change. "In theory, theory and practice are the same, but in practice..." :-) I suspect there will be a few glitches since this will be the first such model. Lubomir