O-RAN E Maintenance Release contribution for ODULOW
[o-du/phy.git] / fhi_lib / lib / api / xran_compression.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19 /*!
20     \file   xran_compression.h
21     \brief  External C-callable API for compression/decompression with the use BFP algorithm and Modulation compression
22 */
23
24 #ifndef _XRAN_COMPRESSION_H_
25 #define _XRAN_COMPRESSION_H_
26
27 #include <stdint.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /*!
34     \struct xranlib_compress_request
35     \brief Request structure containing pointer to data and its length.
36 */
37 struct xranlib_compress_request {
38     int16_t *data_in;   /*!< Pointer to data to compress. */
39     int16_t numRBs;     /*!< numRBs  */
40     int16_t numDataElements; /*!< number of elements in block process [UP: 24 i.e 12RE*2; CP: 16,32,64,128. i.e AntElm*2] */
41     int16_t compMethod; /*!< Compression method */
42     int16_t iqWidth;    /*!< Bit size */
43     int16_t reMask; /*!< 12-bit RE mask representing 12REs in one RB  */
44     int16_t csf; /*!< 1-bit constellation shift flag defined in section 5.4.7.4  */
45     uint16_t ScaleFactor; /*!< Scale factor as defined in section A.5*/
46     int32_t len;        /*!< Length of input buffer in bytes */
47 };
48
49 /*!
50     \struct xranlib_compress_response
51     \brief Response structure containing pointer to data and its length.
52 */
53 struct xranlib_compress_response {
54     int8_t *data_out; /*!< Pointer to data after compression. */
55
56     int32_t len; /*!< Length of output data. */
57 };
58
59 /*!
60     \struct xranlib_decompress_request
61     \brief Request structure containing pointer to data and its length.
62 */
63 struct xranlib_decompress_request {
64     int8_t *data_in; /*!< Pointer to data to decompress. */
65     int16_t numRBs;     /*!< numRBs  */
66     int16_t numDataElements; /*!< number of elements in block process [UP: 24 i.e 12RE*2; CP: 16,32,64,128. i.e AntElm*2] */
67     int16_t compMethod; /*!< Compression method */
68     int16_t iqWidth;    /*!< Bit size */
69     int16_t reMask; /*!< 12-bit RE mask representing 12REs in one RB  */
70     int16_t csf; /*!< 1-bit constellation shift flag defined in section 5.4.7.4  */
71     uint16_t ScaleFactor; /*!< Scale factor as defined in section A.5*/
72     int32_t len; /*!< Length of input data. */
73 };
74
75 /*!
76     \struct xranlib_decompress_response
77     \brief Response structure containing pointer to data and its length.
78 */
79 struct xranlib_decompress_response {
80     int16_t *data_out; /*!< Pointer to data after decompression. */
81
82     int32_t len; /*!< Length of output data. */
83 };
84
85 /*!
86     \brief Report the version number for the xranlib_companding library.
87     \param [in] version Pointer to a char buffer where the version string should be copied.
88     \param [in] buffer_size The length of the string buffer, must be at least
89                xranlib_SDK_VERSION_STRING_MAX_LEN characters.
90     \return 0 if the version string was populated, otherwise -1.
91 */
92 int16_t
93 xranlib_companding_version(char *version, int buffer_size);
94
95 //! @{
96 /*!
97     \brief Compress functions - it converts a 16-bit linear PCM value to 8-bt A-law.
98     \param [in]  request Structure containing the input data and data length.
99     \param [out] response Structure containing the output data and data length.
100     \return 0 for success, -1 for error
101 */
102 int32_t
103 xranlib_compress(const struct xranlib_compress_request *request,
104     struct xranlib_compress_response *response);
105 int32_t
106 xranlib_compress_sse(const struct xranlib_compress_request *request,
107     struct xranlib_compress_response *response);
108 int32_t
109 xranlib_compress_avx2(const struct xranlib_compress_request *request,
110     struct xranlib_compress_response *response);
111 int32_t
112 xranlib_compress_avx512(const struct xranlib_compress_request *request,
113     struct xranlib_compress_response *response);
114 int32_t
115 xranlib_compress_avxsnc(const struct xranlib_compress_request *request,
116     struct xranlib_compress_response *response);
117 int32_t
118 xranlib_compress_bfw(const struct xranlib_compress_request *request,
119     struct xranlib_compress_response *response);
120 int32_t
121 xranlib_compress_avx512_bfw(const struct xranlib_compress_request *request,
122     struct xranlib_compress_response *response);
123 int32_t
124 xranlib_compress_avxsnc_bfw(const struct xranlib_compress_request *request,
125     struct xranlib_compress_response *response);
126 //! @}
127
128 //! @{
129 /*!
130     \brief Decompress function - it converts an A-law value to 16-bit linear PCM.
131     \param [in] request Structure containing the input data and data length.
132     \param [out] response Structure containing the output data and data length.
133     \return 0 for success, -1 for error.
134 **/
135 int32_t
136 xranlib_decompress(const struct xranlib_decompress_request *request,
137     struct xranlib_decompress_response *response);
138 int32_t
139 xranlib_decompress_sse(const struct xranlib_decompress_request *request,
140     struct xranlib_decompress_response *response);
141 int32_t
142 xranlib_decompress_avx2(const struct xranlib_decompress_request *request,
143     struct xranlib_decompress_response *response);
144 int32_t
145 xranlib_decompress_avx512(const struct xranlib_decompress_request *request,
146     struct xranlib_decompress_response *response);
147 int32_t
148 xranlib_decompress_avxsnc(const struct xranlib_decompress_request *request,
149     struct xranlib_decompress_response *response);
150 int32_t
151 xranlib_decompress_bfw(const struct xranlib_decompress_request *request,
152     struct xranlib_decompress_response *response);
153 int32_t
154 xranlib_decompress_avx512_bfw(const struct xranlib_decompress_request *request,
155      struct xranlib_decompress_response *response);
156 int32_t
157 xranlib_decompress_avxsnc_bfw(const struct xranlib_decompress_request *request,
158      struct xranlib_decompress_response *response);
159
160 //! @}
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif /* _XRAN_COMPRESSION_H_ */