debugmodes.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 "blockd.h"
  12. void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols,
  13. int frame) {
  14. int mb_row;
  15. int mb_col;
  16. int mb_index = 0;
  17. FILE *mvs = fopen("mvs.stt", "a");
  18. /* print out the macroblock Y modes */
  19. mb_index = 0;
  20. fprintf(mvs, "Mb Modes for Frame %d\n", frame);
  21. for (mb_row = 0; mb_row < rows; ++mb_row) {
  22. for (mb_col = 0; mb_col < cols; ++mb_col) {
  23. fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);
  24. mb_index++;
  25. }
  26. fprintf(mvs, "\n");
  27. mb_index++;
  28. }
  29. fprintf(mvs, "\n");
  30. mb_index = 0;
  31. fprintf(mvs, "Mb mv ref for Frame %d\n", frame);
  32. for (mb_row = 0; mb_row < rows; ++mb_row) {
  33. for (mb_col = 0; mb_col < cols; ++mb_col) {
  34. fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);
  35. mb_index++;
  36. }
  37. fprintf(mvs, "\n");
  38. mb_index++;
  39. }
  40. fprintf(mvs, "\n");
  41. /* print out the macroblock UV modes */
  42. mb_index = 0;
  43. fprintf(mvs, "UV Modes for Frame %d\n", frame);
  44. for (mb_row = 0; mb_row < rows; ++mb_row) {
  45. for (mb_col = 0; mb_col < cols; ++mb_col) {
  46. fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);
  47. mb_index++;
  48. }
  49. mb_index++;
  50. fprintf(mvs, "\n");
  51. }
  52. fprintf(mvs, "\n");
  53. /* print out the block modes */
  54. fprintf(mvs, "Mbs for Frame %d\n", frame);
  55. {
  56. int b_row;
  57. for (b_row = 0; b_row < 4 * rows; ++b_row) {
  58. int b_col;
  59. int bindex;
  60. for (b_col = 0; b_col < 4 * cols; ++b_col) {
  61. mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
  62. bindex = (b_row & 3) * 4 + (b_col & 3);
  63. if (mi[mb_index].mbmi.mode == B_PRED)
  64. fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode);
  65. else
  66. fprintf(mvs, "xx ");
  67. }
  68. fprintf(mvs, "\n");
  69. }
  70. }
  71. fprintf(mvs, "\n");
  72. /* print out the macroblock mvs */
  73. mb_index = 0;
  74. fprintf(mvs, "MVs for Frame %d\n", frame);
  75. for (mb_row = 0; mb_row < rows; ++mb_row) {
  76. for (mb_col = 0; mb_col < cols; ++mb_col) {
  77. fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv.as_mv.row / 2,
  78. mi[mb_index].mbmi.mv.as_mv.col / 2);
  79. mb_index++;
  80. }
  81. mb_index++;
  82. fprintf(mvs, "\n");
  83. }
  84. fprintf(mvs, "\n");
  85. /* print out the block modes */
  86. fprintf(mvs, "MVs for Frame %d\n", frame);
  87. {
  88. int b_row;
  89. for (b_row = 0; b_row < 4 * rows; ++b_row) {
  90. int b_col;
  91. int bindex;
  92. for (b_col = 0; b_col < 4 * cols; ++b_col) {
  93. mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
  94. bindex = (b_row & 3) * 4 + (b_col & 3);
  95. fprintf(mvs, "%3d:%-3d ", mi[mb_index].bmi[bindex].mv.as_mv.row,
  96. mi[mb_index].bmi[bindex].mv.as_mv.col);
  97. }
  98. fprintf(mvs, "\n");
  99. }
  100. }
  101. fprintf(mvs, "\n");
  102. fclose(mvs);
  103. }