1 #![allow(dead_code)]
2 #![allow(non_camel_case_types)]
3 #![allow(non_snake_case)]
4 
5 use std::os::raw::c_ulong;
6 
7 pub type dssim_px_t = f32;
8 
9 #[link(name = "Accelerate", kind = "framework")]
10 #[cfg(target_os = "macos")]
11 extern "C" {
vImageConvolve_PlanarF(src: *const vImage_Buffer<*const f32>, dest: *mut vImage_Buffer<*mut f32>, tempBuffer: *mut f32, srcOffsetToROI_X: vImagePixelCount, srcOffsetToROI_Y: vImagePixelCount, kernel: *const f32, kernel_height: u32, kernel_width: u32, backgroundColor: Pixel_F, flags: vImage_Flags) -> vImage_Error12     pub fn vImageConvolve_PlanarF(src: *const vImage_Buffer<*const f32>,
13                                   dest: *mut vImage_Buffer<*mut f32>,
14                                   tempBuffer: *mut f32,
15                                   srcOffsetToROI_X: vImagePixelCount,
16                                   srcOffsetToROI_Y: vImagePixelCount,
17                                   kernel: *const f32,
18                                   kernel_height: u32,
19                                   kernel_width: u32,
20                                   backgroundColor: Pixel_F,
21                                   flags: vImage_Flags) -> vImage_Error;
22 }
23 
24 pub type vImagePixelCount = c_ulong;
25 pub type vImage_Error = isize;
26 pub type Pixel_F = f32;
27 
28 #[repr(u32)]
29 pub enum vImage_Flags {
30     kvImageNoFlags = 0,
31 
32      /* Operate on red, green and blue channels only. Alpha is copied from source
33         to destination. For Interleaved formats only. */
34     kvImageLeaveAlphaUnchanged = 1,
35 
36      /* Copy edge pixels. Convolution Only. */
37     kvImageCopyInPlace = 2,
38 
39     /* Use the background color for missing pixels. */
40     kvImageBackgroundColorFill  = 4,
41 
42     /* Use the nearest pixel for missing pixels. */
43     kvImageEdgeExtend = 8,
44 
45     /* Pass to turn off internal tiling and disable internal multithreading. Use this if
46        you want to do your own tiling, or to use the Min/Max filters in place. */
47     kvImageDoNotTile =   16,
48 
49     /* Use a higher quality, slower resampling filter for Geometry operations
50        (shear, scale, rotate, affine transform, etc.) */
51     kvImageHighQualityResampling =   32,
52 
53      /* Use only the part of the kernel that overlaps the image. For integer kernels,
54         real_divisor = divisor * (sum of used kernel elements) / (sum of kernel elements).
55         This should preserve image brightness at the edges. Convolution only. */
56     kvImageTruncateKernel  =   64,
57 
58     /* The function will return the number of bytes required for the temp buffer.
59        If this value is negative, it is an error, per standard usage. */
60     kvImageGetTempBufferSize =  128,
61 
62     /* Some functions such as vImageConverter_CreateWithCGImageFormat have so many possible error conditions
63        that developers may need more help than a simple error code to diagnose problems. When this
64        flag is set and an error is encountered, an informative error message will be logged to the Apple
65        System Logger (ASL).  The output should be visible in Console.app. */
66     kvImagePrintDiagnosticsToConsole =  256,
67 
68     /* Pass this flag to prevent vImage from allocating additional storage. */
69     kvImageNoAllocate =  512,
70 
71     /* Use methods that are HDR-aware, capable of providing correct results for input images with pixel values
72        outside the otherwise limited (typically [-2,2]) range. This may be slower. */
73     kvImageHDRContent =  1024
74 }
75 
76 
77 #[repr(C)]
78 pub struct vImage_Buffer<T> {
79     pub data: T,
80     pub height: vImagePixelCount,
81     pub width: vImagePixelCount,
82     pub rowBytes: usize,
83 }
84 
85