[svn] / branches / release-0_9_1-fixes / xvidcore / src / bitstream / bitstream.h Repository:
ViewVC logotype

Diff of /branches/release-0_9_1-fixes/xvidcore/src/bitstream/bitstream.h

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

revision 970, Fri Apr 4 22:10:38 2003 UTC revision 971, Fri Apr 4 22:12:07 2003 UTC
# Line 50  Line 50 
50   *  exception also makes it possible to release a modified version which   *  exception also makes it possible to release a modified version which
51   *  carries forward this exception.   *  carries forward this exception.
52   *   *
53   * $Id: bitstream.h,v 1.16 2003-02-09 19:32:52 edgomez Exp $   * $Id: bitstream.h,v 1.16.2.1 2003-04-04 22:12:07 edgomez Exp $
54   *   *
55   ****************************************************************************/   ****************************************************************************/
56    
57  #ifndef _BITSTREAM_H_  #ifndef _BITSTREAM_H_
58  #define _BITSTREAM_H_  #define _BITSTREAM_H_
59    
60    #include <stdio.h>
61    
62  #include "../portab.h"  #include "../portab.h"
63  #include "../decoder.h"  #include "../decoder.h"
64  #include "../encoder.h"  #include "../encoder.h"
# Line 165  Line 167 
167                            uint32_t length)                            uint32_t length)
168  {  {
169          uint32_t tmp;          uint32_t tmp;
170            size_t bitpos;
171            ptr_t adjbitstream = (ptr_t)bitstream;
172    
173          bs->start = bs->tail = (uint32_t *) bitstream;          /*
174             * Start the stream on a uint32_t boundary, by rounding down to the
175             * previous uint32_t and skipping the intervening bytes.
176             */
177            bitpos = ((sizeof(uint32_t)-1) & (size_t)bitstream);
178            adjbitstream = adjbitstream - bitpos;
179            bs->start = bs->tail = (uint32_t *) adjbitstream;
180    
181          tmp = *(uint32_t *) bitstream;          tmp = *bs->start;
182  #ifndef ARCH_IS_BIG_ENDIAN  #ifndef ARCH_IS_BIG_ENDIAN
183          BSWAP(tmp);          BSWAP(tmp);
184  #endif  #endif
185          bs->bufa = tmp;          bs->bufa = tmp;
186    
187          tmp = *((uint32_t *) bitstream + 1);          tmp = *(bs->start + 1);
188  #ifndef ARCH_IS_BIG_ENDIAN  #ifndef ARCH_IS_BIG_ENDIAN
189          BSWAP(tmp);          BSWAP(tmp);
190  #endif  #endif
191          bs->bufb = tmp;          bs->bufb = tmp;
192    
193          bs->buf = 0;          bs->buf = 0;
194          bs->pos = 0;          bs->pos = bs->initpos = bitpos*8;
195          bs->length = length;          bs->length = length;
196  }  }
197    
# Line 208  Line 218 
218          bs->bufb = tmp;          bs->bufb = tmp;
219    
220          bs->buf = 0;          bs->buf = 0;
221          bs->pos = 0;          bs->pos = bs->initpos;
222  }  }
223    
224    
# Line 301  Line 311 
311  static uint32_t __inline  static uint32_t __inline
312  BitstreamPos(const Bitstream * const bs)  BitstreamPos(const Bitstream * const bs)
313  {  {
314          return((uint32_t)(8*((ptr_t)bs->tail - (ptr_t)bs->start) + bs->pos));          return((uint32_t)(8*((ptr_t)bs->tail - (ptr_t)bs->start) + bs->pos - bs->initpos));
315  }  }
316    
317    
# Line 325  Line 335 
335                  len += (bs->pos + 7) / 8;                  len += (bs->pos + 7) / 8;
336          }          }
337    
338            /* initpos is always on a byte boundary */
339            if (bs->initpos)
340                    len -= bs->initpos/8;
341    
342          return len;          return len;
343  }  }
344    

Legend:
Removed from v.970  
changed lines
  Added in v.971

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