资源简介
libogg-1.3.3.tar.gz ,libogg编码器的1.3.3版本的源代码,下载后需要自己编译安装
代码片段和文件信息
/********************************************************************
* *
* THIS FILE IS PART OF THE Ogg CONTAINER 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-2014 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: packing variable sized words into an octet stream
last mod: $Id$
********************************************************************/
/* We‘re ‘LSb‘ endian; if we write a word but read individual bits
then we‘ll read the lsb first */
#include
#include
#include
#include
#define BUFFER_INCREMENT 256
static const unsigned long mask[]=
{0x000000000x000000010x000000030x000000070x0000000f
0x0000001f0x0000003f0x0000007f0x000000ff0x000001ff
0x000003ff0x000007ff0x00000fff0x00001fff0x00003fff
0x00007fff0x0000ffff0x0001ffff0x0003ffff0x0007ffff
0x000fffff0x001fffff0x003fffff0x007fffff0x00ffffff
0x01ffffff0x03ffffff0x07ffffff0x0fffffff0x1fffffff
0x3fffffff0x7fffffff0xffffffff };
static const unsigned int mask8B[]=
{0x000x800xc00xe00xf00xf80xfc0xfe0xff};
void oggpack_writeinit(oggpack_buffer *b){
memset(b0sizeof(*b));
b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
b->buffer[0]=‘\0‘;
b->storage=BUFFER_INCREMENT;
}
void oggpackB_writeinit(oggpack_buffer *b){
oggpack_writeinit(b);
}
int oggpack_writecheck(oggpack_buffer *b){
if(!b->ptr || !b->storage)return -1;
return 0;
}
int oggpackB_writecheck(oggpack_buffer *b){
return oggpack_writecheck(b);
}
void oggpack_writetrunc(oggpack_buffer *blong bits){
long bytes=bits>>3;
if(b->ptr){
bits-=bytes*8;
b->ptr=b->buffer+bytes;
b->endbit=bits;
b->endbyte=bytes;
*b->ptr&=mask[bits];
}
}
void oggpackB_writetrunc(oggpack_buffer *blong bits){
long bytes=bits>>3;
if(b->ptr){
bits-=bytes*8;
b->ptr=b->buffer+bytes;
b->endbit=bits;
b->endbyte=bytes;
*b->ptr&=mask8B[bits];
}
}
/* Takes only up to 32 bits. */
void oggpack_write(oggpack_buffer *bunsigned long valueint bits){
if(bits<0 || bits>32) goto err;
if(b->endbyte>=b->storage-4){
void *ret;
if(!b->ptr)return;
if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
ret=_ogg_realloc(b->bufferb->storage+BUFFER_INCREMENT);
if(!ret) goto err;
b->buffer=ret;
b->storage+=BUFFER_INCREMENT;
b->ptr=b->buffer+b->endbyte;
}
value&=mask[bits];
bits+=b->endbit;
b->ptr[0]|=value<endbit;
if(bi
- 上一篇:程序员英语手册
- 下一篇:xvidcore-1.3.3.源代码
评论
共有 条评论