HPM SDK
HPMicro Software Development Kit
hpm_jpeg.h File Reference
#include <stdint.h>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  hpm_jpeg_image
 
struct  hpm_jpeg_jpeg_file
 
struct  hpm_jpeg_decode_info
 
struct  hpm_jpeg_encode_info
 
struct  hpm_jpeg_decode_cfg
 
struct  hpm_jpeg_encode_cfg
 
struct  hpm_jpeg_cfg
 

Macros

#define HPM_JPEG_LOG_LEVEL   HPM_JPEG_LOG_LEVEL_WARN
 
#define HPM_JPEG_LOG_LEVEL_DEBUG   4
 
#define HPM_JPEG_LOG_LEVEL_INFO   3
 
#define HPM_JPEG_LOG_LEVEL_WARN   2
 
#define HPM_JPEG_LOG_LEVEL_ERR   1
 
#define HPM_JPEG_PRINTF(fmt, ...)   printf(fmt, ##__VA_ARGS__);
 
#define HPM_JPEG_DLOG(fmt, ...)
 
#define HPM_JPEG_ILOG(fmt, ...)
 
#define HPM_JPEG_WLOG(fmt, ...)
 
#define HPM_JPEG_ELOG(fmt, ...)
 
#define HPM_JPEG_RET_OK   0
 
#define HPM_JPEG_RET_MALLOC_ERR   -1
 
#define HPM_JPEG_RET_PARA_ERR   -2
 
#define HPM_JPEG_RET_JPEG_FILE_ERROR   -3
 
#define HPM_JPEG_RET_STATUS_ERR   -4
 
#define HPM_JPEG_RET_MARKER_ERR   -5
 

Typedefs

typedef void hpm_jpeg_job_t
 
typedef enum hpm_jpeg_sampling_format hpm_jpeg_sampling_format_t
 
typedef enum hpm_jpeg_image_format hpm_jpeg_image_format_t
 
typedef struct hpm_jpeg_image hpm_jpeg_image_t
 
typedef struct hpm_jpeg_jpeg_file hpm_jpeg_file_t
 
typedef enum hpm_jpeg_job_status hpm_jpeg_job_status_t
 
typedef struct hpm_jpeg_decode_info hpm_jpeg_decode_info_t
 
typedef struct hpm_jpeg_encode_info hpm_jpeg_encode_info_t
 
typedef struct hpm_jpeg_decode_cfg hpm_jpeg_decode_cfg_t
 
typedef struct hpm_jpeg_encode_cfg hpm_jpeg_encode_cfg_t
 
typedef void(* hpm_jpeg_job_state_cb_t) (hpm_jpeg_job_t *job)
 Job't state info notice callback. More...
 
typedef struct hpm_jpeg_cfg hpm_jpeg_cfg_t
 

Enumerations

enum  hpm_jpeg_sampling_format {
  HPM_JPEG_SAMPLING_FORMAT_420 = 0 , HPM_JPEG_SAMPLING_FORMAT_422H , HPM_JPEG_SAMPLING_FORMAT_422V , HPM_JPEG_SAMPLING_FORMAT_444 ,
  HPM_JPEG_SAMPLING_FORMAT_400
}
 
enum  hpm_jpeg_image_format {
  HPM_JPEG_IMAGE_FORMAT_RGB565 , HPM_JPEG_IMAGE_FORMAT_ARGB8888 , HPM_JPEG_IMAGE_FORMAT_BGRA8888 , HPM_JPEG_IMAGE_FORMAT_YUYV422 ,
  HPM_JPEG_IMAGE_FORMAT_UYVY422 , HPM_JPEG_IMAGE_FORMAT_Y8
}
 
enum  hpm_jpeg_job_status {
  HPM_JPEG_JOB_STATUS_ALLOCED = 0 , HPM_JPEG_JOB_STATUS_FILLING , HPM_JPEG_JOB_STATUS_FILL_FAILED , HPM_JPEG_JOB_STATUS_FILLED ,
  HPM_JPEG_JOB_STATUS_STARTING , HPM_JPEG_JOB_STATUS_START_FAILED , HPM_JPEG_JOB_STATUS_WAITING , HPM_JPEG_JOB_STATUS_PROCESSING ,
  HPM_JPEG_JOB_STATUS_FINISHED , HPM_JPEG_JOB_STATUS_STOPPED , HPM_JPEG_JOB_STATUS_ERROR
}
 

Functions

int hpm_jpeg_init (hpm_jpeg_cfg_t *cfg)
 Initializte hpm_jpeg component. More...
 
int hpm_jpeg_deinit (void)
 Deinitializte hpm_jpeg component and free source. More...
 
void hpm_jpeg_isr (void)
 jpeg ip interrupt service routine More...
 
hpm_jpeg_job_thpm_jpeg_decode_job_alloc (hpm_jpeg_decode_cfg_t *cfg)
 Alloc a decode job. More...
 
int hpm_jpeg_decode_job_fill_file (hpm_jpeg_job_t *job, const hpm_jpeg_file_t *file, int direct)
 Fill jpeg file to job. More...
 
int hpm_jpeg_decode_job_force_direct_image_buf (hpm_jpeg_job_t *job, void *buf, uint32_t len)
 Set a buffer that is used by decoder out image to job. More...
 
int hpm_jpeg_decode_job_start (hpm_jpeg_job_t *job, hpm_jpeg_job_state_cb_t cb)
 Start decode of the job. More...
 
int hpm_jpeg_decode_job_stop (hpm_jpeg_job_t *job)
 Stop decode of the job. More...
 
int hpm_jpeg_decode_job_get_info (hpm_jpeg_job_t *job, hpm_jpeg_decode_info_t *info)
 Get job work info. More...
 
int hpm_jpeg_decode_job_free (hpm_jpeg_job_t *job)
 Free decode job. All source of job will be free. More...
 
hpm_jpeg_job_thpm_jpeg_encode_job_alloc (hpm_jpeg_encode_cfg_t *cfg)
 Alloc a encode job. More...
 
int hpm_jpeg_encode_job_fill_image (hpm_jpeg_job_t *job, const hpm_jpeg_image_t *image, int direct)
 Fill image data to job. More...
 
int hpm_jpeg_encode_job_force_direct_file_buf (hpm_jpeg_job_t *job, void *buf, uint32_t len)
 Set a buffer that is used by encoder out jpeg file to job. More...
 
int hpm_jpeg_encode_job_start (hpm_jpeg_job_t *job, hpm_jpeg_job_state_cb_t cb)
 Start encode of the job. More...
 
int hpm_jpeg_encode_job_stop (hpm_jpeg_job_t *job)
 Stop encode of the job. More...
 
int hpm_jpeg_encode_job_get_info (hpm_jpeg_job_t *job, hpm_jpeg_encode_info_t *info)
 Get job work info. More...
 
int hpm_jpeg_encode_job_free (hpm_jpeg_job_t *job)
 Free encode job. All source of job will be free. More...
 
void hpm_jpeg_job_set_user_data (hpm_jpeg_job_t *job, void *user_data)
 Set user data to job. More...
 
void * hpm_jpeg_job_get_user_data (hpm_jpeg_job_t *job)
 Get user data to job. More...
 

Macro Definition Documentation

◆ HPM_JPEG_DLOG

#define HPM_JPEG_DLOG (   fmt,
  ... 
)

◆ HPM_JPEG_ELOG

#define HPM_JPEG_ELOG (   fmt,
  ... 
)
Value:
({\
printf("HPM_JPEG: [E: %s:%u]: ", __func__, __LINE__);\
printf(fmt, ##__VA_ARGS__);\
})

◆ HPM_JPEG_ILOG

#define HPM_JPEG_ILOG (   fmt,
  ... 
)

◆ HPM_JPEG_LOG_LEVEL

#define HPM_JPEG_LOG_LEVEL   HPM_JPEG_LOG_LEVEL_WARN

◆ HPM_JPEG_LOG_LEVEL_DEBUG

#define HPM_JPEG_LOG_LEVEL_DEBUG   4

◆ HPM_JPEG_LOG_LEVEL_ERR

#define HPM_JPEG_LOG_LEVEL_ERR   1

◆ HPM_JPEG_LOG_LEVEL_INFO

#define HPM_JPEG_LOG_LEVEL_INFO   3

◆ HPM_JPEG_LOG_LEVEL_WARN

#define HPM_JPEG_LOG_LEVEL_WARN   2

◆ HPM_JPEG_PRINTF

#define HPM_JPEG_PRINTF (   fmt,
  ... 
)    printf(fmt, ##__VA_ARGS__);

◆ HPM_JPEG_RET_JPEG_FILE_ERROR

#define HPM_JPEG_RET_JPEG_FILE_ERROR   -3

◆ HPM_JPEG_RET_MALLOC_ERR

#define HPM_JPEG_RET_MALLOC_ERR   -1

◆ HPM_JPEG_RET_MARKER_ERR

#define HPM_JPEG_RET_MARKER_ERR   -5

◆ HPM_JPEG_RET_OK

#define HPM_JPEG_RET_OK   0

◆ HPM_JPEG_RET_PARA_ERR

#define HPM_JPEG_RET_PARA_ERR   -2

◆ HPM_JPEG_RET_STATUS_ERR

#define HPM_JPEG_RET_STATUS_ERR   -4

◆ HPM_JPEG_WLOG

#define HPM_JPEG_WLOG (   fmt,
  ... 
)
Value:
({\
printf("HPM_JPEG: [W: %s:%u]: ", __func__, __LINE__);\
printf(fmt, ##__VA_ARGS__);\
})

Typedef Documentation

◆ hpm_jpeg_cfg_t

typedef struct hpm_jpeg_cfg hpm_jpeg_cfg_t

◆ hpm_jpeg_decode_cfg_t

◆ hpm_jpeg_decode_info_t

◆ hpm_jpeg_encode_cfg_t

◆ hpm_jpeg_encode_info_t

◆ hpm_jpeg_file_t

◆ hpm_jpeg_image_format_t

◆ hpm_jpeg_image_t

◆ hpm_jpeg_job_state_cb_t

typedef void(* hpm_jpeg_job_state_cb_t) (hpm_jpeg_job_t *job)

Job't state info notice callback.

Parameters
[in]jobhpm_jpeg job pointer

Note: The function is called in isr, long-time or complex operation are not recommend.

◆ hpm_jpeg_job_status_t

◆ hpm_jpeg_job_t

typedef void hpm_jpeg_job_t

◆ hpm_jpeg_sampling_format_t

Enumeration Type Documentation

◆ hpm_jpeg_image_format

Enumerator
HPM_JPEG_IMAGE_FORMAT_RGB565 

memory layout: byte0, byte1, byte2... memory: [G2:0,B4:0], [R4:0,G5:3], [G2:0,B4:0], [R4:0,G5:3], ...

HPM_JPEG_IMAGE_FORMAT_ARGB8888 

memory: B, G, R, A, B, G, ...

HPM_JPEG_IMAGE_FORMAT_BGRA8888 

memory: A, R, G, B, A, R, ...

HPM_JPEG_IMAGE_FORMAT_YUYV422 

memory: Y0, U0, Y1, V1, ...

HPM_JPEG_IMAGE_FORMAT_UYVY422 

memory: U0, Y0, V1, Y1, ...

HPM_JPEG_IMAGE_FORMAT_Y8 

memory: Y0, Y1, Y2, Y3, ...

◆ hpm_jpeg_job_status

Enumerator
HPM_JPEG_JOB_STATUS_ALLOCED 
HPM_JPEG_JOB_STATUS_FILLING 
HPM_JPEG_JOB_STATUS_FILL_FAILED 
HPM_JPEG_JOB_STATUS_FILLED 
HPM_JPEG_JOB_STATUS_STARTING 
HPM_JPEG_JOB_STATUS_START_FAILED 
HPM_JPEG_JOB_STATUS_WAITING 
HPM_JPEG_JOB_STATUS_PROCESSING 
HPM_JPEG_JOB_STATUS_FINISHED 
HPM_JPEG_JOB_STATUS_STOPPED 
HPM_JPEG_JOB_STATUS_ERROR 

◆ hpm_jpeg_sampling_format

Enumerator
HPM_JPEG_SAMPLING_FORMAT_420 

hy=2, vy=2, hc=1, vc=1

HPM_JPEG_SAMPLING_FORMAT_422H 

hy=2, vy=1, hc=1, vc=1

HPM_JPEG_SAMPLING_FORMAT_422V 

hy=1, vy=2, hc=1, vc=1

HPM_JPEG_SAMPLING_FORMAT_444 

hy=1, vy=1, hc=1, vc=1

HPM_JPEG_SAMPLING_FORMAT_400 

hy=2, vy=2, hc=0, vc=0

Function Documentation

◆ hpm_jpeg_decode_job_alloc()

hpm_jpeg_job_t* hpm_jpeg_decode_job_alloc ( hpm_jpeg_decode_cfg_t cfg)

Alloc a decode job.

Parameters
[in]cfgjob configuration pointer
Returns
decode job pointer

◆ hpm_jpeg_decode_job_fill_file()

int hpm_jpeg_decode_job_fill_file ( hpm_jpeg_job_t job,
const hpm_jpeg_file_t file,
int  direct 
)

Fill jpeg file to job.

Parameters
[in]jobdecode job pointer
[in]filejpeg file data
[in]direct1: The buffer of file will be used by decoder. 0: Firstly, the buffer of file is copied to internal buffer and the internal buffer will be used.
Returns
failed code

◆ hpm_jpeg_decode_job_force_direct_image_buf()

int hpm_jpeg_decode_job_force_direct_image_buf ( hpm_jpeg_job_t job,
void *  buf,
uint32_t  len 
)

Set a buffer that is used by decoder out image to job.

Parameters
[in]jobdecode job pointer
[in]bufReceive decode image data. the buf will be used decoder, so nocacheable buffer is recommend.
[in]lenThe buf length
Returns
failed code

Note: Internal buffer will be used if the buf have not been set.

◆ hpm_jpeg_decode_job_free()

int hpm_jpeg_decode_job_free ( hpm_jpeg_job_t job)

Free decode job. All source of job will be free.

Parameters
[in]jobdecode job pointer
Returns
failed code

◆ hpm_jpeg_decode_job_get_info()

int hpm_jpeg_decode_job_get_info ( hpm_jpeg_job_t job,
hpm_jpeg_decode_info_t info 
)

Get job work info.

Parameters
[in]jobdecode job pointer
[out]infojob work info pointer
Returns
failed code

◆ hpm_jpeg_decode_job_start()

int hpm_jpeg_decode_job_start ( hpm_jpeg_job_t job,
hpm_jpeg_job_state_cb_t  cb 
)

Start decode of the job.

Parameters
[in]jobdecode job pointer
[in]cbjob state notice callback
Returns
failed code

Note: The cb is called in isr, long-time or complex operation are not recommend.

◆ hpm_jpeg_decode_job_stop()

int hpm_jpeg_decode_job_stop ( hpm_jpeg_job_t job)

Stop decode of the job.

Parameters
[in]jobdecode job pointer
Returns
failed code

◆ hpm_jpeg_deinit()

int hpm_jpeg_deinit ( void  )

Deinitializte hpm_jpeg component and free source.

Returns
failed code

◆ hpm_jpeg_encode_job_alloc()

hpm_jpeg_job_t* hpm_jpeg_encode_job_alloc ( hpm_jpeg_encode_cfg_t cfg)

Alloc a encode job.

Parameters
[in]cfgjob configuration pointer
Returns
encode job pointer

◆ hpm_jpeg_encode_job_fill_image()

int hpm_jpeg_encode_job_fill_image ( hpm_jpeg_job_t job,
const hpm_jpeg_image_t image,
int  direct 
)

Fill image data to job.

Parameters
[in]jobencode job pointer
[in]imageimage data for waiting encode
[in]direct1: The buffer of file will be used by encoder. 0: Firstly, the buffer of image is copied to internal buffer and the internal buffer will be used.
Returns
failed code

◆ hpm_jpeg_encode_job_force_direct_file_buf()

int hpm_jpeg_encode_job_force_direct_file_buf ( hpm_jpeg_job_t job,
void *  buf,
uint32_t  len 
)

Set a buffer that is used by encoder out jpeg file to job.

Parameters
[in]jobencode job pointer
[in]bufReceive encode jpeg file data. the buf will be used encoder, so nocacheable buffer is recommend.
[in]lenThe buf length
Returns
failed code

Note: Internal buffer will be used if the buf have not been set.

◆ hpm_jpeg_encode_job_free()

int hpm_jpeg_encode_job_free ( hpm_jpeg_job_t job)

Free encode job. All source of job will be free.

Parameters
[in]jobencode job pointer
Returns
failed code

◆ hpm_jpeg_encode_job_get_info()

int hpm_jpeg_encode_job_get_info ( hpm_jpeg_job_t job,
hpm_jpeg_encode_info_t info 
)

Get job work info.

Parameters
[in]jobencode job pointer
[out]infojob work info pointer
Returns
failed code

◆ hpm_jpeg_encode_job_start()

int hpm_jpeg_encode_job_start ( hpm_jpeg_job_t job,
hpm_jpeg_job_state_cb_t  cb 
)

Start encode of the job.

Parameters
[in]jobencode job pointer
[in]cbjob state notice callback
Returns
failed code

Note: The cb is called in isr, long-time or complex operation are not recommend.

◆ hpm_jpeg_encode_job_stop()

int hpm_jpeg_encode_job_stop ( hpm_jpeg_job_t job)

Stop encode of the job.

Parameters
[in]jobencode job pointer
Returns
failed code

◆ hpm_jpeg_init()

int hpm_jpeg_init ( hpm_jpeg_cfg_t cfg)

Initializte hpm_jpeg component.

Parameters
[in]cfghpm_jpeg configuration pointer
Returns
failed code

◆ hpm_jpeg_isr()

void hpm_jpeg_isr ( void  )

jpeg ip interrupt service routine

◆ hpm_jpeg_job_get_user_data()

void* hpm_jpeg_job_get_user_data ( hpm_jpeg_job_t job)

Get user data to job.

Parameters
[in]jobjob pointer
Returns
user data pointer

◆ hpm_jpeg_job_set_user_data()

void hpm_jpeg_job_set_user_data ( hpm_jpeg_job_t job,
void *  user_data 
)

Set user data to job.

Parameters
[in]jobjob pointer
[in]user_datauser data pointer