/src/libvpx/vp8/encoder/segmentation.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2010 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 | | |
11 | | #include "segmentation.h" |
12 | | #include "vpx_mem/vpx_mem.h" |
13 | | |
14 | 70.0k | void vp8_update_gf_usage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x) { |
15 | 70.0k | int mb_row, mb_col; |
16 | | |
17 | 70.0k | MODE_INFO *this_mb_mode_info = cm->mi; |
18 | | |
19 | 70.0k | x->gf_active_ptr = (signed char *)cpi->gf_active_flags; |
20 | | |
21 | 70.0k | if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame)) { |
22 | | /* Reset Gf usage monitors */ |
23 | 17.2k | memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols)); |
24 | 17.2k | cpi->gf_active_count = cm->mb_rows * cm->mb_cols; |
25 | 52.7k | } else { |
26 | | /* for each macroblock row in image */ |
27 | 190k | for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) { |
28 | | /* for each macroblock col in image */ |
29 | 1.13M | for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) { |
30 | | /* If using golden then set GF active flag if not already set. |
31 | | * If using last frame 0,0 mode then leave flag as it is |
32 | | * else if using non 0,0 motion or intra modes then clear |
33 | | * flag if it is currently set |
34 | | */ |
35 | 996k | if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) || |
36 | 996k | (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME)) { |
37 | 54.0k | if (*(x->gf_active_ptr) == 0) { |
38 | 36.0k | *(x->gf_active_ptr) = 1; |
39 | 36.0k | cpi->gf_active_count++; |
40 | 36.0k | } |
41 | 942k | } else if ((this_mb_mode_info->mbmi.mode != ZEROMV) && |
42 | 942k | *(x->gf_active_ptr)) { |
43 | 492k | *(x->gf_active_ptr) = 0; |
44 | 492k | cpi->gf_active_count--; |
45 | 492k | } |
46 | | |
47 | 996k | x->gf_active_ptr++; /* Step onto next entry */ |
48 | 996k | this_mb_mode_info++; /* skip to next mb */ |
49 | 996k | } |
50 | | |
51 | | /* this is to account for the border */ |
52 | 137k | this_mb_mode_info++; |
53 | 137k | } |
54 | 52.7k | } |
55 | 70.0k | } |