Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE OggTheora SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
9 * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
10 * *
11 ********************************************************************
13 function: packing variable sized words into an octet stream
14 last mod: $Id: bitwise.c 7675 2004-09-01 00:34:39Z xiphmont $
16 ********************************************************************/
17 #if !defined(_bitpack_H)
18 # define _bitpack_H (1)
19 # include <stddef.h>
20 # include <limits.h>
21 # include "internal.h"
25 typedef size_t oc_pb_window;
26 typedef struct oc_pack_buf oc_pack_buf;
30 /*Custom bitpacker implementations.*/
31 # if defined(OC_ARM_ASM)
32 # include "arm/armbits.h"
33 # endif
35 # if !defined(oc_pack_read)
36 # define oc_pack_read oc_pack_read_c
37 # endif
38 # if !defined(oc_pack_read1)
39 # define oc_pack_read1 oc_pack_read1_c
40 # endif
41 # if !defined(oc_huff_token_decode)
42 # define oc_huff_token_decode oc_huff_token_decode_c
43 # endif
45 # define OC_PB_WINDOW_SIZE ((int)sizeof(oc_pb_window)*CHAR_BIT)
46 /*This is meant to be a large, positive constant that can still be efficiently
47 loaded as an immediate (on platforms like ARM, for example).
48 Even relatively modest values like 100 would work fine.*/
49 # define OC_LOTS_OF_BITS (0x40000000)
53 struct oc_pack_buf{
54 const unsigned char *stop;
55 const unsigned char *ptr;
56 oc_pb_window window;
57 int bits;
58 int eof;
59 };
61 void oc_pack_readinit(oc_pack_buf *_b,unsigned char *_buf,long _bytes);
62 int oc_pack_look1(oc_pack_buf *_b);
63 void oc_pack_adv1(oc_pack_buf *_b);
64 /*Here we assume 0<=_bits&&_bits<=32.*/
65 long oc_pack_read_c(oc_pack_buf *_b,int _bits);
66 int oc_pack_read1_c(oc_pack_buf *_b);
67 /* returns -1 for read beyond EOF, or the number of whole bytes available */
68 long oc_pack_bytes_left(oc_pack_buf *_b);
70 /*These two functions are implemented locally in huffdec.c*/
71 /*Read in bits without advancing the bitptr.
72 Here we assume 0<=_bits&&_bits<=32.*/
73 /*static int oc_pack_look(oc_pack_buf *_b,int _bits);*/
74 /*static void oc_pack_adv(oc_pack_buf *_b,int _bits);*/
76 #endif