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 #include <stdio.h>
12 
13 #include "vp9/common/vp9_blockd.h"
14 #include "vp9/common/vp9_onyxc_int.h"
15 
log_frame_info(VP9_COMMON * cm,const char * str,FILE * f)16 static void log_frame_info(VP9_COMMON *cm, const char *str, FILE *f) {
17   fprintf(f, "%s", str);
18   fprintf(f, "(Frame %d, Show:%d, Q:%d): \n", cm->current_video_frame,
19           cm->show_frame, cm->base_qindex);
20 }
21 /* This function dereferences a pointer to the mbmi structure
22  * and uses the passed in member offset to print out the value of an integer
23  * for each mbmi member value in the mi structure.
24  */
print_mi_data(VP9_COMMON * cm,FILE * file,const char * descriptor,size_t member_offset)25 static void print_mi_data(VP9_COMMON *cm, FILE *file, const char *descriptor,
26                           size_t member_offset) {
27   int mi_row, mi_col;
28   int mi_index = 0;
29   MODE_INFO **mi = cm->mi_grid_visible;
30   int rows = cm->mi_rows;
31   int cols = cm->mi_cols;
32   char prefix = descriptor[0];
33 
34   log_frame_info(cm, descriptor, file);
35   mi_index = 0;
36   for (mi_row = 0; mi_row < rows; mi_row++) {
37     fprintf(file, "%c ", prefix);
38     for (mi_col = 0; mi_col < cols; mi_col++) {
39       fprintf(file, "%2d ",
40               *((int*) ((char *) (&mi[mi_index]->mbmi) +
41                         member_offset)));
42       mi_index++;
43     }
44     fprintf(file, "\n");
45     mi_index += 8;
46   }
47   fprintf(file, "\n");
48 }
vp9_print_modes_and_motion_vectors(VP9_COMMON * cm,const char * file)49 void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, const char *file) {
50   int mi_row;
51   int mi_col;
52   int mi_index = 0;
53   FILE *mvs = fopen(file, "a");
54   MODE_INFO **mi = cm->mi_grid_visible;
55   int rows = cm->mi_rows;
56   int cols = cm->mi_cols;
57 
58   print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type));
59   print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode));
60   print_mi_data(cm, mvs, "Skips:", offsetof(MB_MODE_INFO, skip));
61   print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0]));
62   print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size));
63   print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode));
64 
65   log_frame_info(cm, "Vectors ", mvs);
66   for (mi_row = 0; mi_row < rows; mi_row++) {
67     fprintf(mvs, "V ");
68     for (mi_col = 0; mi_col < cols; mi_col++) {
69       fprintf(mvs, "%4d:%4d ", mi[mi_index]->mbmi.mv[0].as_mv.row,
70                                mi[mi_index]->mbmi.mv[0].as_mv.col);
71       mi_index++;
72     }
73     fprintf(mvs, "\n");
74     mi_index += 8;
75   }
76   fprintf(mvs, "\n");
77 
78   fclose(mvs);
79 }
80