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

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /****************************************************************************/
  2. /*   MPEG4 Visual Texture Coding (VTC) Mode Software                        */
  3. /*                                                                          */
  4. /*   This software was jointly developed by the following participants:     */
  5. /*                                                                          */
  6. /*   Single-quant,  multi-quant and flow control                            */
  7. /*   are provided by  Sarnoff Corporation                                   */
  8. /*     Iraj Sodagar   (iraj@sarnoff.com)                                    */
  9. /*     Hung-Ju Lee    (hjlee@sarnoff.com)                                   */
  10. /*     Paul Hatrack   (hatrack@sarnoff.com)                                 */
  11. /*     Shipeng Li     (shipeng@sarnoff.com)                                 */
  12. /*     Bing-Bing Chai (bchai@sarnoff.com)                                   */
  13. /*     B.S. Srinivas  (bsrinivas@sarnoff.com)                               */
  14. /*                                                                          */
  15. /*   Bi-level is provided by Texas Instruments                              */
  16. /*     Jie Liang      (liang@ti.com)                                        */
  17. /*                                                                          */
  18. /*   Shape Coding is provided by  OKI Electric Industry Co., Ltd.           */
  19. /*     Zhixiong Wu    (sgo@hlabs.oki.co.jp)                                 */
  20. /*     Yoshihiro Ueda (yueda@hlabs.oki.co.jp)                               */
  21. /*     Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp)                        */
  22. /*                                                                          */
  23. /*   OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream         */
  24. /*   exchange and bug fixing.                                               */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* In the course of development of the MPEG-4 standard, this software       */
  28. /* module is an implementation of a part of one or more MPEG-4 tools as     */
  29. /* specified by the MPEG-4 standard.                                        */
  30. /*                                                                          */
  31. /* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use     */
  32. /* of the MPEG-4 standard free license to use this  software module or      */
  33. /* modifications thereof for hardware or software products claiming         */
  34. /* conformance to the MPEG-4 standard.                                      */
  35. /*                                                                          */
  36. /* Those intending to use this software module in hardware or software      */
  37. /* products are advised that use may infringe existing  patents. The        */
  38. /* original developers of this software module and their companies, the     */
  39. /* subsequent editors and their companies, and ISO/IEC have no liability    */
  40. /* and ISO/IEC have no liability for use of this software module or         */
  41. /* modification thereof in an implementation.                               */
  42. /*                                                                          */
  43. /* Permission is granted to MPEG members to use, copy, modify,              */
  44. /* and distribute the software modules ( or portions thereof )              */
  45. /* for standardization activity within ISO/IEC JTC1/SC29/WG11.              */
  46. /*                                                                          */
  47. /* Copyright 1995, 1996, 1997, 1998 ISO/IEC                                 */
  48. /****************************************************************************/
  49. /****************************************************************************/
  50. /*     Texas Instruments Predictive Embedded Zerotree (PEZW) Image Codec    */
  51. /*    Developed by Jie Liang (liang@ti.com)                                */
  52. /*                         */ 
  53. /*     Copyright 1996, 1997, 1998 Texas Instruments                    */
  54. /****************************************************************************/
  55. /****************************************************************************
  56.    File name:         PEZW_ac.h
  57.    Author:            Jie Liang  (liang@ti.com)
  58.    Functions:         header file for adaptive arithmetic coding functions
  59.    Revisions:         This file was adopted from public domain
  60.                       arithmetic coder with changes suited to PEZW coder.
  61. *****************************************************************************/
  62. #ifndef PEZW_AC_HEADER
  63. #define PEZW_AC_HEADER
  64. #include <stdio.h>
  65. typedef struct {
  66.   FILE *fp;
  67.   unsigned char *stream;
  68.   long low;
  69.   long high;
  70.   long fbits;
  71.   int buffer;
  72.   int bits_to_go;
  73.   long total_bits;
  74.   /* buffer management */
  75.   unsigned char *original_stream;
  76.   int space_left;  /* in bytes */
  77. } Ac_encoder;
  78. typedef struct {
  79.   FILE *fp;
  80.   unsigned char *stream;
  81.   long value;
  82.   long low;
  83.   long high;
  84.   int  buffer;
  85.   int bits_to_go;
  86.   int garbage_bits;
  87. } Ac_decoder;
  88. typedef struct {
  89.   int nsym;
  90.   int Max_frequency;
  91. #ifndef MODEL_COUNT_LARGE
  92.   unsigned char *freq;
  93. #else
  94.   int *freq;
  95. #endif
  96.   int *cfreq;
  97.   int adapt;
  98. } Ac_model;
  99. void Ac_encoder_init (Ac_encoder *, unsigned char *, int, int);
  100. void Ac_encoder_done (Ac_encoder *);
  101. void Ac_decoder_open (Ac_decoder *, unsigned char *, int);
  102. void Ac_decoder_init (Ac_decoder *, unsigned char *);
  103. void Ac_decoder_done (Ac_decoder *);
  104. void Ac_model_init (Ac_model *, int, int *, int, int);
  105. void Ac_model_save (Ac_model *, int *);
  106. void Ac_model_done (Ac_model *);
  107. long Ac_encoder_bits (Ac_encoder *);
  108. void Ac_encode_symbol (Ac_encoder *, Ac_model *, int);
  109. int Ac_decode_symbol (Ac_decoder *, Ac_model *);
  110. int getc_buffer (unsigned char **buffer);
  111. void putc_buffer (int x, unsigned char **buffer_curr, 
  112.          unsigned char **buffer_start, int *space_len);
  113. int AC_decoder_buffer_adjust (Ac_decoder *acd);
  114. void AC_free_model (Ac_model *acm);
  115. #endif