Synergy Software Package User's Manual

Driver for the JPEG CODEC. More...

Data Structures

struct  jpeg_encode_instance_ctrl_t
 

Macros

#define JPEG_ENCODE_CODE_VERSION_MAJOR   (2U)
 

Functions

ssp_err_t R_JPEG_Encode_Open (jpeg_encode_ctrl_t *const p_api_ctrl, jpeg_encode_cfg_t const *const p_cfg)
 Initialize the JPEG Codec module. This function configures the JPEG Codec for encoding operation, sets up the registers for data format, pixel format, vertical and horizontal resolution stride based on user-supplied configuration parameters. More...
 
ssp_err_t R_JPEG_Encode_OutputBufferSet (jpeg_encode_ctrl_t *p_api_ctrl, void *p_output_buffer)
 Assign output buffer to the JPEG Codec for storing output data. More...
 
ssp_err_t R_JPEG_Encode_InputBufferSet (jpeg_encode_ctrl_t *const p_api_ctrl, void *p_data_buffer, uint32_t data_buffer_size)
 Assign input data buffer to JPEG codec for processing. More...
 
ssp_err_t R_JPEG_Encode_ImageParameterSet (jpeg_encode_ctrl_t *const p_api_ctrl, jpeg_encode_raw_image_parameters *p_image_parameters)
 Setup the image parameters to JPEG Codec device. More...
 
ssp_err_t R_JPEG_Encode_StatusGet (jpeg_encode_ctrl_t *p_api_ctrl, volatile jpeg_encode_status_t *p_status)
 Get the status of the JPEG codec. This function can also be used to poll the device. More...
 
ssp_err_t R_JPEG_Encode_Close (jpeg_encode_ctrl_t *p_api_ctrl)
 Cancel an outstanding JPEG codec operation and close the device. More...
 
ssp_err_t R_JPEG_Encode_VersionGet (ssp_version_t *p_version)
 Get version of the display interface and GLCD HAL code. More...
 

Detailed Description

Driver for the JPEG CODEC.

Macro Definition Documentation

◆ JPEG_ENCODE_CODE_VERSION_MAJOR

#define JPEG_ENCODE_CODE_VERSION_MAJOR   (2U)

Configuration for this module

Function Documentation

◆ R_JPEG_Encode_Close()

ssp_err_t R_JPEG_Encode_Close ( jpeg_encode_ctrl_t p_api_ctrl)

Cancel an outstanding JPEG codec operation and close the device.

Return values
SSP_SUCCESSThe input data buffer is properly assigned to JPEG Codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_NOT_OPENJPEG not opened.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Clear JPEG JINTE0 interrupt and JINTE1 interrupt.

Disable JEDI and JDTI at NVIC

Power off the JPEG codec.

Reset the jpeg status flag in the driver.

Unlock module at BSP level.

◆ R_JPEG_Encode_ImageParameterSet()

ssp_err_t R_JPEG_Encode_ImageParameterSet ( jpeg_encode_ctrl_t *const  p_api_ctrl,
jpeg_encode_raw_image_parameters p_image_parameters 
)

Setup the image parameters to JPEG Codec device.

Note
Image parameters needs to be set before the setting the input buffer.DO NOT call this function during the JPEG Codec operation.
Return values
SSP_SUCCESSImage parameter is properly assigned to JPEG Codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL,
SSP_ERR_INVALID_ALIGNMENTHorizontal stride is not 8-byte aligned.
SSP_ERR_INVALID_ARGUMENTHorizontal and Vertical resolution is invalid or zero.
SSP_ERR_NOT_OPENJPEG not opened.
SSP_ERR_INVALID_CALLAn invalid call has been made.

Do not change the JPEG Codec image setting while JPEG Codec is in progress

Record the horizontal stride and vertical size value in the control block

Set the horizontal stride.

Set the image horizontal and vertical size.

◆ R_JPEG_Encode_InputBufferSet()

ssp_err_t R_JPEG_Encode_InputBufferSet ( jpeg_encode_ctrl_t *const  p_api_ctrl,
void *  p_data_buffer,
uint32_t  data_buffer_size 
)

Assign input data buffer to JPEG codec for processing.

Note
1.After the amount of data is processed, the JPEG driver triggers a callback function with the flag JPEG_OPERATION_INPUT_PAUSE set. The application supplies the next chunk of data to the driver so JPEG encoding can resume. 2.Image size should be greater or equal to minimum coded unit (MCU) for YCbCr422 (only supported color space) the MCU is 8 lines by 16 pixel (where 1 pixel = 2 bytes) hence size can not be less than 8x16x2 = 256

The JPEG encoding operation automatically starts after setting the input buffer.

Return values
SSP_SUCCESSThe input data buffer is properly assigned to JPEG Codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL, or the pointer to the p_data_buffer is NULL.
SSP_ERR_INVALID_ALIGNMENTBuffer starting address or image line to encode or size of buffer is not 8-byte aligned.
SSP_ERR_NOT_OPENJPEG not opened.
SSP_ERR_INVALID_CALLAn invalid call has been made, set output buffer first
SSP_ERR_JPEG_IMAGE_SIZE_ERRORImage size is not supported by JPEG Codec

Validate the the size : JPEG Codec can process minimum up to 8 lines by 16 pixel for YCbCr422 meaning 8x16x2 = 256

Calculate the number of lines to be encode

JPEG Codec required Lines to be byte aligned

Check, If output image buffer is set or not

Configure the input buffer address.

if JPEG is just opened or completed one image, make DONE and IDLE status flag zero to encode next image

Remove the Done and IDLE status flag

Set the driver status to JPEG_ENCODE_STATUS_RUNNING.

Start the encoder

JPEG is PAUSE for next chunk of image

Clear internal status information.

Set RUNNING status

Resume the count mode

JPEG is running Notify the user, return error

◆ R_JPEG_Encode_Open()

ssp_err_t R_JPEG_Encode_Open ( jpeg_encode_ctrl_t *const  p_api_ctrl,
jpeg_encode_cfg_t const *const  p_cfg 
)

Initialize the JPEG Codec module. This function configures the JPEG Codec for encoding operation, sets up the registers for data format, pixel format, vertical and horizontal resolution stride based on user-supplied configuration parameters.

Return values
SSP_SUCCESSJPEG Codec module is properly configured and is ready to take input data.
SSP_ERR_IN_USEJPEG Codec is already in use.
SSP_ERR_ASSERTIONPointer to the control block or the configuration structure is NULL.
SSP_ERR_HW_LOCKEDJPEG Codec resource is locked.
SSP_ERR_INVALID_ARGUMENTInvalid parameter is passed.
SSP_ERR_INVALID_ALIGNMENTHorizontal stride is not 8-byte aligned.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Verify JPEG Codec is not already used.

Update the common control parameter with the control and JDEI and JDTI callback handler for JPEG encode, the handlers will be called from r_jpeg_common, which implements JPEG JDTI and JDEI ISR for r_jpeg_decode and r_jpeg_encode driver.

Get the JDTI event information from FMI

Get the vector table information of JDTI event

Record the JPEG Encoder ctrl and internal ISR callback handler to JDTI event vector table

Get the JEDI event information from FMI

Get the vector table information of JEDI event

Record the JPEG Encoder ctrl and internal ISR callback handler to JEDI event vector table

Provide power to the JPEG module.

Perform bus reset

Reset the destination buffer address.

Reset the source buffer address.

Set the horizontal stride.

Set the image horizontal and vertical size.

Configure the JPEG module for encode operation.

Set the output data format.

Set input pixel format for JPEG Encoder NOTE : only ycbcr422 is valid for encoder

Quantization table setting NOTE: Table 0(zero) is used for Luminance and Table 1(one) is used for Chrominance - Cr and Cb component

Upload Luminance and Chrominance table to JPEG Codec

Huffman table setting

Upload the Huffman table to JPEG Codec

Reset Marker setting

Record image parameters to ctrl

Set the driver status.

Record the user context information

Record user supplied callback routine.

Enabled JPEG Compression data transfer complete interrupt and Count mode Interrupt

Enable the JDTI and JDEI interrupts

All done. Return success.

◆ R_JPEG_Encode_OutputBufferSet()

ssp_err_t R_JPEG_Encode_OutputBufferSet ( jpeg_encode_ctrl_t p_api_ctrl,
void *  p_output_buffer 
)

Assign output buffer to the JPEG Codec for storing output data.

Note
Buffer size should be sufficient to hold the encoded jpeg image.
Return values
SSP_SUCCESSThe output buffer is properly assigned to JPEG codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL, or the pointer to the output_buffer. is NULL, or the output_buffer_size is 0.
SSP_ERR_INVALID_ALIGNMENTBuffer starting address is not 8-byte aligned.
SSP_ERR_NOT_OPENJPEG not opened.
SSP_ERR_INVALID_CALLAn invalid call has been made, Codec output buffer address is attempted to changed during codec operation

Output buffer cannot be change during codec operation

Set the encoding destination address.

◆ R_JPEG_Encode_StatusGet()

ssp_err_t R_JPEG_Encode_StatusGet ( jpeg_encode_ctrl_t p_api_ctrl,
volatile jpeg_encode_status_t p_status 
)

Get the status of the JPEG codec. This function can also be used to poll the device.

Return values
SSP_SUCCESSThe status information is successfully retrieved.
SSP_ERR_ASSERTIONPointer to the control block is NULL.

HW does not report error. Return internal status information.

◆ R_JPEG_Encode_VersionGet()

ssp_err_t R_JPEG_Encode_VersionGet ( ssp_version_t p_version)

Get version of the display interface and GLCD HAL code.

Return values
SSP_SUCCESSVersion number
SSP_ERR_ASSERTIONThe parameter p_version is NULL.
Note
This function is reentrant.