xref: /rockchip-linux_mpp/mpp/hal/rkdec/vp9d/hal_vp9d_com.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2020 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_VP9D_COM_H__
18 #define __HAL_VP9D_COM_H__
19 
20 #include "rk_type.h"
21 #include "mpp_err.h"
22 
23 typedef RK_U8 vp9_prob;
24 
25 #define PARTITION_CONTEXTS              16
26 #define PARTITION_TYPES                 4
27 #define MAX_SEGMENTS                    8
28 #define SEG_TREE_PROBS                  (MAX_SEGMENTS-1)
29 #define PREDICTION_PROBS                3
30 #define SKIP_CONTEXTS                   3
31 #define TX_SIZE_CONTEXTS                2
32 #define TX_SIZES                        4
33 #define INTRA_INTER_CONTEXTS            4
34 #define PLANE_TYPES                     2
35 #define COEF_BANDS                      6
36 #define COEFF_CONTEXTS                  6
37 #define UNCONSTRAINED_NODES             3
38 #define INTRA_MODES                     10
39 #define INTER_PROB_SIZE_ALIGN_TO_128    151
40 #define INTRA_PROB_SIZE_ALIGN_TO_128    149
41 #define BLOCK_SIZE_GROUPS               4
42 #define COMP_INTER_CONTEXTS             5
43 #define REF_CONTEXTS                    5
44 #define INTER_MODE_CONTEXTS             7
45 #define SWITCHABLE_FILTERS              3   // number of switchable filters
46 #define SWITCHABLE_FILTER_CONTEXTS      (SWITCHABLE_FILTERS + 1)
47 #define INTER_MODES                     4
48 #define MV_JOINTS                       4
49 #define MV_CLASSES                      11
50 #define CLASS0_BITS                     1  /* bits at integer precision for class 0 */
51 #define CLASS0_SIZE                     (1 << CLASS0_BITS)
52 #define MV_OFFSET_BITS                  (MV_CLASSES + CLASS0_BITS - 2)
53 #define MV_FP_SIZE                      4
54 
55 #define PROB_SIZE                       4864
56 #define PROB_KF_SIZE                    (82 * 16)
57 #define COUNT_SIZE                      13208
58 
59 /*
60  * MAX_SEGMAP_SIZE calculate(e.g. 4096x2304):
61  *      nCtuX*nCtuY*8*8/2
62  *      MaxnCtuX = 4096/64
63  *      MaxnCtuY = 2304/64
64  * for support 8k resolusion, segmap_size(8k) = segmap_size(4k) * 4
65  */
66 #define MAX_SEGMAP_SIZE                 (73728 * 4)
67 
68 #define VP9_DUMP 0
69 
70 //!< memory malloc check
71 #define MEM_CHECK(ret, val, ...)\
72 do{\
73     if (!(val)) {\
74         ret = MPP_ERR_MALLOC; \
75         mpp_err("malloc buffer error(%d).\n", __LINE__); \
76         mpp_assert(0); goto __FAILED; \
77 }} while (0)
78 
79 
80 extern const vp9_prob vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1];
81 extern const vp9_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
82 extern const vp9_prob vp9_kf_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
88 RK_U32 vp9_ver_align(RK_U32 val);
89 RK_U32 vp9_hor_align(RK_U32 val);
90 
91 MPP_RET hal_vp9d_output_probe(void *buf, void *dxva);
92 MPP_RET hal_vp9d_prob_flag_delta(void *buf, void *dxva);
93 void hal_vp9d_update_counts(void *buf, void *dxva);
94 MPP_RET hal_vp9d_prob_default(void *buf, void *dxva);
95 MPP_RET hal_vp9d_prob_kf(void *buf);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif
102