HPM SDK
HPMicro Software Development Kit
hpm_jpeg.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <hpm_jpeg_drv.h>
#include <hpm_l1c_drv.h>
#include "hpm_jpeg.h"
#include "hpm_interrupt.h"

Data Structures

struct  hpm_jpeg_core_htab
 
struct  hpm_jpeg_core_qtab
 
struct  hpm_jpeg_sof0_info
 
struct  hpm_jpeg_sos_info
 
struct  hpm_jpeg_jpeg_info
 
struct  hpm_jpeg_sampling_tab
 
struct  hpm_jpeg_std_tab
 
struct  hpm_jpeg_buf
 
struct  jpeg_list
 
struct  hpm_jpeg_context
 
struct  hpm_jpeg_base_job
 
struct  hpm_jpeg_decode_job
 
struct  hpm_jpeg_encode_job
 

Macros

#define HPM_JPEG_CACHE_LINE   hpm_jpeg_cache_line_size()
 
#define HPM_JPEG_ROUNDUP(x, y)   ((((x) + ((y) - 1)) / (y)) * y)
 
#define HPM_JPEG_ROUNDDOWN(x, y)   ((x) - ((x) % (y)))
 
#define JPEG_MARKER_SOI   0xd8
 
#define JPEG_MARKER_APP0   0xe0
 
#define JPEG_MARKER_SOF0   0xc0
 
#define JPEG_MARKER_DHT   0xc4
 
#define JPEG_MARKER_SOS   0xda
 
#define JPEG_MARKER_DQT   0xdb
 
#define JPEG_MARKER_EOI   0xd9
 
#define jpeg_list_for_each(node, head)   for (jpeg_list_t *node = (head)->nxt; node != (head); node = node->nxt)
 
#define JPEG_INFO_DUMP()
 

Typedefs

typedef struct hpm_jpeg_core_htab hpm_jpeg_core_htab_t
 
typedef struct hpm_jpeg_core_qtab hpm_jpeg_core_qtab_t
 
typedef enum hpm_jpeg_codec_type hpm_jpeg_codec_type_t
 
typedef struct hpm_jpeg_sof0_info hpm_jpeg_sof0_info_t
 
typedef struct hpm_jpeg_sos_info hpm_jpeg_sos_info_t
 
typedef struct hpm_jpeg_jpeg_info hpm_jpeg_jpeg_info_t
 
typedef struct hpm_jpeg_sampling_tab hpm_jpeg_sampling_tab_t
 
typedef struct hpm_jpeg_std_tab hpm_jpeg_std_tab_t
 
typedef struct hpm_jpeg_buf hpm_jpeg_buf_t
 
typedef struct jpeg_list jpeg_list_t
 
typedef struct hpm_jpeg_context hpm_jpeg_context_t
 
typedef struct hpm_jpeg_base_job hpm_jpeg_base_job_t
 
typedef struct hpm_jpeg_decode_job hpm_jpeg_decode_job_t
 
typedef struct hpm_jpeg_encode_job hpm_jpeg_encode_job_t
 

Enumerations

enum  hpm_jpeg_codec_type { HPM_JPEG_CODEC_DECODE , HPM_JPEG_CODEC_ENCODE }
 

Functions

static uint32_t hpm_jpeg_lock (void)
 
static void hpm_jpeg_unlock (uint32_t restore)
 
static void * hpm_jpeg_malloc (uint32_t size)
 
static void hpm_jpeg_free (void *ptr)
 
static uint32_t hpm_jpeg_cache_line_size (void)
 
static void hpm_jpeg_cache_writeback (void *start, uint32_t size)
 
static void hpm_jpeg_cache_invalid (void *start, uint32_t size)
 
static void jpeg_list_node_init (jpeg_list_t *node)
 
static void jpeg_list_del (jpeg_list_t *node)
 
static void jpeg_list_add_tail (jpeg_list_t *head, jpeg_list_t *node)
 
static jpeg_list_tjpeg_list_node_get (jpeg_list_t *head)
 
void hpm_jpeg_hexdump (void *str, const void *data, uint32_t data_len)
 
int hpm_jpeg_create_htab_for_core (hpm_jpeg_core_htab_t *htab_core, void *dht_ac0, void *dht_ac1, void *dht_dc0, void *dht_dc1)
 
static int hpm_jpeg_create_qtab_for_core (hpm_jpeg_core_qtab_t *qtab_core, int is_encode, uint8_t *jpeg_qtabs[])
 
static int hpm_jpeg_get_align_pixel (hpm_jpeg_sampling_format_t sampling, uint16_t *x, uint16_t *y)
 
static int hpm_jpeg_get_sof0_info_from_buf (const void *sof0, hpm_jpeg_sof0_info_t *info)
 
static int hpm_jpeg_set_sof0_info_to_buf (void *sof0, const hpm_jpeg_sof0_info_t *info)
 
static int hpm_jpeg_get_sampling_format_from_sof0_info (hpm_jpeg_sof0_info_t *info, hpm_jpeg_sampling_format_t *sampling)
 
static int hpm_jpeg_init_sof0_info (hpm_jpeg_sof0_info_t *info, hpm_jpeg_sampling_format_t sampling, uint16_t x, uint16_t y)
 
static int hpm_jpeg_get_sos_info_from_buf (const void *sos, hpm_jpeg_sos_info_t *info)
 
static int hpm_jpeg_set_sos_info_to_buf (void *sos, const hpm_jpeg_sos_info_t *info)
 
static int hpm_jpeg_init_sos_info (hpm_jpeg_sos_info_t *info, hpm_jpeg_sampling_format_t sampling)
 
static int hpm_jpege_quality_scaling (int quality)
 
static void hpm_jpege_scale_qtab (uint8_t *qtab_scaled, const uint8_t *qtab_basic, int quality)
 
static void hpm_jpege_get_qtab_luminance (uint8_t *qtab_zig_zag, int quality)
 
static void hpm_jpege_get_qtab_chrominance (uint8_t *qtab_zig_zag, int quality)
 
static int hpm_jpeg_fill_jpeg_info_to_file (hpm_jpeg_encode_job_t *job, void *buf, uint32_t len)
 
static int hpm_jpeg_get_jpeg_info_from_file (hpm_jpeg_jpeg_info_t *info, const void *buf, uint32_t len)
 
static int hpm_jpeg_get_pixel_size (hpm_jpeg_image_format_t format)
 
static int hpm_jpeg_decode_image_buf_init (hpm_jpeg_decode_job_t *job)
 
static int hpm_jpeg_decode_image_buf_deinit (hpm_jpeg_decode_job_t *job)
 
static int hpm_jpeg_encode_file_buf_init (hpm_jpeg_encode_job_t *job)
 
static int hpm_jpeg_encode_file_buf_deinit (hpm_jpeg_encode_job_t *job)
 
static int hpm_jpeg_interrupt_enable (hpm_jpeg_context_t *ctx)
 
static int hpm_jpeg_decode_config_and_start (hpm_jpeg_decode_job_t *job)
 
static int hpm_jpeg_encode_config_and_start (hpm_jpeg_encode_job_t *job)
 
static int hpm_jpeg_decode_init_tabs (hpm_jpeg_decode_job_t *job)
 
static int hpm_jpeg_encode_init_tabs (hpm_jpeg_encode_job_t *job)
 
static int hpm_jpeg_start_next_job (hpm_jpeg_context_t *ctx)
 
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 *file_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...
 
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...
 

Variables

static hpm_jpeg_context_t hpm_jpeg_context
 
static const uint16_t qlook [256]
 
static const hpm_jpeg_sampling_tab_t sampling_tabs []
 
static const uint8_t std_app0 []
 
static const uint8_t jpeg_std_htab_ac0 []
 
static const uint8_t jpeg_std_htab_ac1 []
 
static const uint8_t jpeg_std_htab_dc0 []
 
static const uint8_t jpeg_std_htab_dc1 []
 
static const uint8_t std_luminance_qtab [64]
 
static const uint8_t std_chrominance_qtab [64]
 

Macro Definition Documentation

◆ HPM_JPEG_CACHE_LINE

#define HPM_JPEG_CACHE_LINE   hpm_jpeg_cache_line_size()

◆ HPM_JPEG_ROUNDDOWN

#define HPM_JPEG_ROUNDDOWN (   x,
 
)    ((x) - ((x) % (y)))

◆ HPM_JPEG_ROUNDUP

#define HPM_JPEG_ROUNDUP (   x,
 
)    ((((x) + ((y) - 1)) / (y)) * y)

◆ JPEG_INFO_DUMP

#define JPEG_INFO_DUMP ( )
Value:
{\
HPM_JPEG_DLOG("file_buf->is_direct: 0x%x\n", (uint32_t)file_buf->is_direct);\
HPM_JPEG_DLOG("file_buf->alloced_buf: 0x%x\n", (uint32_t)file_buf->alloced_buf);\
HPM_JPEG_DLOG("file_buf->alloced_len: %u\n", (uint32_t)file_buf->alloced_len);\
HPM_JPEG_DLOG("file_buf->aligned_buf: 0x%x\n", (uint32_t)file_buf->aligned_buf);\
HPM_JPEG_DLOG("file_buf->aligned_len: %u\n", (uint32_t)file_buf->aligned_len);\
HPM_JPEG_DLOG("image_buf->is_direct: 0x%x\n", (uint32_t)image_buf->is_direct);\
HPM_JPEG_DLOG("image_buf->alloced_buf: 0x%x\n", (uint32_t)image_buf->alloced_buf);\
HPM_JPEG_DLOG("image_buf->alloced_len: %u\n", (uint32_t)image_buf->alloced_len);\
HPM_JPEG_DLOG("image_buf->aligned_buf: 0x%x\n", (uint32_t)image_buf->aligned_buf);\
HPM_JPEG_DLOG("image_buf->aligned_len: %u\n", (uint32_t)image_buf->aligned_len);\
HPM_JPEG_DLOG("image->format: %u\n", (uint32_t)image->format);\
HPM_JPEG_DLOG("image->height: %u\n", (uint32_t)image->height);\
HPM_JPEG_DLOG("image->width: %u\n", (uint32_t)image->width);\
HPM_JPEG_DLOG("image->stride: %u\n", (uint32_t)image->stride);\
HPM_JPEG_DLOG("image->image_buf: 0x%x\n", (uint32_t)image->image_buf);\
HPM_JPEG_DLOG("jpeg_info->soi: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->soi,\
(uint32_t)(jpeg_info->soi - jpeg_info->soi),\
(uint32_t)(jpeg_info->soi - jpeg_info->soi));\
HPM_JPEG_DLOG("jpeg_info->app0: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->app0,\
(uint32_t)(jpeg_info->app0 - jpeg_info->soi),\
(uint32_t)(jpeg_info->app0 - jpeg_info->soi));\
HPM_JPEG_DLOG("jpeg_info->dqt[0]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dqt[0],\
(uint32_t)(jpeg_info->dqt[0] ? jpeg_info->dqt[0] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dqt[0] ? jpeg_info->dqt[0] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->dqt[1]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dqt[1],\
(uint32_t)(jpeg_info->dqt[1] ? jpeg_info->dqt[1] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dqt[1] ? jpeg_info->dqt[1] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->dqt[2]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dqt[2],\
(uint32_t)(jpeg_info->dqt[2] ? jpeg_info->dqt[2] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dqt[2] ? jpeg_info->dqt[2] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->sof0: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->sof0,\
(uint32_t)(jpeg_info->sof0 - jpeg_info->soi),\
(uint32_t)(jpeg_info->sof0 - jpeg_info->soi));\
HPM_JPEG_DLOG("jpeg_info->dht_dc[0]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dht_dc[0],\
(uint32_t)(jpeg_info->dht_dc[0] ? jpeg_info->dht_dc[0] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dht_dc[0] ? jpeg_info->dht_dc[0] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->dht_ac[0]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dht_ac[0],\
(uint32_t)(jpeg_info->dht_ac[0] ? jpeg_info->dht_ac[0] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dht_ac[0] ? jpeg_info->dht_ac[0] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->dht_dc[1]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dht_dc[1],\
(uint32_t)(jpeg_info->dht_dc[1] ? jpeg_info->dht_dc[1] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dht_dc[1] ? jpeg_info->dht_dc[1] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->dht_ac[1]: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->dht_ac[1],\
(uint32_t)(jpeg_info->dht_ac[1] ? jpeg_info->dht_ac[1] - jpeg_info->soi : 0),\
(uint32_t)(jpeg_info->dht_ac[1] ? jpeg_info->dht_ac[1] - jpeg_info->soi : 0));\
HPM_JPEG_DLOG("jpeg_info->sos: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->sos,\
(uint32_t)(jpeg_info->sos - jpeg_info->soi),\
(uint32_t)(jpeg_info->sos - jpeg_info->soi));\
HPM_JPEG_DLOG("jpeg_info->ecs: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->ecs,\
(uint32_t)(jpeg_info->ecs - jpeg_info->soi),\
(uint32_t)(jpeg_info->ecs - jpeg_info->soi));\
HPM_JPEG_DLOG("jpeg_info->ecs_len: %u\n", (uint32_t)jpeg_info->ecs_len);\
HPM_JPEG_DLOG("jpeg_info->eoi: 0x%x, offset: %u[0x%x]\n",\
(uint32_t)jpeg_info->eoi,\
(uint32_t)(jpeg_info->eoi - jpeg_info->soi),\
(uint32_t)(jpeg_info->eoi - jpeg_info->soi));\
HPM_JPEG_DLOG("sof0 x: %u\n", sof0_info->x);\
HPM_JPEG_DLOG("sof0 y: %u\n", sof0_info->y);\
HPM_JPEG_DLOG("sof0 nf: %u\n", sof0_info->nf);\
for (uint32_t i = 0; i < sof0_info->nf; i++) {\
HPM_JPEG_DLOG("sof0 component[%u].c: %u\n", i, sof0_info->component[i].c);\
HPM_JPEG_DLOG("sof0 component[%u].h: %u\n", i, sof0_info->component[i].h);\
HPM_JPEG_DLOG("sof0 component[%u].v: %u\n", i, sof0_info->component[i].v);\
HPM_JPEG_DLOG("sof0 component[%u].tq: %u\n", i, sof0_info->component[i].tq);\
} \
HPM_JPEG_DLOG("sos ns: %u\n", sos_info->ns);\
for (uint32_t i = 0; i < sos_info->ns; i++) {\
HPM_JPEG_DLOG("sos component[%u].cs: %u\n", i, sos_info->component[i].cs);\
HPM_JPEG_DLOG("sos component[%u].ta: %u\n", i, sos_info->component[i].ta);\
HPM_JPEG_DLOG("sos component[%u].td: %u\n", i, sos_info->component[i].td);\
} \
}
#define HPM_JPEG_DLOG(fmt,...)
Definition: hpm_jpeg.h:31

◆ jpeg_list_for_each

#define jpeg_list_for_each (   node,
  head 
)    for (jpeg_list_t *node = (head)->nxt; node != (head); node = node->nxt)

◆ JPEG_MARKER_APP0

#define JPEG_MARKER_APP0   0xe0

◆ JPEG_MARKER_DHT

#define JPEG_MARKER_DHT   0xc4

◆ JPEG_MARKER_DQT

#define JPEG_MARKER_DQT   0xdb

◆ JPEG_MARKER_EOI

#define JPEG_MARKER_EOI   0xd9

◆ JPEG_MARKER_SOF0

#define JPEG_MARKER_SOF0   0xc0

◆ JPEG_MARKER_SOI

#define JPEG_MARKER_SOI   0xd8

◆ JPEG_MARKER_SOS

#define JPEG_MARKER_SOS   0xda

Typedef Documentation

◆ hpm_jpeg_base_job_t

◆ hpm_jpeg_buf_t

typedef struct hpm_jpeg_buf hpm_jpeg_buf_t

◆ hpm_jpeg_codec_type_t

◆ hpm_jpeg_context_t

◆ hpm_jpeg_core_htab_t

◆ hpm_jpeg_core_qtab_t

◆ hpm_jpeg_decode_job_t

◆ hpm_jpeg_encode_job_t

◆ hpm_jpeg_jpeg_info_t

◆ hpm_jpeg_sampling_tab_t

◆ hpm_jpeg_sof0_info_t

◆ hpm_jpeg_sos_info_t

◆ hpm_jpeg_std_tab_t

◆ jpeg_list_t

typedef struct jpeg_list jpeg_list_t

Enumeration Type Documentation

◆ hpm_jpeg_codec_type

Enumerator
HPM_JPEG_CODEC_DECODE 
HPM_JPEG_CODEC_ENCODE 

Function Documentation

◆ hpm_jpeg_cache_invalid()

static void hpm_jpeg_cache_invalid ( void *  start,
uint32_t  size 
)
static

◆ hpm_jpeg_cache_line_size()

static uint32_t hpm_jpeg_cache_line_size ( void  )
inlinestatic

◆ hpm_jpeg_cache_writeback()

static void hpm_jpeg_cache_writeback ( void *  start,
uint32_t  size 
)
static

◆ hpm_jpeg_create_htab_for_core()

int hpm_jpeg_create_htab_for_core ( hpm_jpeg_core_htab_t htab_core,
void *  dht_ac0,
void *  dht_ac1,
void *  dht_dc0,
void *  dht_dc1 
)

◆ hpm_jpeg_create_qtab_for_core()

static int hpm_jpeg_create_qtab_for_core ( hpm_jpeg_core_qtab_t qtab_core,
int  is_encode,
uint8_t *  jpeg_qtabs[] 
)
static

◆ hpm_jpeg_decode_config_and_start()

static int hpm_jpeg_decode_config_and_start ( hpm_jpeg_decode_job_t job)
static

◆ hpm_jpeg_decode_image_buf_deinit()

static int hpm_jpeg_decode_image_buf_deinit ( hpm_jpeg_decode_job_t job)
static

◆ hpm_jpeg_decode_image_buf_init()

static int hpm_jpeg_decode_image_buf_init ( hpm_jpeg_decode_job_t job)
static

◆ hpm_jpeg_decode_init_tabs()

static int hpm_jpeg_decode_init_tabs ( hpm_jpeg_decode_job_t job)
static

◆ 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_config_and_start()

static int hpm_jpeg_encode_config_and_start ( hpm_jpeg_encode_job_t job)
static

◆ hpm_jpeg_encode_file_buf_deinit()

static int hpm_jpeg_encode_file_buf_deinit ( hpm_jpeg_encode_job_t job)
static

◆ hpm_jpeg_encode_file_buf_init()

static int hpm_jpeg_encode_file_buf_init ( hpm_jpeg_encode_job_t job)
static

◆ hpm_jpeg_encode_init_tabs()

static int hpm_jpeg_encode_init_tabs ( hpm_jpeg_encode_job_t job)
static

◆ 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_fill_jpeg_info_to_file()

static int hpm_jpeg_fill_jpeg_info_to_file ( hpm_jpeg_encode_job_t job,
void *  buf,
uint32_t  len 
)
static

◆ hpm_jpeg_free()

static void hpm_jpeg_free ( void *  ptr)
static

◆ hpm_jpeg_get_align_pixel()

static int hpm_jpeg_get_align_pixel ( hpm_jpeg_sampling_format_t  sampling,
uint16_t *  x,
uint16_t *  y 
)
static

◆ hpm_jpeg_get_jpeg_info_from_file()

static int hpm_jpeg_get_jpeg_info_from_file ( hpm_jpeg_jpeg_info_t info,
const void *  buf,
uint32_t  len 
)
static

◆ hpm_jpeg_get_pixel_size()

static int hpm_jpeg_get_pixel_size ( hpm_jpeg_image_format_t  format)
static

◆ hpm_jpeg_get_sampling_format_from_sof0_info()

static int hpm_jpeg_get_sampling_format_from_sof0_info ( hpm_jpeg_sof0_info_t info,
hpm_jpeg_sampling_format_t sampling 
)
static

◆ hpm_jpeg_get_sof0_info_from_buf()

static int hpm_jpeg_get_sof0_info_from_buf ( const void *  sof0,
hpm_jpeg_sof0_info_t info 
)
static

◆ hpm_jpeg_get_sos_info_from_buf()

static int hpm_jpeg_get_sos_info_from_buf ( const void *  sos,
hpm_jpeg_sos_info_t info 
)
static

◆ hpm_jpeg_hexdump()

void hpm_jpeg_hexdump ( void *  str,
const void *  data,
uint32_t  data_len 
)

◆ 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_init_sof0_info()

static int hpm_jpeg_init_sof0_info ( hpm_jpeg_sof0_info_t info,
hpm_jpeg_sampling_format_t  sampling,
uint16_t  x,
uint16_t  y 
)
static

◆ hpm_jpeg_init_sos_info()

static int hpm_jpeg_init_sos_info ( hpm_jpeg_sos_info_t info,
hpm_jpeg_sampling_format_t  sampling 
)
static

◆ hpm_jpeg_interrupt_enable()

static int hpm_jpeg_interrupt_enable ( hpm_jpeg_context_t ctx)
static

◆ 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

◆ hpm_jpeg_lock()

static uint32_t hpm_jpeg_lock ( void  )
inlinestatic

◆ hpm_jpeg_malloc()

static void* hpm_jpeg_malloc ( uint32_t  size)
static

◆ hpm_jpeg_set_sof0_info_to_buf()

static int hpm_jpeg_set_sof0_info_to_buf ( void *  sof0,
const hpm_jpeg_sof0_info_t info 
)
static

◆ hpm_jpeg_set_sos_info_to_buf()

static int hpm_jpeg_set_sos_info_to_buf ( void *  sos,
const hpm_jpeg_sos_info_t info 
)
static

◆ hpm_jpeg_start_next_job()

static int hpm_jpeg_start_next_job ( hpm_jpeg_context_t ctx)
static

◆ hpm_jpeg_unlock()

static void hpm_jpeg_unlock ( uint32_t  restore)
inlinestatic

◆ hpm_jpege_get_qtab_chrominance()

static void hpm_jpege_get_qtab_chrominance ( uint8_t *  qtab_zig_zag,
int  quality 
)
static

◆ hpm_jpege_get_qtab_luminance()

static void hpm_jpege_get_qtab_luminance ( uint8_t *  qtab_zig_zag,
int  quality 
)
static

◆ hpm_jpege_quality_scaling()

static int hpm_jpege_quality_scaling ( int  quality)
static

◆ hpm_jpege_scale_qtab()

static void hpm_jpege_scale_qtab ( uint8_t *  qtab_scaled,
const uint8_t *  qtab_basic,
int  quality 
)
static

◆ jpeg_list_add_tail()

static void jpeg_list_add_tail ( jpeg_list_t head,
jpeg_list_t node 
)
inlinestatic

◆ jpeg_list_del()

static void jpeg_list_del ( jpeg_list_t node)
inlinestatic

◆ jpeg_list_node_get()

static jpeg_list_t* jpeg_list_node_get ( jpeg_list_t head)
inlinestatic

◆ jpeg_list_node_init()

static void jpeg_list_node_init ( jpeg_list_t node)
inlinestatic

Variable Documentation

◆ hpm_jpeg_context

◆ jpeg_std_htab_ac0

const uint8_t jpeg_std_htab_ac0[]
static
Initial value:
= {
0xFF, 0xC4, 0x00, 0xB5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04,
0x04, 0x00, 0x00, 0x01, 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41,
0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1,
0xC1, 0x15, 0x52, 0xD1, 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44,
0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x83, 0x84,
0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2,
0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9,
0xBA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
0xD8, 0xD9, 0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3,
0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA
}

◆ jpeg_std_htab_ac1

const uint8_t jpeg_std_htab_ac1[]
static
Initial value:
= {
0xFF, 0xC4, 0x00, 0xB5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04,
0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12,
0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1, 0xC1,
0x09, 0x23, 0x33, 0x52, 0xF0, 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25, 0xF1,
0x17, 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43,
0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x82,
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5,
0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2, 0xF3,
0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA
}

◆ jpeg_std_htab_dc0

const uint8_t jpeg_std_htab_dc0[]
static
Initial value:
= {
0xFF, 0xC4, 0x00, 0x1F, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B
}

◆ jpeg_std_htab_dc1

const uint8_t jpeg_std_htab_dc1[]
static
Initial value:
= {
0xFF, 0xC4, 0x00, 0x1F, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B
}

◆ qlook

const uint16_t qlook[256]
static
Initial value:
= {
0x0000, 0x0001, 0x0400, 0x02ab, 0x0200, 0x0b33, 0x0155, 0x0a49,
0x0100, 0x09c7, 0x00cd, 0x12e9, 0x0955, 0x093b, 0x1249, 0x0911,
0x0080, 0x08f1, 0x11c7, 0x11af, 0x08cd, 0x08c3, 0x08ba, 0x08b2,
0x1155, 0x251f, 0x113b, 0x1a5f, 0x1a49, 0x1a35, 0x1111, 0x2421,
0x0880, 0x23e1, 0x10f1, 0x10ea, 0x19c7, 0x19bb, 0x19af, 0x10d2,
0x10cd, 0x231f, 0x10c3, 0x197d, 0x10ba, 0x10b6, 0x10b2, 0x22b9,
0x1955, 0x229d, 0x10a4, 0x2d05, 0x193b, 0x1935, 0x225f, 0x1095,
0x2249, 0x223f, 0x2235, 0x2c57, 0x1911, 0x2219, 0x1084, 0x1082,
0x1080, 0x18fc, 0x18f8, 0x21e9, 0x18f1, 0x21db, 0x18ea, 0x2b9b,
0x21c7, 0x21c1, 0x21bb, 0x21b5, 0x21af, 0x2b53, 0x18d2, 0x367b,
0x18cd, 0x2b29, 0x18c8, 0x218b, 0x18c3, 0x2b03, 0x217d, 0x2af1,
0x18ba, 0x18b8, 0x18b6, 0x18b4, 0x18b2, 0x2ac1, 0x2ab9, 0x2159,
0x2155, 0x3547, 0x2a9d, 0x214b, 0x18a4, 0x2a89, 0x2141, 0x189f,
0x213b, 0x189c, 0x2135, 0x34c9, 0x2a5f, 0x2a59, 0x1895, 0x349d,
0x2a49, 0x1891, 0x2a3f, 0x211d, 0x2a35, 0x188c, 0x2a2b, 0x344d,
0x2111, 0x343b, 0x2a19, 0x2a15, 0x1884, 0x3419, 0x1882, 0x1881,
0x1880, 0x20fe, 0x20fc, 0x33e9, 0x20f8, 0x3fb3, 0x29e9, 0x33cb,
0x20f1, 0x33bd, 0x29db, 0x33af, 0x20ea, 0x29d1, 0x20e7, 0x3395,
0x29c7, 0x20e2, 0x29c1, 0x20df, 0x29bb, 0x20dc, 0x29b5, 0x20d9,
0x29af, 0x3359, 0x3353, 0x29a7, 0x20d2, 0x3343, 0x299f, 0x20ce,
0x20cd, 0x2997, 0x3329, 0x20c9, 0x20c8, 0x298d, 0x298b, 0x3311,
0x20c3, 0x3e0f, 0x3303, 0x3dfd, 0x297d, 0x297b, 0x2979, 0x32ed,
0x20ba, 0x3dc9, 0x20b8, 0x20b7, 0x20b6, 0x20b5, 0x20b4, 0x20b3,
0x20b2, 0x3d89, 0x20b0, 0x32bd, 0x295d, 0x3d6b, 0x2959, 0x2957,
0x2955, 0x32a7, 0x20a9, 0x20a8, 0x20a7, 0x3299, 0x294b, 0x3293,
0x20a4, 0x20a3, 0x3289, 0x2943, 0x2941, 0x3cff, 0x209f, 0x3279,
0x293b, 0x3273, 0x209c, 0x326d, 0x2935, 0x3ccf, 0x2099, 0x3cc3,
0x325f, 0x2097, 0x3259, 0x3cad, 0x2095, 0x3251, 0x2927, 0x2093,
0x3249, 0x3c8d, 0x2091, 0x3c83, 0x323f, 0x3c79, 0x291d, 0x3c6f,
0x3235, 0x3c65, 0x208c, 0x2917, 0x208b, 0x3229, 0x3227, 0x3c49,
0x2911, 0x2088, 0x290f, 0x3c37, 0x3219, 0x3217, 0x3215, 0x3c25,
0x2084, 0x3c1d, 0x2083, 0x2905, 0x2082, 0x2903, 0x2081, 0x2901
}

◆ sampling_tabs

const hpm_jpeg_sampling_tab_t sampling_tabs[]
static
Initial value:
= {
}
@ HPM_JPEG_SAMPLING_FORMAT_400
Definition: hpm_jpeg.h:75
@ HPM_JPEG_SAMPLING_FORMAT_422V
Definition: hpm_jpeg.h:73
@ HPM_JPEG_SAMPLING_FORMAT_420
Definition: hpm_jpeg.h:71
@ HPM_JPEG_SAMPLING_FORMAT_444
Definition: hpm_jpeg.h:74
@ HPM_JPEG_SAMPLING_FORMAT_422H
Definition: hpm_jpeg.h:72

◆ std_app0

const uint8_t std_app0[]
static
Initial value:
= {
0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48,
0x00, 0x48, 0x00, 0x00
}

◆ std_chrominance_qtab

const uint8_t std_chrominance_qtab[64]
static
Initial value:
= {
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
}

◆ std_luminance_qtab

const uint8_t std_luminance_qtab[64]
static
Initial value:
= {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
}