Update to odulow per maintenance bronze
[o-du/phy.git] / fhi_lib / lib / api / xran_compression.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 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 API for compading with the use BFP algorithm.
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     int32_t len;        /*!< Length of input buffer in bytes */
44 };
45
46 /*!
47     \struct xranlib_compress_response
48     \brief Response structure containing pointer to data and its length.
49 */
50 struct xranlib_compress_response {
51     int8_t *data_out; /*!< Pointer to data after compression. */
52
53     int32_t len; /*!< Length of output data. */
54 };
55
56 /*!
57     \struct xranlib_decompress_request
58     \brief Request structure containing pointer to data and its length.
59 */
60 struct xranlib_decompress_request {
61     int8_t *data_in; /*!< Pointer to data to decompress. */
62     int16_t numRBs;     /*!< numRBs  */
63     int16_t numDataElements; /*!< number of elements in block process [UP: 24 i.e 12RE*2; CP: 16,32,64,128. i.e AntElm*2] */
64     int16_t compMethod; /*!< Compression method */
65     int16_t iqWidth;    /*!< Bit size */
66
67     int32_t len; /*!< Length of input data. */
68 };
69
70 /*!
71     \struct xranlib_decompress_response
72     \brief Response structure containing pointer to data and its length.
73 */
74 struct xranlib_decompress_response {
75     int16_t *data_out; /*!< Pointer to data after decompression. */
76
77     int32_t len; /*!< Length of output data. */
78 };
79
80 /*!
81     \brief Report the version number for the xranlib_companding library.
82     \param [in] version Pointer to a char buffer where the version string should be copied.
83     \param [in] buffer_size The length of the string buffer, must be at least
84                xranlib_SDK_VERSION_STRING_MAX_LEN characters.
85     \return 0 if the version string was populated, otherwise -1.
86 */
87 int16_t
88 xranlib_companding_version(char *version, int buffer_size);
89
90 //! @{
91 /*!
92     \brief Compress functions - it converts a 16-bit linear PCM value to 8-bt A-law.
93     \param [in]  request Structure containing the input data and data length.
94     \param [out] response Structure containing the output data and data length.
95     \return 0 for success, -1 for error
96 */
97 int32_t
98 xranlib_compress(const struct xranlib_compress_request *request,
99     struct xranlib_compress_response *response);
100 int32_t
101 xranlib_compress_sse(const struct xranlib_compress_request *request,
102     struct xranlib_compress_response *response);
103 int32_t
104 xranlib_compress_avx2(const struct xranlib_compress_request *request,
105     struct xranlib_compress_response *response);
106 int32_t
107 xranlib_compress_avx512(const struct xranlib_compress_request *request,
108     struct xranlib_compress_response *response);
109 int32_t
110 xranlib_compress_avx512_bfw(const struct xranlib_compress_request *request,
111     struct xranlib_compress_response *response);
112 //! @}
113
114 //! @{
115 /*!
116     \brief Decompress function - it converts an A-law value to 16-bit linear PCM.
117     \param [in] request Structure containing the input data and data length.
118     \param [out] response Structure containing the output data and data length.
119     \return 0 for success, -1 for error.
120 **/
121 int32_t
122 xranlib_decompress(const struct xranlib_decompress_request *request,
123     struct xranlib_decompress_response *response);
124
125 int32_t
126 xranlib_decompress_sse(const struct xranlib_decompress_request *request,
127     struct xranlib_decompress_response *response);
128 int32_t
129 xranlib_decompress_avx2(const struct xranlib_decompress_request *request,
130     struct xranlib_decompress_response *response);
131 int32_t
132 xranlib_decompress_avx512(const struct xranlib_decompress_request *request,
133     struct xranlib_decompress_response *response);
134 int32_t
135 xranlib_decompress_avx512_bfw(const struct xranlib_decompress_request *request,
136      struct xranlib_decompress_response *response);
137
138 //! @}
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif /* _XRAN_COMPRESSION_H_ */