| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Theora
Revision: 15176
Author: giles
Date: 12 Aug 2008 20:27:18
Changes:Rename the bitpacker source files imported from libogg to avoid
confusing simple build systems using both libraries.
| ... | ...@@ -1,78 +0,0 @@ | |
| 1 | /******************************************************************** | |
| 2 | * * | |
| 3 | * THIS FILE IS PART OF THE OggVorbis 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 OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * | |
| 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * | |
| 10 | * * | |
| 11 | ******************************************************************** | |
| 12 | ||
| 13 | function: packing variable sized words into an octet stream | |
| 14 | last mod: $Id: bitwise.c 7675 2004-09-01 00:34:39Z xiphmont $ | |
| 15 | ||
| 16 | ********************************************************************/ | |
| 17 | #if !defined(_bitwise_H) | |
| 18 | # define _bitwise_H (1) | |
| 19 | # include <ogg/ogg.h> | |
| 20 | ||
| 21 | void theorapackB_readinit(oggpack_buffer *_b,unsigned char *_buf,int _bytes); | |
| 22 | /*Read in bits without advancing the bitptr. | |
| 23 | Here we assume 0<=_bits&&_bits<=32.*/ | |
| 24 | static int theorapackB_look(oggpack_buffer *_b,int _bits,long *_ret); | |
| 25 | int theorapackB_look1(oggpack_buffer *_b,long *_ret); | |
| 26 | static void theorapackB_adv(oggpack_buffer *_b,int _bits); | |
| 27 | void theorapackB_adv1(oggpack_buffer *_b); | |
| 28 | /*Here we assume 0<=_bits&&_bits<=32.*/ | |
| 29 | int theorapackB_read(oggpack_buffer *_b,int _bits,long *_ret); | |
| 30 | int theorapackB_read1(oggpack_buffer *_b,long *_ret); | |
| 31 | long theorapackB_bytes(oggpack_buffer *_b); | |
| 32 | long theorapackB_bits(oggpack_buffer *_b); | |
| 33 | unsigned char *theorapackB_get_buffer(oggpack_buffer *_b); | |
| 34 | ||
| 35 | /*These two functions are only used in one place, and declaring them static so | |
| 36 | they can be inlined saves considerable function call overhead.*/ | |
| 37 | ||
| 38 | /*Read in bits without advancing the bitptr. | |
| 39 | Here we assume 0<=_bits&&_bits<=32.*/ | |
| 40 | static int theorapackB_look(oggpack_buffer *_b,int _bits,long *_ret){ | |
| 41 | long ret; | |
| 42 | long m; | |
| 43 | long d; | |
| 44 | m=32-_bits; | |
| 45 | _bits+=_b->endbit; | |
| 46 | d=_b->storage-_b->endbyte; | |
| 47 | if(d<=4){ | |
| 48 | /*Not the main path.*/ | |
| 49 | if(d<=0){ | |
| 50 | *_ret=0L; | |
| 51 | return -(_bits>d*8); | |
| 52 | } | |
| 53 | /*If we have some bits left, but not enough, return the ones we have.*/ | |
| 54 | if(d*8<_bits)_bits=d*8; | |
| 55 | } | |
| 56 | ret=_b->ptr[0]<<24+_b->endbit; | |
| 57 | if(_bits>8){ | |
| 58 | ret|=_b->ptr[1]<<16+_b->endbit; | |
| 59 | if(_bits>16){ | |
| 60 | ret|=_b->ptr[2]<<8+_b->endbit; | |
| 61 | if(_bits>24){ | |
| 62 | ret|=_b->ptr[3]<<_b->endbit; | |
| 63 | if(_bits>32)ret|=_b->ptr[4]>>8-_b->endbit; | |
| 64 | } | |
| 65 | } | |
| 66 | } | |
| 67 | *_ret=((ret&0xFFFFFFFF)>>(m>>1))>>(m+1>>1); | |
| 68 | return 0; | |
| 69 | } | |
| 70 | ||
| 71 | static void theorapackB_adv(oggpack_buffer *_b,int _bits){ | |
| 72 | _bits+=_b->endbit; | |
| 73 | _b->ptr+=_bits>>3; | |
| 74 | _b->endbyte+=_bits>>3; | |
| 75 | _b->endbit=_bits&7; | |
| 76 | } | |
| 77 | ||
| 78 | #endif |
| ... | ...@@ -20,7 +20,7 @@ | |
| 20 | 20 | # define _decint_H (1) |
| 21 | 21 | # include "theora/theoradec.h" |
| 22 | 22 | # include "../internal.h" |
| 23 | # include "bitwise.h" | |
| 23 | # include "bitpack.h" | |
| 24 | 24 | |
| 25 | 25 | typedef struct th_setup_info oc_setup_info; |
| 26 | 26 | typedef struct th_dec_ctx oc_dec_ctx; |
| ... | ...@@ -0,0 +1,121 @@ | |
| 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-2008 * | |
| 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * | |
| 10 | * * | |
| 11 | ******************************************************************** | |
| 12 | ||
| 13 | function: packing variable sized words into an octet stream | |
| 14 | last mod: $Id$ | |
| 15 | ||
| 16 | ********************************************************************/ | |
| 17 | ||
| 18 | /*We're 'MSb' endian; if we write a word but read individual bits, | |
| 19 | then we'll read the MSb first.*/ | |
| 20 | ||
| 21 | #include <string.h> | |
| 22 | #include <stdlib.h> | |
| 23 | #include "bitpack.h" | |
| 24 | ||
| 25 | void theorapackB_readinit(oggpack_buffer *_b,unsigned char *_buf,int _bytes){ | |
| 26 | memset(_b,0,sizeof(*_b)); | |
| 27 | _b->buffer=_b->ptr=_buf; | |
| 28 | _b->storage=_bytes; | |
| 29 | } | |
| 30 | ||
| 31 | int theorapackB_look1(oggpack_buffer *_b,long *_ret){ | |
| 32 | if(_b->endbyte>=_b->storage){ | |
| 33 | *_ret=0L; | |
| 34 | return -1; | |
| 35 | } | |
| 36 | *_ret=(_b->ptr[0]>>7-_b->endbit)&1; | |
| 37 | return 0; | |
| 38 | } | |
| 39 | ||
| 40 | void theorapackB_adv1(oggpack_buffer *_b){ | |
| 41 | if(++(_b->endbit)>7){ | |
| 42 | _b->endbit=0; | |
| 43 | _b->ptr++; | |
| 44 | _b->endbyte++; | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| 48 | /*Here we assume that 0<=_bits&&_bits<=32.*/ | |
| 49 | int theorapackB_read(oggpack_buffer *_b,int _bits,long *_ret){ | |
| 50 | long ret; | |
| 51 | long m; | |
| 52 | long d; | |
| 53 | int fail; | |
| 54 | m=32-_bits; | |
| 55 | _bits+=_b->endbit; | |
| 56 | d=_b->storage-_b->endbyte; | |
| 57 | if(d<=4){ | |
| 58 | /*Not the main path.*/ | |
| 59 | if(d*8<_bits){ | |
| 60 | *_ret=0L; | |
| 61 | fail=-1; | |
| 62 | goto overflow; | |
| 63 | } | |
| 64 | /*Special case to avoid reading _b->ptr[0], which might be past the end of | |
| 65 | the buffer; also skips some useless accounting.*/ | |
| 66 | else if(!_bits){ | |
| 67 | *_ret=0L; | |
| 68 | return 0; | |
| 69 | } | |
| 70 | } | |
| 71 | ret=_b->ptr[0]<<24+_b->endbit; | |
| 72 | if(_bits>8){ | |
| 73 | ret|=_b->ptr[1]<<16+_b->endbit; | |
| 74 | if(_bits>16){ | |
| 75 | ret|=_b->ptr[2]<<8+_b->endbit; | |
| 76 | if(_bits>24){ | |
| 77 | ret|=_b->ptr[3]<<_b->endbit; | |
| 78 | if(_bits>32)ret|=_b->ptr[4]>>8-_b->endbit; | |
| 79 | } | |
| 80 | } | |
| 81 | } | |
| 82 | *_ret=((ret&0xFFFFFFFFUL)>>(m>>1))>>(m+1>>1); | |
| 83 | fail=0; | |
| 84 | overflow: | |
| 85 | _b->ptr+=_bits>>3; | |
| 86 | _b->endbyte+=_bits>>3; | |
| 87 | _b->endbit=_bits&7; | |
| 88 | return fail; | |
| 89 | } | |
| 90 | ||
| 91 | int theorapackB_read1(oggpack_buffer *_b,long *_ret){ | |
| 92 | int fail; | |
| 93 | if(_b->endbyte>=_b->storage){ | |
| 94 | /*Not the main path.*/ | |
| 95 | *_ret=0L; | |
| 96 | fail=-1; | |
| 97 | } | |
| 98 | else{ | |
| 99 | *_ret=(_b->ptr[0]>>7-_b->endbit)&1; | |
| 100 | fail=0; | |
| 101 | } | |
| 102 | _b->endbit++; | |
| 103 | if(_b->endbit>7){ | |
| 104 | _b->endbit=0; | |
| 105 | _b->ptr++; | |
| 106 | _b->endbyte++; | |
| 107 | } | |
| 108 | return fail; | |
| 109 | } | |
| 110 | ||
| 111 | long theorapackB_bytes(oggpack_buffer *_b){ | |
| 112 | return _b->endbyte+(_b->endbit+7>>3); | |
| 113 | } | |
| 114 | ||
| 115 | long theorapackB_bits(oggpack_buffer *_b){ | |
| 116 | return _b->endbyte*8+_b->endbit; | |
| 117 | } | |
| 118 | ||
| 119 | unsigned char *theorapackB_get_buffer(oggpack_buffer *_b){ | |
| 120 | return _b->buffer; | |
| 121 | } |
| ... | ...@@ -75,7 +75,7 @@ | |
| 75 | 75 | |
| 76 | 76 | decoder_sources = \ |
| 77 | 77 | dec/apiwrapper.c \ |
| 78 | dec/bitwise.c \ | |
| 78 | dec/bitpack.c \ | |
| 79 | 79 | dec/decapiwrapper.c \ |
| 80 | 80 | dec/decinfo.c \ |
| 81 | 81 | dec/decode.c \ |
| ... | ...@@ -116,7 +116,7 @@ | |
| 116 | 116 | enc/toplevel_lookup.h \ |
| 117 | 117 | enc/dsp.h \ |
| 118 | 118 | dec/apiwrapper.h \ |
| 119 | dec/bitwise.h \ | |
| 119 | dec/bitpack.h \ | |
| 120 | 120 | dec/dct.h \ |
| 121 | 121 | dec/decint.h \ |
| 122 | 122 | dec/dequant.h \ |
| ... | ...@@ -0,0 +1,78 @@ | |
| 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-2008 * | |
| 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * | |
| 10 | * * | |
| 11 | ******************************************************************** | |
| 12 | ||
| 13 | function: packing variable sized words into an octet stream | |
| 14 | last mod: $Id: bitwise.c 7675 2004-09-01 00:34:39Z xiphmont $ | |
| 15 | ||
| 16 | ********************************************************************/ | |
| 17 | #if !defined(_bitpack_H) | |
| 18 | # define _bitpack_H (1) | |
| 19 | # include <ogg/ogg.h> | |
| 20 | ||
| 21 | void theorapackB_readinit(oggpack_buffer *_b,unsigned char *_buf,int _bytes); | |
| 22 | /*Read in bits without advancing the bitptr. | |
| 23 | Here we assume 0<=_bits&&_bits<=32.*/ | |
| 24 | static int theorapackB_look(oggpack_buffer *_b,int _bits,long *_ret); | |
| 25 | int theorapackB_look1(oggpack_buffer *_b,long *_ret); | |
| 26 | static void theorapackB_adv(oggpack_buffer *_b,int _bits); | |
| 27 | void theorapackB_adv1(oggpack_buffer *_b); | |
| 28 | /*Here we assume 0<=_bits&&_bits<=32.*/ | |
| 29 | int theorapackB_read(oggpack_buffer *_b,int _bits,long *_ret); | |
| 30 | int theorapackB_read1(oggpack_buffer *_b,long *_ret); | |
| 31 | long theorapackB_bytes(oggpack_buffer *_b); | |
| 32 | long theorapackB_bits(oggpack_buffer *_b); | |
| 33 | unsigned char *theorapackB_get_buffer(oggpack_buffer *_b); | |
| 34 | ||
| 35 | /*These two functions are only used in one place, and declaring them static so | |
| 36 | they can be inlined saves considerable function call overhead.*/ | |
| 37 | ||
| 38 | /*Read in bits without advancing the bitptr. | |
| 39 | Here we assume 0<=_bits&&_bits<=32.*/ | |
| 40 | static int theorapackB_look(oggpack_buffer *_b,int _bits,long *_ret){ | |
| 41 | long ret; | |
| 42 | long m; | |
| 43 | long d; | |
| 44 | m=32-_bits; | |
| 45 | _bits+=_b->endbit; | |
| 46 | d=_b->storage-_b->endbyte; | |
| 47 | if(d<=4){ | |
| 48 | /*Not the main path.*/ | |
| 49 | if(d<=0){ | |
| 50 | *_ret=0L; | |
| 51 | return -(_bits>d*8); | |
| 52 | } | |
| 53 | /*If we have some bits left, but not enough, return the ones we have.*/ | |
| 54 | if(d*8<_bits)_bits=d*8; | |
| 55 | } | |
| 56 | ret=_b->ptr[0]<<24+_b->endbit; | |
| 57 | if(_bits>8){ | |
| 58 | ret|=_b->ptr[1]<<16+_b->endbit; | |
| 59 | if(_bits>16){ | |
| 60 | ret|=_b->ptr[2]<<8+_b->endbit; | |
| 61 | if(_bits>24){ | |
| 62 | ret|=_b->ptr[3]<<_b->endbit; | |
| 63 | if(_bits>32)ret|=_b->ptr[4]>>8-_b->endbit; | |
| 64 | } | |
| 65 | } | |
| 66 | } | |
| 67 | *_ret=((ret&0xFFFFFFFF)>>(m>>1))>>(m+1>>1); | |
| 68 | return 0; | |
| 69 | } | |
| 70 | ||
| 71 | static void theorapackB_adv(oggpack_buffer *_b,int _bits){ | |
| 72 | _bits+=_b->endbit; | |
| 73 | _b->ptr+=_bits>>3; | |
| 74 | _b->endbyte+=_bits>>3; | |
| 75 | _b->endbit=_bits&7; | |
| 76 | } | |
| 77 | ||
| 78 | #endif |
| ... | ...@@ -30,7 +30,7 @@ | |
| 30 | 30 | |
| 31 | 31 | decoder_sources = """ |
| 32 | 32 | dec/apiwrapper.c \ |
| 33 | dec/bitwise.c \ | |
| 33 | dec/bitpack.c \ | |
| 34 | 34 | dec/decapiwrapper.c \ |
| 35 | 35 | dec/decinfo.c \ |
| 36 | 36 | dec/decode.c \ |
| ... | ...@@ -1,121 +0,0 @@ | |
| 1 | /******************************************************************** | |
| 2 | * * | |
| 3 | * THIS FILE IS PART OF THE OggVorbis 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 OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * | |
| 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * | |
| 10 | * * | |
| 11 | ******************************************************************** | |
| 12 | ||
| 13 | function: packing variable sized words into an octet stream | |
| 14 | last mod: $Id$ | |
| 15 | ||
| 16 | ********************************************************************/ | |
| 17 | ||
| 18 | /*We're 'MSb' endian; if we write a word but read individual bits, | |
| 19 | then we'll read the MSb first.*/ | |
| 20 | ||
| 21 | #include <string.h> | |
| 22 | #include <stdlib.h> | |
| 23 | #include "bitwise.h" | |
| 24 | ||
| 25 | void theorapackB_readinit(oggpack_buffer *_b,unsigned char *_buf,int _bytes){ | |
| 26 | memset(_b,0,sizeof(*_b)); | |
| 27 | _b->buffer=_b->ptr=_buf; | |
| 28 | _b->storage=_bytes; | |
| 29 | } | |
| 30 | ||
| 31 | int theorapackB_look1(oggpack_buffer *_b,long *_ret){ | |
| 32 | if(_b->endbyte>=_b->storage){ | |
| 33 | *_ret=0L; | |
| 34 | return -1; | |
| 35 | } | |
| 36 | *_ret=(_b->ptr[0]>>7-_b->endbit)&1; | |
| 37 | return 0; | |
| 38 | } | |
| 39 | ||
| 40 | void theorapackB_adv1(oggpack_buffer *_b){ | |
| 41 | if(++(_b->endbit)>7){ | |
| 42 | _b->endbit=0; | |
| 43 | _b->ptr++; | |
| 44 | _b->endbyte++; | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| 48 | /*Here we assume that 0<=_bits&&_bits<=32.*/ | |
| 49 | int theorapackB_read(oggpack_buffer *_b,int _bits,long *_ret){ | |
| 50 | long ret; | |
| 51 | long m; | |
| 52 | long d; | |
| 53 | int fail; | |
| 54 | m=32-_bits; | |
| 55 | _bits+=_b->endbit; | |
| 56 | d=_b->storage-_b->endbyte; | |
| 57 | if(d<=4){ | |
| 58 | /*Not the main path.*/ | |
| 59 | if(d*8<_bits){ | |
| 60 | *_ret=0L; | |
| 61 | fail=-1; | |
| 62 | goto overflow; | |
| 63 | } | |
| 64 | /*Special case to avoid reading _b->ptr[0], which might be past the end of | |
| 65 | the buffer; also skips some useless accounting.*/ | |
| 66 | else if(!_bits){ | |
| 67 | *_ret=0L; | |
| 68 | return 0; | |
| 69 | } | |
| 70 | } | |
| 71 | ret=_b->ptr[0]<<24+_b->endbit; | |
| 72 | if(_bits>8){ | |
| 73 | ret|=_b->ptr[1]<<16+_b->endbit; | |
| 74 | if(_bits>16){ | |
| 75 | ret|=_b->ptr[2]<<8+_b->endbit; | |
| 76 | if(_bits>24){ | |
| 77 | ret|=_b->ptr[3]<<_b->endbit; | |
| 78 | if(_bits>32)ret|=_b->ptr[4]>>8-_b->endbit; | |
| 79 | } | |
| 80 | } | |
| 81 | } | |
| 82 | *_ret=((ret&0xFFFFFFFFUL)>>(m>>1))>>(m+1>>1); | |
| 83 | fail=0; | |
| 84 | overflow: | |
| 85 | _b->ptr+=_bits>>3; | |
| 86 | _b->endbyte+=_bits>>3; | |
| 87 | _b->endbit=_bits&7; | |
| 88 | return fail; | |
| 89 | } | |
| 90 | ||
| 91 | int theorapackB_read1(oggpack_buffer *_b,long *_ret){ | |
| 92 | int fail; | |
| 93 | if(_b->endbyte>=_b->storage){ | |
| 94 | /*Not the main path.*/ | |
| 95 | *_ret=0L; | |
| 96 | fail=-1; | |
| 97 | } | |
| 98 | else{ | |
| 99 | *_ret=(_b->ptr[0]>>7-_b->endbit)&1; | |
| 100 | fail=0; | |
| 101 | } | |
| 102 | _b->endbit++; | |
| 103 | if(_b->endbit>7){ | |
| 104 | _b->endbit=0; | |
| 105 | _b->ptr++; | |
| 106 | _b->endbyte++; | |
| 107 | } | |
| 108 | return fail; | |
| 109 | } | |
| 110 | ||
| 111 | long theorapackB_bytes(oggpack_buffer *_b){ | |
| 112 | return _b->endbyte+(_b->endbit+7>>3); | |
| 113 | } | |
| 114 | ||
| 115 | long theorapackB_bits(oggpack_buffer *_b){ | |
| 116 | return _b->endbyte*8+_b->endbit; | |
| 117 | } | |
| 118 | ||
| 119 | unsigned char *theorapackB_get_buffer(oggpack_buffer *_b){ | |
| 120 | return _b->buffer; | |
| 121 | } |