Audio Software Codecs
Loading...
Searching...
No Matches
Functions

General Description

Functions

cy_rslt_t cy_audio_sw_codec_init (cy_audio_sw_codec_operation_t codec_operation, void *codec_config, cy_audio_sw_codec_t *handle)
 Initializes the software codec for either decoding and encoding.
 
cy_rslt_t cy_audio_sw_codec_encode (cy_audio_sw_codec_t handle, uint8_t *in_pcm_buff, uint32_t *in_pcm_data_len, uint8_t *out_buff, uint32_t *outbuf_len)
 Encodes the input PCM data and returns the encoded data.
 
cy_rslt_t cy_audio_sw_codec_decode (cy_audio_sw_codec_t handle, uint8_t *in_encoded_buff, uint32_t *in_encoded_data_len, uint8_t *out_buff, uint32_t *outbuf_len)
 Decodes the encoded data and returns the PCM data.
 
cy_rslt_t cy_audio_sw_codec_get_encoder_recommended_inbuf_size (cy_audio_sw_codec_t handle, uint32_t *recommended_in_size)
 Get the recommended size of the input buffer for the codec encode operation configured.
 
cy_rslt_t cy_audio_sw_codec_get_encoder_recommended_outbuf_size (cy_audio_sw_codec_t handle, uint32_t in_size, uint32_t *recommended_out_size)
 Get the recommended size of the output buffer for the codec encoding operation configured.
 
cy_rslt_t cy_audio_sw_codec_get_decoder_recommended_outbuf_size (cy_audio_sw_codec_t handle, cy_audio_sw_codec_stream_info_t *stream_info, uint32_t *recommended_out_size)
 Get the recommended size of the output buffer for the codec decoding operation configured.
 
cy_rslt_t cy_audio_sw_codec_decode_stream_info_header (cy_audio_sw_codec_t handle, uint8_t *in_encoded_buff, uint32_t *in_encoded_data_len, cy_audio_sw_codec_stream_info_t *stream_info)
 Parse the header information from the input encoded data, used with decoder.
 
cy_rslt_t cy_audio_sw_codec_deinit (cy_audio_sw_codec_t *handle)
 Deinit the software codec instance.
 

Function Documentation

◆ cy_audio_sw_codec_init()

cy_rslt_t cy_audio_sw_codec_init ( cy_audio_sw_codec_operation_t  codec_operation,
void *  codec_config,
cy_audio_sw_codec_t *  handle 
)

Initializes the software codec for either decoding and encoding.

Parameters
[in]codec_operationCodec operation to be done (either encode / decode)
[in]codec_configCodec configuration parameter. 1) If the codec_operation refers to CY_AUDIO_CODEC_OPERATION_ENCODE, then the codec_config should corresponds to cy_audio_sw_codec_encode_config_t 2) If the codec_operation refers to CY_AUDIO_CODEC_OPERATION_DECODE, then the codec_config should corresponds to cy_audio_sw_codec_decode_config_t 3) For MP3 decoding this paramater is unused, config will be parsed from the MP3 header and provides 16bit(bitwidth) output data always
[out]handlePointer to store the audio software codec instance
Returns
CY_RSLT_SUCCESS on success; an error code on failure.

◆ cy_audio_sw_codec_encode()

cy_rslt_t cy_audio_sw_codec_encode ( cy_audio_sw_codec_t  handle,
uint8_t *  in_pcm_buff,
uint32_t *  in_pcm_data_len,
uint8_t *  out_buff,
uint32_t *  outbuf_len 
)

Encodes the input PCM data and returns the encoded data.

Parameters
[in]handleHandle to the software codec instance
[in]in_pcm_buffPointer to input PCM data buffer.
[in,out]in_pcm_data_len1) Length of the input data referred by in_pcm_buff. 2) Once the API returns, return number of bytes processed/accepted successfully in the codec-mw as part of processing.
[in]out_buffPointer to output encoded buffer
[in,out]outbuf_len1) Length of the output buffer. 2) Once the API returns, return number of bytes filled in the out_buff will be returned in the outbuf_len pointer.
Returns
CY_RSLT_SUCCESS on success; an error code on failure.

◆ cy_audio_sw_codec_decode()

cy_rslt_t cy_audio_sw_codec_decode ( cy_audio_sw_codec_t  handle,
uint8_t *  in_encoded_buff,
uint32_t *  in_encoded_data_len,
uint8_t *  out_buff,
uint32_t *  outbuf_len 
)

Decodes the encoded data and returns the PCM data.

Parameters
[in]handleHandle to the software codec instance
[in]in_encoded_buffPointer to input encoded data.
[in]in_encoded_data_len1) Length of the input data referred by in_encoded_data_len. 2) Once the API returns, return number of bytes processed/accepted successfully in the codec-mw as part of processing.
[in]out_buffPointer to output PCM data
[in,out]outbuf_len1) Length of the output buffer. 2) Once the API returns, return number of bytes filled in the output buffer will be returned in the outbuf_len pointer.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. CY_RSLT_ASC_HEADER_NOT_FOUND - error code if no stream info provided during init and no header found in buffer "in_encoded_buff".

◆ cy_audio_sw_codec_get_encoder_recommended_inbuf_size()

cy_rslt_t cy_audio_sw_codec_get_encoder_recommended_inbuf_size ( cy_audio_sw_codec_t  handle,
uint32_t *  recommended_in_size 
)

Get the recommended size of the input buffer for the codec encode operation configured.

  1. Input size can be any length but suggested to have multiples of the recommended size.
  2. For optimal, suggested passing multiples of recommended input, so that internal copy could be avoided.
  3. use api cy_audio_sw_codec_get_encoder_recommended_outbuf_size to get the recommended output size for the input size.
  4. Since it is PCM data length is fixed for provided config (sample rate, bit width, channel ), accurate prediction is possible for input.
Parameters
[in]handleHandle to the software codec instance
[out]recommended_in_sizeRecommended Input buffer size
Returns
cy_rslt_t on success; an error code on failure.

◆ cy_audio_sw_codec_get_encoder_recommended_outbuf_size()

cy_rslt_t cy_audio_sw_codec_get_encoder_recommended_outbuf_size ( cy_audio_sw_codec_t  handle,
uint32_t  in_size,
uint32_t *  recommended_out_size 
)

Get the recommended size of the output buffer for the codec encoding operation configured.

Input buffer size is provided to get the corresponding output buffer recommendation

Parameters
[in]handleHandle to the software codec instance
[in]in_sizeInput buffer size corresponding to the output buffer size
[out]recommended_out_sizeRecommended Output buffer size
Returns
cy_rslt_t on success; an error code on failure.

◆ cy_audio_sw_codec_get_decoder_recommended_outbuf_size()

cy_rslt_t cy_audio_sw_codec_get_decoder_recommended_outbuf_size ( cy_audio_sw_codec_t  handle,
cy_audio_sw_codec_stream_info_t *  stream_info,
uint32_t *  recommended_out_size 
)

Get the recommended size of the output buffer for the codec decoding operation configured.

  1. if the application knows the stream info prior, this API call can be invoked at any point in time.
  2. if the application doesn't know the stream info prior, application can all the cy_audio_sw_codec_decode_stream_info_header and get the stream info and then call this API to get the right recommended out size.
Parameters
[in]handleHandle to the software codec instance
[in]stream_infoInformation about decoded stream.
[out]recommended_out_sizeRecommended Output buffer size
Returns
cy_rslt_t on success; an error code on failure.

◆ cy_audio_sw_codec_decode_stream_info_header()

cy_rslt_t cy_audio_sw_codec_decode_stream_info_header ( cy_audio_sw_codec_t  handle,
uint8_t *  in_encoded_buff,
uint32_t *  in_encoded_data_len,
cy_audio_sw_codec_stream_info_t *  stream_info 
)

Parse the header information from the input encoded data, used with decoder.

This API can be used by the application to know the stream information, so that 'cy_audio_sw_codec_get_decoder_recommended_outbuf_size' can give the right output size for 'cy_audio_sw_codec_decode' api.

Parameters
[in]handleHandle to the software codec instance
[in]in_encoded_buffPointer to input encoded data.
[in,out]in_encoded_data_len1) Length of the input data referred by in_encoded_data_len. 2) Once the API returns, return number of bytes processed/accepted successfully in the codec-mw as part of processing.
[out]stream_infoInformation about decoded stream
Returns
cy_rslt_t on success, in_encoded_data_len - Offset to the end of header.

an error code on failure,

  1. CY_RSLT_ASC_HEADER_NOT_FOUND - no input data is accepted. appl should send next buffers
  2. CY_RSLT_ASC_PARTIAL_HEADER_IDENTIFIED
    • returns accepted data in in_encoded_data_len, appl can provide continuous data

◆ cy_audio_sw_codec_deinit()

cy_rslt_t cy_audio_sw_codec_deinit ( cy_audio_sw_codec_t *  handle)

Deinit the software codec instance.

Parameters
[out]handleAddress of the Handle to audio software codec instance created by the cy_audio_sw_codec_init() API.Once API returns cy_audio_sw_codec_t handle will be reset to NULL.
Returns
CY_RSLT_SUCCESS on success; an error code on failure.