michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #include "segmentation.h" michael@0: #include "vpx_mem/vpx_mem.h" michael@0: michael@0: void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x) michael@0: { michael@0: int mb_row, mb_col; michael@0: michael@0: MODE_INFO *this_mb_mode_info = cm->mi; michael@0: michael@0: x->gf_active_ptr = (signed char *)cpi->gf_active_flags; michael@0: michael@0: if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame)) michael@0: { michael@0: /* Reset Gf useage monitors */ michael@0: vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols)); michael@0: cpi->gf_active_count = cm->mb_rows * cm->mb_cols; michael@0: } michael@0: else michael@0: { michael@0: /* for each macroblock row in image */ michael@0: for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) michael@0: { michael@0: /* for each macroblock col in image */ michael@0: for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) michael@0: { michael@0: michael@0: /* If using golden then set GF active flag if not already set. michael@0: * If using last frame 0,0 mode then leave flag as it is michael@0: * else if using non 0,0 motion or intra modes then clear michael@0: * flag if it is currently set michael@0: */ michael@0: if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) || (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME)) michael@0: { michael@0: if (*(x->gf_active_ptr) == 0) michael@0: { michael@0: *(x->gf_active_ptr) = 1; michael@0: cpi->gf_active_count ++; michael@0: } michael@0: } michael@0: else if ((this_mb_mode_info->mbmi.mode != ZEROMV) && *(x->gf_active_ptr)) michael@0: { michael@0: *(x->gf_active_ptr) = 0; michael@0: cpi->gf_active_count--; michael@0: } michael@0: michael@0: x->gf_active_ptr++; /* Step onto next entry */ michael@0: this_mb_mode_info++; /* skip to next mb */ michael@0: michael@0: } michael@0: michael@0: /* this is to account for the border */ michael@0: this_mb_mode_info++; michael@0: } michael@0: } michael@0: }