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 
12 #include <stdio.h>
13 #include "blockd.h"
14 
15 
vp8_print_modes_and_motion_vectors(MODE_INFO * mi,int rows,int cols,int frame)16 void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int frame)
17 {
18 
19     int mb_row;
20     int mb_col;
21     int mb_index = 0;
22     FILE *mvs = fopen("mvs.stt", "a");
23 
24     /* print out the macroblock Y modes */
25     mb_index = 0;
26     fprintf(mvs, "Mb Modes for Frame %d\n", frame);
27 
28     for (mb_row = 0; mb_row < rows; mb_row++)
29     {
30         for (mb_col = 0; mb_col < cols; mb_col++)
31         {
32 
33             fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);
34 
35             mb_index++;
36         }
37 
38         fprintf(mvs, "\n");
39         mb_index++;
40     }
41 
42     fprintf(mvs, "\n");
43 
44     mb_index = 0;
45     fprintf(mvs, "Mb mv ref for Frame %d\n", frame);
46 
47     for (mb_row = 0; mb_row < rows; mb_row++)
48     {
49         for (mb_col = 0; mb_col < cols; mb_col++)
50         {
51 
52             fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);
53 
54             mb_index++;
55         }
56 
57         fprintf(mvs, "\n");
58         mb_index++;
59     }
60 
61     fprintf(mvs, "\n");
62 
63     /* print out the macroblock UV modes */
64     mb_index = 0;
65     fprintf(mvs, "UV Modes for Frame %d\n", frame);
66 
67     for (mb_row = 0; mb_row < rows; mb_row++)
68     {
69         for (mb_col = 0; mb_col < cols; mb_col++)
70         {
71 
72             fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);
73 
74             mb_index++;
75         }
76 
77         mb_index++;
78         fprintf(mvs, "\n");
79     }
80 
81     fprintf(mvs, "\n");
82 
83     /* print out the block modes */
84     fprintf(mvs, "Mbs for Frame %d\n", frame);
85     {
86         int b_row;
87 
88         for (b_row = 0; b_row < 4 * rows; b_row++)
89         {
90             int b_col;
91             int bindex;
92 
93             for (b_col = 0; b_col < 4 * cols; b_col++)
94             {
95                 mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
96                 bindex = (b_row & 3) * 4 + (b_col & 3);
97 
98                 if (mi[mb_index].mbmi.mode == B_PRED)
99                     fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode);
100                 else
101                     fprintf(mvs, "xx ");
102 
103             }
104 
105             fprintf(mvs, "\n");
106         }
107     }
108     fprintf(mvs, "\n");
109 
110     /* print out the macroblock mvs */
111     mb_index = 0;
112     fprintf(mvs, "MVs for Frame %d\n", frame);
113 
114     for (mb_row = 0; mb_row < rows; mb_row++)
115     {
116         for (mb_col = 0; mb_col < cols; mb_col++)
117         {
118             fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv.as_mv.row / 2, mi[mb_index].mbmi.mv.as_mv.col / 2);
119 
120             mb_index++;
121         }
122 
123         mb_index++;
124         fprintf(mvs, "\n");
125     }
126 
127     fprintf(mvs, "\n");
128 
129 
130     /* print out the block modes */
131     fprintf(mvs, "MVs for Frame %d\n", frame);
132     {
133         int b_row;
134 
135         for (b_row = 0; b_row < 4 * rows; b_row++)
136         {
137             int b_col;
138             int bindex;
139 
140             for (b_col = 0; b_col < 4 * cols; b_col++)
141             {
142                 mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
143                 bindex = (b_row & 3) * 4 + (b_col & 3);
144                 fprintf(mvs, "%3d:%-3d ", mi[mb_index].bmi[bindex].mv.as_mv.row, mi[mb_index].bmi[bindex].mv.as_mv.col);
145 
146             }
147 
148             fprintf(mvs, "\n");
149         }
150     }
151     fprintf(mvs, "\n");
152 
153 
154     fclose(mvs);
155 }
156