| /* |
| * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
| * |
| * This source code is subject to the terms of the BSD 2 Clause License and |
| * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| * was not distributed with this source code in the LICENSE file, you can |
| * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| * Media Patent License 1.0 was not distributed with this source code in the |
| * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
| */ |
| |
| #include "av1/common/onyxc_int.h" |
| #include "av1/common/entropymv.h" |
| |
| static const nmv_context default_nmv_context = { |
| { AOM_CDF4(4096, 11264, 19328) }, // joints_cdf |
| { { |
| // Vertical component |
| { AOM_CDF11(28672, 30976, 31858, 32320, 32551, 32656, 32740, 32757, |
| 32762, 32767) }, // class_cdf // fp |
| { { AOM_CDF4(16384, 24576, 26624) }, |
| { AOM_CDF4(12288, 21248, 24128) } }, // class0_fp_cdf |
| { AOM_CDF4(8192, 17408, 21248) }, // fp_cdf |
| { AOM_CDF2(128 * 128) }, // sign_cdf |
| { AOM_CDF2(160 * 128) }, // class0_hp_cdf |
| { AOM_CDF2(128 * 128) }, // hp_cdf |
| { AOM_CDF2(216 * 128) }, // class0_cdf |
| { { AOM_CDF2(128 * 136) }, |
| { AOM_CDF2(128 * 140) }, |
| { AOM_CDF2(128 * 148) }, |
| { AOM_CDF2(128 * 160) }, |
| { AOM_CDF2(128 * 176) }, |
| { AOM_CDF2(128 * 192) }, |
| { AOM_CDF2(128 * 224) }, |
| { AOM_CDF2(128 * 234) }, |
| { AOM_CDF2(128 * 234) }, |
| { AOM_CDF2(128 * 240) } }, // bits_cdf |
| }, |
| { |
| // Horizontal component |
| { AOM_CDF11(28672, 30976, 31858, 32320, 32551, 32656, 32740, 32757, |
| 32762, 32767) }, // class_cdf // fp |
| { { AOM_CDF4(16384, 24576, 26624) }, |
| { AOM_CDF4(12288, 21248, 24128) } }, // class0_fp_cdf |
| { AOM_CDF4(8192, 17408, 21248) }, // fp_cdf |
| { AOM_CDF2(128 * 128) }, // sign_cdf |
| { AOM_CDF2(160 * 128) }, // class0_hp_cdf |
| { AOM_CDF2(128 * 128) }, // hp_cdf |
| { AOM_CDF2(216 * 128) }, // class0_cdf |
| { { AOM_CDF2(128 * 136) }, |
| { AOM_CDF2(128 * 140) }, |
| { AOM_CDF2(128 * 148) }, |
| { AOM_CDF2(128 * 160) }, |
| { AOM_CDF2(128 * 176) }, |
| { AOM_CDF2(128 * 192) }, |
| { AOM_CDF2(128 * 224) }, |
| { AOM_CDF2(128 * 234) }, |
| { AOM_CDF2(128 * 234) }, |
| { AOM_CDF2(128 * 240) } }, // bits_cdf |
| } }, |
| }; |
| |
| static const uint8_t log_in_base_2[] = { |
| 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, |
| 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, |
| 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, |
| 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, |
| 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, |
| 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 7, 7, 7, 7, 7, 7, 7,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, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
| 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
| 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
| 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
| 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
| 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
| 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10 |
| }; |
| |
| static INLINE int mv_class_base(MV_CLASS_TYPE c) { |
| return c ? CLASS0_SIZE << (c + 2) : 0; |
| } |
| |
| MV_CLASS_TYPE av1_get_mv_class(int z, int *offset) { |
| const MV_CLASS_TYPE c = (z >= CLASS0_SIZE * 4096) |
| ? MV_CLASS_10 |
| : (MV_CLASS_TYPE)log_in_base_2[z >> 3]; |
| if (offset) *offset = z - mv_class_base(c); |
| return c; |
| } |
| |
| void av1_init_mv_probs(AV1_COMMON *cm) { |
| // NB: this sets CDFs too |
| cm->fc->nmvc = default_nmv_context; |
| cm->fc->ndvc = default_nmv_context; |
| } |