/src/Simd/src/Simd/SimdBaseBayerToBgr.cpp
Line | Count | Source |
1 | | /* |
2 | | * Simd Library (http://ermig1979.github.io/Simd). |
3 | | * |
4 | | * Copyright (c) 2011-2018 Yermalayeu Ihar. |
5 | | * |
6 | | * Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | | * of this software and associated documentation files (the "Software"), to deal |
8 | | * in the Software without restriction, including without limitation the rights |
9 | | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
10 | | * copies of the Software, and to permit persons to whom the Software is |
11 | | * furnished to do so, subject to the following conditions: |
12 | | * |
13 | | * The above copyright notice and this permission notice shall be included in |
14 | | * all copies or substantial portions of the Software. |
15 | | * |
16 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
20 | | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
21 | | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
22 | | * SOFTWARE. |
23 | | */ |
24 | | #include "Simd/SimdBayer.h" |
25 | | |
26 | | namespace Simd |
27 | | { |
28 | | namespace Base |
29 | | { |
30 | | template <SimdPixelFormatType bayerFormat> void BayerToBgr(const uint8_t * src[6], |
31 | | size_t col0, size_t col2, size_t col4, uint8_t * dst, size_t stride) |
32 | 0 | { |
33 | 0 | BayerToBgr<bayerFormat>(src, |
34 | 0 | col0, col0 + 1, col2, col2 + 1, col4, col4 + 1, |
35 | 0 | dst, dst + 3, dst + stride, dst + stride + 3); |
36 | 0 | } Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)10>(unsigned char const**, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)11>(unsigned char const**, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)12>(unsigned char const**, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)13>(unsigned char const**, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) |
37 | | |
38 | | template <SimdPixelFormatType bayerFormat> void BayerToBgr(const uint8_t * bayer, size_t width, size_t height, size_t bayerStride, uint8_t * bgr, size_t bgrStride) |
39 | 0 | { |
40 | 0 | const uint8_t * src[6]; |
41 | 0 | for (size_t row = 0; row < height; row += 2) |
42 | 0 | { |
43 | 0 | src[0] = (row == 0 ? bayer : bayer - 2 * bayerStride); |
44 | 0 | src[1] = src[0] + bayerStride; |
45 | 0 | src[2] = bayer; |
46 | 0 | src[3] = src[2] + bayerStride; |
47 | 0 | src[4] = (row == height - 2 ? bayer : bayer + 2 * bayerStride); |
48 | 0 | src[5] = src[4] + bayerStride; |
49 | |
|
50 | 0 | BayerToBgr<bayerFormat>(src, 0, 0, 2, bgr, bgrStride); |
51 | |
|
52 | 0 | for (size_t col = 2; col < width - 2; col += 2) |
53 | 0 | BayerToBgr<bayerFormat>(src, col - 2, col, col + 2, bgr + 3 * col, bgrStride); |
54 | |
|
55 | 0 | BayerToBgr<bayerFormat>(src, width - 4, width - 2, width - 2, bgr + 3 * (width - 2), bgrStride); |
56 | |
|
57 | 0 | bayer += 2 * bayerStride; |
58 | 0 | bgr += 2 * bgrStride; |
59 | 0 | } |
60 | 0 | } Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)10>(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)11>(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)12>(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) Unexecuted instantiation: void Simd::Base::BayerToBgr<(SimdPixelFormatType)13>(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) |
61 | | |
62 | | void BayerToBgr(const uint8_t * bayer, size_t width, size_t height, size_t bayerStride, SimdPixelFormatType bayerFormat, uint8_t * bgr, size_t bgrStride) |
63 | 0 | { |
64 | 0 | assert((width % 2 == 0) && (height % 2 == 0)); |
65 | |
|
66 | 0 | switch (bayerFormat) |
67 | 0 | { |
68 | 0 | case SimdPixelFormatBayerGrbg: |
69 | 0 | BayerToBgr<SimdPixelFormatBayerGrbg>(bayer, width, height, bayerStride, bgr, bgrStride); |
70 | 0 | break; |
71 | 0 | case SimdPixelFormatBayerGbrg: |
72 | 0 | BayerToBgr<SimdPixelFormatBayerGbrg>(bayer, width, height, bayerStride, bgr, bgrStride); |
73 | 0 | break; |
74 | 0 | case SimdPixelFormatBayerRggb: |
75 | 0 | BayerToBgr<SimdPixelFormatBayerRggb>(bayer, width, height, bayerStride, bgr, bgrStride); |
76 | 0 | break; |
77 | 0 | case SimdPixelFormatBayerBggr: |
78 | 0 | BayerToBgr<SimdPixelFormatBayerBggr>(bayer, width, height, bayerStride, bgr, bgrStride); |
79 | 0 | break; |
80 | 0 | default: |
81 | | assert(0); |
82 | 0 | } |
83 | 0 | } |
84 | | } |
85 | | } |