| 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(); | 21 void vp9_entropy_mv_init(); |
| 22 void vp9_init_mv_probs(struct VP9Common *cm); | 22 void vp9_init_mv_probs(struct VP9Common *cm); |
| 23 | 23 |
| 24 void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp); | 24 void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp); |
| 25 int vp9_use_mv_hp(const MV *ref); | 25 int vp9_use_mv_hp(const MV *ref); |
| 26 | 26 |
| 27 #define NMV_UPDATE_PROB 252 | 27 #define NMV_UPDATE_PROB 252 |
| 28 | 28 |
| 29 /* Symbols for coding which components are zero jointly */ | 29 /* Symbols for coding which components are zero jointly */ |
| 30 #define MV_JOINTS 4 | 30 #define MV_JOINTS 4 |
| 31 typedef enum { | 31 typedef enum { |
| 32 MV_JOINT_ZERO = 0, /* Zero vector */ | 32 MV_JOINT_ZERO = 0, /* Zero vector */ |
| 33 MV_JOINT_HNZVZ = 1, /* Vert zero, hor nonzero */ | 33 MV_JOINT_HNZVZ = 1, /* Vert zero, hor nonzero */ |
| 34 MV_JOINT_HZVNZ = 2, /* Hor zero, vert nonzero */ | 34 MV_JOINT_HZVNZ = 2, /* Hor zero, vert nonzero */ |
| 35 MV_JOINT_HNZVNZ = 3, /* Both components nonzero */ | 35 MV_JOINT_HNZVNZ = 3, /* Both components nonzero */ |
| 36 } MV_JOINT_TYPE; | 36 } MV_JOINT_TYPE; |
| 37 | 37 |
| 38 static INLINE int mv_joint_vertical(MV_JOINT_TYPE type) { | 38 static INLINE int mv_joint_vertical(MV_JOINT_TYPE type) { |
| 39 return type == MV_JOINT_HZVNZ || type == MV_JOINT_HNZVNZ; | 39 return type == MV_JOINT_HZVNZ || type == MV_JOINT_HNZVNZ; |
| 40 } | 40 } |
| 41 | 41 |
| 42 static INLINE int mv_joint_horizontal(MV_JOINT_TYPE type) { | 42 static INLINE int mv_joint_horizontal(MV_JOINT_TYPE type) { |
| 43 return type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ; | 43 return type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ; |
| 44 } | 44 } |
| 45 | 45 |
| 46 extern const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2]; | |
| 47 extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; | |
| 48 | |
| 49 /* Symbols for coding magnitude class of nonzero components */ | 46 /* Symbols for coding magnitude class of nonzero components */ |
| 50 #define MV_CLASSES 11 | 47 #define MV_CLASSES 11 |
| 51 typedef enum { | 48 typedef enum { |
| 52 MV_CLASS_0 = 0, /* (0, 2] integer pel */ | 49 MV_CLASS_0 = 0, /* (0, 2] integer pel */ |
| 53 MV_CLASS_1 = 1, /* (2, 4] integer pel */ | 50 MV_CLASS_1 = 1, /* (2, 4] integer pel */ |
| 54 MV_CLASS_2 = 2, /* (4, 8] integer pel */ | 51 MV_CLASS_2 = 2, /* (4, 8] integer pel */ |
| 55 MV_CLASS_3 = 3, /* (8, 16] integer pel */ | 52 MV_CLASS_3 = 3, /* (8, 16] integer pel */ |
| 56 MV_CLASS_4 = 4, /* (16, 32] integer pel */ | 53 MV_CLASS_4 = 4, /* (16, 32] integer pel */ |
| 57 MV_CLASS_5 = 5, /* (32, 64] integer pel */ | 54 MV_CLASS_5 = 5, /* (32, 64] integer pel */ |
| 58 MV_CLASS_6 = 6, /* (64, 128] integer pel */ | 55 MV_CLASS_6 = 6, /* (64, 128] integer pel */ |
| 59 MV_CLASS_7 = 7, /* (128, 256] integer pel */ | 56 MV_CLASS_7 = 7, /* (128, 256] integer pel */ |
| 60 MV_CLASS_8 = 8, /* (256, 512] integer pel */ | 57 MV_CLASS_8 = 8, /* (256, 512] integer pel */ |
| 61 MV_CLASS_9 = 9, /* (512, 1024] integer pel */ | 58 MV_CLASS_9 = 9, /* (512, 1024] integer pel */ |
| 62 MV_CLASS_10 = 10, /* (1024,2048] integer pel */ | 59 MV_CLASS_10 = 10, /* (1024,2048] integer pel */ |
| 63 } MV_CLASS_TYPE; | 60 } MV_CLASS_TYPE; |
| 64 | 61 |
| 65 extern const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2]; | |
| 66 extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; | |
| 67 | |
| 68 #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ | 62 #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ |
| 69 #define CLASS0_SIZE (1 << CLASS0_BITS) | 63 #define CLASS0_SIZE (1 << CLASS0_BITS) |
| 70 #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) | 64 #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) |
| 71 | 65 |
| 72 #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2) | 66 #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2) |
| 73 #define MV_MAX ((1 << MV_MAX_BITS) - 1) | 67 #define MV_MAX ((1 << MV_MAX_BITS) - 1) |
| 74 #define MV_VALS ((MV_MAX << 1) + 1) | 68 #define MV_VALS ((MV_MAX << 1) + 1) |
| 75 | 69 |
| 76 #define MV_IN_USE_BITS 14 | 70 #define MV_IN_USE_BITS 14 |
| 77 #define MV_UPP ((1 << MV_IN_USE_BITS) - 1) | 71 #define MV_UPP ((1 << MV_IN_USE_BITS) - 1) |
| 78 #define MV_LOW (-(1 << MV_IN_USE_BITS)) | 72 #define MV_LOW (-(1 << MV_IN_USE_BITS)) |
| 79 | 73 |
| 80 extern const vp9_tree_index vp9_mv_class0_tree[2 * CLASS0_SIZE - 2]; | 74 extern const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)]; |
| 75 extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; |
| 76 |
| 77 extern const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)]; |
| 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]; | 81 extern struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE]; |
| 82 | 82 |
| 83 extern const vp9_tree_index vp9_mv_fp_tree[2 * 4 - 2]; | 83 extern const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(4)]; |
| 84 extern struct vp9_token vp9_mv_fp_encodings[4]; | 84 extern struct vp9_token vp9_mv_fp_encodings[4]; |
| 85 | 85 |
| 86 typedef struct { | 86 typedef struct { |
| 87 vp9_prob sign; | 87 vp9_prob sign; |
| 88 vp9_prob classes[MV_CLASSES - 1]; | 88 vp9_prob classes[MV_CLASSES - 1]; |
| 89 vp9_prob class0[CLASS0_SIZE - 1]; | 89 vp9_prob class0[CLASS0_SIZE - 1]; |
| 90 vp9_prob bits[MV_OFFSET_BITS]; | 90 vp9_prob bits[MV_OFFSET_BITS]; |
| 91 vp9_prob class0_fp[CLASS0_SIZE][4 - 1]; | 91 vp9_prob class0_fp[CLASS0_SIZE][4 - 1]; |
| 92 vp9_prob fp[4 - 1]; | 92 vp9_prob fp[4 - 1]; |
| 93 vp9_prob class0_hp; | 93 vp9_prob class0_hp; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 105 } else { | 105 } else { |
| 106 return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ; | 106 return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset); | 110 MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset); |
| 111 int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset); | 111 int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset); |
| 112 | 112 |
| 113 | 113 |
| 114 typedef struct { | 114 typedef struct { |
| 115 unsigned int mvcount[MV_VALS]; | |
| 116 unsigned int sign[2]; | 115 unsigned int sign[2]; |
| 117 unsigned int classes[MV_CLASSES]; | 116 unsigned int classes[MV_CLASSES]; |
| 118 unsigned int class0[CLASS0_SIZE]; | 117 unsigned int class0[CLASS0_SIZE]; |
| 119 unsigned int bits[MV_OFFSET_BITS][2]; | 118 unsigned int bits[MV_OFFSET_BITS][2]; |
| 120 unsigned int class0_fp[CLASS0_SIZE][4]; | 119 unsigned int class0_fp[CLASS0_SIZE][4]; |
| 121 unsigned int fp[4]; | 120 unsigned int fp[4]; |
| 122 unsigned int class0_hp[2]; | 121 unsigned int class0_hp[2]; |
| 123 unsigned int hp[2]; | 122 unsigned int hp[2]; |
| 124 } nmv_component_counts; | 123 } nmv_component_counts; |
| 125 | 124 |
| 126 typedef struct { | 125 typedef struct { |
| 127 unsigned int joints[MV_JOINTS]; | 126 unsigned int joints[MV_JOINTS]; |
| 128 nmv_component_counts comps[2]; | 127 nmv_component_counts comps[2]; |
| 129 } nmv_context_counts; | 128 } nmv_context_counts; |
| 130 | 129 |
| 131 void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx); | 130 void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx); |
| 132 | 131 |
| 133 #endif // VP9_COMMON_VP9_ENTROPYMV_H_ | 132 #endif // VP9_COMMON_VP9_ENTROPYMV_H_ |
| OLD | NEW |