media/libvpx/vp9/common/vp9_seg_common.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp9/common/vp9_seg_common.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +#include <assert.h>
    1.15 +
    1.16 +#include "vp9/common/vp9_blockd.h"
    1.17 +#include "vp9/common/vp9_loopfilter.h"
    1.18 +#include "vp9/common/vp9_seg_common.h"
    1.19 +#include "vp9/common/vp9_quant_common.h"
    1.20 +
    1.21 +static const int seg_feature_data_signed[SEG_LVL_MAX] = { 1, 1, 0, 0 };
    1.22 +
    1.23 +static const int seg_feature_data_max[SEG_LVL_MAX] = {
    1.24 +  MAXQ, MAX_LOOP_FILTER, 3, 0 };
    1.25 +
    1.26 +// These functions provide access to new segment level features.
    1.27 +// Eventually these function may be "optimized out" but for the moment,
    1.28 +// the coding mechanism is still subject to change so these provide a
    1.29 +// convenient single point of change.
    1.30 +
    1.31 +int vp9_segfeature_active(const struct segmentation *seg, int segment_id,
    1.32 +                          SEG_LVL_FEATURES feature_id) {
    1.33 +  return seg->enabled &&
    1.34 +         (seg->feature_mask[segment_id] & (1 << feature_id));
    1.35 +}
    1.36 +
    1.37 +void vp9_clearall_segfeatures(struct segmentation *seg) {
    1.38 +  vp9_zero(seg->feature_data);
    1.39 +  vp9_zero(seg->feature_mask);
    1.40 +}
    1.41 +
    1.42 +void vp9_enable_segfeature(struct segmentation *seg, int segment_id,
    1.43 +                           SEG_LVL_FEATURES feature_id) {
    1.44 +  seg->feature_mask[segment_id] |= 1 << feature_id;
    1.45 +}
    1.46 +
    1.47 +void vp9_disable_segfeature(struct segmentation *seg, int segment_id,
    1.48 +                            SEG_LVL_FEATURES feature_id) {
    1.49 +  seg->feature_mask[segment_id] &= ~(1 << feature_id);
    1.50 +}
    1.51 +
    1.52 +int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id) {
    1.53 +  return seg_feature_data_max[feature_id];
    1.54 +}
    1.55 +
    1.56 +int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id) {
    1.57 +  return seg_feature_data_signed[feature_id];
    1.58 +}
    1.59 +
    1.60 +void vp9_clear_segdata(struct segmentation *seg, int segment_id,
    1.61 +                       SEG_LVL_FEATURES feature_id) {
    1.62 +  seg->feature_data[segment_id][feature_id] = 0;
    1.63 +}
    1.64 +
    1.65 +void vp9_set_segdata(struct segmentation *seg, int segment_id,
    1.66 +                     SEG_LVL_FEATURES feature_id, int seg_data) {
    1.67 +  assert(seg_data <= seg_feature_data_max[feature_id]);
    1.68 +  if (seg_data < 0) {
    1.69 +    assert(seg_feature_data_signed[feature_id]);
    1.70 +    assert(-seg_data <= seg_feature_data_max[feature_id]);
    1.71 +  }
    1.72 +
    1.73 +  seg->feature_data[segment_id][feature_id] = seg_data;
    1.74 +}
    1.75 +
    1.76 +int vp9_get_segdata(const struct segmentation *seg, int segment_id,
    1.77 +                    SEG_LVL_FEATURES feature_id) {
    1.78 +  return seg->feature_data[segment_id][feature_id];
    1.79 +}
    1.80 +
    1.81 +
    1.82 +const vp9_tree_index vp9_segment_tree[TREE_SIZE(MAX_SEGMENTS)] = {
    1.83 +  2,  4,  6,  8, 10, 12,
    1.84 +  0, -1, -2, -3, -4, -5, -6, -7
    1.85 +};
    1.86 +
    1.87 +
    1.88 +// TBD? Functions to read and write segment data with range / validity checking

mercurial