vp9_debugmodes.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 ", *((char *)((char *)(mi[0]) + member_offset)));
  34. mi++;
  35. }
  36. fprintf(file, "\n");
  37. mi += 8;
  38. }
  39. fprintf(file, "\n");
  40. }
  41. void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, const char *file) {
  42. int mi_row;
  43. int mi_col;
  44. FILE *mvs = fopen(file, "a");
  45. MODE_INFO **mi = cm->mi_grid_visible;
  46. int rows = cm->mi_rows;
  47. int cols = cm->mi_cols;
  48. print_mi_data(cm, mvs, "Partitions:", offsetof(MODE_INFO, sb_type));
  49. print_mi_data(cm, mvs, "Modes:", offsetof(MODE_INFO, mode));
  50. print_mi_data(cm, mvs, "Ref frame:", offsetof(MODE_INFO, ref_frame[0]));
  51. print_mi_data(cm, mvs, "Transform:", offsetof(MODE_INFO, tx_size));
  52. print_mi_data(cm, mvs, "UV Modes:", offsetof(MODE_INFO, uv_mode));
  53. // output skip infomation.
  54. log_frame_info(cm, "Skips:", mvs);
  55. for (mi_row = 0; mi_row < rows; mi_row++) {
  56. fprintf(mvs, "S ");
  57. for (mi_col = 0; mi_col < cols; mi_col++) {
  58. fprintf(mvs, "%2d ", mi[0]->skip);
  59. mi++;
  60. }
  61. fprintf(mvs, "\n");
  62. mi += 8;
  63. }
  64. fprintf(mvs, "\n");
  65. // output motion vectors.
  66. log_frame_info(cm, "Vectors ", mvs);
  67. mi = cm->mi_grid_visible;
  68. for (mi_row = 0; mi_row < rows; mi_row++) {
  69. fprintf(mvs, "V ");
  70. for (mi_col = 0; mi_col < cols; mi_col++) {
  71. fprintf(mvs, "%4d:%4d ", mi[0]->mv[0].as_mv.row, mi[0]->mv[0].as_mv.col);
  72. mi++;
  73. }
  74. fprintf(mvs, "\n");
  75. mi += 8;
  76. }
  77. fprintf(mvs, "\n");
  78. fclose(mvs);
  79. }