Ocean
Loading...
Searching...
No Matches
TestOpenImageLibraries.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_TESTMEDIA_TEST_OPEN_IMAGE_LIBRARIES_H
9#define META_OCEAN_TEST_TESTMEDIA_TEST_OPEN_IMAGE_LIBRARIES_H
10
12
14
15#include "ocean/base/Frame.h"
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestMedia
24{
25
26/**
27 * This class implements a test for the OpenImageLibraries media library.
28 * @ingroup testmedia
29 */
30class OCEAN_TEST_MEDIA_EXPORT TestOpenImageLibraries
31{
32 public:
33
34 /**
35 * Invokes all tests that are defined.
36 * @param testDuration The number of seconds for each test
37 * @param selector The test selector
38 * @return True, if succeeded
39 */
40 static bool test(const double testDuration, const TestSelector& selector);
41
42#ifdef OCEAN_MEDIA_OIL_SUPPORT_JPG
43
44 /**
45 * Tests the read and write functions for JPEG images.
46 * @param testDuration The number of seconds for each test
47 * @return True, if succeeded
48 */
49 static bool testJpgImageEncodeDecode(const double testDuration);
50
51#endif // OCEAN_MEDIA_OIL_SUPPORT_JPG
52
53#ifdef OCEAN_MEDIA_OIL_SUPPORT_PNG
54
55 /**
56 * Tests the read and write functions for PNG images.
57 * @param testDuration The number of seconds for each test
58 * @return True, if succeeded
59 */
60 static bool testPngImageEncodeDecode(const double testDuration);
61
62#endif // OCEAN_MEDIA_OIL_SUPPORT_PNG
63
64#ifdef OCEAN_MEDIA_OIL_SUPPORT_TIF
65
66 /**
67 * Tests the read and write functions for TIF images.
68 * @param testDuration The number of seconds for each test
69 * @return True, if succeeded
70 */
71 static bool testTifImageEncodeDecode(const double testDuration);
72
73#endif // OCEAN_MEDIA_OIL_SUPPORT_TIF
74
75#ifdef OCEAN_MEDIA_OIL_SUPPORT_WEBP
76
77 /**
78 * Tests the read and write functions for WEBP images.
79 * @param testDuration The number of seconds for each test
80 * @return True, if succeeded
81 */
82 static bool testWebpImageEncodeDecode(const double testDuration);
83
84#endif // OCEAN_MEDIA_OIL_SUPPORT_WEBP
85
86 /**
87 * Tests the read and write functions for any image.
88 * @param testDuration The number of seconds for each test
89 * @return True, if succeeded
90 */
91 static bool testAnyImageEncodeDecode(const double testDuration);
92
93#ifdef OCEAN_MEDIA_OIL_SUPPORT_JPG
94
95 /**
96 * Tests the read and write functions for JPEG images.
97 * @param width The width of the frame to be tested, with range [1, infinity)
98 * @param height The height of the frame to be tested, with range [1, infinity)
99 * @param pixelFormat The pixel format of the frame to be tested, must be valid
100 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
101 * @param testDuration The number of seconds for each test
102 * @return True, if succeeded
103 */
104 static bool testJpgImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
105
106 /**
107 * Applies a stress test for the JPEG decoder.
108 * @return True, if succeeded
109 */
111
112#endif // OCEAN_MEDIA_OIL_SUPPORT_JPG
113
114#ifdef OCEAN_MEDIA_OIL_SUPPORT_PNG
115
116 /**
117 * Tests the read and write functions for PNG images.
118 * @param width The width of the frame to be tested, with range [1, infinity)
119 * @param height The height of the frame to be tested, with range [1, infinity)
120 * @param pixelFormat The pixel format of the frame to be tested, must be valid
121 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
122 * @param testDuration The number of seconds for each test
123 * @return True, if succeeded
124 */
125 static bool testPngImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
126
127 /**
128 * Applies a stress test for the PNG decoder.
129 * @return True, if succeeded
130 */
132
133#endif // OCEAN_MEDIA_OIL_SUPPORT_PNG
134
135#ifdef OCEAN_MEDIA_OIL_SUPPORT_TIF
136
137 /**
138 * Tests the read and write functions for TIFF images.
139 * @param width The width of the frame to be tested, with range [1, infinity)
140 * @param height The height of the frame to be tested, with range [1, infinity)
141 * @param pixelFormat The pixel format of the frame to be tested, must be valid
142 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
143 * @param testDuration The number of seconds for each test
144 * @return True, if succeeded
145 */
146 static bool testTifImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
147
148 /**
149 * Applies a stress test for the TIFF decoder.
150 * @return True, if succeeded
151 */
153
154#endif // OCEAN_MEDIA_OIL_SUPPORT_TIF
155
156#ifdef OCEAN_MEDIA_OIL_SUPPORT_GIF
157
158 /**
159 * Applies a stress test for the GIF decoder.
160 * @return True, if succeeded
161 */
163
164#endif // OCEAN_MEDIA_OIL_SUPPORT_GIF
165
166#ifdef OCEAN_MEDIA_OIL_SUPPORT_WEBP
167
168 /**
169 * Tests the read and write functions for WEBP images.
170 * @param width The width of the frame to be tested, with range [1, infinity)
171 * @param height The height of the frame to be tested, with range [1, infinity)
172 * @param pixelFormat The pixel format of the frame to be tested, must be valid
173 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
174 * @param testDuration The number of seconds for each test
175 * @return True, if succeeded
176 */
177 static bool testWebpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
178
179 /**
180 * Applies a stress test for the WEBP decoder.
181 * @return True, if succeeded
182 */
184
185#endif // OCEAN_MEDIA_OIL_SUPPORT_WEBP
186
187 /**
188 * Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
189 * @param frameType The frame type to be used for testing, must be valid
190 * @param imageType The file extension of the image to be created (e.g. jpg, png, bmp, or tif), must be defined
191 * @param maximalAverageDifference The maximal average difference between two frames so that they still count as similar, with range [0, infinity), 0 for lossless compress, >0 for lossy compression
192 * @return True, if succeeded
193 */
194 static bool testBufferImageRecorder(const FrameType& frameType, const std::string& imageType, const double maximalAverageDifference);
195
196 /**
197 * Applies a stress test for any decoder.
198 * @return True, if succeeded
199 */
200 static bool testDecodeStressTest();
201
202 protected:
203
204 /**
205 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
206 * @param firstFrame The first frame for which the similarity will be determined, must be valid
207 * @param secondFrame The second frame for which the similarity will be determined, with identical frame type as 'firstFrame' must be valid
208 * @param minDifference Resulting minimal value difference, with range [0, infinity)
209 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
210 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
211 * @return True, if succeeded
212 */
213 static bool determineSimilarity(const Frame& firstFrame, const Frame& secondFrame, double& minDifference, double& aveDifference, double& maxDifference);
214
215 /**
216 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
217 * @param firstFrame The image data of the first frame for which the similarity will be determined, must be valid
218 * @param secondFrame The image data of the second frame for which the similarity will be determined, must be valid
219 * @param width The width of the frames in pixel, with range [1, infinity)
220 * @param height The height of the frames in pixel, with range [1, infinity)
221 * @param channels The number of frame channels, with range [1, infinity)
222 * @param firstFramePaddingElements The number of padding elements at the end of each first image row, in elements, with range [0, infinity)
223 * @param secondFramePaddingElements The number of padding elements at the end of each second image row, in elements, with range [0, infinity)
224 * @param minDifference Resulting minimal value difference, with range [0, infinity)
225 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
226 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
227 */
228 template <typename T>
229 static void determineSimilarity(const T* firstFrame, const T* secondFrame, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int firstFramePaddingElements, const unsigned int secondFramePaddingElements, double& minDifference, double& aveDifference, double& maxDifference);
230};
231
232}
233
234}
235
236}
237
238#endif // META_OCEAN_TEST_TESTMEDIA_TEST_OPEN_IMAGE_LIBRARIES_H
This class implements Ocean's image class.
Definition Frame.h:1879
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1046
This class implements a test for the OpenImageLibraries media library.
Definition TestOpenImageLibraries.h:31
static void determineSimilarity(const T *firstFrame, const T *secondFrame, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int firstFramePaddingElements, const unsigned int secondFramePaddingElements, double &minDifference, double &aveDifference, double &maxDifference)
Determines the minimal, the average and the maximal distance between corresponding pixel values (chan...
static bool testAnyImageEncodeDecode(const double testDuration)
Tests the read and write functions for any image.
static bool testPngDecodeStressTest()
Applies a stress test for the PNG decoder.
static bool testJpgImageEncodeDecode(const double testDuration)
Tests the read and write functions for JPEG images.
static bool testWebpDecodeStressTest()
Applies a stress test for the WEBP decoder.
static bool testTifImageEncodeDecode(const double testDuration)
Tests the read and write functions for TIF images.
static bool testWebpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for WEBP images.
static bool testTifImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for TIFF images.
static bool testPngImageEncodeDecode(const double testDuration)
Tests the read and write functions for PNG images.
static bool testDecodeStressTest()
Applies a stress test for any decoder.
static bool testGifDecodeStressTest()
Applies a stress test for the GIF decoder.
static bool testTifDecodeStressTest()
Applies a stress test for the TIFF decoder.
static bool testWebpImageEncodeDecode(const double testDuration)
Tests the read and write functions for WEBP images.
static bool testPngImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for PNG images.
static bool test(const double testDuration, const TestSelector &selector)
Invokes all tests that are defined.
static bool determineSimilarity(const Frame &firstFrame, const Frame &secondFrame, double &minDifference, double &aveDifference, double &maxDifference)
Determines the minimal, the average and the maximal distance between corresponding pixel values (chan...
static bool testJpgDecodeStressTest()
Applies a stress test for the JPEG decoder.
static bool testBufferImageRecorder(const FrameType &frameType, const std::string &imageType, const double maximalAverageDifference)
Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
static bool testJpgImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for JPEG images.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
The namespace covering the entire Ocean framework.
Definition Accessor.h:15