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