globals.hpp
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:9k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /* $Id: globals.hpp,v 1.4 2001/04/30 20:46:24 dmackie Exp $ */
  2. /****************************************************************************/
  3. /*   MPEG4 Visual Texture Coding (VTC) Mode Software                        */
  4. /*                                                                          */
  5. /*   This software was jointly developed by the following participants:     */
  6. /*                                                                          */
  7. /*   Single-quant,  multi-quant and flow control                            */
  8. /*   are provided by  Sarnoff Corporation                                   */
  9. /*     Iraj Sodagar   (iraj@sarnoff.com)                                    */
  10. /*     Hung-Ju Lee    (hjlee@sarnoff.com)                                   */
  11. /*     Paul Hatrack   (hatrack@sarnoff.com)                                 */
  12. /*     Shipeng Li     (shipeng@sarnoff.com)                                 */
  13. /*     Bing-Bing Chai (bchai@sarnoff.com)                                   */
  14. /*     B.S. Srinivas  (bsrinivas@sarnoff.com)                               */
  15. /*                                                                          */
  16. /*   Bi-level is provided by Texas Instruments                              */
  17. /*     Jie Liang      (liang@ti.com)                                        */
  18. /*                                                                          */
  19. /*   Shape Coding is provided by  OKI Electric Industry Co., Ltd.           */
  20. /*     Zhixiong Wu    (sgo@hlabs.oki.co.jp)                                 */
  21. /*     Yoshihiro Ueda (yueda@hlabs.oki.co.jp)                               */
  22. /*     Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp)                        */
  23. /*                                                                          */
  24. /*   OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream         */
  25. /*   exchange and bug fixing.                                               */
  26. /*                                                                          */
  27. /*                                                                          */
  28. /* In the course of development of the MPEG-4 standard, this software       */
  29. /* module is an implementation of a part of one or more MPEG-4 tools as     */
  30. /* specified by the MPEG-4 standard.                                        */
  31. /*                                                                          */
  32. /* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use     */
  33. /* of the MPEG-4 standard free license to use this  software module or      */
  34. /* modifications thereof for hardware or software products claiming         */
  35. /* conformance to the MPEG-4 standard.                                      */
  36. /*                                                                          */
  37. /* Those intending to use this software module in hardware or software      */
  38. /* products are advised that use may infringe existing  patents. The        */
  39. /* original developers of this software module and their companies, the     */
  40. /* subsequent editors and their companies, and ISO/IEC have no liability    */
  41. /* and ISO/IEC have no liability for use of this software module or         */
  42. /* modification thereof in an implementation.                               */
  43. /*                                                                          */
  44. /* Permission is granted to MPEG members to use, copy, modify,              */
  45. /* and distribute the software modules ( or portions thereof )              */
  46. /* for standardization activity within ISO/IEC JTC1/SC29/WG11.              */
  47. /*                                                                          */
  48. /* Copyright 1995, 1996, 1997, 1998 ISO/IEC                                 */
  49. /****************************************************************************/
  50. /************************************************************/
  51. /*     Sarnoff Very Low Bit Rate Still Image Coder          */
  52. /*     Copyright 1995, 1996, 1997, 1998 Sarnoff Corporation */
  53. /************************************************************/
  54. #ifndef GLOBALS_H
  55. #define GLOBALS_H
  56. #include "basic.hpp"
  57. #ifdef DEFINE_GLOBALS
  58. #define EXTERN
  59. #else
  60. #define EXTERN  extern
  61. #endif
  62. #ifndef DATA_STRUCT_H
  63. #include "dataStruct.hpp"
  64. #endif /* DATA_STRUCT_H */
  65. #ifndef MSG_H
  66. #include "msg.hpp"
  67. #endif /* MSG_H */
  68. /* main data structure */
  69. EXTERN WVT_CODEC mzte_codec;
  70. /* for displaying state information */
  71. EXTERN Char *mapStateToText[]
  72. #ifdef DEFINE_GLOBALS
  73.  = {"S_DC", "S_INIT", "S_ZTR", "S_ZTR_D", "S_IZ", "S_VZTR", "S_VAL", "S_LINIT",
  74.  "S_LZTR", "S_LZTR_D", "S_LVZTR"}
  75. #endif
  76. ;
  77. /* for displaying Type information */
  78. EXTERN Char *mapTypeToText[]
  79. #ifdef DEFINE_GLOBALS
  80.  =  {"IZ", "VAL", "ZTR", "VZTR", "ZTR_D", "VLEAF", "ZLEAF",
  81.      "UNTYPED"}
  82. #endif
  83. ;
  84. /* for displaying arithmetic probability model information */
  85. EXTERN Char *mapArithModelToText[]
  86. #ifdef DEFINE_GLOBALS
  87. = {"ACM_NONE", "ACM_SKIP", "ACM_ROOT", "ACM_VALZ", "ACM_VALNZ", "ACM_RESID",
  88.   "ACM_DC"}
  89. #endif
  90. ;
  91. /* Maps the state to the arithmetic codeing probability model. */
  92. EXTERN Int stateToProbModel[] 
  93. #ifdef DEFINE_GLOBALS
  94.  = {ACM_ROOT, ACM_VALNZ, ACM_VALZ, ACM_RESID, ACM_RESID, ACM_RESID, ACM_DC}
  95. #endif
  96. ;
  97. /* The filename (sans suffix) where the coefficient info. during 
  98.    the encoding phase is written. */
  99. EXTERN Char *mapFileEnc
  100. #ifdef DEFINE_GLOBALS
  101. ="mapEnc"
  102. #endif
  103. ;
  104. /* The filename (sans suffix) where the coefficient info. during 
  105.    the decoding phase is written. */
  106. EXTERN Char *mapFileDec
  107. #ifdef DEFINE_GLOBALS
  108. ="mapDec"
  109. #endif
  110. ;
  111. /* Variables to keep track of quantization values. Used when calaculating
  112.    number of residual levels */
  113. EXTERN Int *prevQList[3];
  114. EXTERN Int *prevQList2[3];
  115. EXTERN Int *scaleLev[3];
  116. /* Probability model orders for arithmetic coder */
  117. #define AC_MODEL_ZEROTH 0
  118. #define AC_MODEL_FIRST  1
  119. #define AC_MODEL_MIXED  99
  120. /* Some arithmetic functions - be careful about using expressions
  121.    in these as they may be calculated twice.
  122. */
  123. #ifndef ABS
  124. #define ABS(x) (((x)<0) ? -(x) : (x))
  125. #endif
  126. #ifndef MIN
  127. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  128. #endif
  129. #ifndef MAX
  130. #define MAX(a,b) (((a) > (b)) ? (a) : (b))
  131. #endif
  132. /*----- Shorthand for accessing global information -----*/
  133. #define USER_Q(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.quant)
  134. #define ROOT_MAX(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.root_max)
  135. #define VALZ_MAX(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.valz_max)
  136. #define VALNZ_MAX(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.valnz_max)
  137. #define RESID_MAX(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.residual_max)
  138. // hjlee 0901
  139. #define WVTDECOMP_MAX(c,l) 
  140.   (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.wvtDecompMax[l])
  141. #define RESID_MAX(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.residual_max)
  142. #define WVTDECOMP_NUMBITPLANES(c,l) 
  143.   (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.wvtDecompNumBitPlanes[l])
  144. #define WVTDECOMP_RES_NUMBITPLANES(c) 
  145.   (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.wvtDecompResNumBitPlanes)
  146. #define ALL_ZERO(c) (mzte_codec.m_SPlayer[c].SNRlayer.snr_image.allzero)
  147. #define COEFF_VAL(x,y,c) 
  148.   (mzte_codec.m_SPlayer[c].coeffinfo[y][x].quantized_value)
  149. #define COEFF_ORGVAL(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].wvt_coeff)
  150. #define COEFF_RECVAL(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].rec_coeff)
  151. #define COEFF_QSTATE(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].qState)
  152. #define COEFF_STATE(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].state)
  153. #define COEFF_TYPE(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].type)
  154. #define COEFF_SKIP(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].skip)
  155. #define COEFF_MASK(x,y,c) (mzte_codec.m_SPlayer[c].coeffinfo[y][x].mask)
  156. #define snrStartCode (mzte_codec.m_bStartCodeEnable)
  157. #define IS_RESID(x,y,c) (COEFF_STATE(x,y,c)==S_VZTR  || 
  158.  COEFF_STATE(x,y,c)==S_VAL   || 
  159.  COEFF_STATE(x,y,c)==S_LVZTR)
  160. #define IS_LEAF(x,y,c) (COEFF_STATE(x,y,c)==S_LINIT  || 
  161. COEFF_STATE(x,y,c)==S_LZTR   || 
  162. COEFF_STATE(x,y,c)==S_LZTR_D || 
  163. COEFF_STATE(x,y,c)==S_LVZTR)
  164. #define IS_STATE_LEAF(state) ((state)==S_LINIT  || 
  165.       (state)==S_LZTR   || 
  166.       (state)==S_LZTR_D || 
  167.       (state)==S_LVZTR)
  168. /* Do Y, not U or V condition. */
  169. #define NCOL ((mzte_codec.m_iCurSpatialLev==0          
  170.        && (mzte_codec.m_lastWvtDecompInSpaLayer[0][1]<0      
  171.    || mzte_codec.m_lastWvtDecompInSpaLayer[0][2]<0)) 
  172.       ? 1 :  mzte_codec.m_iColors)
  173. #define FIRST_SPA_LEV(numSpa, wvtDecomp, col) 
  174.      ((mzte_codec.m_lastWvtDecompInSpaLayer[0][col]<0) ? 1 : 0)
  175. #endif /* GLOBALS_H */