blob: 91f33d4e34d1e58d99956bf53845e99b08acd018 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
12#include <stdio.h>
13
14#include "av1/common/blockd.h"
Yunqing Wangd097ec12017-05-12 09:52:59 -070015#include "av1/common/enums.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070016#include "av1/common/onyxc_int.h"
17
Yaowu Xuf883b422016-08-30 14:01:10 -070018static void log_frame_info(AV1_COMMON *cm, const char *str, FILE *f) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070019 fprintf(f, "%s", str);
20 fprintf(f, "(Frame %d, Show:%d, Q:%d): \n", cm->current_video_frame,
21 cm->show_frame, cm->base_qindex);
22}
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 */
Yaowu Xuf883b422016-08-30 14:01:10 -070027static void print_mi_data(AV1_COMMON *cm, FILE *file, const char *descriptor,
Yaowu Xuc27fc142016-08-22 16:08:15 -070028 size_t member_offset) {
29 int mi_row, mi_col;
30 MODE_INFO **mi = cm->mi_grid_visible;
31 int rows = cm->mi_rows;
32 int cols = cm->mi_cols;
33 char prefix = descriptor[0];
34
35 log_frame_info(cm, descriptor, file);
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++) {
Yunqing Wangd097ec12017-05-12 09:52:59 -070039 fprintf(file, "%2d ",
40 *((char *)((char *)(&mi[0]->mbmi) + member_offset)));
Yaowu Xuc27fc142016-08-22 16:08:15 -070041 mi++;
42 }
43 fprintf(file, "\n");
Yunqing Wangd097ec12017-05-12 09:52:59 -070044 mi += MAX_MIB_SIZE;
Yaowu Xuc27fc142016-08-22 16:08:15 -070045 }
46 fprintf(file, "\n");
47}
48
Yaowu Xuf883b422016-08-30 14:01:10 -070049void av1_print_modes_and_motion_vectors(AV1_COMMON *cm, const char *file) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070050 int mi_row;
51 int mi_col;
52 FILE *mvs = fopen(file, "a");
53 MODE_INFO **mi = cm->mi_grid_visible;
54 int rows = cm->mi_rows;
55 int cols = cm->mi_cols;
56
57 print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type));
58 print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode));
59 print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0]));
60 print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size));
61 print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode));
62
63 // output skip infomation.
64 log_frame_info(cm, "Skips:", mvs);
65 for (mi_row = 0; mi_row < rows; mi_row++) {
66 fprintf(mvs, "S ");
67 for (mi_col = 0; mi_col < cols; mi_col++) {
68 fprintf(mvs, "%2d ", mi[0]->mbmi.skip);
69 mi++;
70 }
71 fprintf(mvs, "\n");
Yunqing Wangd097ec12017-05-12 09:52:59 -070072 mi += MAX_MIB_SIZE;
Yaowu Xuc27fc142016-08-22 16:08:15 -070073 }
74 fprintf(mvs, "\n");
75
76 // output motion vectors.
77 log_frame_info(cm, "Vectors ", mvs);
78 mi = cm->mi_grid_visible;
79 for (mi_row = 0; mi_row < rows; mi_row++) {
80 fprintf(mvs, "V ");
81 for (mi_col = 0; mi_col < cols; mi_col++) {
82 fprintf(mvs, "%4d:%4d ", mi[0]->mbmi.mv[0].as_mv.row,
83 mi[0]->mbmi.mv[0].as_mv.col);
84 mi++;
85 }
86 fprintf(mvs, "\n");
Yunqing Wangd097ec12017-05-12 09:52:59 -070087 mi += MAX_MIB_SIZE;
Yaowu Xuc27fc142016-08-22 16:08:15 -070088 }
89 fprintf(mvs, "\n");
90
91 fclose(mvs);
92}