xref: /rockchip-linux_mpp/mpp/hal/vpu/jpegd/hal_jpegd_common.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  *
3  * Copyright 2015 - 2017 Rockchip Electronics Co. LTD
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef __HAL_JPEGD_COMMON_H__
18 #define __HAL_JPEGD_COMMON_H__
19 
20 #include "hal_jpegd_base.h"
21 
22 #define BRIGHTNESS                                  4    /* -128 ~ 127 */
23 #define CONTRAST                                    0    /* -64 ~ 64 */
24 #define SATURATION                                  0    /* -64 ~ 128 */
25 #define PP_IN_FORMAT_YUV422INTERLAVE                0
26 #define PP_IN_FORMAT_YUV420SEMI                     1
27 #define PP_IN_FORMAT_YUV420PLANAR                   2
28 #define PP_IN_FORMAT_YUV400                         3
29 #define PP_IN_FORMAT_YUV422SEMI                     4
30 #define PP_IN_FORMAT_YUV420SEMITIELED               5
31 #define PP_IN_FORMAT_YUV440SEMI                     6
32 #define PP_IN_FORMAT_YUV444_SEMI                    7
33 #define PP_IN_FORMAT_YUV411_SEMI                    8
34 
35 #define PP_OUT_FORMAT_RGB565                        0
36 #define PP_OUT_FORMAT_ARGB                          1
37 #define PP_OUT_FORMAT_YUV422INTERLAVE               3
38 #define PP_OUT_FORMAT_YUV420INTERLAVE               5
39 
40 #define MIN_WIDTH                         (48)      /* 48 Bytes */
41 #define MIN_HEIGHT                        (48)      /* 48 Bytes */
42 #define MAX_WIDTH                         (8*1024)  /* 4K Bytes */
43 #define MAX_HEIGHT                        (8*1024)  /* 4K Bytes */
44 #define MAX_STREAM_LENGTH                 (MAX_WIDTH * MAX_HEIGHT) /* 16M Bytes */
45 
46 static const RK_U8 zzOrder[64] = {
47     0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
48     12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
49     35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
50     58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
51 };
52 
53 #define PP_RGB_CFG_LENTH (10)
54 typedef struct PpRgbCfg_t {
55     MppFrameFormat fmt;
56     RK_U8   pp_out_fmt;
57     RK_U8   out_endian;
58     RK_U8   swap_16;
59     RK_U8   swap_32;
60     RK_U8   rgb_in_32;
61     RK_U8   r_padd;
62     RK_U8   g_padd;
63     RK_U8   b_padd;
64     RK_U8   r_dither;
65     RK_U8   g_dither;
66     RK_U8   b_dither;
67     RK_U32  r_mask;
68     RK_U32  g_mask;
69     RK_U32  b_mask;
70 } PpRgbCfg;
71 
72 PpRgbCfg* get_pp_rgb_Cfg(MppFrameFormat fmt);
73 RK_U32 jpegd_vdpu_tail_0xFF_patch(MppBuffer stream, RK_U32 length);
74 
75 void jpegd_write_qp_ac_dc_table(JpegdHalCtx *ctx,
76                                 JpegdSyntax*syntax);
77 
78 MPP_RET jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *syntax,
79                                RK_S32 output);
80 
81 MPP_RET jpeg_image_check_size(RK_U32 hor_stride, RK_U32 ver_stride);
82 
83 #endif /* __HAL_JPEGD_COMMON_H__ */
84