vp9_debugmodes.c 2.8 KB

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