2
0

segmentation.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include "segmentation.h"
  11. #include "vpx_mem/vpx_mem.h"
  12. void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x) {
  13. int mb_row, mb_col;
  14. MODE_INFO *this_mb_mode_info = cm->mi;
  15. x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
  16. if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame)) {
  17. /* Reset Gf useage monitors */
  18. memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
  19. cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
  20. } else {
  21. /* for each macroblock row in image */
  22. for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
  23. /* for each macroblock col in image */
  24. for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
  25. /* If using golden then set GF active flag if not already set.
  26. * If using last frame 0,0 mode then leave flag as it is
  27. * else if using non 0,0 motion or intra modes then clear
  28. * flag if it is currently set
  29. */
  30. if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) ||
  31. (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME)) {
  32. if (*(x->gf_active_ptr) == 0) {
  33. *(x->gf_active_ptr) = 1;
  34. cpi->gf_active_count++;
  35. }
  36. } else if ((this_mb_mode_info->mbmi.mode != ZEROMV) &&
  37. *(x->gf_active_ptr)) {
  38. *(x->gf_active_ptr) = 0;
  39. cpi->gf_active_count--;
  40. }
  41. x->gf_active_ptr++; /* Step onto next entry */
  42. this_mb_mode_info++; /* skip to next mb */
  43. }
  44. /* this is to account for the border */
  45. this_mb_mode_info++;
  46. }
  47. }
  48. }