Ocean
Loading...
Searching...
No Matches
TestWIC.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_WIC_H
9#define META_OCEAN_TEST_TESTMEDIA_TEST_WIC_H
10
12
14
15#ifdef OCEAN_PLATFORM_BUILD_WINDOWS
16
17#include "ocean/base/Frame.h"
18
19namespace Ocean
20{
21
22namespace Test
23{
24
25namespace TestMedia
26{
27
28/**
29 * This class implements a test for the WIC media library.
30 * @ingroup testmedia
31 */
32class OCEAN_TEST_MEDIA_EXPORT TestWIC
33{
34 public:
35
36 /**
37 * Invokes all tests that are defined.
38 * @param testDuration The number of seconds for each test
39 * @param selector The test selector
40 * @return True, if succeeded
41 */
42 static bool test(const double testDuration, const TestSelector& selector);
43
44 /**
45 * Tests the read and write functions for any image.
46 * @param testDuration The number of seconds for each test
47 * @return True, if succeeded
48 */
49 static bool testAnyImageEncodeDecode(const double testDuration);
50
51 /**
52 * Tests the read and write functions for BMP images.
53 * @param width The width of the frame to be tested, with range [1, infinity)
54 * @param height The height of the frame to be tested, with range [1, infinity)
55 * @param pixelFormat The pixel format of the frame to be tested, must be valid
56 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
57 * @param testDuration The number of seconds for each test
58 * @return True, if succeeded
59 */
60 static bool testBmpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
61
62#ifdef OCEAN_MEDIA_OIL_SUPPORT_JPG
63
64 /**
65 * Tests the read and write functions for JPEG images.
66 * @param width The width of the frame to be tested, with range [1, infinity)
67 * @param height The height of the frame to be tested, with range [1, infinity)
68 * @param pixelFormat The pixel format of the frame to be tested, must be valid
69 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
70 * @param testDuration The number of seconds for each test
71 * @return True, if succeeded
72 */
73 static bool testJpgImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
74
75#endif // OCEAN_MEDIA_OIL_SUPPORT_JPG
76
77#ifdef OCEAN_MEDIA_OIL_SUPPORT_PNG
78
79 /**
80 * Tests the read and write functions for PNG images.
81 * @param width The width of the frame to be tested, with range [1, infinity)
82 * @param height The height of the frame to be tested, with range [1, infinity)
83 * @param pixelFormat The pixel format of the frame to be tested, must be valid
84 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
85 * @param testDuration The number of seconds for each test
86 * @return True, if succeeded
87 */
88 static bool testPngImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
89
90#endif // OCEAN_MEDIA_OIL_SUPPORT_PNG
91
92#ifdef OCEAN_MEDIA_OIL_SUPPORT_TIF
93
94 /**
95 * Tests the read and write functions for TIFF images.
96 * @param width The width of the frame to be tested, with range [1, infinity)
97 * @param height The height of the frame to be tested, with range [1, infinity)
98 * @param pixelFormat The pixel format of the frame to be tested, must be valid
99 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
100 * @param testDuration The number of seconds for each test
101 * @return True, if succeeded
102 */
103 static bool testTifImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
104
105#endif // OCEAN_MEDIA_OIL_SUPPORT_TIF
106
107 /**
108 * Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
109 * @param frameType The frame type to be used for testing, must be valid
110 * @param imageType The file extension of the image to be created (e.g. jpg, png, bmp, or tif), must be defined
111 * @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
112 * @return True, if succeeded
113 */
114 static bool testBufferImageRecorder(const FrameType& frameType, const std::string& imageType, const double maximalAverageDifference);
115
116 protected:
117
118 /**
119 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
120 * @param firstFrame The first frame for which the similarity will be determined, must be valid
121 * @param secondFrame The second frame for which the similarity will be determined, with identical frame type as 'firstFrame' must be valid
122 * @param minDifference Resulting minimal value difference, with range [0, infinity)
123 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
124 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
125 * @return True, if succeeded
126 */
127 static bool determineSimilarity(const Frame& firstFrame, const Frame& secondFrame, double& minDifference, double& aveDifference, double& maxDifference);
128
129 /**
130 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
131 * @param firstFrame The image data of the first frame for which the similarity will be determined, must be valid
132 * @param secondFrame The image data of the second frame for which the similarity will be determined, must be valid
133 * @param width The width of the frames in pixel, with range [1, infinity)
134 * @param height The height of the frames in pixel, with range [1, infinity)
135 * @param channels The number of frame channels, with range [1, infinity)
136 * @param firstFramePaddingElements The number of padding elements at the end of each first image row, in elements, with range [0, infinity)
137 * @param secondFramePaddingElements The number of padding elements at the end of each second image row, in elements, with range [0, infinity)
138 * @param minDifference Resulting minimal value difference, with range [0, infinity)
139 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
140 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
141 */
142 template <typename T>
143 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);
144};
145
146}
147
148}
149
150}
151
152#endif // META_OCEAN_TEST_TESTMEDIA_TEST_WIC_H
153
154#endif // OCEAN_PLATFORM_BUILD_WINDOWS
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 WIC media library.
Definition TestWIC.h:33
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 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 testAnyImageEncodeDecode(const double testDuration)
Tests the read and write functions for any image.
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 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.
static bool test(const double testDuration, const TestSelector &selector)
Invokes all tests that are defined.
static bool testBmpImageEncodeDecode(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 BMP 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 testBufferImageRecorder(const FrameType &frameType, const std::string &imageType, const double maximalAverageDifference)
Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
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