OLD | NEW |
(Empty) | |
| 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 |
| 12 #ifndef VP9_COMMON_VP9_ENTROPYMV_H_ |
| 13 #define VP9_COMMON_VP9_ENTROPYMV_H_ |
| 14 |
| 15 #include "vp9/common/vp9_treecoder.h" |
| 16 #include "vpx_config.h" |
| 17 #include "vp9/common/vp9_blockd.h" |
| 18 |
| 19 struct VP9Common; |
| 20 |
| 21 void vp9_entropy_mv_init(); |
| 22 void vp9_init_mv_probs(struct VP9Common *cm); |
| 23 |
| 24 void vp9_adapt_nmv_probs(struct VP9Common *cm, int usehp); |
| 25 int vp9_use_nmv_hp(const MV *ref); |
| 26 |
| 27 #define VP9_NMV_UPDATE_PROB 255 |
| 28 //#define MV_GROUP_UPDATE |
| 29 |
| 30 #define LOW_PRECISION_MV_UPDATE /* Use 7 bit forward update */ |
| 31 |
| 32 /* Symbols for coding which components are zero jointly */ |
| 33 #define MV_JOINTS 4 |
| 34 typedef enum { |
| 35 MV_JOINT_ZERO = 0, /* Zero vector */ |
| 36 MV_JOINT_HNZVZ = 1, /* Vert zero, hor nonzero */ |
| 37 MV_JOINT_HZVNZ = 2, /* Hor zero, vert nonzero */ |
| 38 MV_JOINT_HNZVNZ = 3, /* Both components nonzero */ |
| 39 } MV_JOINT_TYPE; |
| 40 |
| 41 extern const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2]; |
| 42 extern struct vp9_token_struct vp9_mv_joint_encodings [MV_JOINTS]; |
| 43 |
| 44 /* Symbols for coding magnitude class of nonzero components */ |
| 45 #define MV_CLASSES 8 |
| 46 typedef enum { |
| 47 MV_CLASS_0 = 0, /* (0, 2] integer pel */ |
| 48 MV_CLASS_1 = 1, /* (2, 4] integer pel */ |
| 49 MV_CLASS_2 = 2, /* (4, 8] integer pel */ |
| 50 MV_CLASS_3 = 3, /* (8, 16] integer pel */ |
| 51 MV_CLASS_4 = 4, /* (16, 32] integer pel */ |
| 52 MV_CLASS_5 = 5, /* (32, 64] integer pel */ |
| 53 MV_CLASS_6 = 6, /* (64, 128] integer pel */ |
| 54 MV_CLASS_7 = 7, /* (128, 256] integer pel */ |
| 55 } MV_CLASS_TYPE; |
| 56 |
| 57 extern const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2]; |
| 58 extern struct vp9_token_struct vp9_mv_class_encodings [MV_CLASSES]; |
| 59 |
| 60 #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ |
| 61 #define CLASS0_SIZE (1 << CLASS0_BITS) |
| 62 #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) |
| 63 |
| 64 #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2) |
| 65 #define MV_MAX ((1 << MV_MAX_BITS) - 1) |
| 66 #define MV_VALS ((MV_MAX << 1) + 1) |
| 67 |
| 68 extern const vp9_tree_index vp9_mv_class0_tree[2 * CLASS0_SIZE - 2]; |
| 69 extern struct vp9_token_struct vp9_mv_class0_encodings[CLASS0_SIZE]; |
| 70 |
| 71 extern const vp9_tree_index vp9_mv_fp_tree[2 * 4 - 2]; |
| 72 extern struct vp9_token_struct vp9_mv_fp_encodings[4]; |
| 73 |
| 74 typedef struct { |
| 75 vp9_prob sign; |
| 76 vp9_prob classes[MV_CLASSES - 1]; |
| 77 vp9_prob class0[CLASS0_SIZE - 1]; |
| 78 vp9_prob bits[MV_OFFSET_BITS]; |
| 79 vp9_prob class0_fp[CLASS0_SIZE][4 - 1]; |
| 80 vp9_prob fp[4 - 1]; |
| 81 vp9_prob class0_hp; |
| 82 vp9_prob hp; |
| 83 } nmv_component; |
| 84 |
| 85 typedef struct { |
| 86 vp9_prob joints[MV_JOINTS - 1]; |
| 87 nmv_component comps[2]; |
| 88 } nmv_context; |
| 89 |
| 90 MV_JOINT_TYPE vp9_get_mv_joint(MV mv); |
| 91 MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset); |
| 92 int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset); |
| 93 |
| 94 |
| 95 typedef struct { |
| 96 unsigned int mvcount[MV_VALS]; |
| 97 unsigned int sign[2]; |
| 98 unsigned int classes[MV_CLASSES]; |
| 99 unsigned int class0[CLASS0_SIZE]; |
| 100 unsigned int bits[MV_OFFSET_BITS][2]; |
| 101 unsigned int class0_fp[CLASS0_SIZE][4]; |
| 102 unsigned int fp[4]; |
| 103 unsigned int class0_hp[2]; |
| 104 unsigned int hp[2]; |
| 105 } nmv_component_counts; |
| 106 |
| 107 typedef struct { |
| 108 unsigned int joints[MV_JOINTS]; |
| 109 nmv_component_counts comps[2]; |
| 110 } nmv_context_counts; |
| 111 |
| 112 void vp9_increment_nmv(const MV *mv, const MV *ref, nmv_context_counts *mvctx, |
| 113 int usehp); |
| 114 extern const nmv_context vp9_default_nmv_context; |
| 115 void vp9_counts_to_nmv_context( |
| 116 nmv_context_counts *NMVcount, |
| 117 nmv_context *prob, |
| 118 int usehp, |
| 119 unsigned int (*branch_ct_joint)[2], |
| 120 unsigned int (*branch_ct_sign)[2], |
| 121 unsigned int (*branch_ct_classes)[MV_CLASSES - 1][2], |
| 122 unsigned int (*branch_ct_class0)[CLASS0_SIZE - 1][2], |
| 123 unsigned int (*branch_ct_bits)[MV_OFFSET_BITS][2], |
| 124 unsigned int (*branch_ct_class0_fp)[CLASS0_SIZE][4 - 1][2], |
| 125 unsigned int (*branch_ct_fp)[4 - 1][2], |
| 126 unsigned int (*branch_ct_class0_hp)[2], |
| 127 unsigned int (*branch_ct_hp)[2]); |
| 128 void vp9_counts_process(nmv_context_counts *NMVcount, int usehp); |
| 129 #endif |
OLD | NEW |