• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VP9_COMMON_VP9_ENTROPYMODE_H_
12 #define VP9_COMMON_VP9_ENTROPYMODE_H_
13 
14 #include "vp9/common/vp9_entropy.h"
15 #include "vp9/common/vp9_entropymv.h"
16 #include "vp9/common/vp9_filter.h"
17 #include "vpx_dsp/vpx_filter.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define BLOCK_SIZE_GROUPS 4
24 
25 #define TX_SIZE_CONTEXTS 2
26 
27 #define INTER_OFFSET(mode) ((mode)-NEARESTMV)
28 
29 struct VP9Common;
30 
31 struct tx_probs {
32   vpx_prob p32x32[TX_SIZE_CONTEXTS][TX_SIZES - 1];
33   vpx_prob p16x16[TX_SIZE_CONTEXTS][TX_SIZES - 2];
34   vpx_prob p8x8[TX_SIZE_CONTEXTS][TX_SIZES - 3];
35 };
36 
37 struct tx_counts {
38   unsigned int p32x32[TX_SIZE_CONTEXTS][TX_SIZES];
39   unsigned int p16x16[TX_SIZE_CONTEXTS][TX_SIZES - 1];
40   unsigned int p8x8[TX_SIZE_CONTEXTS][TX_SIZES - 2];
41   unsigned int tx_totals[TX_SIZES];
42 };
43 
44 typedef struct frame_contexts {
45   vpx_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1];
46   vpx_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
47   vpx_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
48   vp9_coeff_probs_model coef_probs[TX_SIZES][PLANE_TYPES];
49   vpx_prob switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
50                                  [SWITCHABLE_FILTERS - 1];
51   vpx_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1];
52   vpx_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
53   vpx_prob comp_inter_prob[COMP_INTER_CONTEXTS];
54   vpx_prob single_ref_prob[REF_CONTEXTS][2];
55   vpx_prob comp_ref_prob[REF_CONTEXTS];
56   struct tx_probs tx_probs;
57   vpx_prob skip_probs[SKIP_CONTEXTS];
58   nmv_context nmvc;
59   int initialized;
60 } FRAME_CONTEXT;
61 
62 typedef struct FRAME_COUNTS {
63   unsigned int y_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
64   unsigned int uv_mode[INTRA_MODES][INTRA_MODES];
65   unsigned int partition[PARTITION_CONTEXTS][PARTITION_TYPES];
66   vp9_coeff_count_model coef[TX_SIZES][PLANE_TYPES];
67   unsigned int eob_branch[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS]
68                          [COEFF_CONTEXTS];
69   unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
70                                 [SWITCHABLE_FILTERS];
71   unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
72   unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
73   unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
74   unsigned int single_ref[REF_CONTEXTS][2][2];
75   unsigned int comp_ref[REF_CONTEXTS][2];
76   struct tx_counts tx;
77   unsigned int skip[SKIP_CONTEXTS][2];
78   nmv_context_counts mv;
79 } FRAME_COUNTS;
80 
81 extern const vpx_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
82 extern const vpx_prob vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
83                                         [INTRA_MODES - 1];
84 extern const vpx_prob vp9_kf_partition_probs[PARTITION_CONTEXTS]
85                                             [PARTITION_TYPES - 1];
86 extern const vpx_tree_index vp9_intra_mode_tree[TREE_SIZE(INTRA_MODES)];
87 extern const vpx_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)];
88 extern const vpx_tree_index vp9_partition_tree[TREE_SIZE(PARTITION_TYPES)];
89 extern const vpx_tree_index
90     vp9_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)];
91 
92 void vp9_setup_past_independence(struct VP9Common *cm);
93 
94 void vp9_adapt_mode_probs(struct VP9Common *cm);
95 
96 void tx_counts_to_branch_counts_32x32(const unsigned int *tx_count_32x32p,
97                                       unsigned int (*ct_32x32p)[2]);
98 void tx_counts_to_branch_counts_16x16(const unsigned int *tx_count_16x16p,
99                                       unsigned int (*ct_16x16p)[2]);
100 void tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
101                                     unsigned int (*ct_8x8p)[2]);
102 
103 #ifdef __cplusplus
104 }  // extern "C"
105 #endif
106 
107 #endif  // VP9_COMMON_VP9_ENTROPYMODE_H_
108