⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codebook.h

📁 OGG文件格式音频数解压缩SDK.现在OGG文件格式在一些游戏开发中使用的比较多.
💻 H
字号:
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
 * by the XIPHOPHORUS Company http://www.xiph.org/                  *
 *                                                                  *
 ********************************************************************

 function: basic shared codebook operations
 last mod: $Id: codebook.h,v 1.13 2002/06/28 22:19:35 xiphmont Exp $

 ********************************************************************/

#ifndef _V_CODEBOOK_H_
#define _V_CODEBOOK_H_

#include <ogg/ogg.h>

/* This structure encapsulates huffman and VQ style encoding books; it
   doesn't do anything specific to either.

   valuelist/quantlist are nonNULL (and q_* significant) only if
   there's entry->value mapping to be done.

   If encode-side mapping must be done (and thus the entry needs to be
   hunted), the auxiliary encode pointer will point to a decision
   tree.  This is true of both VQ and huffman, but is mostly useful
   with VQ.

*/

typedef struct static_codebook{
  ogg_int32_t   dim;            /* codebook dimensions (elements per vector) */
  ogg_int32_t   entries;        /* codebook entries */
  signed char   *lengthlist;     /* codeword lengths in bits */

  /* The below does a linear, single monotonic sequence mapping. */
  ogg_int32_t   q_min;       /* packed 32 bit float; quant value 0 maps to minval */
  ogg_int32_t   q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
  int           q_quant;     /* bits: 0 < quant <= 16 */
  int           q_sequencep; /* bitflag */

  ogg_int32_t  *quantlist;  /* map == 1: (int)(entries^(1/dim)) element column map map == 2: list of dim*entries quantized entry vals */
  int           maptype;        /* 0=none   1=implicitly populated values from map column   2=listed arbitrary values */

} static_codebook;

typedef struct codebook{
  ogg_int32_t dim;           /* codebook dimensions (elements per vector) */
  ogg_int32_t entries;       /* codebook entries */
  ogg_int32_t used_entries;  /* populated codebook entries */

  /* the below are ordered by bitreversed codeword and only
     used entries are populated */
  
  float        *valuelist;  /* list of dim*entries actual entry values */  
  ogg_uint32_t *codelist;   /* list of bitstream codewords for each entry */

  short          *dec_index;  /* only used if sparseness collapsed */
  char         *dec_codelengths;
  ogg_uint32_t *dec_firsttable;
  int           dec_firsttablen;
  int           dec_maxlength;
} codebook;

extern void vorbis_staticbook_clear(static_codebook *b);
extern void vorbis_staticbook_destroy(static_codebook *b);
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
extern void vorbis_book_clear(codebook *b);

extern float *_book_unquantize(const static_codebook *b,int n,int *map);
extern float *_book_logdist(const static_codebook *b,float *vals);
extern float _float32_unpack(ogg_int32_t val);
extern ogg_int32_t   _float32_pack(float val);
extern int  _best(codebook *book, float *a, int step);
extern int _ilog(unsigned int v);
extern ogg_int32_t _book_maptype1_quantvals(const static_codebook *b);

extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul);
extern ogg_int32_t vorbis_book_codeword(codebook *book,int entry);
extern ogg_int32_t vorbis_book_codelen(codebook *book,int entry);



extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);

extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
extern int vorbis_book_errorv(codebook *book, float *a);
extern int vorbis_book_encodev(codebook *book, int best,float *a, 
			       oggpack_buffer *b);

extern ogg_int32_t vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern ogg_int32_t vorbis_book_decodevs_add(codebook *book, float *a, 
				     oggpack_buffer *b,int n);
extern ogg_int32_t vorbis_book_decodev_set(codebook *book, float *a, 
				    oggpack_buffer *b,int n);
extern ogg_int32_t vorbis_book_decodev_add(codebook *book, float *a, 
				    oggpack_buffer *b,int n);
extern ogg_int32_t vorbis_book_decodevv_add(codebook *book, float **a,
				     ogg_int32_t off,int ch, 
				    oggpack_buffer *b,int n);



#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -