1 /*******************************************************************************
2 * Copyright 2016-2019 Intel Corporation.
3 *
4 * This software and the related documents are Intel copyrighted  materials,  and
5 * your use of  them is  governed by the  express license  under which  they were
6 * provided to you (License).  Unless the License provides otherwise, you may not
7 * use, modify, copy, publish, distribute,  disclose or transmit this software or
8 * the related documents without Intel's prior written permission.
9 *
10 * This software and the related documents  are provided as  is,  with no express
11 * or implied  warranties,  other  than those  that are  expressly stated  in the
12 * License.
13 *******************************************************************************/
14 
15 #if !defined( __IPP_IW_IMAGE_OP__ )
16 #define __IPP_IW_IMAGE_OP__
17 
18 #include "iw/iw_image.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /**/////////////////////////////////////////////////////////////////////////////
25 //                   iwiCopy
26 ///////////////////////////////////////////////////////////////////////////// */
27 
28 // Auxiliary parameters structure
29 typedef struct _IwiCopyParams
30 {
31     int reserved;
32 } IwiCopyParams;
33 
34 // Sets auxiliary parameters to default values
iwiCopy_SetDefaultParams(IwiCopyParams * pParams)35 static IW_INLINE void iwiCopy_SetDefaultParams(
36     IwiCopyParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
37 )
38 {
39     (void)pParams;
40 }
41 
42 // Copies image data to destination image with masking.
43 // If mask is NULL, then calls iwiCopy function.
44 // For masked operation, the function writes pixel values in the destination buffer only if the spatially corresponding
45 // mask array value is non-zero.
46 // Features support:
47 //      Inplace mode:            inapplicable
48 //      64-bit sizes:            no
49 //      Internal threading:      no
50 //      Manual tiling:           yes
51 //      IwiTile simple tiling:   yes
52 //      IwiTile pipeline tiling: yes
53 // Returns:
54 //      ippStsNotSupportedModeErr           selected function mode is not supported
55 //      ippStsSizeErr                       size fields values are illegal
56 //      ippStsNullPtrErr                    unexpected NULL pointer
57 //      ippStsNoErr                         no errors
58 IW_DECL(IppStatus) iwiCopy(
59     const IwiImage      *pSrcImage,  // [in]     Pointer to the source image
60     IwiImage            *pDstImage,  // [in,out] Pointer to the destination image
61     const IwiImage      *pMaskImage, // [in]     Pointer to mask image. Mask must be 8-bit, 1 channel image. If NULL - no masking will be performed
62     const IwiCopyParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
63     const IwiTile       *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
64 );
65 
66 /**/////////////////////////////////////////////////////////////////////////////
67 //                   iwiCopyChannel
68 ///////////////////////////////////////////////////////////////////////////// */
69 
70 // Auxiliary parameters structure
71 typedef struct _IwiCopyChannelParams
72 {
73     int reserved;
74 } IwiCopyChannelParams;
75 
76 // Sets auxiliary parameters to default values
iwiCopyChannel_SetDefaultParams(IwiCopyChannelParams * pParams)77 static IW_INLINE void iwiCopyChannel_SetDefaultParams(
78     IwiCopyChannelParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
79 )
80 {
81     (void)pParams;
82 }
83 
84 // Copies selected channel from one image to another.
85 // Features support:
86 //      Inplace mode:            yes
87 //      64-bit sizes:            no
88 //      Internal threading:      no
89 //      Manual tiling:           yes
90 //      IwiTile simple tiling:   yes
91 //      IwiTile pipeline tiling: yes
92 // Returns:
93 //      ippStsDataTypeErr                   data type is illegal
94 //      ippStsNumChannelsErr                channels value is illegal
95 //      ippStsSizeErr                       size fields values are illegal
96 //      ippStsNullPtrErr                    unexpected NULL pointer
97 //      ippStsNoErr                         no errors
98 IW_DECL(IppStatus) iwiCopyChannel(
99     const IwiImage             *pSrcImage,  // [in]     Pointer to the source image
100     int                         srcChannel, // [in]     Source channel to copy from (starting from 0)
101     IwiImage                   *pDstImage,  // [in,out] Pointer to the destination image
102     int                         dstChannel, // [in]     Destination channel to copy to (starting from 0)
103     const IwiCopyChannelParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
104     const IwiTile              *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
105 );
106 
107 /**/////////////////////////////////////////////////////////////////////////////
108 //                   iwiSplitChannels
109 ///////////////////////////////////////////////////////////////////////////// */
110 
111 // Auxiliary parameters structure
112 typedef struct _IwiSplitChannelsParams
113 {
114     int reserved;
115 } IwiSplitChannelsParams;
116 
117 // Sets auxiliary parameters to default values
iwiSplitChannels_SetDefaultParams(IwiSplitChannelsParams * pParams)118 static IW_INLINE void iwiSplitChannels_SetDefaultParams(
119     IwiSplitChannelsParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
120 )
121 {
122     (void)pParams;
123 }
124 
125 // Splits multi-channel image into array of single channel images.
126 // Features support:
127 //      Inplace mode:            no
128 //      64-bit sizes:            no
129 //      Internal threading:      no
130 //      Manual tiling:           yes
131 //      IwiTile simple tiling:   yes
132 //      IwiTile pipeline tiling: yes
133 // Returns:
134 //      ippStsDataTypeErr                   data type is illegal
135 //      ippStsNumChannelsErr                channels value is illegal
136 //      ippStsSizeErr                       size fields values are illegal
137 //      ippStsNullPtrErr                    unexpected NULL pointer
138 //      ippStsNoErr                         no errors
139 IW_DECL(IppStatus) iwiSplitChannels(
140     const IwiImage               *pSrcImage,    // [in]     Pointer to the source image
141     IwiImage* const               pDstImages[], // [in,out] Array of pointers to destination images. Size of this array must not be less than number of channels in the source image
142                                                 //          NULL pointers will be skipped.
143     const IwiSplitChannelsParams *pAuxParams,   // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
144     const IwiTile                *pTile         // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
145 );
146 
147 /**/////////////////////////////////////////////////////////////////////////////
148 //                   iwiMergeChannels
149 ///////////////////////////////////////////////////////////////////////////// */
150 
151 // Auxiliary parameters structure
152 typedef struct _IwiMergeChannelsParams
153 {
154     int reserved;
155 } IwiMergeChannelsParams;
156 
157 // Sets auxiliary parameters to default values
iwiMergeChannels_SetDefaultParams(IwiMergeChannelsParams * pParams)158 static IW_INLINE void iwiMergeChannels_SetDefaultParams(
159     IwiMergeChannelsParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
160 )
161 {
162     (void)pParams;
163 }
164 
165 // Merges array of single channel images into one multi-channel image.
166 // Features support:
167 //      Inplace mode:            no
168 //      64-bit sizes:            no
169 //      Internal threading:      no
170 //      Manual tiling:           yes
171 //      IwiTile simple tiling:   yes
172 //      IwiTile pipeline tiling: yes
173 // Returns:
174 //      ippStsDataTypeErr                   data type is illegal
175 //      ippStsNumChannelsErr                channels value is illegal
176 //      ippStsSizeErr                       size fields values are illegal
177 //      ippStsNullPtrErr                    unexpected NULL pointer
178 //      ippStsNoErr                         no errors
179 IW_DECL(IppStatus) iwiMergeChannels(
180     const IwiImage* const         pSrcImages[], // [in]     Array of pointers to source images. Size of this array must not be less than number of channels in the destination image
181                                                 //          NULL pointers will be skipped.
182     IwiImage                     *pDstImage,    // [in,out] Pointer to the destination image
183     const IwiMergeChannelsParams *pAuxParams,   // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
184     const IwiTile                *pTile         // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
185 );
186 
187 /**/////////////////////////////////////////////////////////////////////////////
188 //                   iwiCreateBorder
189 ///////////////////////////////////////////////////////////////////////////// */
190 
191 // Auxiliary parameters structure
192 typedef struct _IwiCreateBorderParams
193 {
194     int reserved;
195 } IwiCreateBorderParams;
196 
197 // Sets auxiliary parameters to default values
iwiCreateBorder_SetDefaultParams(IwiCreateBorderParams * pParams)198 static IW_INLINE void iwiCreateBorder_SetDefaultParams(
199     IwiCreateBorderParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
200 )
201 {
202     (void)pParams;
203 }
204 
205 // Copies image data to destination image and constructs border of specified size.
206 // Destination image must have enough memory for a border according to inMemSize member.
207 // If border is specified with InMem flags then image will be extended by border size to include InMem pixels,
208 // but will not build border in this direction.
209 // Features support:
210 //      Inplace mode:            yes
211 //      64-bit sizes:            yes
212 //      Internal threading:      no
213 //      Manual tiling:           yes
214 //      IwiTile simple tiling:   yes
215 //      IwiTile pipeline tiling: yes
216 // Returns:
217 //      ippStsNotSupportedModeErr           selected function mode is not supported
218 //      ippStsSizeErr                       1) size fields values are illegal
219 //                                          2) border.top or border.left are greater than corresponding inMemSize values of destination image
220 //                                          3) dst_width  + dst_inMemSize.right  < min_width  + border.right
221 //                                          4) dst_height + dst_inMemSize.bottom < min_height + border.bottom
222 //      ippStsNullPtrErr                    unexpected NULL pointer
223 //      ippStsNoErr                         no errors
224 IW_DECL(IppStatus) iwiCreateBorder(
225     const IwiImage                 *pSrcImage,      // [in]     Pointer to the source image
226     IwiImage                       *pDstImage,      // [in,out] Pointer to the destination image which points to actual data start
227     IwiBorderSize                   borderSize,     // [in]     Size of border to reconstruct. Destination image must have greater or equal inMemSize values
228     IwiBorderType                   border,         // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderWrap
229     const Ipp64f                   *pBorderVal,     // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
230     const IwiCreateBorderParams    *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
231     const IwiTile                  *pTile           // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
232 );
233 
234 /**/////////////////////////////////////////////////////////////////////////////
235 //                   iwiSet
236 ///////////////////////////////////////////////////////////////////////////// */
237 
238 // Auxiliary parameters structure
239 typedef struct _IwiSetParams
240 {
241     int reserved;
242 } IwiSetParams;
243 
244 // Sets auxiliary parameters to default values
iwiSet_SetDefaultParams(IwiSetParams * pParams)245 static IW_INLINE void iwiSet_SetDefaultParams(
246     IwiSetParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
247 )
248 {
249     (void)pParams;
250 }
251 
252 // Sets each channel of the image to the specified values with masking.
253 // If mask is NULL, then calls iwiSet function.
254 // For masked operation, the function writes pixel values in the destination buffer only if the spatially corresponding
255 // mask array value is non-zero.
256 // Features support:
257 //      Inplace mode:            inapplicable
258 //      64-bit sizes:            no
259 //      Internal threading:      no
260 //      Manual tiling:           yes
261 //      IwiTile simple tiling:   yes
262 //      IwiTile pipeline tiling: yes
263 // Returns:
264 //      ippStsDataTypeErr                   data type is illegal
265 //      ippStsNumChannelsErr                channels value is illegal
266 //      ippStsSizeErr                       size fields values are illegal
267 //      ippStsNullPtrErr                    unexpected NULL pointer
268 //      ippStsNoErr                         no errors
269 IW_DECL(IppStatus) iwiSet(
270     const double       *pValues,        // [in]     Pointer to the array of values
271     int                 valuesNum,      // [in]     Number of value elements.
272                                         //          If valuesSize > number of channels then exceeding values will be ignored.
273                                         //          If valuesSize < number of channels then the last value will be replicated for the remaining channels
274     IwiImage           *pDstImage,      // [in,out] Pointer to the destination image
275     const IwiImage     *pMaskImage,     // [in]     Pointer to the mask image. Mask must be 8-bit, 1 channel image. If NULL - no masking will be performed
276     const IwiSetParams *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
277     const IwiTile      *pTile           // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
278 );
279 
280 /**/////////////////////////////////////////////////////////////////////////////
281 //                   iwiSetChannel
282 ///////////////////////////////////////////////////////////////////////////// */
283 
284 // Auxiliary parameters structure
285 typedef struct _IwiSetChannelParams
286 {
287     int reserved;
288 } IwiSetChannelParams;
289 
290 // Sets auxiliary parameters to default values
iwiSetChannel_SetDefaultParams(IwiSetChannelParams * pParams)291 static IW_INLINE void iwiSetChannel_SetDefaultParams(
292     IwiSetChannelParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
293 )
294 {
295     (void)pParams;
296 }
297 
298 // Sets selected channel of the multi-channel image to the specified value.
299 // Features support:
300 //      Inplace mode:            inapplicable
301 //      64-bit sizes:            no
302 //      Internal threading:      no
303 //      Manual tiling:           yes
304 //      IwiTile simple tiling:   yes
305 //      IwiTile pipeline tiling: yes
306 // Returns:
307 //      ippStsDataTypeErr                   data type is illegal
308 //      ippStsNumChannelsErr                channels value is illegal
309 //      ippStsSizeErr                       size fields values are illegal
310 //      ippStsNullPtrErr                    unexpected NULL pointer
311 //      ippStsNoErr                         no errors
312 IW_DECL(IppStatus) iwiSetChannel(
313     double                     value,      // [in]     Value for a selected channel
314     IwiImage                  *pDstImage,  // [in,out] Pointer to the destination image
315     int                        channelNum, // [in]     Number of channel to be set (starting from 0)
316     const IwiSetChannelParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
317     const IwiTile             *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
318 );
319 
320 /**/////////////////////////////////////////////////////////////////////////////
321 //                   iwiAdd
322 ///////////////////////////////////////////////////////////////////////////// */
323 
324 // Auxiliary parameters structure
325 typedef struct _IwiAddParams
326 {
327     int             scaleFactor;    // Scale factor
328     IwiChDescriptor chDesc;         // Special channels processing mode
329 } IwiAddParams;
330 
331 // Sets auxiliary parameters to default values
iwiAdd_SetDefaultParams(IwiAddParams * pParams)332 static IW_INLINE void iwiAdd_SetDefaultParams(
333     IwiAddParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
334 )
335 {
336     if(pParams)
337     {
338         pParams->scaleFactor = 0;
339         pParams->chDesc      = iwiChDesc_None;
340     }
341 }
342 
343 // Performs addition of one image to another and writes result to the output
344 // Features support:
345 //      Inplace mode:            yes (second addend and sum)
346 //      64-bit sizes:            yes
347 //      Internal threading:      no
348 //      Manual tiling:           yes
349 //      IwiTile simple tiling:   yes
350 //      IwiTile pipeline tiling: yes
351 // Returns:
352 //      ippStsDataTypeErr                   data type is illegal
353 //      ippStsNumChannelsErr                channels value is illegal
354 //      ippStsSizeErr                       size fields values are illegal
355 //      ippStsNullPtrErr                    unexpected NULL pointer
356 //      ippStsNoErr                         no errors
357 IW_DECL(IppStatus) iwiAdd(
358     const IwiImage     *pAddend1,   // [in]     Pointer to the first addend image
359     const IwiImage     *pAddend2,   // [in]     Pointer to the second addend image
360     IwiImage           *pDstImage,  // [in,out] Pointer to the result image (can be same as the second addend)
361     const IwiAddParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
362     const IwiTile      *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
363 );
364 
365 /**/////////////////////////////////////////////////////////////////////////////
366 //                   iwiAddC
367 ///////////////////////////////////////////////////////////////////////////// */
368 
369 // Auxiliary parameters structure
370 typedef struct _IwiAddCParams
371 {
372     int             scaleFactor;    // Scale factor
373     IwiChDescriptor chDesc;         // Special channels processing mode
374 } IwiAddCParams;
375 
376 // Sets auxiliary parameters to default values
iwiAddC_SetDefaultParams(IwiAddCParams * pParams)377 static IW_INLINE void iwiAddC_SetDefaultParams(
378     IwiAddCParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
379 )
380 {
381     if(pParams)
382     {
383         pParams->scaleFactor = 0;
384         pParams->chDesc      = iwiChDesc_None;
385     }
386 }
387 
388 // Performs addition of the constant to the image another and writes result to the output
389 // Features support:
390 //      Inplace mode:            yes (addend image and sum)
391 //      64-bit sizes:            yes
392 //      Internal threading:      no
393 //      Manual tiling:           yes
394 //      IwiTile simple tiling:   yes
395 //      IwiTile pipeline tiling: yes
396 // Returns:
397 //      ippStsDataTypeErr                   data type is illegal
398 //      ippStsNumChannelsErr                channels value is illegal
399 //      ippStsSizeErr                       size fields values are illegal
400 //      ippStsNullPtrErr                    unexpected NULL pointer
401 //      ippStsNoErr                         no errors
402 IW_DECL(IppStatus) iwiAddC(
403     const double        *pAddend,       // [in]     Pointer to the array of addends. One element for each channel
404     int                  addendsNum,    // [in]     Number of addends.
405                                         //          If addendsNum > number of channels then exceeding values will be ignored.
406                                         //          If addendsNum < number of channels then the last value will be replicated for the remaining channels
407     const IwiImage      *pAddendImage,  // [in]     Pointer to the addend image
408     IwiImage            *pDstImage,     // [in,out] Pointer to the difference image (can be same as addend image)
409     const IwiAddCParams *pAuxParams,    // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
410     const IwiTile       *pTile          // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
411 );
412 
413 /**/////////////////////////////////////////////////////////////////////////////
414 //                   iwiSub
415 ///////////////////////////////////////////////////////////////////////////// */
416 
417 // Auxiliary parameters structure
418 typedef struct _IwiSubParams
419 {
420     int             scaleFactor;    // Scale factor
421     IwiChDescriptor chDesc;         // Special channels processing mode
422 } IwiSubParams;
423 
424 // Sets auxiliary parameters to default values
iwiSub_SetDefaultParams(IwiSubParams * pParams)425 static IW_INLINE void iwiSub_SetDefaultParams(
426     IwiSubParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
427 )
428 {
429     if(pParams)
430     {
431         pParams->scaleFactor = 0;
432         pParams->chDesc      = iwiChDesc_None;
433     }
434 }
435 
436 // Performs subtraction of the first image from the second image and writes result to the output
437 // Features support:
438 //      Inplace mode:            yes (minuend and difference)
439 //      64-bit sizes:            yes
440 //      Internal threading:      no
441 //      Manual tiling:           yes
442 //      IwiTile simple tiling:   yes
443 //      IwiTile pipeline tiling: yes
444 // Returns:
445 //      ippStsDataTypeErr                   data type is illegal
446 //      ippStsNumChannelsErr                channels value is illegal
447 //      ippStsSizeErr                       size fields values are illegal
448 //      ippStsNullPtrErr                    unexpected NULL pointer
449 //      ippStsNoErr                         no errors
450 IW_DECL(IppStatus) iwiSub(
451     const IwiImage      *pSubtrahend,   // [in]     Pointer to the subtrahend image
452     const IwiImage      *pMinuend,      // [in]     Pointer to the minuend image
453     IwiImage            *pDstImage,     // [in,out] Pointer to the difference image (can be same as minuend)
454     const IwiSubParams  *pAuxParams,    // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
455     const IwiTile       *pTile          // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
456 );
457 
458 /**/////////////////////////////////////////////////////////////////////////////
459 //                   iwiSubC
460 ///////////////////////////////////////////////////////////////////////////// */
461 
462 // Auxiliary parameters structure
463 typedef struct _IwiSubCParams
464 {
465     int             scaleFactor;    // Scale factor
466     IwiChDescriptor chDesc;         // Special channels processing mode
467 } IwiSubCParams;
468 
469 // Sets auxiliary parameters to default values
iwiSubC_SetDefaultParams(IwiSubCParams * pParams)470 static IW_INLINE void iwiSubC_SetDefaultParams(
471     IwiSubCParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
472 )
473 {
474     if(pParams)
475     {
476         pParams->scaleFactor = 0;
477         pParams->chDesc      = iwiChDesc_None;
478     }
479 }
480 
481 // Performs subtraction of the constant from the image and writes result to the output
482 // Features support:
483 //      Inplace mode:            yes (minuend and difference)
484 //      64-bit sizes:            yes
485 //      Internal threading:      no
486 //      Manual tiling:           yes
487 //      IwiTile simple tiling:   yes
488 //      IwiTile pipeline tiling: yes
489 // Returns:
490 //      ippStsDataTypeErr                   data type is illegal
491 //      ippStsNumChannelsErr                channels value is illegal
492 //      ippStsSizeErr                       size fields values are illegal
493 //      ippStsNullPtrErr                    unexpected NULL pointer
494 //      ippStsNoErr                         no errors
495 IW_DECL(IppStatus) iwiSubC(
496     const double        *pSubtrahend,       // [in]     Pointer to the array of subtrahends. One element for each channel
497     int                  subtrahendsNum,    // [in]     Number of subtrahends.
498                                             //          If subtrahendsNum > number of channels then exceeding values will be ignored.
499                                             //          If subtrahendsNum < number of channels then the last value will be replicated for the remaining channels
500     const IwiImage      *pMinuendImage,     // [in]     Pointer to the minuend image
501     IwiImage            *pDstImage,         // [in,out] Pointer to the difference image (can be same as minuend)
502     const IwiSubCParams *pAuxParams,        // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
503     const IwiTile       *pTile              // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
504 );
505 
506 /**/////////////////////////////////////////////////////////////////////////////
507 //                   iwiMul
508 ///////////////////////////////////////////////////////////////////////////// */
509 
510 // Auxiliary parameters structure
511 typedef struct _IwiMulParams
512 {
513     IppHintAlgorithm algoMode;          // Accuracy mode
514     int              scaleFactor;       // Scale factor
515     IwiChDescriptor  chDesc;            // Special channels processing mode
516 } IwiMulParams;
517 
518 // Sets auxiliary parameters to default values
iwiMul_SetDefaultParams(IwiMulParams * pParams)519 static IW_INLINE void iwiMul_SetDefaultParams(
520     IwiMulParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
521 )
522 {
523     if(pParams)
524     {
525         pParams->algoMode           = ippAlgHintNone;
526         pParams->scaleFactor        = 0;
527         pParams->chDesc             = iwiChDesc_None;
528     }
529 }
530 
531 // Performs multiplication of one image by another and writes result to the output
532 // Features support:
533 //      Inplace mode:            yes (second factor and product)
534 //      64-bit sizes:            yes
535 //      Internal threading:      no
536 //      Manual tiling:           yes
537 //      IwiTile simple tiling:   yes
538 //      IwiTile pipeline tiling: yes
539 // Returns:
540 //      ippStsDataTypeErr                   data type is illegal
541 //      ippStsNumChannelsErr                channels value is illegal
542 //      ippStsSizeErr                       size fields values are illegal
543 //      ippStsNullPtrErr                    unexpected NULL pointer
544 //      ippStsNoErr                         no errors
545 IW_DECL(IppStatus) iwiMul(
546     const IwiImage     *pFactor1,   // [in]     Pointer to the first factor image
547     const IwiImage     *pFactor2,   // [in]     Pointer to the second factor image
548     IwiImage           *pDstImage,  // [in,out] Pointer to the product image (can be same as the second factor)
549     const IwiMulParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
550     const IwiTile      *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
551 );
552 /**/////////////////////////////////////////////////////////////////////////////
553 //                   iwiMulC
554 ///////////////////////////////////////////////////////////////////////////// */
555 
556 // Auxiliary parameters structure
557 typedef struct _IwiMulCParams
558 {
559     IppRoundMode     roundMode;     // Rounding mode
560     IppHintAlgorithm algoMode;      // Accuracy mode
561     int              scaleFactor;   // Scale factor
562     IwiChDescriptor  chDesc;        // Special channels processing mode
563 } IwiMulCParams;
564 
565 // Sets auxiliary parameters to default values
iwiMulC_SetDefaultParams(IwiMulCParams * pParams)566 static IW_INLINE void iwiMulC_SetDefaultParams(
567     IwiMulCParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
568 )
569 {
570     if(pParams)
571     {
572         pParams->roundMode   = ippRndNear;
573         pParams->algoMode    = ippAlgHintNone;
574         pParams->scaleFactor = 0;
575         pParams->chDesc      = iwiChDesc_None;
576     }
577 }
578 
579 // Performs multiplication of one image by constant and writes result to the output
580 // Features support:
581 //      Inplace mode:            yes (factor image and product)
582 //      64-bit sizes:            no
583 //      Internal threading:      no
584 //      Manual tiling:           yes
585 //      IwiTile simple tiling:   yes
586 //      IwiTile pipeline tiling: yes
587 // Returns:
588 //      ippStsDataTypeErr                   data type is illegal
589 //      ippStsNumChannelsErr                channels value is illegal
590 //      ippStsSizeErr                       size fields values are illegal
591 //      ippStsNullPtrErr                    unexpected NULL pointer
592 //      ippStsNoErr                         no errors
593 IW_DECL(IppStatus) iwiMulC(
594     const double        *pFactor,       // [in]     Pointer to the array of factors. One element for each channel
595     int                  factorsNum,    // [in]     Number of factors.
596                                         //          If factorsNum > number of channels then exceeding values will be ignored.
597                                         //          If factorsNum < number of channels then the last value will be replicated for the remaining channels
598     const IwiImage      *pFactorImage,  // [in]     Pointer to the factor image
599     IwiImage            *pDstImage,     // [in,out] Pointer to the product image (can be same as factor image)
600     const IwiMulCParams *pAuxParams,    // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
601     const IwiTile       *pTile          // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
602 );
603 
604 /**/////////////////////////////////////////////////////////////////////////////
605 //                   iwiDiv
606 ///////////////////////////////////////////////////////////////////////////// */
607 
608 // Auxiliary parameters structure
609 typedef struct _IwiDivParams
610 {
611     IppHintAlgorithm algoMode;          // Accuracy mode
612     int              scaleFactor;       // Scale factor
613     IwiChDescriptor  chDesc;            // Special channels processing mode
614 } IwiDivParams;
615 
616 // Sets auxiliary parameters to default values
iwiDiv_SetDefaultParams(IwiDivParams * pParams)617 static IW_INLINE void iwiDiv_SetDefaultParams(
618     IwiDivParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
619 )
620 {
621     if(pParams)
622     {
623         pParams->algoMode       = ippAlgHintNone;
624         pParams->scaleFactor    = 0;
625         pParams->chDesc         = iwiChDesc_None;
626     }
627 }
628 
629 // Performs division of the second image by the first image and writes result to the output
630 // Features support:
631 //      Inplace mode:            yes (numerator and fraction)
632 //      64-bit sizes:            yes
633 //      Internal threading:      no
634 //      Manual tiling:           yes
635 //      IwiTile simple tiling:   yes
636 //      IwiTile pipeline tiling: yes
637 // Returns:
638 //      ippStsDataTypeErr                   data type is illegal
639 //      ippStsNumChannelsErr                channels value is illegal
640 //      ippStsSizeErr                       size fields values are illegal
641 //      ippStsNullPtrErr                    unexpected NULL pointer
642 //      ippStsNoErr                         no errors
643 IW_DECL(IppStatus) iwiDiv(
644     const IwiImage     *pDenominator,   // [in]     Pointer to the denominator image
645     const IwiImage     *pNumerator,     // [in]     Pointer to the numerator image
646     IwiImage           *pDstImage,      // [in,out] Pointer to the fraction image (can be same as numerator)
647     const IwiDivParams *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
648     const IwiTile      *pTile           // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
649 );
650 
651 /**/////////////////////////////////////////////////////////////////////////////
652 //                   iwiDivC
653 ///////////////////////////////////////////////////////////////////////////// */
654 
655 // Auxiliary parameters structure
656 typedef struct _IwiDivCParams
657 {
658     IppRoundMode     roundMode;     // Rounding mode
659     IppHintAlgorithm algoMode;      // Accuracy mode
660     int              scaleFactor;   // Scale factor
661     IwiChDescriptor  chDesc;        // Special channels processing mode
662 } IwiDivCParams;
663 
664 // Sets auxiliary parameters to default values
iwiDivC_SetDefaultParams(IwiDivCParams * pParams)665 static IW_INLINE void iwiDivC_SetDefaultParams(
666     IwiDivCParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
667 )
668 {
669     if(pParams)
670     {
671         pParams->roundMode   = ippRndNear;
672         pParams->algoMode    = ippAlgHintNone;
673         pParams->scaleFactor = 0;
674         pParams->chDesc      = iwiChDesc_None;
675     }
676 }
677 
678 // Performs division of the second image by constant and writes result to the output
679 // Features support:
680 //      Inplace mode:            yes (numerator and fraction)
681 //      64-bit sizes:            no
682 //      Internal threading:      no
683 //      Manual tiling:           yes
684 //      IwiTile simple tiling:   yes
685 //      IwiTile pipeline tiling: yes
686 // Returns:
687 //      ippStsDataTypeErr                   data type is illegal
688 //      ippStsNumChannelsErr                channels value is illegal
689 //      ippStsSizeErr                       size fields values are illegal
690 //      ippStsNullPtrErr                    unexpected NULL pointer
691 //      ippStsNoErr                         no errors
692 IW_DECL(IppStatus) iwiDivC(
693     const double        *pDenominator,      // [in]     Pointer to the array of denominators. One element for each channel
694     int                  denominatorsNum,   // [in]     Number of denominators.
695                                             //          If denominatorsNum > number of channels then exceeding values will be ignored.
696                                             //          If denominatorsNum < number of channels then the last value will be replicated for the remaining channels
697     const IwiImage      *pNumeratorImage,   // [in]     Pointer to the numerator image
698     IwiImage            *pDstImage,         // [in,out] Pointer to the fraction image (can be same as numerator)
699     const IwiDivCParams *pAuxParams,        // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
700     const IwiTile       *pTile              // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
701 );
702 
703 /**/////////////////////////////////////////////////////////////////////////////
704 //                   iwiSwapChannels
705 ///////////////////////////////////////////////////////////////////////////// */
706 
707 // Auxiliary parameters structure
708 typedef struct _IwiSwapChannelsParams
709 {
710     IwiChDescriptor chDesc;     // Special channels processing mode
711 } IwiSwapChannelsParams;
712 
713 // Sets auxiliary parameters to default values
iwiSwapChannels_SetDefaultParams(IwiSwapChannelsParams * pParams)714 static IW_INLINE void iwiSwapChannels_SetDefaultParams(
715     IwiSwapChannelsParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
716 )
717 {
718     if(pParams)
719     {
720         pParams->chDesc = iwiChDesc_None;
721     }
722 }
723 
724 // Swaps image channels according to the destination order parameter.
725 // One source channel can be mapped to several destination channels.
726 // Special order rules:
727 // 1) if(dstOrder[channel] == srcChannels) dst[channel] = constValue
728 // 2) if(dstOrder[channel] < 0 || dstOrder[channel] > srcChannels) dst[channel] is unchanged
729 // Features support:
730 //      Inplace mode:            yes (8u only)
731 //      64-bit sizes:            no
732 //      Internal threading:      no
733 //      Manual tiling:           yes
734 //      IwiTile simple tiling:   yes
735 //      IwiTile pipeline tiling: yes
736 // Returns:
737 //      ippStsChannelOrderErr               destination order is out of the range
738 //      ippStsDataTypeErr                   data type is illegal
739 //      ippStsNumChannelsErr                channels value is illegal
740 //      ippStsSizeErr                       size fields values are illegal
741 //      ippStsNullPtrErr                    unexpected NULL pointer
742 //      ippStsNoErr                         no errors
743 IW_DECL(IppStatus) iwiSwapChannels(
744     const IwiImage              *pSrcImage,  // [in]     Pointer to the source image
745     IwiImage                    *pDstImage,  // [in,out] Pointer to the destination image
746     const int                   *pDstOrder,  // [in]     Pointer to the destination image channels order: dst[channel] = src[dstOrder[channel]]
747     double                       value,      // [in]     Value to fill the destination channel if number of destination channels is bigger than number of source channels
748     const IwiSwapChannelsParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
749     const IwiTile               *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
750 );
751 
752 /**/////////////////////////////////////////////////////////////////////////////
753 //                   iwiScale
754 ///////////////////////////////////////////////////////////////////////////// */
755 
756 // Auxiliary parameters structure
757 typedef struct _IwiScaleParams
758 {
759     IppHintAlgorithm algoMode;   // Accuracy mode
760 } IwiScaleParams;
761 
762 // Sets auxiliary parameters to default values
iwiScale_SetDefaultParams(IwiScaleParams * pParams)763 static IW_INLINE void iwiScale_SetDefaultParams(
764     IwiScaleParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
765 )
766 {
767     if(pParams)
768     {
769         pParams->algoMode = ippAlgHintNone;
770     }
771 }
772 
773 // Converts image from one data type to another with specified scaling and shifting
774 // DST = saturate(SRC*mulVal + addVal)
775 // Features support:
776 //      Inplace mode:            yes (for images of same type)
777 //      64-bit sizes:            no
778 //      Internal threading:      no
779 //      Manual tiling:           yes
780 //      IwiTile simple tiling:   yes
781 //      IwiTile pipeline tiling: yes
782 // Returns:
783 //      ippStsDataTypeErr                   data type is illegal
784 //      ippStsSizeErr                       size fields values are illegal
785 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer. If data types are different
786 //      ippStsNullPtrErr                    unexpected NULL pointer
787 //      ippStsNoErr                         no errors
788 IW_DECL(IppStatus) iwiScale(
789     const IwiImage         *pSrcImage,  // [in]     Pointer to the source image
790     IwiImage               *pDstImage,  // [in,out] Pointer to the destination image
791     Ipp64f                  mulVal,     // [in]     Multiplier
792     Ipp64f                  addVal,     // [in]     Addend
793     const IwiScaleParams   *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
794     const IwiTile          *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
795 );
796 
797 // Returns multiplication and addend values for iwiScale function to perform accurate data range scaling between two data types
798 // Data range for float values is considered to be from 0 to 1
799 // Returns:
800 //      ippStsDataTypeErr                   data type is illegal
801 //      ippStsNullPtrErr                    unexpected NULL pointer
802 //      ippStsNoErr                         no errors
803 IW_DECL(IppStatus) iwiScale_GetScaleVals(
804     IppDataType srcType,    // [in]     Source data type
805     IppDataType dstType,    // [in]     Destination data type
806     Ipp64f     *pMulVal,    // [out]    Pointer to multiplier
807     Ipp64f     *pAddVal     // [out]    Pointer to addend
808 );
809 
810 #ifdef __cplusplus
811 }
812 #endif
813 
814 #endif
815