[cvs] / xvidcore / src / bitstream / bitstream.h Repository:
ViewVC logotype

Diff of /xvidcore/src/bitstream/bitstream.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5, Fri May 3 00:45:10 2002 UTC revision 1.6, Wed Jun 12 20:38:40 2002 UTC
# Line 112  Line 112 
112    
113    
114  // header stuff  // header stuff
115  int BitstreamReadHeaders(Bitstream * bs, DECODER * dec, uint32_t * rounding,  int BitstreamReadHeaders(Bitstream * bs,
116                                                   uint32_t * quant, uint32_t * fcode_forward, uint32_t * fcode_backward, uint32_t * intra_dc_threshold);                                                   DECODER * dec,
117                                                     uint32_t * rounding,
118                                                     uint32_t * quant,
119                                                     uint32_t * fcode_forward,
120                                                     uint32_t * fcode_backward,
121                                                     uint32_t * intra_dc_threshold);
122    
123    
124  void BitstreamWriteVolHeader(Bitstream * const bs,  void BitstreamWriteVolHeader(Bitstream * const bs,
# Line 126  Line 131 
131    
132  /* initialise bitstream structure */  /* initialise bitstream structure */
133    
134  static void __inline BitstreamInit(Bitstream * const bs,  static void __inline
135    BitstreamInit(Bitstream * const bs,
136                                                                     void * const bitstream,                                                                     void * const bitstream,
137                                                                     uint32_t length)                                                                     uint32_t length)
138  {  {
# Line 154  Line 160 
160    
161  /* reset bitstream state */  /* reset bitstream state */
162    
163  static void __inline BitstreamReset(Bitstream * const bs)  static void __inline
164    BitstreamReset(Bitstream * const bs)
165  {  {
166          uint32_t tmp;          uint32_t tmp;
167    
# Line 179  Line 186 
186    
187  /* reads n bits from bitstream without changing the stream pos */  /* reads n bits from bitstream without changing the stream pos */
188    
189  static uint32_t __inline BitstreamShowBits(Bitstream * const bs,  static uint32_t __inline
190    BitstreamShowBits(Bitstream * const bs,
191                                                                                     const uint32_t bits)                                                                                     const uint32_t bits)
192  {  {
193          int nbit = (bits + bs->pos) - 32;          int nbit = (bits + bs->pos) - 32;
194          if (nbit > 0)  
195          {          if (nbit > 0) {
196                  return ((bs->bufa & (0xffffffff >> bs->pos)) << nbit) |                  return ((bs->bufa & (0xffffffff >> bs->pos)) << nbit) | (bs->
197                                  (bs->bufb >> (32 - nbit));                                                                                                                                   bufb >> (32 -
198          }                                                                                                                                                    nbit));
199          else          } else {
         {  
200                  return (bs->bufa & (0xffffffff >> bs->pos)) >> (32 - bs->pos - bits);                  return (bs->bufa & (0xffffffff >> bs->pos)) >> (32 - bs->pos - bits);
201          }          }
202  }  }
# Line 197  Line 204 
204    
205  /* skip n bits forward in bitstream */  /* skip n bits forward in bitstream */
206    
207  static __inline void BitstreamSkip(Bitstream * const bs, const uint32_t bits)  static __inline void
208    BitstreamSkip(Bitstream * const bs,
209                              const uint32_t bits)
210  {  {
211          bs->pos += bits;          bs->pos += bits;
212    
213          if (bs->pos >= 32)          if (bs->pos >= 32) {
         {  
214                  uint32_t tmp;                  uint32_t tmp;
215    
216                  bs->bufa = bs->bufb;                  bs->bufa = bs->bufb;
# Line 219  Line 227 
227    
228  /* move forward to the next byte boundary */  /* move forward to the next byte boundary */
229    
230  static __inline void BitstreamByteAlign(Bitstream * const bs)  static __inline void
231    BitstreamByteAlign(Bitstream * const bs)
232  {  {
233          uint32_t remainder = bs->pos % 8;          uint32_t remainder = bs->pos % 8;
234          if (remainder)  
235          {          if (remainder) {
236                  BitstreamSkip(bs, 8 - remainder);                  BitstreamSkip(bs, 8 - remainder);
237          }          }
238  }  }
# Line 231  Line 240 
240    
241  /* bitstream length (unit bits) */  /* bitstream length (unit bits) */
242    
243  static uint32_t __inline BitstreamPos(const Bitstream * const bs)  static uint32_t __inline
244    BitstreamPos(const Bitstream * const bs)
245  {  {
246      return 8 * ((uint32_t)bs->tail - (uint32_t)bs->start) + bs->pos;      return 8 * ((uint32_t)bs->tail - (uint32_t)bs->start) + bs->pos;
247  }  }
# Line 241  Line 251 
251          NOTE: assumes no futher bitstream functions will be called.          NOTE: assumes no futher bitstream functions will be called.
252   */   */
253    
254  static uint32_t __inline BitstreamLength(Bitstream * const bs)  static uint32_t __inline
255    BitstreamLength(Bitstream * const bs)
256  {  {
257          uint32_t len = (uint32_t) bs->tail - (uint32_t) bs->start;          uint32_t len = (uint32_t) bs->tail - (uint32_t) bs->start;
258    
259      if (bs->pos)          if (bs->pos) {
     {  
260                  uint32_t b = bs->buf;                  uint32_t b = bs->buf;
261    
262  #ifndef ARCH_IS_BIG_ENDIAN  #ifndef ARCH_IS_BIG_ENDIAN
263                  BSWAP(b);                  BSWAP(b);
264  #endif  #endif
# Line 262  Line 273 
273    
274  /* move bitstream position forward by n bits and write out buffer if needed */  /* move bitstream position forward by n bits and write out buffer if needed */
275    
276  static void __inline BitstreamForward(Bitstream * const bs, const uint32_t bits)  static void __inline
277    BitstreamForward(Bitstream * const bs,
278                                     const uint32_t bits)
279  {  {
280      bs->pos += bits;      bs->pos += bits;
281    
282      if (bs->pos >= 32)          if (bs->pos >= 32) {
     {  
283                  uint32_t b = bs->buf;                  uint32_t b = bs->buf;
284    
285  #ifndef ARCH_IS_BIG_ENDIAN  #ifndef ARCH_IS_BIG_ENDIAN
286                  BSWAP(b);                  BSWAP(b);
287  #endif  #endif
# Line 281  Line 294 
294    
295  /* pad bitstream to the next byte boundary */  /* pad bitstream to the next byte boundary */
296    
297  static void __inline BitstreamPad(Bitstream * const bs)  static void __inline
298    BitstreamPad(Bitstream * const bs)
299  {  {
300          uint32_t remainder = bs->pos % 8;          uint32_t remainder = bs->pos % 8;
301    
302      if (remainder)          if (remainder) {
     {  
303                  BitstreamForward(bs, 8 - remainder);                  BitstreamForward(bs, 8 - remainder);
304      }      }
305  }  }
# Line 294  Line 307 
307    
308  /* read n bits from bitstream */  /* read n bits from bitstream */
309    
310  static uint32_t __inline BitstreamGetBits(Bitstream * const bs,  static uint32_t __inline
311    BitstreamGetBits(Bitstream * const bs,
312                                                                                    const uint32_t n)                                                                                    const uint32_t n)
313  {  {
314          uint32_t ret = BitstreamShowBits(bs, n);          uint32_t ret = BitstreamShowBits(bs, n);
315    
316          BitstreamSkip(bs, n);          BitstreamSkip(bs, n);
317          return ret;          return ret;
318  }  }
# Line 305  Line 320 
320    
321  /* read single bit from bitstream */  /* read single bit from bitstream */
322    
323  static uint32_t __inline BitstreamGetBit(Bitstream * const bs)  static uint32_t __inline
324    BitstreamGetBit(Bitstream * const bs)
325  {  {
326          return BitstreamGetBits(bs, 1);          return BitstreamGetBits(bs, 1);
327  }  }
# Line 313  Line 329 
329    
330  /* write single bit to bitstream */  /* write single bit to bitstream */
331    
332  static void __inline BitstreamPutBit(Bitstream * const bs,  static void __inline
333    BitstreamPutBit(Bitstream * const bs,
334                                                                          const uint32_t bit)                                                                          const uint32_t bit)
335  {  {
336      if (bit)      if (bit)
# Line 325  Line 342 
342    
343  /* write n bits to bitstream */  /* write n bits to bitstream */
344    
345  static void __inline BitstreamPutBits(Bitstream * const bs,  static void __inline
346    BitstreamPutBits(Bitstream * const bs,
347                                                                          const uint32_t value,                                                                          const uint32_t value,
348                                                                          const uint32_t size)                                                                          const uint32_t size)
349  {  {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4