2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-11-30 01:36:10 +01:00
|
|
|
#ifndef VP9_COMMON_VP9_ENTROPYMV_H_
|
|
|
|
#define VP9_COMMON_VP9_ENTROPYMV_H_
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_treecoder.h"
|
2012-02-16 18:29:54 +01:00
|
|
|
#include "vpx_config.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_blockd.h"
|
2012-02-16 18:29:54 +01:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
struct VP9Common;
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_entropy_mv_init();
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_init_mv_probs(struct VP9Common *cm);
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2013-06-19 03:28:10 +02:00
|
|
|
void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp);
|
|
|
|
int vp9_use_mv_hp(const MV *ref);
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2013-06-10 21:00:43 +02:00
|
|
|
#define VP9_NMV_UPDATE_PROB 252
|
2012-07-26 22:42:07 +02:00
|
|
|
#define LOW_PRECISION_MV_UPDATE /* Use 7 bit forward update */
|
|
|
|
|
|
|
|
/* Symbols for coding which components are zero jointly */
|
|
|
|
#define MV_JOINTS 4
|
|
|
|
typedef enum {
|
|
|
|
MV_JOINT_ZERO = 0, /* Zero vector */
|
|
|
|
MV_JOINT_HNZVZ = 1, /* Vert zero, hor nonzero */
|
|
|
|
MV_JOINT_HZVNZ = 2, /* Hor zero, vert nonzero */
|
|
|
|
MV_JOINT_HNZVNZ = 3, /* Both components nonzero */
|
|
|
|
} MV_JOINT_TYPE;
|
|
|
|
|
2013-04-15 21:07:26 +02:00
|
|
|
static INLINE int mv_joint_vertical(MV_JOINT_TYPE type) {
|
|
|
|
return type == MV_JOINT_HZVNZ || type == MV_JOINT_HNZVNZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE int mv_joint_horizontal(MV_JOINT_TYPE type) {
|
|
|
|
return type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ;
|
|
|
|
}
|
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
extern const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2];
|
2013-04-11 22:01:52 +02:00
|
|
|
extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
|
|
|
/* Symbols for coding magnitude class of nonzero components */
|
2013-03-12 05:51:00 +01:00
|
|
|
#define MV_CLASSES 11
|
2012-07-26 22:42:07 +02:00
|
|
|
typedef enum {
|
|
|
|
MV_CLASS_0 = 0, /* (0, 2] integer pel */
|
|
|
|
MV_CLASS_1 = 1, /* (2, 4] integer pel */
|
|
|
|
MV_CLASS_2 = 2, /* (4, 8] integer pel */
|
|
|
|
MV_CLASS_3 = 3, /* (8, 16] integer pel */
|
|
|
|
MV_CLASS_4 = 4, /* (16, 32] integer pel */
|
|
|
|
MV_CLASS_5 = 5, /* (32, 64] integer pel */
|
|
|
|
MV_CLASS_6 = 6, /* (64, 128] integer pel */
|
|
|
|
MV_CLASS_7 = 7, /* (128, 256] integer pel */
|
2013-03-06 21:02:15 +01:00
|
|
|
MV_CLASS_8 = 8, /* (256, 512] integer pel */
|
|
|
|
MV_CLASS_9 = 9, /* (512, 1024] integer pel */
|
2013-03-12 05:51:00 +01:00
|
|
|
MV_CLASS_10 = 10, /* (1024,2048] integer pel */
|
2012-07-26 22:42:07 +02:00
|
|
|
} MV_CLASS_TYPE;
|
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
extern const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2];
|
2013-04-11 22:01:52 +02:00
|
|
|
extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
|
|
|
#define CLASS0_BITS 1 /* bits at integer precision for class 0 */
|
|
|
|
#define CLASS0_SIZE (1 << CLASS0_BITS)
|
|
|
|
#define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2)
|
|
|
|
|
|
|
|
#define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2)
|
|
|
|
#define MV_MAX ((1 << MV_MAX_BITS) - 1)
|
|
|
|
#define MV_VALS ((MV_MAX << 1) + 1)
|
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
extern const vp9_tree_index vp9_mv_class0_tree[2 * CLASS0_SIZE - 2];
|
2013-04-11 22:01:52 +02:00
|
|
|
extern struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
extern const vp9_tree_index vp9_mv_fp_tree[2 * 4 - 2];
|
2013-04-11 22:01:52 +02:00
|
|
|
extern struct vp9_token vp9_mv_fp_encodings[4];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2012-10-31 22:40:53 +01:00
|
|
|
vp9_prob sign;
|
|
|
|
vp9_prob classes[MV_CLASSES - 1];
|
|
|
|
vp9_prob class0[CLASS0_SIZE - 1];
|
|
|
|
vp9_prob bits[MV_OFFSET_BITS];
|
|
|
|
vp9_prob class0_fp[CLASS0_SIZE][4 - 1];
|
|
|
|
vp9_prob fp[4 - 1];
|
|
|
|
vp9_prob class0_hp;
|
|
|
|
vp9_prob hp;
|
2012-07-26 22:42:07 +02:00
|
|
|
} nmv_component;
|
|
|
|
|
|
|
|
typedef struct {
|
2012-10-31 22:40:53 +01:00
|
|
|
vp9_prob joints[MV_JOINTS - 1];
|
2012-07-26 22:42:07 +02:00
|
|
|
nmv_component comps[2];
|
|
|
|
} nmv_context;
|
|
|
|
|
2013-07-03 21:04:30 +02:00
|
|
|
static INLINE MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv) {
|
|
|
|
if (mv->row == 0) {
|
|
|
|
return mv->col == 0 ? MV_JOINT_ZERO : MV_JOINT_HNZVZ;
|
|
|
|
} else {
|
|
|
|
return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset);
|
|
|
|
int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset);
|
2012-07-26 22:42:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int mvcount[MV_VALS];
|
|
|
|
unsigned int sign[2];
|
|
|
|
unsigned int classes[MV_CLASSES];
|
|
|
|
unsigned int class0[CLASS0_SIZE];
|
|
|
|
unsigned int bits[MV_OFFSET_BITS][2];
|
|
|
|
unsigned int class0_fp[CLASS0_SIZE][4];
|
|
|
|
unsigned int fp[4];
|
|
|
|
unsigned int class0_hp[2];
|
|
|
|
unsigned int hp[2];
|
|
|
|
} nmv_component_counts;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int joints[MV_JOINTS];
|
|
|
|
nmv_component_counts comps[2];
|
|
|
|
} nmv_context_counts;
|
|
|
|
|
2013-07-17 02:01:08 +02:00
|
|
|
void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx);
|
2013-06-25 00:58:18 +02:00
|
|
|
|
2012-11-09 19:52:08 +01:00
|
|
|
void vp9_counts_process(nmv_context_counts *NMVcount, int usehp);
|
2012-12-19 00:31:19 +01:00
|
|
|
|
|
|
|
#endif // VP9_COMMON_VP9_ENTROPYMV_H_
|