1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp9/common/vp9_debugmodes.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +#include <stdio.h> 1.15 + 1.16 +#include "vp9/common/vp9_blockd.h" 1.17 +#include "vp9/common/vp9_onyxc_int.h" 1.18 + 1.19 +static void log_frame_info(VP9_COMMON *cm, const char *str, FILE *f) { 1.20 + fprintf(f, "%s", str); 1.21 + fprintf(f, "(Frame %d, Show:%d, Q:%d): \n", cm->current_video_frame, 1.22 + cm->show_frame, cm->base_qindex); 1.23 +} 1.24 +/* This function dereferences a pointer to the mbmi structure 1.25 + * and uses the passed in member offset to print out the value of an integer 1.26 + * for each mbmi member value in the mi structure. 1.27 + */ 1.28 +static void print_mi_data(VP9_COMMON *cm, FILE *file, char *descriptor, 1.29 + size_t member_offset) { 1.30 + int mi_row; 1.31 + int mi_col; 1.32 + int mi_index = 0; 1.33 + MODE_INFO **mi_8x8 = cm->mi_grid_visible; 1.34 + int rows = cm->mi_rows; 1.35 + int cols = cm->mi_cols; 1.36 + char prefix = descriptor[0]; 1.37 + 1.38 + log_frame_info(cm, descriptor, file); 1.39 + mi_index = 0; 1.40 + for (mi_row = 0; mi_row < rows; mi_row++) { 1.41 + fprintf(file, "%c ", prefix); 1.42 + for (mi_col = 0; mi_col < cols; mi_col++) { 1.43 + fprintf(file, "%2d ", 1.44 + *((int*) ((char *) (&mi_8x8[mi_index]->mbmi) + 1.45 + member_offset))); 1.46 + mi_index++; 1.47 + } 1.48 + fprintf(file, "\n"); 1.49 + mi_index += 8; 1.50 + } 1.51 + fprintf(file, "\n"); 1.52 +} 1.53 +void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, char *file) { 1.54 + int mi_row; 1.55 + int mi_col; 1.56 + int mi_index = 0; 1.57 + FILE *mvs = fopen(file, "a"); 1.58 + MODE_INFO **mi_8x8 = cm->mi_grid_visible; 1.59 + int rows = cm->mi_rows; 1.60 + int cols = cm->mi_cols; 1.61 + 1.62 + print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type)); 1.63 + print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode)); 1.64 + print_mi_data(cm, mvs, "Skips:", offsetof(MB_MODE_INFO, skip_coeff)); 1.65 + print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0])); 1.66 + print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size)); 1.67 + print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode)); 1.68 + 1.69 + log_frame_info(cm, "Vectors ", mvs); 1.70 + for (mi_row = 0; mi_row < rows; mi_row++) { 1.71 + fprintf(mvs, "V "); 1.72 + for (mi_col = 0; mi_col < cols; mi_col++) { 1.73 + fprintf(mvs, "%4d:%4d ", mi_8x8[mi_index]->mbmi.mv[0].as_mv.row, 1.74 + mi_8x8[mi_index]->mbmi.mv[0].as_mv.col); 1.75 + mi_index++; 1.76 + } 1.77 + fprintf(mvs, "\n"); 1.78 + mi_index += 8; 1.79 + } 1.80 + fprintf(mvs, "\n"); 1.81 + 1.82 + fclose(mvs); 1.83 +}