]> granicus.if.org Git - libvpx/blob - vp10/common/seg_common.h
97b875c9c8f1d67d44adf7c386f12ba59b085f3b
[libvpx] / vp10 / common / seg_common.h
1 /*
2  *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3  *
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  */
10
11 #ifndef VP10_COMMON_SEG_COMMON_H_
12 #define VP10_COMMON_SEG_COMMON_H_
13
14 #include "vpx_dsp/prob.h"
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #define SEGMENT_DELTADATA   0
21 #define SEGMENT_ABSDATA     1
22
23 #define MAX_SEGMENTS     8
24 #define SEG_TREE_PROBS   (MAX_SEGMENTS-1)
25
26 #define PREDICTION_PROBS 3
27
28 // Segment level features.
29 typedef enum {
30   SEG_LVL_ALT_Q = 0,               // Use alternate Quantizer ....
31   SEG_LVL_ALT_LF = 1,              // Use alternate loop filter value...
32   SEG_LVL_REF_FRAME = 2,           // Optional Segment reference frame
33   SEG_LVL_SKIP = 3,                // Optional Segment (0,0) + skip mode
34   SEG_LVL_MAX = 4                  // Number of features supported
35 } SEG_LVL_FEATURES;
36
37
38 struct segmentation {
39   uint8_t enabled;
40   uint8_t update_map;
41   uint8_t update_data;
42   uint8_t abs_delta;
43   uint8_t temporal_update;
44
45   vpx_prob tree_probs[SEG_TREE_PROBS];
46   vpx_prob pred_probs[PREDICTION_PROBS];
47
48   int16_t feature_data[MAX_SEGMENTS][SEG_LVL_MAX];
49   unsigned int feature_mask[MAX_SEGMENTS];
50 };
51
52 static INLINE int segfeature_active(const struct segmentation *seg,
53                                     int segment_id,
54                                     SEG_LVL_FEATURES feature_id) {
55   return seg->enabled &&
56          (seg->feature_mask[segment_id] & (1 << feature_id));
57 }
58
59 void vp10_clearall_segfeatures(struct segmentation *seg);
60
61 void vp10_enable_segfeature(struct segmentation *seg,
62                            int segment_id,
63                            SEG_LVL_FEATURES feature_id);
64
65 int vp10_seg_feature_data_max(SEG_LVL_FEATURES feature_id);
66
67 int vp10_is_segfeature_signed(SEG_LVL_FEATURES feature_id);
68
69 void vp10_set_segdata(struct segmentation *seg,
70                      int segment_id,
71                      SEG_LVL_FEATURES feature_id,
72                      int seg_data);
73
74 static INLINE int get_segdata(const struct segmentation *seg, int segment_id,
75                               SEG_LVL_FEATURES feature_id) {
76   return seg->feature_data[segment_id][feature_id];
77 }
78
79 extern const vpx_tree_index vp10_segment_tree[TREE_SIZE(MAX_SEGMENTS)];
80
81 #ifdef __cplusplus
82 }  // extern "C"
83 #endif
84
85 #endif  // VP10_COMMON_SEG_COMMON_H_
86