Ocean
DiscreteCosineTransform.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_MATH_DISCRETE_COSINE_TRANSFORM_H
9 #define META_OCEAN_MATH_DISCRETE_COSINE_TRANSFORM_H
10 
11 #include "ocean/math/Math.h"
12 
13 namespace Ocean
14 {
15 
16 /**
17  * This class implements discrete cosine transform functions.
18  * @ingroup math
19  */
20 class OCEAN_MATH_EXPORT DiscreteCosineTransform
21 {
22  public:
23 
24  /**
25  * Applies a 2D discrete cosine transform for a given 2D data block.
26  * The resulting coefficients are stored in an row aligned order.<br>
27  * @param data Data block for that the transform is applied
28  * @param xElements Number of horizontal data elements, with range [1, infinity)
29  * @param yElements Number of vertical data elements, with range [1, infinity)
30  * @param coefficients Resulting number of coefficients, an array with xElements * yElements values must be provided
31  */
32  static inline void transform2(const Scalar* data, const unsigned int xElements, const unsigned int yElements, Scalar* coefficients);
33 
34  /**
35  * Applies a 2D discrete cosine transform for a given 2D data block that might be larger than the actual DCT data block.
36  * The resulting coefficients are stored in an row aligned order.<br>
37  * @param data Data block for that the transform is applied (pointer to the first element)
38  * @param xElements Number of horizontal data elements, with range [1, infinity)
39  * @param yElements Number of vertical data elements, with range [1, infinity)
40  * @param stride Width of the entire data information including the xElements, with range [xElements, infinity)
41  * @param coefficients Resulting number of coefficients, an array with xElements * yElements values must be provided
42  */
43  static void transform2(const Scalar* data, const unsigned int xElements, const unsigned int yElements, const unsigned int stride, Scalar* coefficients);
44 
45  /**
46  * Applies a inverse 2D discrete cosine transform for a given set of DCT coefficients.
47  * @param coefficients DCT coefficients from that the data information will be recovered
48  * @param xElements Number of horizontal data elements, with range [1, infinity)
49  * @param yElements Number of vertical data elements, with range [1, infinity)
50  * @param data Resulting data block, an array with xElements * yElements values must be provided
51  */
52  static inline void iTransform2(const Scalar* coefficients, const unsigned int xElements, const unsigned int yElements, Scalar* data);
53 
54  /**
55  * Applies a inverse 2D discrete cosine transform for a given set of DCT coefficients.
56  * @param coefficients DCT coefficients from that the data information will be recovered
57  * @param xElements Number of horizontal data elements, with range [1, infinity)
58  * @param yElements Number of vertical data elements, with range [1, infinity)
59  * @param stride Width of the data information including the xElements, with range [xElements, infinity)
60  * @param data Resulting data block, a data block that might be larger than the actual number of DCT coefficients as an explicit stride parameter can be defined
61  */
62  static void iTransform2(const Scalar* coefficients, const unsigned int xElements, const unsigned int yElements, const unsigned int stride, Scalar* data);
63 };
64 
65 inline void DiscreteCosineTransform::transform2(const Scalar* data, const unsigned int xElements, const unsigned int yElements, Scalar* coefficients)
66 {
67  transform2(data, xElements, yElements, xElements, coefficients);
68 }
69 
70 inline void DiscreteCosineTransform::iTransform2(const Scalar* coefficients, const unsigned int xElements, const unsigned int yElements, Scalar* data)
71 {
72  iTransform2(coefficients, xElements, yElements, xElements, data);
73 }
74 
75 }
76 
77 #endif // META_OCEAN_MATH_DISCRETE_COSINE_TRANSFORM_H
This class implements discrete cosine transform functions.
Definition: DiscreteCosineTransform.h:21
static void transform2(const Scalar *data, const unsigned int xElements, const unsigned int yElements, const unsigned int stride, Scalar *coefficients)
Applies a 2D discrete cosine transform for a given 2D data block that might be larger than the actual...
static void iTransform2(const Scalar *coefficients, const unsigned int xElements, const unsigned int yElements, Scalar *data)
Applies a inverse 2D discrete cosine transform for a given set of DCT coefficients.
Definition: DiscreteCosineTransform.h:70
static void transform2(const Scalar *data, const unsigned int xElements, const unsigned int yElements, Scalar *coefficients)
Applies a 2D discrete cosine transform for a given 2D data block.
Definition: DiscreteCosineTransform.h:65
static void iTransform2(const Scalar *coefficients, const unsigned int xElements, const unsigned int yElements, const unsigned int stride, Scalar *data)
Applies a inverse 2D discrete cosine transform for a given set of DCT coefficients.
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15