OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 | 11 |
12 #ifndef VP9_COMMON_VP9_ENTROPYMV_H_ | 12 #ifndef VP9_COMMON_VP9_ENTROPYMV_H_ |
13 #define VP9_COMMON_VP9_ENTROPYMV_H_ | 13 #define VP9_COMMON_VP9_ENTROPYMV_H_ |
14 | 14 |
15 #include "vp9/common/vp9_treecoder.h" | 15 #include "vp9/common/vp9_treecoder.h" |
16 #include "./vpx_config.h" | 16 #include "./vpx_config.h" |
17 #include "vp9/common/vp9_blockd.h" | 17 #include "vp9/common/vp9_blockd.h" |
18 | 18 |
19 struct VP9Common; | 19 struct VP9Common; |
20 | 20 |
21 void vp9_entropy_mv_init(); | |
22 void vp9_init_mv_probs(struct VP9Common *cm); | 21 void vp9_init_mv_probs(struct VP9Common *cm); |
23 | 22 |
24 void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp); | 23 void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp); |
25 int vp9_use_mv_hp(const MV *ref); | 24 int vp9_use_mv_hp(const MV *ref); |
26 | 25 |
27 #define NMV_UPDATE_PROB 252 | 26 #define NMV_UPDATE_PROB 252 |
28 | 27 |
29 /* Symbols for coding which components are zero jointly */ | 28 /* Symbols for coding which components are zero jointly */ |
30 #define MV_JOINTS 4 | 29 #define MV_JOINTS 4 |
31 typedef enum { | 30 typedef enum { |
(...skipping 23 matching lines...) Expand all Loading... |
55 MV_CLASS_6 = 6, /* (64, 128] integer pel */ | 54 MV_CLASS_6 = 6, /* (64, 128] integer pel */ |
56 MV_CLASS_7 = 7, /* (128, 256] integer pel */ | 55 MV_CLASS_7 = 7, /* (128, 256] integer pel */ |
57 MV_CLASS_8 = 8, /* (256, 512] integer pel */ | 56 MV_CLASS_8 = 8, /* (256, 512] integer pel */ |
58 MV_CLASS_9 = 9, /* (512, 1024] integer pel */ | 57 MV_CLASS_9 = 9, /* (512, 1024] integer pel */ |
59 MV_CLASS_10 = 10, /* (1024,2048] integer pel */ | 58 MV_CLASS_10 = 10, /* (1024,2048] integer pel */ |
60 } MV_CLASS_TYPE; | 59 } MV_CLASS_TYPE; |
61 | 60 |
62 #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ | 61 #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ |
63 #define CLASS0_SIZE (1 << CLASS0_BITS) | 62 #define CLASS0_SIZE (1 << CLASS0_BITS) |
64 #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) | 63 #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) |
| 64 #define MV_FP_SIZE 4 |
65 | 65 |
66 #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2) | 66 #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2) |
67 #define MV_MAX ((1 << MV_MAX_BITS) - 1) | 67 #define MV_MAX ((1 << MV_MAX_BITS) - 1) |
68 #define MV_VALS ((MV_MAX << 1) + 1) | 68 #define MV_VALS ((MV_MAX << 1) + 1) |
69 | 69 |
70 #define MV_IN_USE_BITS 14 | 70 #define MV_IN_USE_BITS 14 |
71 #define MV_UPP ((1 << MV_IN_USE_BITS) - 1) | 71 #define MV_UPP ((1 << MV_IN_USE_BITS) - 1) |
72 #define MV_LOW (-(1 << MV_IN_USE_BITS)) | 72 #define MV_LOW (-(1 << MV_IN_USE_BITS)) |
73 | 73 |
74 extern const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)]; | 74 extern const vp9_tree_index vp9_mv_joint_tree[]; |
75 extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; | 75 extern const vp9_tree_index vp9_mv_class_tree[]; |
76 | 76 extern const vp9_tree_index vp9_mv_class0_tree[]; |
77 extern const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)]; | 77 extern const vp9_tree_index vp9_mv_fp_tree[]; |
78 extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; | |
79 | |
80 extern const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)]; | |
81 extern struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE]; | |
82 | |
83 extern const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(4)]; | |
84 extern struct vp9_token vp9_mv_fp_encodings[4]; | |
85 | 78 |
86 typedef struct { | 79 typedef struct { |
87 vp9_prob sign; | 80 vp9_prob sign; |
88 vp9_prob classes[MV_CLASSES - 1]; | 81 vp9_prob classes[MV_CLASSES - 1]; |
89 vp9_prob class0[CLASS0_SIZE - 1]; | 82 vp9_prob class0[CLASS0_SIZE - 1]; |
90 vp9_prob bits[MV_OFFSET_BITS]; | 83 vp9_prob bits[MV_OFFSET_BITS]; |
91 vp9_prob class0_fp[CLASS0_SIZE][4 - 1]; | 84 vp9_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1]; |
92 vp9_prob fp[4 - 1]; | 85 vp9_prob fp[MV_FP_SIZE - 1]; |
93 vp9_prob class0_hp; | 86 vp9_prob class0_hp; |
94 vp9_prob hp; | 87 vp9_prob hp; |
95 } nmv_component; | 88 } nmv_component; |
96 | 89 |
97 typedef struct { | 90 typedef struct { |
98 vp9_prob joints[MV_JOINTS - 1]; | 91 vp9_prob joints[MV_JOINTS - 1]; |
99 nmv_component comps[2]; | 92 nmv_component comps[2]; |
100 } nmv_context; | 93 } nmv_context; |
101 | 94 |
102 static INLINE MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv) { | 95 static INLINE MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv) { |
103 if (mv->row == 0) { | 96 if (mv->row == 0) { |
104 return mv->col == 0 ? MV_JOINT_ZERO : MV_JOINT_HNZVZ; | 97 return mv->col == 0 ? MV_JOINT_ZERO : MV_JOINT_HNZVZ; |
105 } else { | 98 } else { |
106 return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ; | 99 return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ; |
107 } | 100 } |
108 } | 101 } |
109 | 102 |
110 MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset); | 103 MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset); |
111 int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset); | 104 int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset); |
112 | 105 |
113 | 106 |
114 typedef struct { | 107 typedef struct { |
115 unsigned int sign[2]; | 108 unsigned int sign[2]; |
116 unsigned int classes[MV_CLASSES]; | 109 unsigned int classes[MV_CLASSES]; |
117 unsigned int class0[CLASS0_SIZE]; | 110 unsigned int class0[CLASS0_SIZE]; |
118 unsigned int bits[MV_OFFSET_BITS][2]; | 111 unsigned int bits[MV_OFFSET_BITS][2]; |
119 unsigned int class0_fp[CLASS0_SIZE][4]; | 112 unsigned int class0_fp[CLASS0_SIZE][MV_FP_SIZE]; |
120 unsigned int fp[4]; | 113 unsigned int fp[MV_FP_SIZE]; |
121 unsigned int class0_hp[2]; | 114 unsigned int class0_hp[2]; |
122 unsigned int hp[2]; | 115 unsigned int hp[2]; |
123 } nmv_component_counts; | 116 } nmv_component_counts; |
124 | 117 |
125 typedef struct { | 118 typedef struct { |
126 unsigned int joints[MV_JOINTS]; | 119 unsigned int joints[MV_JOINTS]; |
127 nmv_component_counts comps[2]; | 120 nmv_component_counts comps[2]; |
128 } nmv_context_counts; | 121 } nmv_context_counts; |
129 | 122 |
130 void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx); | 123 void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx); |
131 | 124 |
132 #endif // VP9_COMMON_VP9_ENTROPYMV_H_ | 125 #endif // VP9_COMMON_VP9_ENTROPYMV_H_ |
OLD | NEW |