Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 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 "av1/common/blockd.h" |
| 14 | #include "av1/common/onyxc_int.h" |
| 15 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 16 | static void log_frame_info(AV1_COMMON *cm, const char *str, FILE *f) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 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 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 25 | static void print_mi_data(AV1_COMMON *cm, FILE *file, const char *descriptor, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 26 | size_t member_offset) { |
| 27 | int mi_row, mi_col; |
| 28 | MODE_INFO **mi = cm->mi_grid_visible; |
| 29 | int rows = cm->mi_rows; |
| 30 | int cols = cm->mi_cols; |
| 31 | char prefix = descriptor[0]; |
| 32 | |
| 33 | log_frame_info(cm, descriptor, file); |
| 34 | for (mi_row = 0; mi_row < rows; mi_row++) { |
| 35 | fprintf(file, "%c ", prefix); |
| 36 | for (mi_col = 0; mi_col < cols; mi_col++) { |
| 37 | fprintf(file, "%2d ", *((int *)((char *)(&mi[0]->mbmi) + member_offset))); |
| 38 | mi++; |
| 39 | } |
| 40 | fprintf(file, "\n"); |
| 41 | mi += 8; |
| 42 | } |
| 43 | fprintf(file, "\n"); |
| 44 | } |
| 45 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 46 | void av1_print_modes_and_motion_vectors(AV1_COMMON *cm, const char *file) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 47 | int mi_row; |
| 48 | int mi_col; |
| 49 | FILE *mvs = fopen(file, "a"); |
| 50 | MODE_INFO **mi = cm->mi_grid_visible; |
| 51 | int rows = cm->mi_rows; |
| 52 | int cols = cm->mi_cols; |
| 53 | |
| 54 | print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type)); |
| 55 | print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode)); |
| 56 | print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0])); |
| 57 | print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size)); |
| 58 | print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode)); |
| 59 | |
| 60 | // output skip infomation. |
| 61 | log_frame_info(cm, "Skips:", mvs); |
| 62 | for (mi_row = 0; mi_row < rows; mi_row++) { |
| 63 | fprintf(mvs, "S "); |
| 64 | for (mi_col = 0; mi_col < cols; mi_col++) { |
| 65 | fprintf(mvs, "%2d ", mi[0]->mbmi.skip); |
| 66 | mi++; |
| 67 | } |
| 68 | fprintf(mvs, "\n"); |
| 69 | mi += 8; |
| 70 | } |
| 71 | fprintf(mvs, "\n"); |
| 72 | |
| 73 | // output motion vectors. |
| 74 | log_frame_info(cm, "Vectors ", mvs); |
| 75 | mi = cm->mi_grid_visible; |
| 76 | for (mi_row = 0; mi_row < rows; mi_row++) { |
| 77 | fprintf(mvs, "V "); |
| 78 | for (mi_col = 0; mi_col < cols; mi_col++) { |
| 79 | fprintf(mvs, "%4d:%4d ", mi[0]->mbmi.mv[0].as_mv.row, |
| 80 | mi[0]->mbmi.mv[0].as_mv.col); |
| 81 | mi++; |
| 82 | } |
| 83 | fprintf(mvs, "\n"); |
| 84 | mi += 8; |
| 85 | } |
| 86 | fprintf(mvs, "\n"); |
| 87 | |
| 88 | fclose(mvs); |
| 89 | } |