/********************************************************************1* *2* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *3* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *4* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *5* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *6* *7* THE OggTheora SOURCE CODE IS (C) COPYRIGHT 1994-2009 *8* by the Xiph.Org Foundation and contributors *9* https://www.xiph.org/ *10* *11********************************************************************1213function: packing variable sized words into an octet stream1415********************************************************************/16#if !defined(_bitpack_H)17# define _bitpack_H (1)18# include <stddef.h>19# include <limits.h>20# include "internal.h"21222324typedef size_t oc_pb_window;25typedef struct oc_pack_buf oc_pack_buf;26272829/*Custom bitpacker implementations.*/30# if defined(OC_ARM_ASM)31# include "arm/armbits.h"32# endif3334# if !defined(oc_pack_read)35# define oc_pack_read oc_pack_read_c36# endif37# if !defined(oc_pack_read1)38# define oc_pack_read1 oc_pack_read1_c39# endif40# if !defined(oc_huff_token_decode)41# define oc_huff_token_decode oc_huff_token_decode_c42# endif4344# define OC_PB_WINDOW_SIZE ((int)sizeof(oc_pb_window)*CHAR_BIT)45/*This is meant to be a large, positive constant that can still be efficiently46loaded as an immediate (on platforms like ARM, for example).47Even relatively modest values like 100 would work fine.*/48# define OC_LOTS_OF_BITS (0x40000000)49505152struct oc_pack_buf{53const unsigned char *stop;54const unsigned char *ptr;55oc_pb_window window;56int bits;57int eof;58};5960void oc_pack_readinit(oc_pack_buf *_b,unsigned char *_buf,long _bytes);61int oc_pack_look1(oc_pack_buf *_b);62void oc_pack_adv1(oc_pack_buf *_b);63/*Here we assume 0<=_bits&&_bits<=32.*/64long oc_pack_read_c(oc_pack_buf *_b,int _bits);65int oc_pack_read1_c(oc_pack_buf *_b);66/* returns -1 for read beyond EOF, or the number of whole bytes available */67long oc_pack_bytes_left(oc_pack_buf *_b);6869/*These two functions are implemented locally in huffdec.c*/70/*Read in bits without advancing the bitptr.71Here we assume 0<=_bits&&_bits<=32.*/72/*static int oc_pack_look(oc_pack_buf *_b,int _bits);*/73/*static void oc_pack_adv(oc_pack_buf *_b,int _bits);*/7475#endif767778