2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * This file defines some vp9 probability tables, and
27 * they are ported from libvpx (https://github.com/webmproject/libvpx/).
28 * The original copyright and licence statement as below.
32 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
34 * Use of this source code is governed by a BSD-style license
35 * that can be found in the LICENSE file in the root of the source
36 * tree. An additional intellectual property rights grant can be found
37 * in the file PATENTS. All contributing project authors may
38 * be found in the AUTHORS file in the root of the source tree.
44 #define TX_SIZE_CONTEXTS 2
47 #define SKIP_CONTEXTS 3
48 #define INTER_MODE_CONTEXTS 7
50 #define SWITCHABLE_FILTERS 3
51 #define SWITCHABLE_FILTER_CONTEXTS (SWITCHABLE_FILTERS + 1)
52 #define MAX_SEGMENTS 8
53 #define PREDICTION_PROBS 3
54 #define SEG_TREE_PROBS (MAX_SEGMENTS-1)
56 #define INTRA_INTER_CONTEXTS 4
57 #define COMP_INTER_CONTEXTS 5
58 #define REF_CONTEXTS 5
59 #define BLOCK_SIZE_GROUPS 4
60 #define INTRA_MODES 10
61 #define PARTITION_PLOFFSET 4 // number of probability models per block size
62 #define PARTITION_CONTEXTS (4 * PARTITION_PLOFFSET)
63 #define PARTITION_TYPES 4
64 #define REF_TYPES 2 // intra=0, inter=1
66 #define COEFF_CONTEXTS 6
67 #define UNCONSTRAINED_NODES 3
69 #define CLASS0_BITS 1 /* bits at integer precision for class 0 */
70 #define CLASS0_SIZE (1 << CLASS0_BITS)
71 #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2)
72 #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2)
74 #define FRAME_CONTEXTS_LOG2 2
75 #define FRAME_CONTEXTS (1 << FRAME_CONTEXTS_LOG2)
77 #define COEFF_PROB_SIZE 132
78 #define COEFF_PROB_NUM 3
80 #define TX_PROBS_IDX 0
81 #define COEFF_PROBS_IDX 64
82 #define INTRA_PROBS_IDX 1603
83 #define SEG_PROBS_IDX 2010
85 typedef uint8_t vp9_prob;
87 #define vpx_memset memset
88 #define vpx_memcpy memcpy
90 #define vp9_zero(dest) memset(&dest, 0, sizeof(dest))
92 #define vp9_copy(dest, src) { \
93 assert(sizeof(dest) == sizeof(src)); \
94 vpx_memcpy(dest, src, sizeof(src)); \
98 vp9_prob p8x8[TX_SIZE_CONTEXTS][TX_SIZES - 3];
99 vp9_prob p16x16[TX_SIZE_CONTEXTS][TX_SIZES - 2];
100 vp9_prob p32x32[TX_SIZE_CONTEXTS][TX_SIZES - 1];
104 unsigned int p32x32[TX_SIZE_CONTEXTS][TX_SIZES];
105 unsigned int p16x16[TX_SIZE_CONTEXTS][TX_SIZES - 1];
106 unsigned int p8x8[TX_SIZE_CONTEXTS][TX_SIZES - 2];
107 unsigned int tx_totals[TX_SIZES];
112 vp9_prob classes[MV_CLASSES - 1];
113 vp9_prob class0[CLASS0_SIZE - 1];
114 vp9_prob bits[MV_OFFSET_BITS];
117 //Modified the nmv_context from libvpx to suit our HW needs
119 vp9_prob joints[MV_JOINTS-1];
120 nmv_component comps[2];
121 vp9_prob class0_fp0[CLASS0_SIZE][MV_FP_SIZE - 1];
122 vp9_prob fp0[MV_FP_SIZE - 1];
123 vp9_prob class0_fp1[CLASS0_SIZE][MV_FP_SIZE - 1];
124 vp9_prob fp1[MV_FP_SIZE - 1];
125 vp9_prob class0_hp[2];
129 //Modified the FRAME_CONTEXT from libvpx to suit our HW needs
130 typedef struct frame_contexts {
131 struct tx_probs tx_probs;
133 vp9_prob coeff_probs4x4[COEFF_PROB_SIZE][COEFF_PROB_NUM];
134 vp9_prob coeff_probs8x8[COEFF_PROB_SIZE][COEFF_PROB_NUM];
135 vp9_prob coeff_probs16x16[COEFF_PROB_SIZE][COEFF_PROB_NUM];
136 vp9_prob coeff_probs32x32[COEFF_PROB_SIZE][COEFF_PROB_NUM];
138 vp9_prob skip_probs[SKIP_CONTEXTS];
139 vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1];
140 vp9_prob switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
141 [SWITCHABLE_FILTERS - 1];
142 vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
143 vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
144 vp9_prob single_ref_prob[REF_CONTEXTS][2];
145 vp9_prob comp_ref_prob[REF_CONTEXTS];
146 vp9_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1];
147 vp9_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
150 vp9_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
151 vp9_prob seg_tree_probs[SEG_TREE_PROBS];
152 vp9_prob seg_pred_probs[PREDICTION_PROBS];
158 extern struct tx_probs default_tx_probs;
160 extern vp9_prob default_skip_probs[SKIP_CONTEXTS];
162 extern vp9_prob default_inter_mode_probs[INTER_MODE_CONTEXTS]
165 extern vp9_prob default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
166 [SWITCHABLE_FILTERS - 1];
168 extern vp9_prob default_intra_inter_p[INTRA_INTER_CONTEXTS];
170 extern vp9_prob default_comp_inter_p[COMP_INTER_CONTEXTS];
172 extern vp9_prob default_single_ref_p[REF_CONTEXTS][2];
174 extern vp9_prob default_comp_ref_p[REF_CONTEXTS];
176 extern vp9_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
178 extern vp9_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1];
180 extern vp9_prob default_if_uv_probs[INTRA_MODES][INTRA_MODES - 1];
182 extern vp9_prob default_seg_tree_probs[SEG_TREE_PROBS];
184 extern vp9_prob default_seg_pred_probs[PREDICTION_PROBS];
186 extern vp9_prob vp9_kf_partition_probs[PARTITION_CONTEXTS]
187 [PARTITION_TYPES - 1];
189 extern vp9_prob default_partition_probs[PARTITION_CONTEXTS]
190 [PARTITION_TYPES - 1];
192 extern nmv_context default_nmv_context;
194 extern vp9_prob default_coef_probs_4x4[COEFF_PROB_SIZE][COEFF_PROB_NUM];
196 extern vp9_prob default_coef_probs_8x8[COEFF_PROB_SIZE][COEFF_PROB_NUM];
198 extern vp9_prob default_coef_probs_16x16[COEFF_PROB_SIZE][COEFF_PROB_NUM];
200 extern vp9_prob default_coef_probs_32x32[COEFF_PROB_SIZE][COEFF_PROB_NUM];
202 #endif /*VP9_PROBS_H */