An error occurred while loading the file. Please try again.
-
Dmitry Kovalev authored939b1e4a
vp9_segmentation.c 10.12 KiB
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <limits.h>
#include "vpx_mem/vpx_mem.h"
#include "vp9/encoder/vp9_segmentation.h"
#include "vp9/common/vp9_pred_common.h"
#include "vp9/common/vp9_tile_common.h"
void vp9_enable_segmentation(VP9_PTR ptr) {
VP9_COMP *cpi = (VP9_COMP *)ptr;
struct segmentation *const seg = &cpi->common.seg;
seg->enabled = 1;
seg->update_map = 1;
seg->update_data = 1;
}
void vp9_disable_segmentation(VP9_PTR ptr) {
VP9_COMP *cpi = (VP9_COMP *)ptr;
struct segmentation *const seg = &cpi->common.seg;
seg->enabled = 0;
}
void vp9_set_segmentation_map(VP9_PTR ptr,
unsigned char *segmentation_map) {
VP9_COMP *cpi = (VP9_COMP *)ptr;
struct segmentation *const seg = &cpi->common.seg;
// Copy in the new segmentation map
vpx_memcpy(cpi->segmentation_map, segmentation_map,
(cpi->common.mi_rows * cpi->common.mi_cols));
// Signal that the map should be updated.
seg->update_map = 1;
seg->update_data = 1;
}
void vp9_set_segment_data(VP9_PTR ptr,
signed char *feature_data,
unsigned char abs_delta) {
VP9_COMP *cpi = (VP9_COMP *)ptr;
struct segmentation *const seg = &cpi->common.seg;
seg->abs_delta = abs_delta;
vpx_memcpy(seg->feature_data, feature_data, sizeof(seg->feature_data));
// TBD ?? Set the feature mask
// vpx_memcpy(cpi->mb.e_mbd.segment_feature_mask, 0,
// sizeof(cpi->mb.e_mbd.segment_feature_mask));
}
// Based on set of segment counts calculate a probability tree
static void calc_segtree_probs(int *segcounts, vp9_prob *segment_tree_probs) {
// Work out probabilities of each segment
const int c01 = segcounts[0] + segcounts[1];
const int c23 = segcounts[2] + segcounts[3];
const int c45 = segcounts[4] + segcounts[5];
const int c67 = segcounts[6] + segcounts[7];
segment_tree_probs[0] = get_binary_prob(c01 + c23, c45 + c67);