/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2019. All rights reserved. * Description: jpge API declaration * Create: 2019-11-19 */ #ifndef __UAPI_JPGE_H__ #define __UAPI_JPGE_H__ #include "td_type.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif /* __cplusplus */ #define UAPI_JPGE_HEADER_LEN (8 * 1024) #define UAPI_JPGE_OUT_BUF 2 /* 0: save header 1: save compress data */ #define UAPI_JPGE_COMPONENT 3 #define UAPI_ERR_JPGE_BASE ((td_s32)(((0x80UL + 0x20UL) << 24) | (200 << 16) | (4 << 13) | 1)) /* 错误码 */ typedef enum { UAPI_JPGE_ERR_DEV_NOT_OPEN = UAPI_ERR_JPGE_BASE, /* jpge device not open yet */ UAPI_JPGE_ERR_DEV_OPEN_FAILED, /* open jpge device failed */ UAPI_JPGE_ERR_NULL_PTR, /* input parameters contain null ptr */ UAPI_JPGE_ERR_INVALID_HANDLE, /* invalid job handle */ UAPI_JPGE_ERR_INVALID_PARA, /* invalid parameter */ UAPI_JPGE_ERR_UNSUPPORT, /* not support */ UAPI_JPGE_ERR_MAX, } uapi_jpge_errcode; /* 像素格式 */ typedef enum { UAPI_JPGE_PIXEL_FMT_YUV420 = 0x0, /* 像素格式为YUV420 */ UAPI_JPGE_PIXEL_FMT_YVU420, /* 像素格式为YVU420 */ UAPI_JPGE_PIXEL_FMT_YUV422, /* 像素格式为YUV422 */ UAPI_JPGE_PIXEL_FMT_YVU422, /* 像素格式为YVU422 */ UAPI_JPGE_PIXEL_FMT_UVY422, /* 像素格式为UVY422 */ UAPI_JPGE_PIXEL_FMT_YUV444, /* 像素格式为YUV444 */ UAPI_JPGE_PIXEL_FMT_MAX } uapi_jpge_pixel_fmt; /* 图像像素数据存储方式 */ typedef enum { UAPI_JPGE_MEM_SPACE_SEMI_PLANAR = 0x0, /* 数据存储方式为semi-planar */ UAPI_JPGE_MEM_SPACE_PLANAR, /* 数据存储方式为planar */ UAPI_JPGE_MEM_SPACE_PACKED, /* 数据存储方式为packed */ UAPI_JPGE_MEM_SPACE_MAX } uapi_jpge_mem_space; /* 旋转模式 */ typedef enum { UAPI_JPGE_ROTATION_0 = 0x0, /* 旋转模式为无旋转 */ UAPI_JPGE_ROTATION_90, /* 旋转模式为90度 */ UAPI_JPGE_ROTATION_180, /* 旋转模式为180度 */ UAPI_JPGE_ROTATION_270, /* 旋转模式为270度 */ UAPI_JPGE_ROTATION_MAX } uapi_jpge_rotation; /* jpge属性 */ typedef struct { td_u32 quality_level; /* 1 ~ 99, large value = high image quality = large JFIF size */ td_u32 width; /* 图像宽度 */ td_u32 height; /* 图像高度 */ uapi_jpge_pixel_fmt pixel_fmt; /* 像素格式 */ uapi_jpge_mem_space mem_space; /* 图像像素数据存储方式 */ uapi_jpge_rotation rotation_angle; /* 旋转模式 */ } uapi_jpge_attr; /* surface */ typedef struct { td_u32 stride; /* 行宽 */ td_mem_handle handle; /* buffer handle */ td_mem_size_t size; /* buffer size */ } uapi_jpge_surface; /* 用户输入 */ typedef struct { uapi_jpge_surface in_surface[UAPI_JPGE_COMPONENT]; /* 输入图像的surface */ uapi_jpge_surface out_surface[UAPI_JPGE_OUT_BUF]; /* 输出图像的surface, 由用户申请buffer */ } uapi_jpge_input; /* jpge输出 */ typedef struct { td_u32 offset[UAPI_JPGE_OUT_BUF]; /* JFIF stream data start position */ td_mem_handle handle[UAPI_JPGE_OUT_BUF]; /* buffer handle */ td_mem_size_t size[UAPI_JPGE_OUT_BUF]; /* buffer size */ } uapi_jpge_output; /* open device */ td_s32 uapi_jpge_open(td_void); /* close device */ td_void uapi_jpge_close(td_void); /* create jpge job */ td_s32 uapi_jpge_create(td_handle *handle, const uapi_jpge_attr *attr); /* jpge encode */ td_s32 uapi_jpge_encode(td_handle handle, const uapi_jpge_input *in_surface, uapi_jpge_output *out_surface); /* jpge destroy */ td_s32 uapi_jpge_destroy(td_handle handle); #ifdef __cplusplus #if __cplusplus } #endif #endif /* __cplusplus */ #endif /* __UAPI_JPGE_H__ */