2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
17 #include "onyxc_int.h"
18 #include "vpx_mem/vpx_mem.h"
20 #define uchar unsigned char /* typedefs can clash */
21 #define uint unsigned int
23 typedef const uchar cuchar
;
24 typedef const uint cuint
;
26 typedef vp8_prob Prob
;
28 #include "coefupdateprobs.h"
30 DECLARE_ALIGNED(16, const unsigned char, vp8_norm
[256]) =
32 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
33 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
34 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
35 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
36 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
39 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
40 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
50 DECLARE_ALIGNED(16, cuchar
, vp8_coef_bands
[16]) =
51 { 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
53 DECLARE_ALIGNED(16, cuchar
, vp8_prev_token_class
[MAX_ENTROPY_TOKENS
]) =
54 { 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
56 DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d
[16]) =
64 DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag
[16]) =
72 DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask
[16]);
74 const int vp8_mb_feature_data_bits
[MB_LVL_MAX
] = {7, 6};
76 /* Array indices are identical to previously-existing CONTEXT_NODE indices */
78 const vp8_tree_index vp8_coef_tree
[ 22] = /* corresponding _CONTEXT_NODEs */
80 -DCT_EOB_TOKEN
, 2, /* 0 = EOB */
81 -ZERO_TOKEN
, 4, /* 1 = ZERO */
82 -ONE_TOKEN
, 6, /* 2 = ONE */
83 8, 12, /* 3 = LOW_VAL */
84 -TWO_TOKEN
, 10, /* 4 = TWO */
85 -THREE_TOKEN
, -FOUR_TOKEN
, /* 5 = THREE */
86 14, 16, /* 6 = HIGH_LOW */
87 -DCT_VAL_CATEGORY1
, -DCT_VAL_CATEGORY2
, /* 7 = CAT_ONE */
88 18, 20, /* 8 = CAT_THREEFOUR */
89 -DCT_VAL_CATEGORY3
, -DCT_VAL_CATEGORY4
, /* 9 = CAT_THREE */
90 -DCT_VAL_CATEGORY5
, -DCT_VAL_CATEGORY6
/* 10 = CAT_FIVE */
93 struct vp8_token_struct vp8_coef_encodings
[MAX_ENTROPY_TOKENS
];
95 /* Trees for extra bits. Probabilities are constant and
96 do not depend on previously encoded bits */
98 static const Prob Pcat1
[] = { 159};
99 static const Prob Pcat2
[] = { 165, 145};
100 static const Prob Pcat3
[] = { 173, 148, 140};
101 static const Prob Pcat4
[] = { 176, 155, 140, 135};
102 static const Prob Pcat5
[] = { 180, 157, 141, 134, 130};
103 static const Prob Pcat6
[] =
104 { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129};
106 static vp8_tree_index cat1
[2], cat2
[4], cat3
[6], cat4
[8], cat5
[10], cat6
[22];
108 void vp8_init_scan_order_mask()
112 for (i
= 0; i
< 16; i
++)
114 vp8_default_zig_zag_mask
[vp8_default_zig_zag1d
[i
]] = 1 << i
;
119 static void init_bit_tree(vp8_tree_index
*p
, int n
)
125 p
[0] = p
[1] = i
<< 1;
132 static void init_bit_trees()
134 init_bit_tree(cat1
, 1);
135 init_bit_tree(cat2
, 2);
136 init_bit_tree(cat3
, 3);
137 init_bit_tree(cat4
, 4);
138 init_bit_tree(cat5
, 5);
139 init_bit_tree(cat6
, 11);
142 vp8_extra_bit_struct vp8_extra_bits
[12] =
149 { cat1
, Pcat1
, 1, 5},
150 { cat2
, Pcat2
, 2, 7},
151 { cat3
, Pcat3
, 3, 11},
152 { cat4
, Pcat4
, 4, 19},
153 { cat5
, Pcat5
, 5, 35},
154 { cat6
, Pcat6
, 11, 67},
158 #include "default_coef_probs.h"
160 void vp8_default_coef_probs(VP8_COMMON
*pc
)
162 vpx_memcpy(pc
->fc
.coef_probs
, default_coef_probs
,
163 sizeof(default_coef_probs
));
166 void vp8_coef_tree_initialize()
169 vp8_tokens_from_tree(vp8_coef_encodings
, vp8_coef_tree
);