michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #define USE_PREBUILT_TABLES michael@0: michael@0: #include "entropymode.h" michael@0: #include "entropy.h" michael@0: #include "vpx_mem/vpx_mem.h" michael@0: michael@0: #include "vp8_entropymodedata.h" michael@0: michael@0: int vp8_mv_cont(const int_mv *l, const int_mv *a) michael@0: { michael@0: int lez = (l->as_int == 0); michael@0: int aez = (a->as_int == 0); michael@0: int lea = (l->as_int == a->as_int); michael@0: michael@0: if (lea && lez) michael@0: return SUBMVREF_LEFT_ABOVE_ZED; michael@0: michael@0: if (lea) michael@0: return SUBMVREF_LEFT_ABOVE_SAME; michael@0: michael@0: if (aez) michael@0: return SUBMVREF_ABOVE_ZED; michael@0: michael@0: if (lez) michael@0: return SUBMVREF_LEFT_ZED; michael@0: michael@0: return SUBMVREF_NORMAL; michael@0: } michael@0: michael@0: static const vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25}; michael@0: michael@0: const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] = michael@0: { michael@0: { 147, 136, 18 }, michael@0: { 106, 145, 1 }, michael@0: { 179, 121, 1 }, michael@0: { 223, 1 , 34 }, michael@0: { 208, 1 , 1 } michael@0: }; michael@0: michael@0: michael@0: michael@0: const vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] = michael@0: { michael@0: { michael@0: 0, 0, 0, 0, michael@0: 0, 0, 0, 0, michael@0: 1, 1, 1, 1, michael@0: 1, 1, 1, 1, michael@0: }, michael@0: { michael@0: 0, 0, 1, 1, michael@0: 0, 0, 1, 1, michael@0: 0, 0, 1, 1, michael@0: 0, 0, 1, 1, michael@0: }, michael@0: { michael@0: 0, 0, 1, 1, michael@0: 0, 0, 1, 1, michael@0: 2, 2, 3, 3, michael@0: 2, 2, 3, 3, michael@0: }, michael@0: { michael@0: 0, 1, 2, 3, michael@0: 4, 5, 6, 7, michael@0: 8, 9, 10, 11, michael@0: 12, 13, 14, 15, michael@0: } michael@0: }; michael@0: michael@0: const int vp8_mbsplit_count [VP8_NUMMBSPLITS] = { 2, 2, 4, 16}; michael@0: michael@0: const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150}; michael@0: michael@0: michael@0: /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ michael@0: michael@0: const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */ michael@0: { michael@0: -B_DC_PRED, 2, /* 0 = DC_NODE */ michael@0: -B_TM_PRED, 4, /* 1 = TM_NODE */ michael@0: -B_VE_PRED, 6, /* 2 = VE_NODE */ michael@0: 8, 12, /* 3 = COM_NODE */ michael@0: -B_HE_PRED, 10, /* 4 = HE_NODE */ michael@0: -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */ michael@0: -B_LD_PRED, 14, /* 6 = LD_NODE */ michael@0: -B_VL_PRED, 16, /* 7 = VL_NODE */ michael@0: -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */ michael@0: }; michael@0: michael@0: /* Again, these trees use the same probability indices as their michael@0: explicitly-programmed predecessors. */ michael@0: michael@0: const vp8_tree_index vp8_ymode_tree[8] = michael@0: { michael@0: -DC_PRED, 2, michael@0: 4, 6, michael@0: -V_PRED, -H_PRED, michael@0: -TM_PRED, -B_PRED michael@0: }; michael@0: michael@0: const vp8_tree_index vp8_kf_ymode_tree[8] = michael@0: { michael@0: -B_PRED, 2, michael@0: 4, 6, michael@0: -DC_PRED, -V_PRED, michael@0: -H_PRED, -TM_PRED michael@0: }; michael@0: michael@0: const vp8_tree_index vp8_uv_mode_tree[6] = michael@0: { michael@0: -DC_PRED, 2, michael@0: -V_PRED, 4, michael@0: -H_PRED, -TM_PRED michael@0: }; michael@0: michael@0: const vp8_tree_index vp8_mbsplit_tree[6] = michael@0: { michael@0: -3, 2, michael@0: -2, 4, michael@0: -0, -1 michael@0: }; michael@0: michael@0: const vp8_tree_index vp8_mv_ref_tree[8] = michael@0: { michael@0: -ZEROMV, 2, michael@0: -NEARESTMV, 4, michael@0: -NEARMV, 6, michael@0: -NEWMV, -SPLITMV michael@0: }; michael@0: michael@0: const vp8_tree_index vp8_sub_mv_ref_tree[6] = michael@0: { michael@0: -LEFT4X4, 2, michael@0: -ABOVE4X4, 4, michael@0: -ZERO4X4, -NEW4X4 michael@0: }; michael@0: michael@0: const vp8_tree_index vp8_small_mvtree [14] = michael@0: { michael@0: 2, 8, michael@0: 4, 6, michael@0: -0, -1, michael@0: -2, -3, michael@0: 10, 12, michael@0: -4, -5, michael@0: -6, -7 michael@0: }; michael@0: michael@0: void vp8_init_mbmode_probs(VP8_COMMON *x) michael@0: { michael@0: vpx_memcpy(x->fc.ymode_prob, vp8_ymode_prob, sizeof(vp8_ymode_prob)); michael@0: vpx_memcpy(x->fc.uv_mode_prob, vp8_uv_mode_prob, sizeof(vp8_uv_mode_prob)); michael@0: vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob)); michael@0: } michael@0: michael@0: void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1]) michael@0: { michael@0: vpx_memcpy(p, vp8_bmode_prob, sizeof(vp8_bmode_prob)); michael@0: } michael@0: