Ocean
Loading...
Searching...
No Matches
TestAVFoundation.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_AV_FOUNDATION_H
9#define META_OCEAN_TEST_TESTMEDIA_TEST_AV_FOUNDATION_H
10
12
14
15#include "ocean/base/Frame.h"
17
18namespace Ocean
19{
20
21namespace Test
22{
23
24namespace TestMedia
25{
26
27/**
28 * This class implements a test for the AVFoundation media library.
29 * @ingroup testmedia
30 */
31class OCEAN_TEST_MEDIA_EXPORT TestAVFoundation
32{
33 public:
34
35 /**
36 * Invokes all tests that are defined.
37 * @param testDuration The number of seconds for each test
38 * @param selector The test selector
39 * @return True, if succeeded
40 */
41 static bool test(const double testDuration, const TestSelector& selector);
42
43 /**
44 * Tests the pixel buffer accessor for generic pixel formats.
45 * @param testDuration The number of seconds for each test
46 * @return True, if succeeded
47 */
48 static bool testPixelBufferAccessorGenericPixelFormats(const double testDuration);
49
50 /**
51 * Tests the pixel buffer accessor for non-generic pixel formats.
52 * @param testDuration The number of seconds for each test
53 * @return True, if succeeded
54 */
55 static bool testPixelBufferAccessorNonGenericPixelFormats(const double testDuration);
56
57 /**
58 * Tests the video encoder and decoder by encoding frames and decoding them again.
59 * @param testDuration The number of seconds for each test
60 * @return True, if succeeded
61 */
62 static bool testVideoEncoderDecoder(const double testDuration);
63
64 protected:
65
66 /**
67 * Creates a test frame with a unique pattern based on the frame index.
68 * @param width The width of the frame, in pixel, with range [1, infinity)
69 * @param height The height of the frame, in pixel, with range [1, infinity)
70 * @param frameIndex The index of the frame, used to create a unique pattern
71 * @return The resulting test frame
72 */
73 static Frame createTestFrame(const unsigned int width, const unsigned int height, const unsigned int frameIndex);
74
75 /**
76 * Validates that the decoded frame matches the original test frame within acceptable compression tolerances.
77 * @param testFrame The original test frame
78 * @param decodedFrame The decoded frame to validate
79 * @return True, if the frames match within tolerance
80 */
81 static bool validateTestFrame(const Frame& testFrame, const Frame& decodedFrame);
82
83 /**
84 * Fills a CVPixelBuffer object with random image data.
85 * @param pixelBuffer The pixel buffer to which the random data will be written, must be valid
86 * @param expectedPlanes The number of expected planes of the pixel buffer, with range [1, infinity)
87 * @param randomGenerator The random generator to be used
88 * @param memoryCopy The resulting copy of the random memory which has been set, memory block for each plane of the pixel buffer
89 * @param heights The resulting heights of each individual memory block
90 * @param strideBytes The resulting number of bytes per row for each individual memory block
91 * @return True, if succeeded
92 */
93 static bool writeRandomDataToPixelBuffer(void* pixelBuffer, size_t expectedPlanes, RandomGenerator& randomGenerator, std::vector<std::vector<uint8_t>>& memoryCopy, Indices32& heights, Indices32& strideBytes);
94};
95
96}
97
98}
99
100}
101
102#endif // META_OCEAN_TEST_TESTMEDIA_TEST_AV_FOUNDATION_H
This class implements Ocean's image class.
Definition Frame.h:1879
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
This class implements a test for the AVFoundation media library.
Definition TestAVFoundation.h:32
static Frame createTestFrame(const unsigned int width, const unsigned int height, const unsigned int frameIndex)
Creates a test frame with a unique pattern based on the frame index.
static bool testPixelBufferAccessorGenericPixelFormats(const double testDuration)
Tests the pixel buffer accessor for generic pixel formats.
static bool validateTestFrame(const Frame &testFrame, const Frame &decodedFrame)
Validates that the decoded frame matches the original test frame within acceptable compression tolera...
static bool testVideoEncoderDecoder(const double testDuration)
Tests the video encoder and decoder by encoding frames and decoding them again.
static bool writeRandomDataToPixelBuffer(void *pixelBuffer, size_t expectedPlanes, RandomGenerator &randomGenerator, std::vector< std::vector< uint8_t > > &memoryCopy, Indices32 &heights, Indices32 &strideBytes)
Fills a CVPixelBuffer object with random image data.
static bool testPixelBufferAccessorNonGenericPixelFormats(const double testDuration)
Tests the pixel buffer accessor for non-generic pixel formats.
static bool test(const double testDuration, const TestSelector &selector)
Invokes all tests that are defined.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
The namespace covering the entire Ocean framework.
Definition Accessor.h:15