summaryrefslogtreecommitdiffstats
path: root/media/libvpx/vp8/common/debugmodes.c
blob: 159fddc6a765b9a060e144169e61b9313d39e501 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 *  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 "blockd.h"


void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int frame)
{

    int mb_row;
    int mb_col;
    int mb_index = 0;
    FILE *mvs = fopen("mvs.stt", "a");

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

    for (mb_row = 0; mb_row < rows; mb_row++)
    {
        for (mb_col = 0; mb_col < cols; mb_col++)
        {

            fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);

            mb_index++;
        }

        fprintf(mvs, "\n");
        mb_index++;
    }

    fprintf(mvs, "\n");

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

    for (mb_row = 0; mb_row < rows; mb_row++)
    {
        for (mb_col = 0; mb_col < cols; mb_col++)
        {

            fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);

            mb_index++;
        }

        fprintf(mvs, "\n");
        mb_index++;
    }

    fprintf(mvs, "\n");

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

    for (mb_row = 0; mb_row < rows; mb_row++)
    {
        for (mb_col = 0; mb_col < cols; mb_col++)
        {

            fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);

            mb_index++;
        }

        mb_index++;
        fprintf(mvs, "\n");
    }

    fprintf(mvs, "\n");

    /* print out the block modes */
    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);

                if (mi[mb_index].mbmi.mode == B_PRED)
                    fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode);
                else
                    fprintf(mvs, "xx ");

            }

            fprintf(mvs, "\n");
        }
    }
    fprintf(mvs, "\n");

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

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

            mb_index++;
        }

        mb_index++;
        fprintf(mvs, "\n");
    }

    fprintf(mvs, "\n");


    /* print out the block modes */
    fprintf(mvs, "MVs 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);
                fprintf(mvs, "%3d:%-3d ", mi[mb_index].bmi[bindex].mv.as_mv.row, mi[mb_index].bmi[bindex].mv.as_mv.col);

            }

            fprintf(mvs, "\n");
        }
    }
    fprintf(mvs, "\n");


    fclose(mvs);
}