MI JPD API¶
REVISION HISTORY¶
| Revision No. | Description |
Date |
|---|---|---|
| 2.00 | 12/17/2020 | |
| 08/25/2021 | ||
| 06/28/2022 | ||
| 06/29/2021 | ||
| 2.01 | 07/15/2022 | |
MI_JPD_StreamBuf_t MI_JPD_DirectInputBuf_t |
10/25/2022 | |
MI_JPD_StreamBuf_t |
11/10/2022 | |
| 12/01/2022 | ||
| 01/09/2023 | ||
| 03/13/2023 | ||
| 03/13/2023 | ||
| 04/12/2023 | ||
| 2.02 | 08/26/2024 | |
| 2.03 | 01/10/2025 | |
| 2.04 | 02/27/2025 | |
| 2.05 | 11/12/2025 | |
| 2.06 | 05/25/2026 |
1. OVERVIEW¶
1.1. Module Overview¶
JPD module provides the functions of creating decoding channel, controlling decoding, and transmitting coded streams.
There are two main types of input sources of JPD module:
-
APP reads stream file and sends data to JPD module;
-
APP sends the stream data received by the network directly to JPD module.
Table 1‑1 Chip decoding specifications
Chip Max Channels Channel Number Range Protocol Resolution Range Max Performance Tiramisu 16 [0, 16) JPEG max 8192x8192, min 16x8 3840x2160@20fps Muffin 16*4 [0, 16) JPEG max 8192x8192, min 16x8 3840x2160@20fps Mochi 16*2 [0, 16) JPEG max 8192x8192, min 16x8 3840x2160@20fps Opera 16 [0, 16) JPEG max 8192x8192, min 16x8 1920x1080@60fps Souffle 64 [0, 64) JPEG max 8192x8192, min 16x8 3840x2160@15fps iFackel 64 [0, 64) JPEG max 8192x8192, min 16x16 1920x1080@60fps iBopper 64 [0, 64) JPEG max 8192x8192, min 16x16 1920x1080@60fps jaguar1 64 [0, 64) JPEG max 8192x8192, min 16x16 1920x1080@30fps mhera 64*2 [0, 128) JPEG max 8192x8192, min 16x16 3840x2160@20fps
Note :
The channel number range describes the range of legal values for the decoding channel number. The total number of channels that a single JPD device can create is constrained by its maximum number of channels.
1.2. Decode Flow Chart¶
1.2.1. Tiramisu Decode Flow Chart¶
Tiramisu only supports 1 device, and device id is 0.
1.2.2. Muffin Decode Flow Chart¶
Muffin supports 4 devices, and the id are 0, 1, 2, 3.
1.2.3. Mochi Decode Flow Chart¶
Mochi supports 2 devices, and the id are 0, 1.
1.2.4. Opera Decode Flow Chart¶
Opera only supports 1 device, and device id is 0.
1.2.5. Souffle Decode Flow Chart¶
Souffle only supports 1 device, and device id is 0.
1.2.6. iFackel Decode Flow Chart¶
iFackel only supports 1 device, and device id is 0.
1.2.7. iBopper Decode Flow Chart¶
iBopper only supports 1 device, and device id is 0.
1.2.8. jaguar1 Decode Flow Chart¶
jaguar1 only supports 1 device, and device id is 0.
1.2.9. mhera Decode Flow Chart¶
mhera supports 2 devices, and the id are 0, 1.
1.3. Keyword Description¶
-
JPG/JPEG
Joint Photographic Experts Group: the JPEG standard is developed by the organization.
-
JPD
JPG Decoder.
-
STR
Suspend To RAM: It means that after the system is shut down or enters the power saving mode, other hardware except the memory is powered off, achieving the effect of fast restart while being compatible with low power consumption.
-
APP
Application.
1.4. modparam¶
-
The JPD supports modifying some parameter configurations through modparam, users can modify it as required. The following table describes the parameters:
Parameter name Default Supported platforms Customer configuration Function jpd_clock 0 iFackel/iBopper/jaguar1/mhera Y JPD hardware clock. If not set or set to 0, the default value will be used internally. maxChnNum 16/16/16/64 iFackel/iBopper/jaguar1/mhera Y The maximum number of channels that can be created on a single JPD device, with a valid range of [1, N] (where N refers to Table 1‑1 Chip decoding specifications). If left unconfigured or set beyond the valid range, the system will internally use the default value. maxChnId 64 mhera Y The maximum channel number that can be created on a single JPD channel, with a valid range of [1, N) (where N refers to Table 1‑1 Chip decoding specifications). If left unconfigured or set beyond the valid range, the system will internally use the default value. -
Module parameters can be configured and modified using modparam.json files, which is usually under /config path in the board.
"E_MI_MODULE_ID_JPD" : { "maxChnNum" : 16, "maxChnId" : 64, "jpd_clock" : 0 } -
Module parameters can be configured and modified using echo commands, the process is as follows:
-
Create a json file or copy from /config path, and modify according to the required format. Take parameter jpd_clock as an example: Create a file named jpd_clock.json with:
"E_MI_MODULE_ID_JPD" : { "maxChnNum" : 64, "maxChnId" : 16, "jpd_clock": 384000000 } -
Import the json configuration using the following commands:
echo jpd_clock.json > /proc/mi_modules/mi_common/modparam -
Run the application or call the JPD related api.
-
-
Note
-
Module parameters take effect when insmod mi_jpd.ko, after the JPD module is started, the modification command cannot take effect.
-
After the system restarts, module parameters are reset to default values. Users needs to reconfigure module parameters.
-
2. API REFERENCE¶
This module provides the following APIs:
| API Name | Function |
|---|---|
| MI_JPD_CreateDev | Create device |
| MI_JPD_DestroyDev | Destroy device |
| MI_JPD_CreateChn | Create a decoding channel. |
| MI_JPD_DestroyChn | Destroy a decoding channel. |
| MI_JPD_GetChnAttr | Get the decoding channel attribute. |
| MI_JPD_StartChn | Decoding channel starts receiving code stream. |
| MI_JPD_StopChn | Decoding channel stops receiving code stream. |
| MI_JPD_GetChnStatus | Get the decoding channel status. |
| MI_JPD_ResetChn | Reset the decoding channel. |
| MI_JPD_GetStreamBuf | Get the specified length bitstream buffer from the decoding channel. |
| MI_JPD_PutStreamBuf | Notify the decoding channel that the stream is put successfully and the decoding channel will start decoding. |
| MI_JPD_DropStreamBuf | Notify the decoding channel that the stream is dropped, and the decoding channel will release the corresponding code stream buffer obtained through MI_JPD_GetStreamBuf. MI_JPD_DropStreamBuf and MI_JPD_PutStreamBuf are mutually exclusive calls. |
| MI_JPD_QueryStreamInfo | Query the stream information from the decoding channel. |
| MI_JPD_DirectBufDecode | The decoding channel decodes directly according to the input and output buffer specified by app. |
| MI_JPD_PauseChn | Pause channel decoding. |
| MI_JPD_RefreshChn | Refresh the channel and re-decode the current frame. |
| MI_JPD_ResumeChn | Resume channel decoding. |
| MI_JPD_StepChn | Channel single frame decoding. |
2.1. MI_JPD_CreateDev¶
-
Function
Create device.
-
Syntax
MI_S32 MI_JPD_CreateDev(MI_JPD_DEV JpdDev, MI_JPD_InitParam_t *pstInitParam); -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input pstInitParam Initialization parameters, which have no actual effect at present, are reserved for future expansion. Please refer to MI_JPD_InitParam_t. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
This function cannot be called, MI_JPD_CreateChn needs to specify a valid device id, and the corresponding device will be created internally.
-
This interface cannot be called repeatedly, it needs to be used in a pair with MI_JPD_DestroyDev, otherwise it returns to fail.
-
-
Related API
2.2. MI_JPD_DestroyDev¶
-
Function
Destroy device.
-
Syntax
MI_S32 MI_JPD_DestroyDev(MI_JPD_DEV JpdDev); -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
This function must be called after the device is created, otherwise it returns to fail.
-
If this interface is not called before the app exits, the device will be automatically destroyed internally.
-
This interface cannot be called repeatedly, it needs to be used in a pair with MI_JPD_CreateDev, otherwise it returns to fail.
-
-
Related API
2.3. MI_JPD_CreateChn¶
-
Function
Create a decoding channel.
-
Syntax
MI_S32 MI_JPD_CreateChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_ChnCreatConf_t *pstChnCreatConf) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstChnCreatConf The decoding channel create configuration pointer, please refer to MI_JPD_ChnCreatConf_t. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
The channel ID cannot exceed the maximum channel number range.
-
The user can set the output pixel format through the ePixelFormat parameter when calling MI_JPD_CreateChn.
Chip Max Decoding Channels Output Pixel Format Tiramisu 16 YUYV Muffin 16 YUYV Mochi 16 YUYV Opera 16 YUYV Souffle 64 YUYV,NV12 iFackel 16(Default value. The actual value is determined by module parameter maxChnNum if maxChnNum was set) YUYV,NV12 iBopper 16(Default value. The actual value is determined by module parameter maxChnNum if maxChnNum was set) YUYV jaguar1 16(Default value. The actual value is determined by module parameter maxChnNum if maxChnNum was set) YUYV,NV12 mhera 64(Default value. The actual value is determined by module parameter maxChnNum if maxChnNum was set) YUYV,NV12 -
The user can set the size of the stream buffer through the u32StreamBufSize parameter when calling MI_JPD_CreateChn. Users can choose a reasonable value setting according to actual needs. According to the empirical value, the buffer size can be referred to as follows.
Resolution Range Buffer Size [min,720x576] 512KB (720x576,1920x1080] 1MB (1920x1080,max] 4MB Among them, min and max can be found in Chip decoding specifications.
-
When user creates multiple channels in one device and binds the channels with SCL module, the binding mode can only be set to one of E_MI_SYS_BIND_TYPE_FRAME_BASE or E_MI_SYS_BIND_TYPE_REALTIME. The simultaneous use of two modes is not supported.
-
-
Example
MI_S32 StartJpd(void) { MI_S32 s32Ret = MI_ERR_JPD_FAILED; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; MI_JPD_ChnCreatConf_t stChnCreatConf; memset(&stChnCreatConf, 0x0, sizeof(MI_JPD_ChnCreatConf_t)); stChnCreatConf.u32StreamBufSize = 0x100000; stChnCreatConf.u32MaxPicWidth = 1920; stChnCreatConf.u32MaxPicHeight = 1080; stChnCreatConf.ePixelFormat = E_MI_SYS_PIXEL_FRAME_YUV422_YUYV; s32Ret = MI_JPD_CreateChn(JpdDev, JpdChn, &stChnCreatConf); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_CreateChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } s32Ret = MI_JPD_StartChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_StartChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } return s32Ret; } -
Related API
2.4. MI_JPD_DestroyChn¶
-
Function
Destroy a decoding channel.
-
Syntax
MI_S32 MI_JPD_DestroyChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
- It is not allowed to destroy the channel before stopping it.
-
Example
MI_S32 StopJpd(void) { MI_S32 s32Ret = MI_ERR_JPD_FAILED; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; // Destroy send stream thread s32Ret = MI_JPD_StopChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_StopChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } s32Ret = MI_JPD_DestroyChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_DestroyChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } return s32Ret; } -
Related API
2.5. MI_JPD_GetChnAttr¶
-
Function
Get the decoding channel attribute.
-
Syntax
MI_S32 MI_JPD_GetChnAttr(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_ChnAttr_t *pstChnAttr) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstChnAttr The decoding channel attribute struct pointer. Please refer to MI_JPD_ChnAttr_t. Output -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
2.6. MI_JPD_StartChn¶
-
Function
The channel starts receiving code stream.
-
Syntax
MI_S32 MI_JPD_StartChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
The channel must be created before starting receiving the code stream.
-
If the module JPD has post-module, it is recommended to bind the module JPD with post-module before starting receiving the code stream.
-
Call MI_JPD_GetStreamBuf/MI_JPD_PutStreamBuf to send stream only after this API has been called first.
-
This API returns success when called repeatedly.
-
-
Example
Please refer to the example of MI_JPD_CreateChn.
-
Related API
2.7. MI_JPD_StopChn¶
-
Function
The channel stops receiving code stream.
-
Syntax
MI_S32 MI_JPD_StopChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
If the module JPD has post-module, it is recommended to stop receiving the code stream before unbinding the module JPD with post-module.
-
After calling this API, the return value of MI_JPD_GetStreamBuf/MI_JPD_PutStreamBuf is MI_ERR_JPD_CHN_NOT_START.
-
This API returns MI_ERR_JPD_CHN_NOT_START when called repeatedly.
-
-
Example
Please refer to the example of MI_JPD_DestroyChn.
-
Related API
2.8. MI_JPD_GetChnStatus¶
-
Function
Get the decoding channel status.
-
Syntax
MI_S32 MI_JPD_GetChnStatus(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_ChnStatus_t *pstChnStatus) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstChnStatus The decoding channel status struct pointer. Please refer to MI_JPD_ChnStatus_t. Output -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
2.9. MI_JPD_ResetChn¶
-
Function
Reset the decoding channel.
-
Syntax
MI_S32 MI_JPD_ResetChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
2.10. MI_JPD_GetStreamBuf¶
-
Function
Get the specified length bitstream buffer from the decoding channel.
-
Syntax
MI_S32 MI_JPD_GetStreamBuf(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_U32 u32RequiredLength, MI_JPD_StreamBuf_t *pstRetStreamBuf, MI_S32 s32MilliSecToWait) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input u32RequiredLength The required length of the stream buffer. Input pstRetStreamBuf The stream buffer struct pointer returned by module, please refer to MI_JPD_StreamBuf_t. Output s32MilliSecToWait Request timeout parameter, value range: -1: block; 0: nonblock; Positive: timeout in milliseconds. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
After calling the interface successfully, copy the corresponding JPG coded stream to the address space returned by the interface. If it succeeds, call MI_JPD_PutStreamBuf; if it fails, call MI_JPD_DropStreamBuf.
-
Only frame streaming mode is supported: a JPG bitstream of one complete frame is sent at a time.
-
-
Example
MI_S32 JpdSendStreamThreadFunc(void) { MI_S32 s32Ret = MI_ERR_JPD_FAILED; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; MI_U32 u32RequiredLength = 0; MI_S32 s32MilliSec = 0; MI_JPD_StreamBuf_t stRetStreamBuf; do { //Check if you need stop sending stream if (g_bStop) { break; } //get one stream from file or ipc, then assign u32RequiredLength to the size of the current stream memset(&stRetStreamBuf, 0x0, sizeof(MI_JPD_StreamBuf_t)); s32MilliSec = 30; //timeout is 30ms s32Ret = MI_JPD_GetStreamBuf(JpdDev, JpdChn, u32RequiredLength, &stRetStreamBuf, s32MilliSec); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_GetStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); continue; } if (stRetStreamBuf.u32HeadLength+stRetStreamBuf.u32TailLength < u32RequiredLength) { //something wrong happen printf("MI_JPD_GetStreamBuf return wrong value: HeadLen%u TailLen%u RequiredLength%u\n", stRetStreamBuf.u32HeadLength, stRetStreamBuf.u32TailLength, u32RequiredLength); s32Ret = MI_JPD_DropStreamBuf(JpdDev, JpdChn, &stRetStreamBuf); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_DropStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); continue; } } else { memcpy(stRetStreamBuf.pu8HeadVirtAddr, addr_of_stream, min(stRetStreamBuf.u32HeadLength, u32RequiredLength)); if (stRetStreamBuf.u32TailLength > 0) memcpy(stRetStreamBuf.pu8TailVirtAddr, addr_of_stream+stRetStreamBuf.u32HeadLength, min(stRetStreamBuf.u32TailLength, u32RequiredLength-stRetStreamBuf.u32HeadLength)); } stRetStreamBuf.u32ContentLength = u32RequiredLength; s32Ret = MI_JPD_PutStreamBuf(JpdDev, JpdChn, &stRetStreamBuf); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PutStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); continue; } }while(!g_bStop); return MI_SUCCESS; } -
Related API
2.11. MI_JPD_PutStreamBuf¶
-
Function
Notify the decoding channel that the stream is sent successfully and the decoding channel will start decoding.
-
Syntax
MI_S32 MI_JPD_PutStreamBuf(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_StreamBuf_t *pstRetStreamBuf) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstRetStreamBuf The stream buffer pointer gotten by calling MI_JPD_GetStreamBuf, please refer to MI_JPD_StreamBuf_t. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
- After calling MI_JPD_GetStreamBuf successfully, copy the corresponding JPG coded stream to the address space returned by MI_JPD_GetStreamBuf. If it succeeds, call this interface; if it fails, call MI_JPD_DropStreamBuf.
-
Example
Please refer to the example of MI_JPD_GetStreamBuf.
-
Related API
2.12. MI_JPD_DropStreamBuf¶
-
Function
Notify the decoding channel that the stream is dropped, and the decoding channel will release the corresponding code stream buffer obtained through MI_JPD_GetStreamBuf.
-
Syntax
MI_S32 MI_JPD_DropStreamBuf(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_StreamBuf_t *pstRetStreamBuf) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstRetStreamBuf The stream buffer pointer gotten by calling MI_JPD_GetStreamBuf, please refer to MI_JPD_StreamBuf_t. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
- After calling MI_JPD_GetStreamBuf successfully, copy the corresponding JPG coded stream to the address space returned by MI_JPD_GetStreamBuf. If it succeeds, call MI_JPD_PutStreamBuf; if it fails, call this interface.
-
Example
Please refer to the example of MI_JPD_GetStreamBuf.
-
Related API
2.13. MI_JPD_QueryStreamInfo¶
-
Function
Query the stream information from the decoding channel.
-
Syntax
MI_S32 MI_JPD_QueryStreamInfo(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_DirectInputBuf_t *pstInputBuf, MI_JPD_StreamInfo_t *pstStreamInfo) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstInputBuf The struct pointer of input buffer, please refer to MI_JPD_DirectInputBuf_t. Input pstStreamInfo The struct pointer of stream information, please refer to MI_JPD_StreamInfo_t. Output -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
- The u32BufWidth/u32BufHeight refers to the actual width/height of the output buffer, while u32CurPicWidth/u32CurPicHeight refers to the effective width/height of the image.
-
Example
Please see the example of MI_JPD_DirectBufDecode.
-
Related API
2.14. MI_JPD_DirectBufDecode¶
-
Function
The decoding channel decodes directly according to the input and output buffer specified by APP.
-
Syntax
MI_S32 MI_JPD_DirectBufDecode(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn, MI_JPD_DirectInputBuf_t *pstInputBuf, MI_JPD_DirectOutputBuf_t *pstOutputBuf) -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input pstInputBuf The struct pointer of input buffer, please refer to MI_JPD_DirectInputBuf_t. Input pstOutputBuf The struct pointer of output buffer, please refer to MI_JPD_DirectOutputBuf_t. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
If the output buffer size is not clear, APP needs to call MI_JPD_QueryStreamInfo before calling this interface.The output buffer size is calculated by u32BufWidth/u32BufHeight of MI_JPD_StreamInfo_t, while u32CurPicWidth/u32CurPicHeight refers to the actual effective width/height of the image.
-
The output pixel format set by this interface needs to be consistent with the value of the output pixel format set by the MI_JPD_CreateChn interface.
-
-
Example
MI_S32 directBufDecode(void) { MI_S32 s32Ret = MI_SUCCESS; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; MI_U8 *pu8Buf = NULL; MI_U32 u32LengthCurStream = 0; MI_JPD_DirectInputBuf_t stInputBuf; MI_JPD_DirectOutputBuf_t stOutputBuf; MI_JPD_StreamInfo_t stStreamInfo; MI_U32 u32OutputBufSize = 0; //get one jpg stream from file or ipc, assign its length to u32LengthCurStream pu8Buf = malloc(u32LengthCurStream); //copy one jpg stream from file or ipc to pu8Buf memset(&stInputBuf, 0, sizeof(MI_JPD_DirectInputBuf_t)); memset(&stOutputBuf, 0, sizeof(MI_JPD_DirectOutputBuf_t)); memset(&stStreamInfo, 0, sizeof(MI_JPD_StreamInfo_t)); stInputBuf.pu8InputJPGRawFrameDataVirtAddr = pu8Buf; stInputBuf.phyAddr = 0; stInputBuf.u32Length = u32LengthCurStream; // get jpeg stream information and use it to configure output buffer s32Ret = MI_JPD_QueryStreamInfo(JpdDev, JpdChn, &stInputBuf, &stStreamInfo); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_QueryStreamInfo failed, s32Ret: 0x%x.\n", s32Ret); goto RETURN_FREE; } // set output pixel format to YUYV422 stOutputBuf.ePixelFormat = E_MI_SYS_PIXEL_FRAME_YUV422_YUYV; stOutputBuf.u32Width = stStreamInfo.u32BufWidth; stOutputBuf.u32Height = stStreamInfo.u32BufHeight; stOutputBuf.u32Stride[0] = stOutputBuf.u32Width * 2; u32OutputBufSize = stOutputBuf.u32Stride[0] * stOutputBuf.u32Height; s32Ret = MI_SYS_MMA_Alloc(NULL, u32OutputBufSize, &stOutputBuf.phyAddr[0]); if (MI_SUCCESS != s32Ret) { printf("MI_SYS_MMA_Alloc failed, s32Ret: 0x%x.\n", s32Ret); goto RETURN_FREE; } // decoding is triggered directly by the specified input and output buffer s32Ret = MI_JPD_DirectBufDecode(JpdDev, JpdChn, &stInputBuf, &stOutputBuf); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_DirectBufDecode failed, s32Ret: 0x%x.\n", s32Ret); goto RETURN_FREE; } RETURN_FREE: free(pu8Buf); return s32Ret; } -
Related API
2.15. MI_JPD_PauseChn¶
-
Function
Pause channel decoding.
-
Syntax
MI_S32 MI_JPD_PauseChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn); -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
After calling this interface, the decoder stops decoding; at this time, the upper layer can continue to send streams, but when the stream buffer is full, MI_JPD_GetStreamBuf will return MI_ERR_JPD_BUF_FULL.
-
This interface can be called repeatedly without error.
-
-
Example
MI_S32 PauseChn(void) { MI_S32 s32Ret = MI_ERR_JPD_FAILED; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; MI_U32 u32RefreshCnt = 0; //While decoding... s32Ret = MI_JPD_PauseChn(JpdDev, JpdChn); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PauseChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } //refresh 10 times while (u32RefreshCnt < 10) { s32Ret = MI_JPD_RefreshChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_RefreshChn failed, s32Ret: 0x%x.\n", s32Ret); break; } u32RefreshCnt ++; usleep(100*1000); } s32Ret = MI_JPD_ResumeChn(JpdDev, JpdChn); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_ResumeChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } return MI_SUCCESS; } -
Related API
2.16. MI_JPD_RefreshChn¶
-
Function
Refresh the channel and re-decode the current frame.
-
Syntax
MI_S32 MI_JPD_RefreshChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn); -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
When calling this interface, please ensure that MI_JPD_PauseChn has been called to stop decoding, otherwise it will return MI_ERR_JPD_NOT_DISABLE.
-
Every time this interface is called, it will trigger the decoder to re-decode the current frame; it can be called more than once, and the zoom factor can be adjusted with MI_SCL to adapt to different scene requirements.
-
When calling this interface, please ensure that there is still data to be decoded in the video stream buffer, otherwise refresh cannot be completed.
-
When the user calls the interface continuously, if the last refresh or step task is not completed, the interface will return MI_ERR_JPD_BUSY.
-
-
Example
Please refer to the example of MI_JPD_PauseChn and MI_JPD_StepChn.
MI_JPD supports digital zoom during pause. Example: Suppose that the output resolution of MI_DISP in preview mode is 1920x1080, and the 4 channels are all 1080P source streams while decoding and previewing, the output resolution of each channel is set to 960x540 for output display. If you pause the decoding and switch channel 2 to full-screen preview, the image of 960x540 will be displayed in full-screen 1920x1080, and the image data will be distorted. By calling MI_JPD_RefreshChn, the 1920x1080 image of the current pause data frame can be displayed without distortion.

The channel relies on the combination of MI_JPD_PauseChn, MI_JPD_RefreshChn, MI_JPD_ResumeChn and MI_JPD_GetStreamBuf, MI_JPD_PutStreamBuf to realize the pause electronic zoom function, so that images with different resolutions can be obtained for the same bitstream data frame. As follows, image 3 needs to be output 4 times repeatedly.
Calling sequence of API combination:
Step 1: Call MI_JPD_GetStreamBuf and MI_JPD_PutStreamBuf to send the video stream data of data frame ‘1’ and ‘2’.
Step 2: Call MI_JPD_PauseChn to pause the decoder and enter the decoded output repeat image frame mode.
Step 3: Call MI_JPD_GetStreamBuf and MI_JPD_PutStreamBuf to send the video stream data that needs to repeatedly output image "3" to the decoder.
Step 4: Repeatedly call MI_JPD_RefreshChn to output image ‘3’, and output 1 frame of image for each call. The number of calls is unlimited. The current example is called 4 times.
Step 5: Call MI_JPD_ResumeChn to exit the repeated decoding same image frame mode.
Step 6: Call MI_JPD_GetStreamBuf and MI_JPD_PutStreamBuf to send the video stream data of data frame ‘4’ and ‘5’.


-
Related API
2.17. MI_JPD_ResumeChn¶
-
Function
Resume channel decoding.
-
Syntax
MI_S32 MI_JPD_ResumeChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn); -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
Before calling this interface, be sure the channel has been created; otherwise, the error code MI_ERR_JPD_CHN_UNEXIST will be returned.
-
Before calling this interface, be sure the channel has been enable; otherwise, the error code MI_ERR_JPD_CHN_NOT_START will be returned.
-
It is allowed to call this interface repeatedly.
-
If the last refresh or step task is not completed when calling this interface, the interface will return MI_ERR_JPD_BUSY.
-
-
Example
Please refer to the example of MI_JPD_PauseChn and MI_JPD_StepChn.
-
Related API
2.18. MI_JPD_StepChn¶
-
Function
Channel single frame decoding.
-
Syntax
MI_S32 MI_JPD_StepChn(MI_JPD_DEV JpdDev, MI_JPD_CHN JpdChn); -
Parameter
Parameter Name Description Input/Output JpdDev Device number Input JpdChn The decoding channel number. Input -
Return Value
-
MI_SUCCESS: Successful.
-
Not MI_SUCCESS: Failed, see ERROR CODE for details.
-
-
Requirement
-
Header: mi_jpd.h, mi_jpd_datatype.h
-
Library: libmi_jpd.a/libmi_jpd.so
-
-
Note
-
Each time this interface is called, it will trigger the decoder to decode the next frame; it can be called multiple times, and the zoom factor can be adjusted with MI_SCL to suit different scene requirements.
-
When calling this interface, the user needs to ensure that there is still data to be decoded in the video stream buffer, otherwise the step cannot be completed.
-
When the user calls the interface multiple times, if the last refresh or step task is not completed, the error code MI_ERR_JPD_BUSY will be returned.
-
-
Example
Case 1:
MI_S32 StepChn(void) { MI_S32 s32Ret = MI_ERR_JPD_FAILED; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; MI_JPD_StreamBuf_t stRetStreamBuf; //While decoding... s32Ret = MI_JPD_PauseChn(JpdDev, JpdChn); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PauseChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } memset(&stRetStreamBuf, 0x0, sizeof(MI_JPD_StreamBuf_t)); u32RequiredLength = u32FrameLen; s32TimeOutMs = 0; /// It can be replaced by another independent thread when calling MI_JPD_GetStreamBuf and MI_JPD_PutStreamBuf s32Ret = MI_JPD_GetStreamBuf(JpdDev, JpdChn, u32RequiredLength, &stRetStreamBuf, s32TimeOutMs); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_GetStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } //Copy data from user buffer to stream buffer s32Ret = MI_JPD_PutStreamBuf(JpdDev, JpdChn, &stRetStreamBuf); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PutStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } s32Ret = MI_JPD_StepChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_StepChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } usleep(20*1000); s32Ret = MI_JPD_ResumeChn(JpdDev, JpdChn); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_ResumeChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } return MI_SUCCESS; }Case 2:
MI_S32 refresh_and_step_chn(void) { MI_S32 s32Ret = MI_ERR_JPD_FAILED; MI_JPD_DEV JpdDev = 0; MI_JPD_CHN JpdChn = 0; MI_U32 u32LoopCnt = 0; MI_JPD_StreamBuf_t stRetStreamBuf; //While decoding... s32Ret = MI_JPD_PauseChn(JpdDev, JpdChn); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PauseChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } memset(&stRetStreamBuf, 0x0, sizeof(MI_JPD_StreamBuf_t)); u32RequiredLength = u32FrameLen; s32TimeOutMs = 0; /// It can be replaced by another independent thread when calling MI_JPD_GetStreamBuf and MI_JPD_PutStreamBuf s32Ret = MI_JPD_GetStreamBuf(JpdDev, JpdChn, u32RequiredLength, &stRetStreamBuf, s32TimeOutMs); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_GetStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } //copy data from user buffer to stream buffer here … s32Ret = MI_JPD_PutStreamBuf(JpdDev, JpdChn, &stRetStreamBuf); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PutStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } /*Loop 10 times*/ While(u32LoopCnt < 10) { s32Ret = MI_JPD_RefreshChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_RefreshChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } usleep(20*1000); memset(&stRetStreamBuf, 0x0, sizeof(MI_JPD_StreamBuf_t)); u32RequiredLength = u32FrameLen; s32TimeOutMs = 0; /// It can be replaced by another independent thread calling MI_JPD_GetStreamBuf ///and MI_JPD_PutStreamBuf s32Ret = MI_JPD_GetStreamBuf(JpdDev, JpdChn, u32RequiredLength, &stRetStreamBuf, s32TimeOutMs); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_GetStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } //Copy data from user buffer to stream buffer s32Ret = MI_JPD_PutStreamBuf(JpdDev, JpdChn, &stRetStreamBuf); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_PutStreamBuf failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } s32Ret = MI_JPD_StepChn(JpdDev, JpdChn); if(MI_SUCCESS != s32Ret) { printf("MI_JPD_StepChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } usleep(20*1000); u32LoopCnt ++; } s32Ret = MI_JPD_ResumeChn(JpdDev, JpdChn); if (MI_SUCCESS != s32Ret) { printf("MI_JPD_ResumeChn failed, s32Ret: 0x%x.\n", s32Ret); return s32Ret; } return MI_SUCCESS; } -
Related API
3. DATA TYPE¶
The JPD related data types and data structures are defined as follows:
| Data Structure | Description |
|---|---|
| MI_JPD_DEV | Define JPD device ID type |
| MI_JPD_CHN | Define JPD channel ID type |
| MI_JPD_ErrCode_e | Define error code enumeration. |
| MI_JPD_InitParam_t | Define device initialization parameter structure. |
| MI_JPD_ChnCreatConf_t | Define channel create configuration structure. |
| MI_JPD_ChnAttr_t | Define channel attribute structure. |
| MI_JPD_ChnStatus_t | Define channel status structure. |
| MI_JPD_StreamBuf_t | Define stream buffer structure. |
| MI_JPD_StreamInfo_t | Define stream information structure. |
| MI_JPD_DirectInputBuf_t | Define input buffer structure. |
| MI_JPD_DirectOutputBuf_t | Define output buffer structure. |
3.1. MI_JPD_DEV¶
-
Description
Define JPD device ID type .
-
Syntax
typedef MI_S32 MI_JPD_DEV;
3.2. MI_JPD_CHN¶
-
Description
Define JPD channel ID type.
-
Syntax
typedef MI_S32 MI_JPD_CHN;
3.3. MI_JPD_ErrCode_e¶
-
Description
Define error code enumeration.
-
Syntax
typedef enum { E_MI_JPD_ERR_CODE_UNKNOW = 0x0, E_MI_JPD_ERR_CODE_ILLEGAL_ACCESS, E_MI_JPD_ERR_CODE_DEC_TIMEOUT, E_MI_JPD_ERR_CODE_OUT_OF_MEMORY, E_MI_JPD_ERR_CODE_MAX } MI_JPD_ErrCode_e; -
Member
Member Description E_MI_JPD_ERR_CODE_UNKNOW Unknown error. E_MI_JPD_ERR_CODE_ILLEGAL_ACCESS Illegal access, e.g. uninitialized or faulty hardware. E_MI_JPD_ERR_CODE_DEC_TIMEOUT Decode timeout. E_MI_JPD_ERR_CODE_OUT_OF_MEMORY Out of memory.
3.4. MI_JPD_InitParam_t¶
-
Description
Define device initialization parameter structure.
-
Syntax
typedef struct MI_JPD_InitParam_s { MI_U32 u32Reserved; } MI_JPD_InitParam_t; -
Member
Member Description u32Reserved Not used, reserved for future expansion. -
Related Data Type and Interface
3.5. MI_JPD_ChnCreatConf_t¶
-
Description
Define channel create configuration structure.
-
Syntax
typedef struct MI_JPD_ChnCreatConf_s { MI_U32 u32StreamBufSize; MI_SYS_PixelFormat_e ePixelFormat; MI_U32 u32MaxPicWidth; MI_U32 u32MaxPicHeight; } MI_JPD_ChnCreatConf_t; -
Member
Member Description u32StreamBufSize The total size of stream buffer. ePixelFormat The pixel format of output Image, Please refer to the description of MI_JPD_CreateChn. u32MaxPicWidth The maximum width of decoded picture. u32MaxPicHeight The maximum height of decoded picture. -
Related Data Type and Interface
3.6. MI_JPD_ChnAttr_t¶
-
Description
Define channel attribute structure.
-
Syntax
typedef struct MI_JPD_ChnAttr_s { MI_U32 u32StreamBufSize; MI_JPD_StreamInfo_t stStreamInfo; } MI_JPD_ChnAttr_t; -
Member
Member Description u32StreamBufSize The total size of stream buffer. stStreamInfo Stream information, please refer to MI_JPD_StreamInfo_t description. -
Related Data Type and Interface
3.7. MI_JPD_ChnStatus_t¶
-
Description
Define channel status structure.
-
Syntax
typedef struct MI_JPD_ChnStatus_s { MI_U32 u32LeftStreamBytes; MI_U32 u32LeftStreamFrames; MI_U32 u32LeftPics; MI_U32 u32RecvStreamFrames; MI_U32 u32DecodeStreamFrames; MI_BOOL bChnStart; MI_JPD_ErrCode_e eErrCode; } MI_JPD_ChnStatus_t; -
Member
Member Description u32LeftStreamBytes The number of bytes to be decoded in the stream buffer. u32LeftStreamFrames The number of frames to be decoded in the stream buffer. u32LeftPics The number of decode pictures in the picture buffer. u32RecvStreamFrames The total number of received frames. u32DecodeStreamFrames The total number of decoded frames. bChnStart Whether the decoding channel has started receiving bitstream. eErrCode Error code. -
Related Data Type and Interface
3.8. MI_JPD_StreamBuf_t¶
-
Description
Define stream buffer structure.
-
Syntax
typedef struct MI_JPD_StreamBuf_s { union { MI_U8* pu8HeadVirtAddr; // ring buffer first part user mode VA MI_PTR64 u64Reserved; }; MI_PHY u64HeadPhyAddr; // ring buffer first part PA MI_U32 u32HeadLength; // ring buffer first part Length union { MI_U8* pu8TailVirtAddr; // ring buffer 2nd part user mode VA MI_PTR64 u64Reserved2; }; MI_PHY u64TailPhyAddr; //ring buffer 2nd part PA MI_U32 u32TailLength; //ring buffer 2nd part length MI_U32 u32ContentLength; //current used content length MI_U64 u64Pts; }MI_JPD_StreamBuf_t; -
Member
Member Description pu8HeadVirtAddr The first part virtual address of bitstream buffer. u64Reserved Reserved, compatible with 32-bit and 64-bit address lengths.(unavailable) u64HeadPhyAddr The first part physical address of bitstream buffer. u32HeadLength The first part length of bitstream buffer. pu8TailVirtAddr The second part virtual address of bitstream buffer.(unavailable) u64Reserved2 Reserved, compatible with 32-bit and 64-bit address lengths.(unavailable) u64TailPhyAddr The second part physical address of bitstream buffer.(unavailable) u32TailLength The second part length of bitstream buffer.(unavailable) u32ContentLength Actual effective data length of bitstream buffer. u64Pts Video stream packet timestamp, unit is microsecond. -
Note
-
The decoding channel stream buffer diagram may have the following situations:
a)
Stream buffer is free. If the length of Free1 meets the expected length u32RequiredLength, the decoding channel will assign the start_addr of stream buffer to pu8HeadVirtAddr, and assign u32RequiredLength to u32HeadLength.
b)
The first part of the stream buffer stores a jpeg coded stream that was previously sent in but has not yet been decoded. If the length of Free1 meets the expected length u32RequiredLength, the decoding channel will assign the start_addr_free1 of stream buffer to pu8HeadVirtAddr, and assign u32RequiredLength to u32HeadLength.
c)
The middle part of the stream buffer stores a jpeg coded stream that was previously sent in but has not yet been decoded, with both sides free. If the length of Free1 meets the expected length u32RequiredLength, the decoding channel will assign the start_addr_free1 of stream buffer to pu8HeadVirtAddr, and assign u32RequiredLength to u32HeadLength.
d)
The last part of the stream buffer stores a jpeg coded stream that was previously sent in but has not yet been decoded. If the length of Free1 meets the expected length u32RequiredLength, the decoding channel will assign the start_addr of stream buffer to pu8HeadVirtAddr, and assign u32RequiredLength to u32HeadLength.
e)
Only the middle part of the stream buffer is free. If the length of Free1 meets the expected length u32RequiredLength, the decoding channel will assign the start_addr_free1 of stream buffer to pu8HeadVirtAddr, and assign u32RequiredLength to u32HeadLength.
-
The decoding channel stream buffer diagram may have the following situations:
The middle part of the stream buffer stores a jpeg coded stream that was previously sent in but has not yet been decoded, the length of Free1 does not meet the expected length u32RequiredLength, there is still a free buffer at the first part of the stream buffer. If the length of Free2 meets the expected length u32RequiredLength, the decoding channel will assign the start_addr of the stream buffer to pu8HeadVirtAddr, and assign u32RequiredLength to u32HeadLength. Otherwise, since the current length of the free buffer is less than the expected length from APP, APP fails to obtain the stream buffer of the expected length.
-
u32ContentLength means actual effective data length of bitstream. If the actual coded stream length transmitted by app is less than the expected length u32RequiredLength of MI_JPD_GetStreamBuf, APP needs to assign the actual length to u32ContentLength, then call MI_JPD_PutStreamBuf.
-
-
Related Data Type and Interface
3.9. MI_JPD_StreamInfo_t¶
-
Description
Define stream information structure.
-
Syntax
typedef struct MI_JPD_StreamInfo_s { MI_U32 u32CurPicWidth; MI_U32 u32CurPicHeight; MI_SYS_PixelFormat_e ePixelFormat; MI_U32 u32BufWidth; MI_U32 u32BufHeight; } MI_JPD_StreamInfo_t; -
Member
Member Description u32CurPicWidth The current effective width of decoded picture. u32CurPicHeight The current effective height of decoded picture. ePixelFormat Input pixel format, with support the code stream encoded by YUV444,YUV440,YUV422,YUV420,YUV411 and YUV400. Please refer to MI_SYS_PixelFormat_e description. u32BufWidth The actual width of the output buffer. u32BufHeight The actual height of the output buffer. -
Note
-
If the output buffer size is not clear, APP needs to call this interface before calling MI_JPD_DirectBufDecode. The output buffer size is calculated by u32BufWidth/u32BufHeight, while u32CurPicWidth/u32CurPicHeight refers to the actual effective width/height of the image.
-
Currently, the query ePixelFormat is not supported.
-
-
Related Data Type and Interface
3.10. MI_JPD_DirectInputBuf_t¶
-
Description
Define input buffer structure.
-
Syntax
typedef struct MI_JPD_DirectInputBuf_s { union { MI_U8* pu8InputJPGRawFrameDataVirtAddr; MI_PTR64 u64Reserved; }; MI_PHY phyAddr; MI_U32 u32Length; }MI_JPD_DirectInputBuf_t; -
Member
Member Description pu8InputJPGRawFrameDataVirtAddr The virtual address that stores JPG bitstream data. u64Reserved Reserved, compatible with 32-bit and 64-bit address lengths.(unavailable) phyAddr Optional, the physical address that stores JPG bitstream data, default value is 0. u32Length The length of JPG bitstream data. -
Note
-
The input buffer cannot be gotten from MI_JPD_GetStreamBuf, but through the system application.
-
If the coded stream is always sent and decoded in this way, the parameter u32StreamBufSize of MI_JPD_CreateChn can be set to 0, to spare the decoding channel the effort of allocating the stream buffer.
-
The purpose of synchronous decoding is achieved through the MI_JPD_DirectBufDecode interface. Pass MI_JPD_GetStreamBuf/ MI_JPD_PutStreamBuf for asynchronous decoding process.
-
-
Related Data Type and Interface
3.11. MI_JPD_DirectOutputBuf_t¶
-
Description
Define output buffer structure.
-
Syntax
typedef struct MI_JPD_DirectOutputBuf_s { MI_SYS_PixelFormat_e ePixelFormat; MI_U32 u32Width; MI_U32 u32Height; MI_U32 u32Stride[2]; MI_PHY phyAddr[2]; }MI_JPD_DirectOutputBuf_t; -
Member
Member Description ePixelFormat Output pixel format, please refer to the description of MI_JPD_CreateChn. u32Width The actual width of output buffer. u32Height The actual height of output buffer. u32Stride u32Stride[0]: the stride of Y data; u32Stride[1]: the stride of UV data. phyAddr phyAddr[0]: the start physical address of Y data; phyAddr[1]: the start physical address of UV data. -
Note
- Output pixel format, Please refer to the description of MI_JPD_CreateChn.
-
Related Data Type and Interface
4. ERROR CODE¶
The error code is shown in the following table:
| Error Code | Macro Definition | Description |
|---|---|---|
| 0xA0202001 | MI_ERR_JPD_INVALID_DEVID | Invalid Device ID. |
| 0xA0202002 | MI_ERR_JPD_INVALID_CHNID | Invalid Channel ID. |
| 0xA0202003 | MI_ERR_JPD_ILLEGAL_PARAM | Illegal parameter or inputted parameter exceeding channel decoding capability. |
| 0xA0202004 | MI_ERR_JPD_CHN_EXIST | Channel to be created already exists. |
| 0xA0202005 | MI_ERR_JPD_CHN_UNEXIST | Channel does not exist. |
| 0xA0202006 | MI_ERR_JPD_NULL_PTR | Null pointer. |
| 0xA0202007 | MI_ERR_JPD_NOT_CONFIG | Not configured before use. |
| 0xA0202008 | MI_ERR_JPD_NOT_SUPPORT | This operation or function is not supported. |
| 0xA0202009 | MI_ERR_JPD_NOT_PERM | Illegal operation |
| 0xA020200C | MI_ERR_JPD_NOMEM | Memory allocation fails, such as insufficient memory |
| 0xA020200D | MI_ERR_JPD_NOBUF | Buffer allocation fails, like the requested data buffer is too large |
| 0xA020200E | MI_ERR_JPD_BUF_EMPTY | No data in buffer. |
| 0xA020200F | MI_ERR_JPD_BUF_FULL | Buffer full. |
| 0xA0202010 | MI_ERR_JPD_SYS_NOTREADY | The system is not initialized or the dependent modules are not loaded. |
| 0xA0202011 | MI_ERR_JPD_BADADDR | Address error. |
| 0xA0202012 | MI_ERR_JPD_BUSY | System busy. |
| 0xA0202013 | MI_ERR_JPD_CHN_NOT_START | Channel not started or already stopped. |
| 0xA0202014 | MI_ERR_JPD_CHN_NOT_STOP | Channel cannot be closed before code stream reception is stopped. |
| 0xA0202015 | MI_ERR_JPD_NOT_INIT | Device is not initialized. |
| 0xA0202016 | MI_ERR_JPD_INITED | Device to be initialized is already initialized. |
| 0xA0202017 | MI_ERR_JPD_NOT_ENABLE | The channel is not enabled. |
| 0xA0202018 | MI_ERR_JPD_NOT_DISABLE | The channel is not disabled. |
| 0xA020201C | MI_ERR_JPD_CHN_NO_CONTENT | Channel has no data. |
| 0xA020201F | MI_ERR_JPD_FAILED | Failed. |
5. PROCFS INTRODUCTION¶
5.1. cat¶
-
Debug info
#cat /proc/mi_modules/mi_jpd/mi_jpdNN represents different devices, and the values of N for different chips are as follows:
Chip N Tiramisu 0 Muffin 0~3 Mochi 0~1 Opera 0 Souffle 0 iFackel 0 iBopper 0 jaguar1 0 mhera 0~1 Cat jpd device 0:
# cat /proc/mi_modules/mi_jpd/mi_jpd0
-
Debug info analysis
The printing is divided into two parts, separated by Private JpdN Info. The upper half is common information, and the lower half is jpd module information. It mainly records the usage and configuration attributes of the decoding channel, which can be used to check the attribute configuration and the working status of the current channel to facilitate debugging.
-
Parameter Description
Parameter Description DEV Info DevID Hardware device id WorkingTaskCnt The number of tasks being processed by the device CHN Info ChnID Channel ID Start Enable state:
0: Disable
1: EnableDecState Decoding state:
0: Parse header
1: Decoding
2: End of decodingWidth Current decoding image width Height Current decoding image height BufW The output buffer width that needs to be allocated for the current decoding image BufH The output buffer height that needs to be allocated for the current decoding image StreamBufSize Code stream input buffer pool size, unit: byte MinAllocSize Allow the input buffer min size to be allocated successfully WorkingTaskCnt The number of tasks being processed by the channel IsrDoneCnt Isr count of done type IsrOtherCnt Isr count of other type Poll Time to run OnPollingAsyncOutputTaskConfig, unit: ms Enque Time to run EnqueueAsyncOutputTask, unit: ms Isr Time to run isr, unit: ms Check Time to run CheckOutputTaskStatus, unit: ms Dequeue Time to run DequeueOutputTask, unit: ms P->E Time from Poll to Enque, unit: ms E->I Time from Enque to Isr, unit: ms I->C Time from Isr to Check, unit: ms C->D Time from Check to Dequeue, unit: ms P->D Time from Poll to Dequeue, unit: ms SmoothDecodeTime Average decode time, unit: ms CHN INPUT Info ChnID Channel ID SendCnt The count of stream sent by App LeftCnt The count of stream left by Input buffer pool SendStreamSize Total size of stream sent by App LeftStreamBytes Total size of stream left by Input buffer pool EnqueueCnt The total number of successful executions of EnqueueAsyncOutputTask DirectCnt The number of times that MI_JPD_DirectBufDecode is called to trigger decoding DropCnt The total number of failed executions of EnqueueAsyncOutputTask RewindCnt The total number of executions of EnqueueAsyncOutputTask rewind ifps Frame rate of App input stream MinIntvl The minimum interval of APP input stream, unit: ms MaxIntvl The maximum interval of APP input stream, unit: ms SumIntvl The accumulation interval of APP input stream, unit: ms AvgIntvl The average interval of APP input stream, unit: ms Diff The current interval of the APP input stream, unit: ms CHN OUTPUT Info ChnID Channel ID DecCnt The total number of successful decoding DirectCnt The total number of successful decoding calls MI_JPD_DirectBufDecode DropCnt The total number of failed decoding ofps Output frame rate MinIntvl The minimum interval of APP output stream, unit: ms MaxIntvl The maximum interval of APP output stream, unit: ms SumIntvl The accumulation interval of APP output stream, unit: ms AvgIntvl The average interval of APP output stream, unit: ms Diff The current interval of the APP output stream, unit: ms
5.2. echo¶
| Function | Dump the bitstream buffer of the specified channel to the specified path |
|---|---|
| Command | echo dumpsb [chn] [bEnable] [path] > /proc/mi_modules/mi_jpd/mi_jpd[dev] |
| Parameter Description | [chn]: Channel ID |
| [bEnable]: 1: enable dump; 0: disable dump | |
| [path]: Path to save the file | |
| [dev]: Device ID | |
| Example | echo dumpsb 3 1 /mnt > /proc/mi_modules/mi_jpd/mi_jpd0 Dump bitstream buffer of channel 3 to /mnt |
| Function | Dump the decoded output data frame of the specified channel to the specified path |
|---|---|
| Command | echo dumpfb [chn] [bEnable] [path] > /proc/mi_modules/mi_jpd/mi_jpd[dev] |
| Parameter Description | [chn]: Channel ID |
| [bEnable]: 1: enable dump; 0: disable dump | |
| [path]: Path to save the file | |
| Example | echo dumpfb 3 1 /mnt > /proc/mi_modules/mi_jpd/mi_jpd0 //Dump output data frame of channel 3 to /mnt |