seg_common.h 2.58 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Jingning Han's avatar
Jingning Han committed
10 11
 */

Yaowu Xu's avatar
Yaowu Xu committed
12 13
#ifndef AV1_COMMON_SEG_COMMON_H_
#define AV1_COMMON_SEG_COMMON_H_
Jingning Han's avatar
Jingning Han committed
14

15
#include "aom_dsp/prob.h"
Jingning Han's avatar
Jingning Han committed
16 17 18 19 20

#ifdef __cplusplus
extern "C" {
#endif

clang-format's avatar
clang-format committed
21 22
#define SEGMENT_DELTADATA 0
#define SEGMENT_ABSDATA 1
Jingning Han's avatar
Jingning Han committed
23

clang-format's avatar
clang-format committed
24 25
#define MAX_SEGMENTS 8
#define SEG_TREE_PROBS (MAX_SEGMENTS - 1)
Jingning Han's avatar
Jingning Han committed
26 27 28 29 30

#define PREDICTION_PROBS 3

// Segment level features.
typedef enum {
clang-format's avatar
clang-format committed
31 32 33 34 35
  SEG_LVL_ALT_Q = 0,      // Use alternate Quantizer ....
  SEG_LVL_ALT_LF = 1,     // Use alternate loop filter value...
  SEG_LVL_REF_FRAME = 2,  // Optional Segment reference frame
  SEG_LVL_SKIP = 3,       // Optional Segment (0,0) + skip mode
  SEG_LVL_MAX = 4         // Number of features supported
Jingning Han's avatar
Jingning Han committed
36 37 38 39 40 41 42 43 44 45 46 47 48
} SEG_LVL_FEATURES;

struct segmentation {
  uint8_t enabled;
  uint8_t update_map;
  uint8_t update_data;
  uint8_t abs_delta;
  uint8_t temporal_update;

  int16_t feature_data[MAX_SEGMENTS][SEG_LVL_MAX];
  unsigned int feature_mask[MAX_SEGMENTS];
};

49
struct segmentation_probs {
Yaowu Xu's avatar
Yaowu Xu committed
50
  aom_prob tree_probs[SEG_TREE_PROBS];
51 52 53
#if CONFIG_DAALA_EC
  aom_cdf_prob tree_cdf[MAX_SEGMENTS];
#endif
Yaowu Xu's avatar
Yaowu Xu committed
54
  aom_prob pred_probs[PREDICTION_PROBS];
55 56
};

Jingning Han's avatar
Jingning Han committed
57 58 59
static INLINE int segfeature_active(const struct segmentation *seg,
                                    int segment_id,
                                    SEG_LVL_FEATURES feature_id) {
clang-format's avatar
clang-format committed
60
  return seg->enabled && (seg->feature_mask[segment_id] & (1 << feature_id));
Jingning Han's avatar
Jingning Han committed
61 62
}

Yaowu Xu's avatar
Yaowu Xu committed
63
void av1_clearall_segfeatures(struct segmentation *seg);
Jingning Han's avatar
Jingning Han committed
64

Yaowu Xu's avatar
Yaowu Xu committed
65 66
void av1_enable_segfeature(struct segmentation *seg, int segment_id,
                           SEG_LVL_FEATURES feature_id);
Jingning Han's avatar
Jingning Han committed
67

Yaowu Xu's avatar
Yaowu Xu committed
68
int av1_seg_feature_data_max(SEG_LVL_FEATURES feature_id);
Jingning Han's avatar
Jingning Han committed
69

Yaowu Xu's avatar
Yaowu Xu committed
70
int av1_is_segfeature_signed(SEG_LVL_FEATURES feature_id);
Jingning Han's avatar
Jingning Han committed
71

Yaowu Xu's avatar
Yaowu Xu committed
72 73
void av1_set_segdata(struct segmentation *seg, int segment_id,
                     SEG_LVL_FEATURES feature_id, int seg_data);
Jingning Han's avatar
Jingning Han committed
74 75 76 77 78 79

static INLINE int get_segdata(const struct segmentation *seg, int segment_id,
                              SEG_LVL_FEATURES feature_id) {
  return seg->feature_data[segment_id][feature_id];
}

Yaowu Xu's avatar
Yaowu Xu committed
80
extern const aom_tree_index av1_segment_tree[TREE_SIZE(MAX_SEGMENTS)];
Jingning Han's avatar
Jingning Han committed
81 82 83 84 85

#ifdef __cplusplus
}  // extern "C"
#endif

Yaowu Xu's avatar
Yaowu Xu committed
86
#endif  // AV1_COMMON_SEG_COMMON_H_