vp9_seg_common.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef VP9_COMMON_VP9_SEG_COMMON_H_
  11. #define VP9_COMMON_VP9_SEG_COMMON_H_
  12. #include "vpx_dsp/prob.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define SEGMENT_DELTADATA 0
  17. #define SEGMENT_ABSDATA 1
  18. #define MAX_SEGMENTS 8
  19. #define SEG_TREE_PROBS (MAX_SEGMENTS-1)
  20. #define PREDICTION_PROBS 3
  21. // Segment level features.
  22. typedef enum {
  23. SEG_LVL_ALT_Q = 0, // Use alternate Quantizer ....
  24. SEG_LVL_ALT_LF = 1, // Use alternate loop filter value...
  25. SEG_LVL_REF_FRAME = 2, // Optional Segment reference frame
  26. SEG_LVL_SKIP = 3, // Optional Segment (0,0) + skip mode
  27. SEG_LVL_MAX = 4 // Number of features supported
  28. } SEG_LVL_FEATURES;
  29. struct segmentation {
  30. uint8_t enabled;
  31. uint8_t update_map;
  32. uint8_t update_data;
  33. uint8_t abs_delta;
  34. uint8_t temporal_update;
  35. vpx_prob tree_probs[SEG_TREE_PROBS];
  36. vpx_prob pred_probs[PREDICTION_PROBS];
  37. int16_t feature_data[MAX_SEGMENTS][SEG_LVL_MAX];
  38. uint32_t feature_mask[MAX_SEGMENTS];
  39. int aq_av_offset;
  40. };
  41. static INLINE int segfeature_active(const struct segmentation *seg,
  42. int segment_id,
  43. SEG_LVL_FEATURES feature_id) {
  44. return seg->enabled &&
  45. (seg->feature_mask[segment_id] & (1 << feature_id));
  46. }
  47. void vp9_clearall_segfeatures(struct segmentation *seg);
  48. void vp9_enable_segfeature(struct segmentation *seg,
  49. int segment_id,
  50. SEG_LVL_FEATURES feature_id);
  51. int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id);
  52. int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id);
  53. void vp9_set_segdata(struct segmentation *seg,
  54. int segment_id,
  55. SEG_LVL_FEATURES feature_id,
  56. int seg_data);
  57. static INLINE int get_segdata(const struct segmentation *seg, int segment_id,
  58. SEG_LVL_FEATURES feature_id) {
  59. return seg->feature_data[segment_id][feature_id];
  60. }
  61. extern const vpx_tree_index vp9_segment_tree[TREE_SIZE(MAX_SEGMENTS)];
  62. #ifdef __cplusplus
  63. } // extern "C"
  64. #endif
  65. #endif // VP9_COMMON_VP9_SEG_COMMON_H_