Line data Source code
1 : /*
2 : * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 : *
4 : * This source code is subject to the terms of the BSD 2 Clause License and
5 : * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 : * was not distributed with this source code in the LICENSE file, you can
7 : * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 : * Media Patent License 1.0 was not distributed with this source code in the
9 : * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 : */
11 :
12 : #include <stdio.h>
13 :
14 : #include "av1/common/blockd.h"
15 : #include "av1/common/enums.h"
16 : #include "av1/common/onyxc_int.h"
17 :
18 0 : static void log_frame_info(AV1_COMMON *cm, const char *str, FILE *f) {
19 0 : fprintf(f, "%s", str);
20 0 : fprintf(f, "(Frame %d, Show:%d, Q:%d): \n", cm->current_video_frame,
21 : cm->show_frame, cm->base_qindex);
22 0 : }
23 : /* This function dereferences a pointer to the mbmi structure
24 : * and uses the passed in member offset to print out the value of an integer
25 : * for each mbmi member value in the mi structure.
26 : */
27 0 : static void print_mi_data(AV1_COMMON *cm, FILE *file, const char *descriptor,
28 : size_t member_offset) {
29 : int mi_row, mi_col;
30 0 : MODE_INFO **mi = cm->mi_grid_visible;
31 0 : int rows = cm->mi_rows;
32 0 : int cols = cm->mi_cols;
33 0 : char prefix = descriptor[0];
34 :
35 0 : log_frame_info(cm, descriptor, file);
36 0 : for (mi_row = 0; mi_row < rows; mi_row++) {
37 0 : fprintf(file, "%c ", prefix);
38 0 : for (mi_col = 0; mi_col < cols; mi_col++) {
39 0 : fprintf(file, "%2d ",
40 0 : *((char *)((char *)(&mi[0]->mbmi) + member_offset)));
41 0 : mi++;
42 : }
43 0 : fprintf(file, "\n");
44 0 : mi += MAX_MIB_SIZE;
45 : }
46 0 : fprintf(file, "\n");
47 0 : }
48 :
49 0 : void av1_print_modes_and_motion_vectors(AV1_COMMON *cm, const char *file) {
50 : int mi_row;
51 : int mi_col;
52 0 : FILE *mvs = fopen(file, "a");
53 0 : MODE_INFO **mi = cm->mi_grid_visible;
54 0 : int rows = cm->mi_rows;
55 0 : int cols = cm->mi_cols;
56 :
57 0 : print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type));
58 0 : print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode));
59 0 : print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0]));
60 0 : print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size));
61 0 : print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode));
62 :
63 : // output skip infomation.
64 0 : log_frame_info(cm, "Skips:", mvs);
65 0 : for (mi_row = 0; mi_row < rows; mi_row++) {
66 0 : fprintf(mvs, "S ");
67 0 : for (mi_col = 0; mi_col < cols; mi_col++) {
68 0 : fprintf(mvs, "%2d ", mi[0]->mbmi.skip);
69 0 : mi++;
70 : }
71 0 : fprintf(mvs, "\n");
72 0 : mi += MAX_MIB_SIZE;
73 : }
74 0 : fprintf(mvs, "\n");
75 :
76 : // output motion vectors.
77 0 : log_frame_info(cm, "Vectors ", mvs);
78 0 : mi = cm->mi_grid_visible;
79 0 : for (mi_row = 0; mi_row < rows; mi_row++) {
80 0 : fprintf(mvs, "V ");
81 0 : for (mi_col = 0; mi_col < cols; mi_col++) {
82 0 : fprintf(mvs, "%4d:%4d ", mi[0]->mbmi.mv[0].as_mv.row,
83 0 : mi[0]->mbmi.mv[0].as_mv.col);
84 0 : mi++;
85 : }
86 0 : fprintf(mvs, "\n");
87 0 : mi += MAX_MIB_SIZE;
88 : }
89 0 : fprintf(mvs, "\n");
90 :
91 0 : fclose(mvs);
92 0 : }
|