stats.c
上传用户:aoeyumen
上传日期:2007-01-06
资源大小:3329k
文件大小:6k
源码类别:

DVD

开发平台:

Unix_Linux

  1. /*
  2.  *  stats.c
  3.  *
  4.  *  Copyright (C) Aaron Holtzman <aholtzma@ess.engr.uvic.ca> - Nov 1999
  5.  *
  6.  *  This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
  7.  *
  8.  *  mpeg2dec is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  mpeg2dec is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 
  21.  *
  22.  */
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. #include "mpeg2.h"
  26. #include "mpeg2_internal.h"
  27. #include "debug.h"
  28. #include "stats.h"
  29. char *chroma_format_str[4] =
  30. {
  31. "Invalid Chroma Format",
  32. "4:2:0 Chroma",
  33. "4:2:2 Chroma",
  34. "4:4:4 Chroma"
  35. };
  36. char *picture_structure_str[4] =
  37. {
  38. "Invalid Picture Structure",
  39. "Top field",
  40. "Bottom field",
  41. "Frame Picture"
  42. };
  43. char *picture_coding_type_str[8] = 
  44. {
  45. "Invalid picture type",
  46. "I-type",
  47. "P-type",
  48. "B-type",
  49. "D (very bad)",
  50. "Invalid","Invalid","Invalid"
  51. };
  52. char *aspect_ratio_information_str[8] = 
  53. {
  54. "Invalid Aspect Ratio",
  55. "1:1",
  56. "4:3",
  57. "16:9",
  58. "2.21:1",
  59. "Invalid Aspect Ratio",
  60. "Invalid Aspect Ratio",
  61. "Invalid Aspect Ratio"
  62. };
  63. char *frame_rate_str[16] = 
  64. {
  65. "Invalid frame_rate_code",
  66. "23.976", "24", "25"   , "29.97",
  67. "30"    , "50", "59.94", "60"   ,
  68. "Invalid frame_rate_code", "Invalid frame_rate_code",
  69. "Invalid frame_rate_code", "Invalid frame_rate_code",
  70. "Invalid frame_rate_code", "Invalid frame_rate_code",
  71. "Invalid frame_rate_code"
  72. };
  73. void stats_sequence_header(picture_t *picture)
  74. {
  75. dprintf("(seq) ");
  76. dprintf("%dx%d ",picture->horizontal_size,picture->vertical_size);
  77. dprintf("%s, ",aspect_ratio_information_str[picture->aspect_ratio_information]);
  78. dprintf("%s fps, ",frame_rate_str[picture->frame_rate_code]);
  79. dprintf("%5.0f kbps, ",picture->bit_rate_value * 400.0 / 1000.0);
  80. dprintf("VBV %d kB ",2 * picture->vbv_buffer_size);
  81. dprintf("%s ",picture->constrained_parameters_flag ? ", CP":"");
  82. dprintf("%s ",picture->use_custom_intra_quantizer_matrix ? ", Custom Intra Matrix":"");
  83. dprintf("%s ",picture->use_custom_non_intra_quantizer_matrix ? ", Custom Non-Intra Matrix":"");
  84. dprintf("n");
  85. }
  86. void stats_gop_header(picture_t *picture)
  87. {
  88. dprintf("(gop) ");
  89. dprintf("drop_flag %d, ", picture->drop_flag);
  90. dprintf("timecode %d:%02d:%02d:%02d, ", picture->hour, picture->minute, 
  91. picture->sec, picture->frame);
  92. dprintf("closed_gop %d, ",picture->closed_gop);
  93. dprintf("broken_link=%dn",picture->broken_link);
  94. }
  95. void stats_picture_header(picture_t *picture)
  96. {
  97. dprintf("(picture) %s ",picture_coding_type_str[picture->picture_coding_type]);
  98. dprintf("temporal_reference %d, ",picture->temporal_reference);
  99. dprintf("vbv_delay %dn",picture->vbv_delay);
  100. }
  101. void stats_slice_header(slice_t *slice)
  102. {
  103. dprintf("(slice) ");
  104. dprintf("quantizer_scale_code = %d, ",slice->quantizer_scale_code);
  105. dprintf("quantizer_scale= %d ",slice->quantizer_scale);
  106. dprintf("n");
  107. }
  108. void stats_macroblock(macroblock_t *mb)
  109. {
  110. dprintf("(macroblock) ");
  111. dprintf("cbp = %d ",mb->coded_block_pattern);
  112. dprintf("n");
  113. }
  114. void 
  115. stats_sequence_ext(picture_t *picture)
  116. {
  117. dprintf("(seq_ext) ");
  118. dprintf("progressive_sequence %d, ",picture->progressive_sequence);
  119. dprintf("%sn",chroma_format_str[picture->chroma_format]);
  120. }
  121. void stats_sequence_display_ext(picture_t *picture)
  122. {
  123. dprintf("(seq dsp ext) ");
  124. dprintf("video_format %d, color_description %d",
  125. picture->video_format,picture->color_description);
  126. dprintf("n");
  127. dprintf("(seq dsp ext) ");
  128. dprintf("display_horizontal_size %4d, display_vertical_size %4d",
  129. picture->display_horizontal_size,picture->display_vertical_size);
  130. dprintf("n");
  131. if (picture->color_description)
  132. {
  133. dprintf("(seq dsp ext) ");
  134. dprintf("color_primaries %d, ",picture->color_primaries);
  135. dprintf("xfer_characteristics %d,",picture->transfer_characteristics);
  136. dprintf("matrix_coefficients %d",picture->matrix_coefficients);
  137. dprintf("n");
  138. }
  139. }
  140. void stats_quant_matrix_ext_header(picture_t *picture)
  141. {
  142. #if 0
  143.   if (Verbose_Flag>NO_LAYER)
  144.   {
  145.    dprintf("quant matrix extension (byte %d)n",(pos>>3)-4);
  146.    dprintf("  load_intra_quantizer_matrix=%dn",
  147.       ld->load_intra_quantizer_matrix);
  148.    dprintf("  load_non_intra_quantizer_matrix=%dn",
  149.       ld->load_non_intra_quantizer_matrix);
  150.    dprintf("  load_chroma_intra_quantizer_matrix=%dn",
  151.       ld->load_chroma_intra_quantizer_matrix);
  152.    dprintf("  load_chroma_non_intra_quantizer_matrix=%dn",
  153.       ld->load_chroma_non_intra_quantizer_matrix);
  154.   }
  155. #endif
  156. }
  157. void 
  158. stats_picture_coding_ext_header(picture_t *picture)
  159. {
  160. dprintf("(pic_ext) ");
  161. dprintf("%s",picture_structure_str[picture->picture_structure]);
  162. dprintf("n");
  163. dprintf("(pic_ext) ");
  164. dprintf("forward horizontal  f_code %d,  forward vertical  f_code   %d", 
  165. picture->f_code[0][0], picture->f_code[0][1]);
  166. dprintf("n");
  167. dprintf("(pic_ext) ");
  168. dprintf("backward horizontal f_code %d,  backward_vertical f_code   %d", 
  169. picture->f_code[1][0], picture->f_code[1][1]);
  170. dprintf("n");
  171. dprintf("(pic_ext) ");
  172. dprintf("frame_pred_frame_dct       %d,  concealment_motion_vectors %d",
  173. picture->frame_pred_frame_dct,picture->concealment_motion_vectors);
  174. dprintf("n");
  175. dprintf("(pic_ext) ");
  176. dprintf("progressive_frame          %d,  composite_display_flag     %d",
  177. picture->progressive_frame, picture->composite_display_flag);
  178. dprintf("n");
  179. dprintf("(pic_ext) ");
  180. dprintf("intra_dc_precision %d, q_scale_type  %d,    top_field_first %d",
  181. picture->intra_dc_precision,picture->q_scale_type,picture->top_field_first);
  182. dprintf("n");
  183. dprintf("(pic_ext) ");
  184. dprintf("alternate_scan     %d, intra_vlc_fmt %d, repeat_first_field %d",
  185. picture->alternate_scan,picture->intra_vlc_format,picture->repeat_first_field);
  186. dprintf("n");
  187. }