xref: /OK3568_Linux_fs/external/mpp/mpp/hal/vpu/jpege/hal_jpege_base.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __HAL_JPEGE_BASE_H__
18 #define __HAL_JPEGE_BASE_H__
19 
20 #include "mpp_device.h"
21 #include "hal_enc_task.h"
22 
23 #include "vepu_common.h"
24 
25 #include "jpege_syntax.h"
26 #include "hal_jpege_hdr.h"
27 
28 #define QUANTIZE_TABLE_SIZE 64
29 
30 typedef struct HalJpegeRc_t {
31     /* For quantization table */
32     RK_S32              q_factor;
33     RK_U8               *qtable_y;
34     RK_U8               *qtable_c;
35     RK_S32              last_quality;
36 } HalJpegeRc;
37 
38 typedef struct hal_jpege_ctx_s {
39     MppDev              dev;
40     MppClientType       type;
41 
42     JpegeBits           bits;
43     /* NOTE: regs should reserve space for extra_info */
44     void                *regs;
45     void                *regs_out;
46     RK_U32              reg_size;
47 
48     MppEncCfgSet        *cfg;
49     JpegeSyntax         syntax;
50     JpegeFeedback       feedback;
51 
52     /* For part encode mode */
53     RK_U32              mcu_h;
54     RK_U32              mcu_y;
55     RK_U8               *base;
56     size_t              size;
57     RK_U32              sw_bit;
58     RK_U32              part_bytepos;
59     RK_U32              part_x_fill;
60     RK_U32              part_y_fill;
61     RK_U32              rst_marker_idx;
62 
63     HalJpegeRc          hal_rc;
64     RK_S32              hal_start_pos;
65     VepuStrideCfg       stride_cfg;
66 
67     void                *ctx_ext;
68 } HalJpegeCtx;
69 
70 extern const RK_U32 qp_reorder_table[QUANTIZE_TABLE_SIZE];
71 extern const RK_U8 jpege_luma_quantizer[QUANTIZE_TABLE_SIZE];
72 extern const RK_U8 jpege_chroma_quantizer[QUANTIZE_TABLE_SIZE];
73 extern const RK_U16 jpege_restart_marker[8];
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 MPP_RET hal_jpege_vepu_rc(HalJpegeCtx *ctx, HalEncTask *task);
80 void get_msb_lsb_at_pos(RK_U32 *msb, RK_U32 *lsb, RK_U8 *buf, RK_U32 bytepos);
81 MPP_RET hal_jpege_vepu_init_rc(HalJpegeRc *hal_rc);
82 MPP_RET hal_jpege_vepu_deinit_rc(HalJpegeRc *hal_rc);
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif /* __HAL_JPEGE_BASE_H__ */
89