summaryrefslogtreecommitdiff
path: root/vp9/common/vp9_debugmodes.c
blob: 5841f8091d38d56593a48dd0834f9c8614f908f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <stdio.h>

#include "vp9/common/vp9_blockd.h"

void vp9_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols,
                                        int frame, char *file) {
  int mi_row;
  int mi_col;
  int mi_index = 0;
  FILE *mvs = fopen(file, "a");

  // Print out the macroblock Y modes
  fprintf(mvs, "SB Types for Frame %d\n", frame);

  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%2d ", mi[mi_index].mbmi.sb_type);

      mi_index++;
    }

    fprintf(mvs, "\n");
    mi_index += 8;
  }

  // Print out the macroblock Y modes
  fprintf(mvs, "Mb Modes for Frame %d\n", frame);
  mi_index = 0;
  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%2d ", mi[mi_index].mbmi.mode);

      mi_index++;
    }

    fprintf(mvs, "\n");
    mi_index += 8;
  }

  fprintf(mvs, "\n");

  mi_index = 0;
  fprintf(mvs, "Mb mv ref for Frame %d\n", frame);

  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%2d ", mi[mi_index].mbmi.ref_frame[0]);

      mi_index++;
    }

    fprintf(mvs, "\n");
    mi_index += 8;
  }
  fprintf(mvs, "\n");

  mi_index = 0;
  fprintf(mvs, "Mb mv ref for Frame %d\n", frame);

  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%4d:%4d ", mi[mi_index].mbmi.mv[0].as_mv.row,
              mi[mi_index].mbmi.mv[0].as_mv.col);

      mi_index++;
    }

    fprintf(mvs, "\n");
    mi_index += 8;
  }

  fprintf(mvs, "\n");

  /* print out the macroblock txform sizes */
  mi_index = 0;
  fprintf(mvs, "TXFM size for Frame %d\n", frame);

  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%2d ", mi[mi_index].mbmi.txfm_size);

      mi_index++;
    }

    mi_index += 8;
    fprintf(mvs, "\n");
  }

  fprintf(mvs, "\n");

  /* print out the macroblock UV modes */
  mi_index = 0;
  fprintf(mvs, "UV Modes for Frame %d\n", frame);

  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%2d ", mi[mi_index].mbmi.uv_mode);

      mi_index++;
    }

    mi_index += 8;
    fprintf(mvs, "\n");
  }

  fprintf(mvs, "\n");

  /* print out the macroblock mvs */
  mi_index = 0;
  fprintf(mvs, "MVs for Frame %d\n", frame);

  for (mi_row = 0; mi_row < rows; mi_row++) {
    for (mi_col = 0; mi_col < cols; mi_col++) {
      fprintf(mvs, "%5d:%-5d", mi[mi_index].mbmi.mv[0].as_mv.row / 2,
              mi[mi_index].mbmi.mv[0].as_mv.col / 2);

      mi_index++;
    }

    mi_index += 8;
    fprintf(mvs, "\n");
  }

  fprintf(mvs, "\n");

  fclose(mvs);
}