063bc49a80441749cbfcdf1573b600ee1e262e0c
[o-du/phy.git] / fhi_lib / lib / api / xran_compression.h
1 /******************************************************************************\r
2 *\r
3 *   Copyright (c) 2019 Intel.\r
4 *\r
5 *   Licensed under the Apache License, Version 2.0 (the "License");\r
6 *   you may not use this file except in compliance with the License.\r
7 *   You may obtain a copy of the License at\r
8 *\r
9 *       http://www.apache.org/licenses/LICENSE-2.0\r
10 *\r
11 *   Unless required by applicable law or agreed to in writing, software\r
12 *   distributed under the License is distributed on an "AS IS" BASIS,\r
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 *   See the License for the specific language governing permissions and\r
15 *   limitations under the License.\r
16 *\r
17 *******************************************************************************/\r
18 \r
19 /*!\r
20     \file   xran_compression.h\r
21     \brief  External API for compading with the use BFP algorithm.\r
22 */\r
23 \r
24 #ifndef _XRAN_COMPRESSION_H_\r
25 #define _XRAN_COMPRESSION_H_\r
26 \r
27 #include <stdint.h>\r
28 \r
29 #ifdef __cplusplus\r
30 extern "C" {\r
31 #endif\r
32 \r
33 /*!\r
34     \struct xranlib_compress_request\r
35     \brief Request structure containing pointer to data and its length.\r
36 */\r
37 struct xranlib_compress_request {\r
38     int16_t *data_in;   /*!< Pointer to data to compress. */\r
39     int16_t numRBs;     /*!< numRBs  */\r
40     int16_t compMethod; /*!< Compression method */\r
41     int16_t iqWidth;    /*!< Bit size */\r
42     int32_t len;        /*!< Length of input buffer in bytes */\r
43 };\r
44 \r
45 /*!\r
46     \struct xranlib_compress_response\r
47     \brief Response structure containing pointer to data and its length.\r
48 */\r
49 struct xranlib_compress_response {\r
50     int8_t *data_out; /*!< Pointer to data after compression. */\r
51 \r
52     int32_t len; /*!< Length of output data. */\r
53 };\r
54 \r
55 /*!\r
56     \struct xranlib_decompress_request\r
57     \brief Request structure containing pointer to data and its length.\r
58 */\r
59 struct xranlib_decompress_request {\r
60     int8_t *data_in; /*!< Pointer to data to decompress. */\r
61     int16_t numRBs;     /*!< numRBs  */\r
62     int16_t compMethod; /*!< Compression method */\r
63     int16_t iqWidth;    /*!< Bit size */\r
64 \r
65     int32_t len; /*!< Length of input data. */\r
66 };\r
67 \r
68 /*!\r
69     \struct xranlib_decompress_response\r
70     \brief Response structure containing pointer to data and its length.\r
71 */\r
72 struct xranlib_decompress_response {\r
73     int16_t *data_out; /*!< Pointer to data after decompression. */\r
74 \r
75     int32_t len; /*!< Length of output data. */\r
76 };\r
77 \r
78 /*!\r
79     \brief Report the version number for the xranlib_companding library.\r
80     \param [in] version Pointer to a char buffer where the version string should be copied.\r
81     \param [in] buffer_size The length of the string buffer, must be at least\r
82                xranlib_SDK_VERSION_STRING_MAX_LEN characters.\r
83     \return 0 if the version string was populated, otherwise -1.\r
84 */\r
85 int16_t\r
86 xranlib_companding_version(char *version, int buffer_size);\r
87 \r
88 //! @{\r
89 /*!\r
90     \brief Compress functions - it converts a 16-bit linear PCM value to 8-bt A-law.\r
91     \param [in]  request Structure containing the input data and data length.\r
92     \param [out] response Structure containing the output data and data length.\r
93     \return 0 for success, -1 for error\r
94 */\r
95 int\r
96 xranlib_compress(const struct xranlib_compress_request *request,\r
97     struct xranlib_compress_response *response);\r
98 \r
99 int  xranlib_compress_sse(const struct xranlib_compress_request *request,\r
100     struct xranlib_compress_response *response);\r
101 int  xranlib_compress_avx2(const struct xranlib_compress_request *request,\r
102     struct xranlib_compress_response *response);\r
103 int xranlib_compress_avx512(const struct xranlib_compress_request *request,\r
104     struct xranlib_compress_response *response);\r
105 int xranlib_compress_avx512_bfw(const struct xranlib_compress_request *request,\r
106     struct xranlib_compress_response *response);\r
107 //! @}\r
108 \r
109 //! @{\r
110 /*!\r
111     \brief Decompress function - it converts an A-law value to 16-bit linear PCM.\r
112     \param [in] request Structure containing the input data and data length.\r
113     \param [out] response Structure containing the output data and data length.\r
114     \return 0 for success, -1 for error.\r
115 **/\r
116 int\r
117 xranlib_decompress(const struct xranlib_decompress_request *request,\r
118     struct xranlib_decompress_response *response);\r
119 \r
120 int xranlib_decompress_sse(const struct xranlib_decompress_request *request,\r
121     struct xranlib_decompress_response *response);\r
122 int xranlib_decompress_avx2(const struct xranlib_decompress_request *request,\r
123     struct xranlib_decompress_response *response);\r
124 int xranlib_decompress_avx512(const struct xranlib_decompress_request *request,\r
125     struct xranlib_decompress_response *response);\r
126 //! @}\r
127 \r
128 #ifdef __cplusplus\r
129 }\r
130 #endif\r
131 \r
132 #endif /* _XRAN_COMPRESSION_H_ */\r