1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/encoder/segmentation.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 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 + 1.15 +#include "segmentation.h" 1.16 +#include "vpx_mem/vpx_mem.h" 1.17 + 1.18 +void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x) 1.19 +{ 1.20 + int mb_row, mb_col; 1.21 + 1.22 + MODE_INFO *this_mb_mode_info = cm->mi; 1.23 + 1.24 + x->gf_active_ptr = (signed char *)cpi->gf_active_flags; 1.25 + 1.26 + if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame)) 1.27 + { 1.28 + /* Reset Gf useage monitors */ 1.29 + vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols)); 1.30 + cpi->gf_active_count = cm->mb_rows * cm->mb_cols; 1.31 + } 1.32 + else 1.33 + { 1.34 + /* for each macroblock row in image */ 1.35 + for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) 1.36 + { 1.37 + /* for each macroblock col in image */ 1.38 + for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) 1.39 + { 1.40 + 1.41 + /* If using golden then set GF active flag if not already set. 1.42 + * If using last frame 0,0 mode then leave flag as it is 1.43 + * else if using non 0,0 motion or intra modes then clear 1.44 + * flag if it is currently set 1.45 + */ 1.46 + if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) || (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME)) 1.47 + { 1.48 + if (*(x->gf_active_ptr) == 0) 1.49 + { 1.50 + *(x->gf_active_ptr) = 1; 1.51 + cpi->gf_active_count ++; 1.52 + } 1.53 + } 1.54 + else if ((this_mb_mode_info->mbmi.mode != ZEROMV) && *(x->gf_active_ptr)) 1.55 + { 1.56 + *(x->gf_active_ptr) = 0; 1.57 + cpi->gf_active_count--; 1.58 + } 1.59 + 1.60 + x->gf_active_ptr++; /* Step onto next entry */ 1.61 + this_mb_mode_info++; /* skip to next mb */ 1.62 + 1.63 + } 1.64 + 1.65 + /* this is to account for the border */ 1.66 + this_mb_mode_info++; 1.67 + } 1.68 + } 1.69 +}