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"
19 #define uchar unsigned char /* typedefs can clash */
20 #define uint unsigned int
22 typedef const uchar cuchar
;
23 typedef const uint cuint
;
25 typedef vp8_prob Prob
;
27 #include "coefupdateprobs.h"
29 DECLARE_ALIGNED(16, cuchar
, vp8_coef_bands
[16]) = { 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
30 DECLARE_ALIGNED(16, cuchar
, vp8_prev_token_class
[MAX_ENTROPY_TOKENS
]) = { 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
31 DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d
[16]) =
39 DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask
[16]);
41 const int vp8_mb_feature_data_bits
[MB_LVL_MAX
] = {7, 6};
43 /* Array indices are identical to previously-existing CONTEXT_NODE indices */
45 const vp8_tree_index vp8_coef_tree
[ 22] = /* corresponding _CONTEXT_NODEs */
47 -DCT_EOB_TOKEN
, 2, /* 0 = EOB */
48 -ZERO_TOKEN
, 4, /* 1 = ZERO */
49 -ONE_TOKEN
, 6, /* 2 = ONE */
50 8, 12, /* 3 = LOW_VAL */
51 -TWO_TOKEN
, 10, /* 4 = TWO */
52 -THREE_TOKEN
, -FOUR_TOKEN
, /* 5 = THREE */
53 14, 16, /* 6 = HIGH_LOW */
54 -DCT_VAL_CATEGORY1
, -DCT_VAL_CATEGORY2
, /* 7 = CAT_ONE */
55 18, 20, /* 8 = CAT_THREEFOUR */
56 -DCT_VAL_CATEGORY3
, -DCT_VAL_CATEGORY4
, /* 9 = CAT_THREE */
57 -DCT_VAL_CATEGORY5
, -DCT_VAL_CATEGORY6
/* 10 = CAT_FIVE */
60 struct vp8_token_struct vp8_coef_encodings
[vp8_coef_tokens
];
62 /* Trees for extra bits. Probabilities are constant and
63 do not depend on previously encoded bits */
65 static const Prob Pcat1
[] = { 159};
66 static const Prob Pcat2
[] = { 165, 145};
67 static const Prob Pcat3
[] = { 173, 148, 140};
68 static const Prob Pcat4
[] = { 176, 155, 140, 135};
69 static const Prob Pcat5
[] = { 180, 157, 141, 134, 130};
70 static const Prob Pcat6
[] =
71 { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129};
73 static vp8_tree_index cat1
[2], cat2
[4], cat3
[6], cat4
[8], cat5
[10], cat6
[22];
75 void vp8_init_scan_order_mask()
79 for (i
= 0; i
< 16; i
++)
81 vp8_default_zig_zag_mask
[vp8_default_zig_zag1d
[i
]] = 1 << i
;
86 static void init_bit_tree(vp8_tree_index
*p
, int n
)
99 static void init_bit_trees()
101 init_bit_tree(cat1
, 1);
102 init_bit_tree(cat2
, 2);
103 init_bit_tree(cat3
, 3);
104 init_bit_tree(cat4
, 4);
105 init_bit_tree(cat5
, 5);
106 init_bit_tree(cat6
, 11);
110 static vp8bc_index_t bcc1
[1], bcc2
[2], bcc3
[3], bcc4
[4], bcc5
[5], bcc6
[11];
112 vp8_extra_bit_struct vp8_extra_bits
[12] =
119 { cat1
, Pcat1
, bcc1
, 1, 5},
120 { cat2
, Pcat2
, bcc2
, 2, 7},
121 { cat3
, Pcat3
, bcc3
, 3, 11},
122 { cat4
, Pcat4
, bcc4
, 4, 19},
123 { cat5
, Pcat5
, bcc5
, 5, 35},
124 { cat6
, Pcat6
, bcc6
, 11, 67},
127 #include "defaultcoefcounts.h"
129 void vp8_default_coef_probs(VP8_COMMON
*pc
)
143 unsigned int branch_ct
[vp8_coef_tokens
-1] [2];
144 vp8_tree_probs_from_distribution(
145 vp8_coef_tokens
, vp8_coef_encodings
, vp8_coef_tree
,
146 pc
->fc
.coef_probs
[h
][i
][k
], branch_ct
, default_coef_counts
[h
][i
][k
],
150 while (++k
< PREV_COEF_CONTEXTS
);
152 while (++i
< COEF_BANDS
);
154 while (++h
< BLOCK_TYPES
);
158 void vp8_coef_tree_initialize()
161 vp8_tokens_from_tree(vp8_coef_encodings
, vp8_coef_tree
);