vp9_debugmodes.c 3.34 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5 6
 *  that can be found in the LICENSE file in the root of the source
 *  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.
John Koleszar's avatar
John Koleszar committed
9 10 11
 */

#include <stdio.h>
12
#include "vp9/common/vp9_blockd.h"
John Koleszar's avatar
John Koleszar committed
13

14 15
void vp9_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols,
                                        int frame) {
John Koleszar's avatar
John Koleszar committed
16 17 18 19
  int mb_row;
  int mb_col;
  int mb_index = 0;
  FILE *mvs = fopen("mvs.stt", "a");
John Koleszar's avatar
John Koleszar committed
20

John Koleszar's avatar
John Koleszar committed
21 22 23
  /* print out the macroblock Y modes */
  mb_index = 0;
  fprintf(mvs, "Mb Modes for Frame %d\n", frame);
John Koleszar's avatar
John Koleszar committed
24

John Koleszar's avatar
John Koleszar committed
25 26
  for (mb_row = 0; mb_row < rows; mb_row++) {
    for (mb_col = 0; mb_col < cols; mb_col++) {
John Koleszar's avatar
John Koleszar committed
27

John Koleszar's avatar
John Koleszar committed
28
      fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);
John Koleszar's avatar
John Koleszar committed
29

John Koleszar's avatar
John Koleszar committed
30
      mb_index++;
John Koleszar's avatar
John Koleszar committed
31 32 33
    }

    fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
34 35
    mb_index++;
  }
John Koleszar's avatar
John Koleszar committed
36

John Koleszar's avatar
John Koleszar committed
37
  fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
38

John Koleszar's avatar
John Koleszar committed
39 40
  mb_index = 0;
  fprintf(mvs, "Mb mv ref for Frame %d\n", frame);
John Koleszar's avatar
John Koleszar committed
41

John Koleszar's avatar
John Koleszar committed
42 43
  for (mb_row = 0; mb_row < rows; mb_row++) {
    for (mb_col = 0; mb_col < cols; mb_col++) {
John Koleszar's avatar
John Koleszar committed
44

John Koleszar's avatar
John Koleszar committed
45
      fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);
John Koleszar's avatar
John Koleszar committed
46

John Koleszar's avatar
John Koleszar committed
47
      mb_index++;
John Koleszar's avatar
John Koleszar committed
48 49 50
    }

    fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
51 52
    mb_index++;
  }
John Koleszar's avatar
John Koleszar committed
53

John Koleszar's avatar
John Koleszar committed
54
  fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
55

John Koleszar's avatar
John Koleszar committed
56 57 58
  /* print out the macroblock UV modes */
  mb_index = 0;
  fprintf(mvs, "UV Modes for Frame %d\n", frame);
John Koleszar's avatar
John Koleszar committed
59

John Koleszar's avatar
John Koleszar committed
60 61
  for (mb_row = 0; mb_row < rows; mb_row++) {
    for (mb_col = 0; mb_col < cols; mb_col++) {
John Koleszar's avatar
John Koleszar committed
62

John Koleszar's avatar
John Koleszar committed
63
      fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);
John Koleszar's avatar
John Koleszar committed
64

John Koleszar's avatar
John Koleszar committed
65
      mb_index++;
John Koleszar's avatar
John Koleszar committed
66 67
    }

John Koleszar's avatar
John Koleszar committed
68
    mb_index++;
John Koleszar's avatar
John Koleszar committed
69
    fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
  }

  fprintf(mvs, "\n");

  /* print out the block modes */
  mb_index = 0;
  fprintf(mvs, "Mbs for Frame %d\n", frame);
  {
    int b_row;

    for (b_row = 0; b_row < 4 * rows; b_row++) {
      int b_col;
      int bindex;

      for (b_col = 0; b_col < 4 * cols; b_col++) {
        mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
        bindex = (b_row & 3) * 4 + (b_col & 3);
John Koleszar's avatar
John Koleszar committed
87

John Koleszar's avatar
John Koleszar committed
88 89
        if (mi[mb_index].mbmi.mode == B_PRED) {
          fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.first);
90
#if CONFIG_COMP_INTRA_PRED
John Koleszar's avatar
John Koleszar committed
91
          fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.second);
92
#endif
John Koleszar's avatar
John Koleszar committed
93 94
        } else
          fprintf(mvs, "xx ");
John Koleszar's avatar
John Koleszar committed
95

John Koleszar's avatar
John Koleszar committed
96
      }
John Koleszar's avatar
John Koleszar committed
97

John Koleszar's avatar
John Koleszar committed
98
      fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
99
    }
John Koleszar's avatar
John Koleszar committed
100 101
  }
  fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
102

John Koleszar's avatar
John Koleszar committed
103 104 105
  /* print out the macroblock mvs */
  mb_index = 0;
  fprintf(mvs, "MVs for Frame %d\n", frame);
John Koleszar's avatar
John Koleszar committed
106

John Koleszar's avatar
John Koleszar committed
107 108
  for (mb_row = 0; mb_row < rows; mb_row++) {
    for (mb_col = 0; mb_col < cols; mb_col++) {
109 110
      fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv[0].as_mv.row / 2,
          mi[mb_index].mbmi.mv[0].as_mv.col / 2);
John Koleszar's avatar
John Koleszar committed
111

John Koleszar's avatar
John Koleszar committed
112
      mb_index++;
John Koleszar's avatar
John Koleszar committed
113 114
    }

John Koleszar's avatar
John Koleszar committed
115
    mb_index++;
John Koleszar's avatar
John Koleszar committed
116
    fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
117
  }
John Koleszar's avatar
John Koleszar committed
118

John Koleszar's avatar
John Koleszar committed
119
  fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
120

John Koleszar's avatar
John Koleszar committed
121 122 123 124 125
  /* print out the block modes */
  mb_index = 0;
  fprintf(mvs, "MVs for Frame %d\n", frame);
  {
    int b_row;
John Koleszar's avatar
John Koleszar committed
126

John Koleszar's avatar
John Koleszar committed
127 128 129
    for (b_row = 0; b_row < 4 * rows; b_row++) {
      int b_col;
      int bindex;
John Koleszar's avatar
John Koleszar committed
130

John Koleszar's avatar
John Koleszar committed
131 132 133 134 135 136
      for (b_col = 0; b_col < 4 * cols; b_col++) {
        mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
        bindex = (b_row & 3) * 4 + (b_col & 3);
        fprintf(mvs, "%3d:%-3d ",
                mi[mb_index].bmi[bindex].as_mv.first.as_mv.row,
                mi[mb_index].bmi[bindex].as_mv.first.as_mv.col);
John Koleszar's avatar
John Koleszar committed
137

John Koleszar's avatar
John Koleszar committed
138 139 140
      }

      fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
141
    }
John Koleszar's avatar
John Koleszar committed
142 143
  }
  fprintf(mvs, "\n");
John Koleszar's avatar
John Koleszar committed
144

John Koleszar's avatar
John Koleszar committed
145
  fclose(mvs);
John Koleszar's avatar
John Koleszar committed
146
}