![]() |
Synergy Software Package User's Manual
|
The JPEG Encode HAL module provides a high-level API for industry standard JPEG image encode processing (compression) and uses the Synergy MCU JPEG Codec peripheral. A user callback function is available to inform the application program of key processing events.
The following hardware features are, or are not, supported by SSP for JPEG.
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Input data format 8 lines by 8 pixels in YCbCr444 | Input data format 8 lines by 16 pixels in YCbCr422 | Input data format 8 lines by 32 pixels in YCbCr411 | Input data format 16 lines by 16 pixels in YCbCr420 | Output format JPEG |
|---|---|---|---|---|---|
| S124 | N/A | N/A | N/A | N/A | N/A |
| S128 | N/A | N/A | N/A | N/A | N/A |
| S1JA | N/A | N/A | N/A | N/A | N/A |
| S3A1 | N/A | N/A | N/A | N/A | N/A |
| S3A3 | N/A | N/A | N/A | N/A | N/A |
| S3A6 | N/A | N/A | N/A | N/A | N/A |
| S3A7 | N/A | N/A | N/A | N/A | N/A |
| S5D3 | N/A | N/A | N/A | N/A | N/A |
| S5D5 | N/A | N/A | N/A | N/A | N/A |
| S5D9 | N/A | ✓ | N/A | N/A | ✓ |
| S7G2 | N/A | ✓ | N/A | N/A | ✓ |
The JPEG Encode HAL Module defines APIs to open, set up processing parameters for, process, get status from and close the module. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the HAL Module API Summary.
JPEG Encode HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_jpeg_encode0.p_api->open(g_jpeg_encode0.p_ctrl, g_jpeg_encode0.p_cfg);Initial configuration. |
| imageParameterSet | g_jpeg_encode0.p_api->imageParameterSet(g_jpeg_encode0.p_ctrl, p_image_parameters);Set image parameters to JPEG Codec. |
| outputBufferSet | g_jpeg_encode0.p_api->outputBufferSet(g_jpeg_encode0.p_ctrl, p_buffer);Assign output buffer to JPEG Codec for storing output data. |
| inputBufferSet | g_jpeg_encode0.p_api->inputBufferSet(g_jpeg_encode0.p_ctrl, p_buffer, buffer_size);Assign input data buffer to JPEG Codec. |
| statusGet | g_jpeg_encode0.p_api->statusGet(g_jpeg_encode0.p_ctrl, p_status);Retrieve current status of the JPEG Codec module. |
| close | g_jpeg_encode0.p_api->close(g_jpeg_encode0.p_ctrl);Cancel an outstanding operation. |
| versionGet | g_jpeg_encode0.p_api->versionGet(&version);Get version and store it in the provided pointer version. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | API Call Successful. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
| SSP_ERR_INVALID_ALIGNMENT | Horizontal stride is not 8-byte aligned. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_ASSERTION | An input pointer is NULL. |
| SSP_ERR_IN_USE | Peripheral is in use or hardware lock is taken. |
| SSP_ERR_HW_LOCKED | JPEG Codec resource is locked. |
| SSP_ERR_INVALID_CALL | An invalid call has been made, Codec output buffer address is attempted to change during codec operation. Or set output buffer first. |
| SSP_ERR_JPEG_IMAGE_SIZE_ERROR | Image size is not supported by JPEG codec. |
The JPEG Encoder HAL module can be used in the input buffer streaming mode or normal mode.
Input Buffer Streaming Mode Operational Description
In this mode the raw image data arrives from the network, file or capturing device in separate data 'chunks'. The HAL-layer driver handles this mode without requiring the input data to be stored in memory first.
Normal Operational Description
In this mode raw image data arrives from the network, file or capturing device as a complete frame. The HAL-layer driver handles this mode and can compress the entire raw image frame.
Motion JPEG
There is no defined standard for Motion JPEG (MJPEG), but the basic concept is to continuously project JPEG images to the rendering device. The basic application steps to implement an MJPEG function using the JPEG Encoder HAL module are as follows:
JPEG Encode Callbacks
A user callback function can be registered in the open API. If a user callback function is provided, the callback function will be called from the interrupt service routine (ISR) each time an interrupt happens. The argument of the callback function status can take the enumerated values listed below so that user can identify which event occurred in the encoding procedure.
| Event Name | Event Condition |
|---|---|
| JPEG_ENCODE_STATUS_INPUT_PAUSE | JPEG Encode paused waiting for more input data. |
| JPEG_ENCODE_STATUS_DONE | JPEG Encode operation has successfully completed. |
This section describes how to include the JPEG Encode HAL Module in an application using the SSP configurator.
To add the JPEG Encode Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the JPEG Encode Driver is g_jpeg_encode0. This name can be changed in the associated Properties window.)
JPEG Encode HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_jpeg_encode0 JPEG Encode Driver on r_jpeg_encode | Threads | New Stack> Driver> Graphics> JPEG Encode Driver |
When the JPEG Encode Driver on r_jpeg_encode is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
The JPEG Encode HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the JPEG Encode HAL Module on r_jpeg_encode
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_jpeg_encode0 | Module name. |
| RAW Image Vertical Resolution | 800 | RAW image vertical resolution selection. |
| RAW Image Horizontal Resolution | 480 | RAW image horizontal resolution selection. |
| Byte Order for Input Data Format | Normal byte order (1)(2)(3)(4)(5)(6)(7)(8), Byte Swap (2)(1)(4)(3)(6)(5)(8)(7), Word Swap (3)(4)(1)(2)(7)(8)(5)(6), Word-Byte Swap (4)(3)(2)(1)(8)(7)(6)(5), Longword Swap (5)(6)(7)(8)(1)(2)(3)(4), Longword-Byte Swap (6)(5)(8)(7)(2)(1)(4)(3), Longword-Word Swap (7)(8)(5)(6)(3)(4)(1)(2), Longword-Word-Byte Swap (8)(7)(6)(5)(4)(3)(2)(1) Default: Normal Byte order | Byte order for input data format selection. |
| Byte Order for Output Data Format | Normal byte order (1)(2)(3)(4)(5)(6)(7)(8), Byte Swap (2)(1)(4)(3)(6)(5)(8)(7), Word Swap (3)(4)(1)(2)(7)(8)(5)(6), Word-Byte Swap (4)(3)(2)(1)(8)(7)(6)(5), Longword Swap (5)(6)(7)(8)(1)(2)(3)(4), Longword-Byte Swap (6)(5)(8)(7)(2)(1)(4)(3), Longword-Word Swap (7)(8)(5)(6)(3)(4)(1)(2), Longword-Word-Byte Swap (8)(7)(6)(5)(4)(3)(2)(1) Default: Normal Byte order | Byte order for output data format selection. |
| Define Restart Marker | 512 | Define restart marker selection. |
| Quality Factor | 50 | Quality factor selection. |
| Name of user callback function | NULL | Name of user callback function selection. |
| Decompression Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | Decompression interrupt priority selection. |
| Data Transfer Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | Data transfer interrupt priority selection. |
Configuration Settings for the JPEG Common Module
| ISDE Property | Value | Description |
|---|---|---|
| Name | g_jpeg_common0 | Module name. |
The JPEG Encode HAL Module uses the PCLKA as its clock source.
To change the clock frequency at run-time, use the CGC Interface.
The JPEG Encode HAL module has no configurable input or output pins on the device.
The typical steps in using the JPEG Encode HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: