Ocean
Loading...
Searching...
No Matches
TestFrameConverterY_U_V12.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_Y_U_V_12_H
9#define META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_Y_U_V_12_H
10
13
14#include "ocean/base/Worker.h"
15
17
19
20namespace Ocean
21{
22
23namespace Test
24{
25
26namespace TestCV
27{
28
29/**
30 * This class implements a Y_U_V 12bit frame converter test.
31 * @ingroup testcv
32 */
33class OCEAN_TEST_CV_EXPORT TestFrameConverterY_U_V12
34{
35 public:
36
37 /**
38 * Tests all Y_U_V12 frame conversion functions.
39 * @param width The width of the original frame in pixel, with range [1, infinity)
40 * @param height The height of the original frame in pixel, with range [1, infinity)
41 * @param testDuration Number of seconds for each test, with range (0, infinity)
42 * @param worker The worker object to distribute the computation
43 * @param selector The test selector to control which tests to run
44 * @return True, if succeeded
45 */
46 static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker, const TestSelector& selector = TestSelector());
47
48 /**
49 * Tests the Y_U_V12 to Y_U_V12 conversion.
50 * @param width The width of the original frame in pixel, with range [1, infinity)
51 * @param height The height of the original frame in pixel, with range [1, infinity)
52 * @param conversionFlag The conversion flag that has been applied during conversion
53 * @param testDuration Number of seconds for each test, with range (0, infinity)
54 * @param worker The worker object to distribute the computation
55 * @return True, if succeeded
56 */
57 static bool testY_U_V12ToY_U_V12(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
58
59 /**
60 * Tests the Y_U_V12_LIMITED_RANGE to BGR24 (full range) conversion.
61 * @param width The width of the original frame in pixel, with range [1, infinity)
62 * @param height The height of the original frame in pixel, with range [1, infinity)
63 * @param conversionFlag The conversion flag that has been applied during conversion
64 * @param testDuration Number of seconds for each test, with range (0, infinity)
65 * @param worker The worker object to distribute the computation
66 * @return True, if succeeded
67 */
68 static bool testY_U_V12LimitedRangeToBGR24FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
69
70 /**
71 * Tests the Y_U_V12_FULL_RANGE to BGR24 (full range) conversion.
72 * @param width The width of the original frame in pixel, with range [1, infinity)
73 * @param height The height of the original frame in pixel, with range [1, infinity)
74 * @param conversionFlag The conversion flag that has been applied during conversion
75 * @param testDuration Number of seconds for each test, with range (0, infinity)
76 * @param worker The worker object to distribute the computation
77 * @return True, if succeeded
78 */
79 static bool testY_U_V12FullRangeToBGR24FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
80
81 /**
82 * Tests the Y_U_V12_LIMITED_RANGE to BGRA32 (full range) conversion with 6 bit precision.
83 * @param width The width of the original frame in pixel, with range [1, infinity)
84 * @param height The height of the original frame in pixel, with range [1, infinity)
85 * @param conversionFlag The conversion flag that has been applied during conversion
86 * @param testDuration Number of seconds for each test, with range (0, infinity)
87 * @param worker The worker object to distribute the computation
88 * @return True, if succeeded
89 */
90 static bool testY_U_V12LimitedRangeToBGRA32FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
91
92 /**
93 * Tests the Y_U_V12_LIMITED_RANGE to RGB24 (full range) conversion.
94 * @param width The width of the original frame in pixel, with range [1, infinity)
95 * @param height The height of the original frame in pixel, with range [1, infinity)
96 * @param conversionFlag The conversion flag that has been applied during conversion
97 * @param testDuration Number of seconds for each test, with range (0, infinity)
98 * @param worker The worker object to distribute the computation
99 * @return True, if succeeded
100 */
101 static bool testY_U_V12LimitedRangeToRGB24FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
102
103 /**
104 * Tests the Y_U_V12_LIMITED_RANGE to RGB24 (full range) conversion with 6 bit precision.
105 * @param width The width of the original frame in pixel, with range [1, infinity)
106 * @param height The height of the original frame in pixel, with range [1, infinity)
107 * @param conversionFlag The conversion flag that has been applied during conversion
108 * @param testDuration Number of seconds for each test, with range (0, infinity)
109 * @param worker The worker object to distribute the computation
110 * @return True, if succeeded
111 */
112 static bool testY_U_V12LimitedRangeToRGB24FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
113
114 /**
115 * Tests the Y_U_V12_FULL_RANGE to RGB24 (full range) conversion.
116 * @param width The width of the original frame in pixel, with range [1, infinity)
117 * @param height The height of the original frame in pixel, with range [1, infinity)
118 * @param conversionFlag The conversion flag that has been applied during conversion
119 * @param testDuration Number of seconds for each test, with range (0, infinity)
120 * @param worker The worker object to distribute the computation
121 * @return True, if succeeded
122 */
123 static bool testY_U_V12FullRangeToRGB24FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
124
125 /**
126 * Tests the Y_U_V12_LIMITED_RANGE to RGBA32 (full range) conversion with 6 bit precision.
127 * @param width The width of the original frame in pixel, with range [1, infinity)
128 * @param height The height of the original frame in pixel, with range [1, infinity)
129 * @param conversionFlag The conversion flag that has been applied during conversion
130 * @param testDuration Number of seconds for each test, with range (0, infinity)
131 * @param worker The worker object to distribute the computation
132 * @return True, if succeeded
133 */
134 static bool testY_U_V12LimitedRangeToRGBA32FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
135
136 /**
137 * Tests the Y_U_V12 to YUV24 conversion.
138 * @param width The width of the original frame in pixel, with range [1, infinity)
139 * @param height The height of the original frame in pixel, with range [1, infinity)
140 * @param conversionFlag The conversion flag that has been applied during conversion
141 * @param testDuration Number of seconds for each test, with range (0, infinity)
142 * @param worker The worker object to distribute the computation
143 * @return True, if succeeded
144 */
145 static bool testY_U_V12ToYUV24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
146
147 /**
148 * Tests the Y_U_V12 to YVU24 conversion.
149 * @param width The width of the original frame in pixel, with range [1, infinity)
150 * @param height The height of the original frame in pixel, with range [1, infinity)
151 * @param conversionFlag The conversion flag that has been applied during conversion
152 * @param testDuration Number of seconds for each test, with range (0, infinity)
153 * @param worker The worker object to distribute the computation
154 * @return True, if succeeded
155 */
156 static bool testY_U_V12ToYVU24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
157
158 /**
159 * Tests the Y_U_V12_LIMITED_RANGE to Y8_LIMITED_RANGE conversion.
160 * @param width The width of the original frame in pixel, with range [1, infinity)
161 * @param height The height of the original frame in pixel, with range [1, infinity)
162 * @param conversionFlag The conversion flag that has been applied during conversion
163 * @param testDuration Number of seconds for each test, with range (0, infinity)
164 * @param worker The worker object to distribute the computation
165 * @return True, if succeeded
166 */
167 static bool testY_U_V12LimitedRangeToY8LimitedRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
168
169 /**
170 * Tests the Y_U_V12_FULL_RANGE to Y8_FULL_RANGE conversion.
171 * @param width The width of the original frame in pixel, with range [1, infinity)
172 * @param height The height of the original frame in pixel, with range [1, infinity)
173 * @param conversionFlag The conversion flag that has been applied during conversion
174 * @param testDuration Number of seconds for each test, with range (0, infinity)
175 * @param worker The worker object to distribute the computation
176 * @return True, if succeeded
177 */
178 static bool testY_U_V12FullRangeToY8FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
179
180 /**
181 * Tests the Y_U_V12_LIMITED_RANGE to Y8_FULL_RANGE conversion.
182 * @param width The width of the original frame in pixel, with range [1, infinity)
183 * @param height The height of the original frame in pixel, with range [1, infinity)
184 * @param conversionFlag The conversion flag that has been applied during conversion
185 * @param testDuration Number of seconds for each test, with range (0, infinity)
186 * @param worker The worker object to distribute the computation
187 * @return True, if succeeded
188 */
189 static bool testY_U_V12LimitedRangeToY8FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
190
191 /**
192 * Tests the Y_U_V12_FULL_RANGE to Y8_LIMITED_RANGE conversion.
193 * @param width The width of the original frame in pixel, with range [1, infinity)
194 * @param height The height of the original frame in pixel, with range [1, infinity)
195 * @param conversionFlag The conversion flag that has been applied during conversion
196 * @param testDuration Number of seconds for each test, with range (0, infinity)
197 * @param worker The worker object to distribute the computation
198 * @return True, if succeeded
199 */
200 static bool testY_U_V12FullRangeToY8LimitedRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker& worker);
201
202 /**
203 * Tests the Y_U_V12 to Y_UV12 conversion.
204 * This conversion is not part of the conversion function map and accepts source planes with a pixel stride larger than 1, so the test is applied manually instead of via FrameConverterTestUtilities.
205 * @param width The width of the original frame in pixel, with range [2, infinity), must be even
206 * @param height The height of the original frame in pixel, with range [2, infinity), must be even
207 * @param testDuration Number of seconds for each test, with range (0, infinity)
208 * @param worker The worker object to distribute the computation
209 * @return True, if succeeded
210 */
211 static bool testY_U_V12ToY_UV12(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
212
213 protected:
214
215 /**
216 * Validates the Y_U_V12 to Y_UV12 conversion.
217 * @param ySource The y source plane, with (width + ySourcePaddingElements) * height elements, must be valid
218 * @param uSource The u source plane, with (width/2 + uSourcePaddingElements) * height/2 elements, must be valid
219 * @param vSource The v source plane, with (width/2 + vSourcePaddingElements) * height/2 elements, must be valid
220 * @param yTarget The y target plane, with (width + yTargetPaddingElements) * height elements, must be valid
221 * @param uvTarget The uv target plane, with (width + uvTargetPaddingElements) * height/2 elements, must be valid
222 * @param width The width of the frame in pixel, with range [2, infinity), must be even
223 * @param height The height of the frame in pixel, with range [2, infinity), must be even
224 * @param ySourcePaddingElements The number of padding elements at the end of each y-source row, in (uint8_t) elements, with range [0, infinity)
225 * @param uSourcePaddingElements The number of padding elements at the end of each u-source row, in (uint8_t) elements, with range [0, infinity)
226 * @param vSourcePaddingElements The number of padding elements at the end of each v-source row, in (uint8_t) elements, with range [0, infinity)
227 * @param yTargetPaddingElements The number of padding elements at the end of each y-target row, in (uint8_t) elements, with range [0, infinity)
228 * @param uvTargetPaddingElements The number of padding elements at the end of each uv-target row, in (uint8_t) elements, with range [0, infinity)
229 * @param ySourcePixelStride The stride between consecutive pixels in the y source plane, in elements, with range [1, infinity)
230 * @param uSourcePixelStride The stride between consecutive pixels in the u source plane, in elements, with range [1, infinity)
231 * @param vSourcePixelStride The stride between consecutive pixels in the v source plane, in elements, with range [1, infinity)
232 * @return True, if the target planes hold the expected values
233 */
234 static bool validateY_U_V12ToY_UV12(const uint8_t* ySource, const uint8_t* uSource, const uint8_t* vSource, const uint8_t* yTarget, const uint8_t* uvTarget, const unsigned int width, const unsigned int height, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uvTargetPaddingElements, const unsigned int ySourcePixelStride, const unsigned int uSourcePixelStride, const unsigned int vSourcePixelStride);
235
236 /**
237 * Extracts one pixel from a Y_U_V12 source frame.
238 * @param frame The frame from which the pixel will be extracted, must be valid
239 * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
240 * @param y The vertical pixel location within the frame, with range [0, frame.height() - 1]
241 * @param conversionFlag The conversion flag that will be applied, must be valid
242 * @return The vector holding the frame's color value at the specified location
243 */
244 static MatrixD pixelFunctionY_U_V12ForYUV24(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag);
245};
246
247}
248
249}
250
251}
252
253#endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_Y_U_V_12_H
ConversionFlag
Definition of individual conversion flags.
Definition FrameConverter.h:40
This class implements Ocean's image class.
Definition Frame.h:1969
This class implements a matrix with arbitrary size.
Definition Matrix.h:63
This class implements a Y_U_V 12bit frame converter test.
Definition TestFrameConverterY_U_V12.h:34
static bool testY_U_V12ToYVU24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12 to YVU24 conversion.
static bool validateY_U_V12ToY_UV12(const uint8_t *ySource, const uint8_t *uSource, const uint8_t *vSource, const uint8_t *yTarget, const uint8_t *uvTarget, const unsigned int width, const unsigned int height, const unsigned int ySourcePaddingElements, const unsigned int uSourcePaddingElements, const unsigned int vSourcePaddingElements, const unsigned int yTargetPaddingElements, const unsigned int uvTargetPaddingElements, const unsigned int ySourcePixelStride, const unsigned int uSourcePixelStride, const unsigned int vSourcePixelStride)
Validates the Y_U_V12 to Y_UV12 conversion.
static bool testY_U_V12LimitedRangeToY8LimitedRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to Y8_LIMITED_RANGE conversion.
static bool testY_U_V12LimitedRangeToY8FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to Y8_FULL_RANGE conversion.
static bool testY_U_V12ToYUV24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12 to YUV24 conversion.
static bool testY_U_V12LimitedRangeToBGR24FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to BGR24 (full range) conversion.
static bool testY_U_V12FullRangeToRGB24FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_FULL_RANGE to RGB24 (full range) conversion.
static bool testY_U_V12LimitedRangeToRGBA32FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to RGBA32 (full range) conversion with 6 bit precision.
static MatrixD pixelFunctionY_U_V12ForYUV24(const Frame &frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag)
Extracts one pixel from a Y_U_V12 source frame.
static bool testY_U_V12ToY_UV12(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the Y_U_V12 to Y_UV12 conversion.
static bool testY_U_V12FullRangeToBGR24FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_FULL_RANGE to BGR24 (full range) conversion.
static bool testY_U_V12ToY_U_V12(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12 to Y_U_V12 conversion.
static bool testY_U_V12LimitedRangeToRGB24FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to RGB24 (full range) conversion with 6 bit precision.
static bool testY_U_V12FullRangeToY8LimitedRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_FULL_RANGE to Y8_LIMITED_RANGE conversion.
static bool testY_U_V12LimitedRangeToRGB24FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to RGB24 (full range) conversion.
static bool testY_U_V12LimitedRangeToBGRA32FullRangePrecision6Bit(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_LIMITED_RANGE to BGRA32 (full range) conversion with 6 bit precision.
static bool testY_U_V12FullRangeToY8FullRange(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag conversionFlag, const double testDuration, Worker &worker)
Tests the Y_U_V12_FULL_RANGE to Y8_FULL_RANGE conversion.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker, const TestSelector &selector=TestSelector())
Tests all Y_U_V12 frame conversion functions.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15