Skip to main content

singe_npp/image/
color_twist_gamma.rs

1use super::*;
2
3impl_gamma_packed!(gamma_forward_u8_c3, C3, nppiGammaFwd_8u_C3R_Ctx);
4impl_gamma_packed_in_place!(gamma_forward_u8_c3_in_place, C3, nppiGammaFwd_8u_C3IR_Ctx);
5impl_gamma_packed!(gamma_forward_u8_ac4, AC4, nppiGammaFwd_8u_AC4R_Ctx);
6impl_gamma_packed_in_place!(
7    gamma_forward_u8_ac4_in_place,
8    AC4,
9    nppiGammaFwd_8u_AC4IR_Ctx
10);
11impl_gamma_planar!(gamma_forward_u8_p3, nppiGammaFwd_8u_P3R_Ctx);
12impl_gamma_planar_in_place!(gamma_forward_u8_p3_in_place, nppiGammaFwd_8u_IP3R_Ctx);
13impl_gamma_packed!(gamma_inverse_u8_c3, C3, nppiGammaInv_8u_C3R_Ctx);
14impl_gamma_packed_in_place!(gamma_inverse_u8_c3_in_place, C3, nppiGammaInv_8u_C3IR_Ctx);
15impl_gamma_packed!(gamma_inverse_u8_ac4, AC4, nppiGammaInv_8u_AC4R_Ctx);
16impl_gamma_packed_in_place!(
17    gamma_inverse_u8_ac4_in_place,
18    AC4,
19    nppiGammaInv_8u_AC4IR_Ctx
20);
21impl_gamma_planar!(gamma_inverse_u8_p3, nppiGammaInv_8u_P3R_Ctx);
22impl_gamma_planar_in_place!(gamma_inverse_u8_p3_in_place, nppiGammaInv_8u_IP3R_Ctx);
23
24impl_generic_gamma!(GammaForwardC3, gamma_forward, gamma_forward_c3, C3, [
25    u8 => gamma_forward_u8_c3
26]);
27impl_generic_gamma_in_place!(
28    GammaForwardC3InPlace,
29    gamma_forward_in_place,
30    gamma_forward_c3_in_place,
31    C3,
32    [u8 => gamma_forward_u8_c3_in_place]
33);
34impl_generic_gamma!(GammaForwardAc4, gamma_forward, gamma_forward_ac4, AC4, [
35    u8 => gamma_forward_u8_ac4
36]);
37impl_generic_gamma_in_place!(
38    GammaForwardAc4InPlace,
39    gamma_forward_in_place,
40    gamma_forward_ac4_in_place,
41    AC4,
42    [u8 => gamma_forward_u8_ac4_in_place]
43);
44impl_generic_gamma!(GammaInverseC3, gamma_inverse, gamma_inverse_c3, C3, [
45    u8 => gamma_inverse_u8_c3
46]);
47impl_generic_gamma_in_place!(
48    GammaInverseC3InPlace,
49    gamma_inverse_in_place,
50    gamma_inverse_c3_in_place,
51    C3,
52    [u8 => gamma_inverse_u8_c3_in_place]
53);
54impl_generic_gamma!(GammaInverseAc4, gamma_inverse, gamma_inverse_ac4, AC4, [
55    u8 => gamma_inverse_u8_ac4
56]);
57impl_generic_gamma_in_place!(
58    GammaInverseAc4InPlace,
59    gamma_inverse_in_place,
60    gamma_inverse_ac4_in_place,
61    AC4,
62    [u8 => gamma_inverse_u8_ac4_in_place]
63);
64
65pub trait GammaForwardPlanar<const PLANES: usize>: DataTypeLike {
66    fn gamma_forward_planar(
67        stream_context: &StreamContext,
68        source: &PlanarImageView<'_, Self, PLANES>,
69        destination: &mut PlanarImageViewMut<'_, Self, PLANES>,
70    ) -> Result<()>;
71}
72
73impl GammaForwardPlanar<3> for u8 {
74    fn gamma_forward_planar(
75        stream_context: &StreamContext,
76        source: &PlanarImageView<'_, Self, 3>,
77        destination: &mut PlanarImageViewMut<'_, Self, 3>,
78    ) -> Result<()> {
79        gamma_forward_u8_p3(stream_context, source, destination)
80    }
81}
82
83pub fn gamma_forward_planar<T, const PLANES: usize>(
84    stream_context: &StreamContext,
85    source: &PlanarImageView<'_, T, PLANES>,
86    destination: &mut PlanarImageViewMut<'_, T, PLANES>,
87) -> Result<()>
88where
89    T: GammaForwardPlanar<PLANES>,
90{
91    T::gamma_forward_planar(stream_context, source, destination)
92}
93
94pub trait GammaForwardPlanarInPlace<const PLANES: usize>: DataTypeLike {
95    fn gamma_forward_planar_in_place(
96        stream_context: &StreamContext,
97        image: &mut PlanarImageViewMut<'_, Self, PLANES>,
98    ) -> Result<()>;
99}
100
101impl GammaForwardPlanarInPlace<3> for u8 {
102    fn gamma_forward_planar_in_place(
103        stream_context: &StreamContext,
104        image: &mut PlanarImageViewMut<'_, Self, 3>,
105    ) -> Result<()> {
106        gamma_forward_u8_p3_in_place(stream_context, image)
107    }
108}
109
110pub fn gamma_forward_planar_in_place<T, const PLANES: usize>(
111    stream_context: &StreamContext,
112    image: &mut PlanarImageViewMut<'_, T, PLANES>,
113) -> Result<()>
114where
115    T: GammaForwardPlanarInPlace<PLANES>,
116{
117    T::gamma_forward_planar_in_place(stream_context, image)
118}
119
120pub trait GammaInversePlanar<const PLANES: usize>: DataTypeLike {
121    fn gamma_inverse_planar(
122        stream_context: &StreamContext,
123        source: &PlanarImageView<'_, Self, PLANES>,
124        destination: &mut PlanarImageViewMut<'_, Self, PLANES>,
125    ) -> Result<()>;
126}
127
128impl GammaInversePlanar<3> for u8 {
129    fn gamma_inverse_planar(
130        stream_context: &StreamContext,
131        source: &PlanarImageView<'_, Self, 3>,
132        destination: &mut PlanarImageViewMut<'_, Self, 3>,
133    ) -> Result<()> {
134        gamma_inverse_u8_p3(stream_context, source, destination)
135    }
136}
137
138pub fn gamma_inverse_planar<T, const PLANES: usize>(
139    stream_context: &StreamContext,
140    source: &PlanarImageView<'_, T, PLANES>,
141    destination: &mut PlanarImageViewMut<'_, T, PLANES>,
142) -> Result<()>
143where
144    T: GammaInversePlanar<PLANES>,
145{
146    T::gamma_inverse_planar(stream_context, source, destination)
147}
148
149pub trait GammaInversePlanarInPlace<const PLANES: usize>: DataTypeLike {
150    fn gamma_inverse_planar_in_place(
151        stream_context: &StreamContext,
152        image: &mut PlanarImageViewMut<'_, Self, PLANES>,
153    ) -> Result<()>;
154}
155
156impl GammaInversePlanarInPlace<3> for u8 {
157    fn gamma_inverse_planar_in_place(
158        stream_context: &StreamContext,
159        image: &mut PlanarImageViewMut<'_, Self, 3>,
160    ) -> Result<()> {
161        gamma_inverse_u8_p3_in_place(stream_context, image)
162    }
163}
164
165pub fn gamma_inverse_planar_in_place<T, const PLANES: usize>(
166    stream_context: &StreamContext,
167    image: &mut PlanarImageViewMut<'_, T, PLANES>,
168) -> Result<()>
169where
170    T: GammaInversePlanarInPlace<PLANES>,
171{
172    T::gamma_inverse_planar_in_place(stream_context, image)
173}