mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.9 KiB
C
82 lines
2.9 KiB
C
4 years ago
|
/**
|
||
4 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
4 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
4 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
4 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/*!
|
||
|
* \file polar_encoder.h
|
||
|
* \brief Declaration of the polar encoder.
|
||
4 years ago
|
* \author Jesus Gomez
|
||
4 years ago
|
* \date 2020
|
||
|
*
|
||
|
* \copyright Software Radio Systems Limited
|
||
|
*
|
||
|
* 5G uses a polar encoder with maximum sizes \f$2^n\f$ with \f$n = 5,...,10\f$.
|
||
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_POLAR_ENCODER_H
|
||
|
#define SRSRAN_POLAR_ENCODER_H
|
||
4 years ago
|
|
||
4 years ago
|
#include "srsran/config.h"
|
||
4 years ago
|
#include <stdint.h>
|
||
|
|
||
|
/*!
|
||
|
* Lists the different types of polar decoder.
|
||
|
*/
|
||
4 years ago
|
typedef enum {
|
||
4 years ago
|
SRSRAN_POLAR_ENCODER_PIPELINED = 0, /*!< \brief Non-optimized version of the pipelined polar encoder*/
|
||
|
SRSRAN_POLAR_ENCODER_AVX2 = 1, /*!< \brief SIMD implementation of the polar encoder */
|
||
|
} srsran_polar_encoder_type_t;
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* \brief Describes a polar encoder.
|
||
|
*/
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
4 years ago
|
void* ptr; /*!< \brief Pointer to the actual polar encoder structure. */
|
||
|
int (*encode)(void* ptr,
|
||
|
const uint8_t* input,
|
||
|
uint8_t* output,
|
||
|
const uint8_t code_size_log); /*!< \brief Pointer to the encoder function. */
|
||
|
void (*free)(void*); /*!< \brief Pointer to a "destructor". */
|
||
4 years ago
|
} srsran_polar_encoder_t;
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* Initializes all the polar encoder variables according to the given code size.
|
||
|
* \param[out] q A pointer to the initialized polar encoder.
|
||
|
* \param[in] polar_encoder_type Polar encoder type.
|
||
|
* \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the encoder input/output vector.
|
||
|
* \return An integer: 0 if the function executes correctly, -1 otherwise.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API int srsran_polar_encoder_init(srsran_polar_encoder_t* q,
|
||
|
srsran_polar_encoder_type_t polar_encoder_type,
|
||
4 years ago
|
uint8_t code_size_log);
|
||
|
|
||
|
/*!
|
||
|
* The polar encoder "destructor": it frees all the resources.
|
||
|
* \param[in, out] q A pointer to the dismantled encoder.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API void srsran_polar_encoder_free(srsran_polar_encoder_t* q);
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* Encodes the input vector into a codeword with the specified polar encoder.
|
||
|
* \param[in] q A pointer to the desired polar encoder.
|
||
|
* \param[in] input The encoder input vector.
|
||
|
* \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the encoder input/output vector.
|
||
|
* It cannot be larger than the maximum code_size_log specified in q.code_size_log of
|
||
4 years ago
|
* the srsran_polar_encoder_t structure.
|
||
4 years ago
|
* \param[out] output The encoder output vector.
|
||
|
* \return An integer: 0 if the function executes correctly, -1 otherwise.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API int
|
||
|
srsran_polar_encoder_encode(srsran_polar_encoder_t* q, const uint8_t* input, uint8_t* output, uint8_t code_size_log);
|
||
4 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_POLAR_ENCODER_H
|