blob: cddc80768c09a7e1457ea82489b4046541c8c93c [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AV1_COMMON_ENTROPYMV_H_
13#define AOM_AV1_COMMON_ENTROPYMV_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Tom Finegan60e653d2018-05-22 11:34:58 -070015#include "config/aom_config.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070016
17#include "aom_dsp/prob.h"
18
19#include "av1/common/mv.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
Yaowu Xuf883b422016-08-30 14:01:10 -070025struct AV1Common;
Yaowu Xuc27fc142016-08-22 16:08:15 -070026
Yaowu Xuf883b422016-08-30 14:01:10 -070027void av1_init_mv_probs(struct AV1Common *cm);
Yaowu Xuc27fc142016-08-22 16:08:15 -070028
Yaowu Xuc27fc142016-08-22 16:08:15 -070029#define MV_UPDATE_PROB 252
30
31/* Symbols for coding which components are zero jointly */
32#define MV_JOINTS 4
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053033enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070034 MV_JOINT_ZERO = 0, /* Zero vector */
35 MV_JOINT_HNZVZ = 1, /* Vert zero, hor nonzero */
36 MV_JOINT_HZVNZ = 2, /* Hor zero, vert nonzero */
37 MV_JOINT_HNZVNZ = 3, /* Both components nonzero */
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053038} UENUM1BYTE(MV_JOINT_TYPE);
Yaowu Xuc27fc142016-08-22 16:08:15 -070039
40static INLINE int mv_joint_vertical(MV_JOINT_TYPE type) {
41 return type == MV_JOINT_HZVNZ || type == MV_JOINT_HNZVNZ;
42}
43
44static INLINE int mv_joint_horizontal(MV_JOINT_TYPE type) {
45 return type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ;
46}
47
48/* Symbols for coding magnitude class of nonzero components */
Yunqing Wang63c0a9b2018-03-16 16:48:01 -070049#define MV_CLASSES 11
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053050enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070051 MV_CLASS_0 = 0, /* (0, 2] integer pel */
52 MV_CLASS_1 = 1, /* (2, 4] integer pel */
53 MV_CLASS_2 = 2, /* (4, 8] integer pel */
54 MV_CLASS_3 = 3, /* (8, 16] integer pel */
55 MV_CLASS_4 = 4, /* (16, 32] integer pel */
56 MV_CLASS_5 = 5, /* (32, 64] integer pel */
57 MV_CLASS_6 = 6, /* (64, 128] integer pel */
58 MV_CLASS_7 = 7, /* (128, 256] integer pel */
59 MV_CLASS_8 = 8, /* (256, 512] integer pel */
60 MV_CLASS_9 = 9, /* (512, 1024] integer pel */
61 MV_CLASS_10 = 10, /* (1024,2048] integer pel */
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053062} UENUM1BYTE(MV_CLASS_TYPE);
Yaowu Xuc27fc142016-08-22 16:08:15 -070063
64#define CLASS0_BITS 1 /* bits at integer precision for class 0 */
65#define CLASS0_SIZE (1 << CLASS0_BITS)
66#define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2)
Yunqing Wang63c0a9b2018-03-16 16:48:01 -070067#define MV_BITS_CONTEXTS 6
Yaowu Xuc27fc142016-08-22 16:08:15 -070068#define MV_FP_SIZE 4
69
70#define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2)
71#define MV_MAX ((1 << MV_MAX_BITS) - 1)
72#define MV_VALS ((MV_MAX << 1) + 1)
73
Yunqing Wangfb049a72018-03-16 16:45:16 -070074#define MV_IN_USE_BITS 14
David Barkerba140782018-06-14 13:17:51 +010075#define MV_UPP (1 << MV_IN_USE_BITS)
Yaowu Xuc27fc142016-08-22 16:08:15 -070076#define MV_LOW (-(1 << MV_IN_USE_BITS))
77
Yaowu Xuc27fc142016-08-22 16:08:15 -070078typedef struct {
Debargha Mukherjee62fcfab2017-11-09 00:51:17 -080079 aom_cdf_prob classes_cdf[CDF_SIZE(MV_CLASSES)];
Thomas Daviesf3eb8402017-02-20 18:20:20 +000080 aom_cdf_prob class0_fp_cdf[CLASS0_SIZE][CDF_SIZE(MV_FP_SIZE)];
81 aom_cdf_prob fp_cdf[CDF_SIZE(MV_FP_SIZE)];
Debargha Mukherjee62fcfab2017-11-09 00:51:17 -080082 aom_cdf_prob sign_cdf[CDF_SIZE(2)];
Thomas Davies599395e2017-07-21 18:02:48 +010083 aom_cdf_prob class0_hp_cdf[CDF_SIZE(2)];
84 aom_cdf_prob hp_cdf[CDF_SIZE(2)];
85 aom_cdf_prob class0_cdf[CDF_SIZE(CLASS0_SIZE)];
Debargha Mukherjee62fcfab2017-11-09 00:51:17 -080086 aom_cdf_prob bits_cdf[MV_OFFSET_BITS][CDF_SIZE(2)];
Yaowu Xuc27fc142016-08-22 16:08:15 -070087} nmv_component;
88
89typedef struct {
Debargha Mukherjee62fcfab2017-11-09 00:51:17 -080090 aom_cdf_prob joints_cdf[CDF_SIZE(MV_JOINTS)];
Yaowu Xuc27fc142016-08-22 16:08:15 -070091 nmv_component comps[2];
92} nmv_context;
93
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053094enum {
Alex Converse6b2584c2017-05-02 09:51:21 -070095 MV_SUBPEL_NONE = -1,
Alex Converse6b2584c2017-05-02 09:51:21 -070096 MV_SUBPEL_LOW_PRECISION = 0,
97 MV_SUBPEL_HIGH_PRECISION,
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053098} SENUM1BYTE(MvSubpelPrecision);
Alex Converse6b2584c2017-05-02 09:51:21 -070099
Yaowu Xuc27fc142016-08-22 16:08:15 -0700100#ifdef __cplusplus
101} // extern "C"
102#endif
103
James Zerne1cbb132018-08-22 14:10:36 -0700104#endif // AOM_AV1_COMMON_ENTROPYMV_H_