Refactor intra block prediction and reconstruction process
[aom.git] / vp9 / encoder / vp9_treewriter.h
blob4a76d87cdfea5fa72a1133bade4f36ae0aa44b7c
1 /*
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.
9 */
11 #ifndef VP9_ENCODER_VP9_TREEWRITER_H_
12 #define VP9_ENCODER_VP9_TREEWRITER_H_
14 #include "vp9/encoder/vp9_writer.h"
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 void vp9_tree_probs_from_distribution(vp9_tree tree,
21 unsigned int branch_ct[ /* n - 1 */ ][2],
22 const unsigned int num_events[ /* n */ ]);
24 struct vp9_token {
25 int value;
26 int len;
29 void vp9_tokens_from_tree(struct vp9_token*, const vp9_tree_index *);
31 static INLINE void vp9_write_tree(vp9_writer *w, const vp9_tree_index *tree,
32 const vp9_prob *probs, int bits, int len,
33 vp9_tree_index i) {
34 do {
35 const int bit = (bits >> --len) & 1;
36 vp9_write(w, bit, probs[i >> 1]);
37 i = tree[i + bit];
38 } while (len);
41 static INLINE void vp9_write_token(vp9_writer *w, const vp9_tree_index *tree,
42 const vp9_prob *probs,
43 const struct vp9_token *token) {
44 vp9_write_tree(w, tree, probs, token->value, token->len, 0);
47 #ifdef __cplusplus
48 } // extern "C"
49 #endif
51 #endif // VP9_ENCODER_VP9_TREEWRITER_H_