dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/utility/bitstream Makefile.am Makefile.in bitbuffer.cc bitbuffer.hh fastbitbuf.hh fastbitbuf.icc membitsread.cc membitsread.hh membitsread.icc

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:45 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/utility/bitstream
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/libvideogfx/libvideogfx/utility/bitstream

Added Files:
	Makefile.am Makefile.in bitbuffer.cc bitbuffer.hh 
	fastbitbuf.hh fastbitbuf.icc membitsread.cc membitsread.hh 
	membitsread.icc 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/utility/bitstream

libvideogfx_utility_bitstream_includedir = \
	$(includedir)/libvideogfx/utility/bitstream

noinst_LTLIBRARIES = libvideogfx-utility-bitstream.la

libvideogfx_utility_bitstream_la_SOURCES = \
	fastbitbuf.hh	\
	fastbitbuf.icc	\
	bitbuffer.hh \
	bitbuffer.cc \
	membitsread.cc	\
	membitsread.hh	\
	membitsread.icc

libvideogfx_utility_bitstream_include_HEADERS = \
	bitbuffer.hh

INCLUDES = \
	-I$(top_srcdir)

.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

--- NEW FILE: membitsread.cc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "config.h"

#include <iostream.h>

#include "libvideogfx/types.hh"

#include "membitsread.hh"


MemBitstreamReader::MemBitstreamReader(const uint8* buffer,uint32 len)
  : d_buffer(0),
    d_bitsleft(0),
    d_ptr(buffer),
    d_endptr(buffer+len)
{
}


--- NEW FILE: fastbitbuf.icc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "config.h"

#include <assert.h>
#include <iostream.h>


inline uint32 MemBitstreamReader::GetBits (int n)
{
  if (n>d_bitsleft)
    Refill();

  uint32 val = d_buffer>>(64-n);
  d_buffer <<= n;
  d_bitsleft -= n;

  return val;
}


inline uint32 MemBitstreamReader::PeekBits(int n)
{
  if (n>d_bitsleft)
    Refill();

  uint32 val = d_buffer>>(64-n);

  return val;
}


inline void   MemBitstreamReader::SkipBits(int nbits)
{
  if (nbits>d_bitsleft)
    Refill();

  d_buffer<<=nbits;
  d_bitsleft-=nbits;
}

inline void   MemBitstreamReader::SkipBitsFast(int nbits)
{
  d_buffer<<=nbits;
  d_bitsleft-=nbits;
}


inline bool   MemBitstreamReader::eof() const
{
  return d_ptr >= d_endptr;
}


inline uint32 MemBitstreamReader::AskBitsLeft() const
{
  return ((d_endptr-d_ptr)<<3) + d_bitsleft;
}

inline void MemBitstreamReader::Refill()
{
#if WORDS_BIGENDIAN
  uint32 val = *((uint32*)d_ptr)++;

  uint64 val64 = val;
  val64 <<= 64-32-d_bitsleft;
  d_buffer |= val64;
  d_bitsleft += 32;
#else

#if CPU_x86
  uint32 val = *((uint32*)d_ptr);
  d_ptr+=4;

  __asm__("bswap %0" : "=r" (val) : "0" (val));

  uint64 val64 = val;
  val64 <<= 64-32-d_bitsleft;
  d_buffer |= val64;
  d_bitsleft += 32;
#else
  int shiftval = 64-8-d_bitsleft;

  while (shiftval>=0)
    {
      uint64 newval = *d_ptr++;
      newval <<= shiftval;
      d_buffer |= newval;
      shiftval  -=8;
   }

  d_bitsleft = 64-8 -shiftval;
#endif
#endif
}

--- NEW FILE: membitsread.hh ---
/********************************************************************************
  libvideogfx/utility/bitstream/membitsread.hh

  purpose:
   Implements bit-access to an externally provided memory buffer.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de

  modifications:
   03/Jul/2000 - Dirk Farin
     - new method: SkipBitsFast()
   20/Jun/2000 - Dirk Farin
     - completely new implementation
   30/Sep/1999 - Dirk Farin
     - integrated from old DVDview into ULib
   26/Dec/1998 - Dirk Farin
     - made most methods inline
     - new method: "AskBitsLeft()"
   23/Dec/1998 - Dirk Farin
     - first implementation, not working yet
 ********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_UTILITY_BITSTREAM_MEMBITSREAD_HH
#define LIBVIDEOGFX_UTILITY_BITSTREAM_MEMBITSREAD_HH


class MemBitstreamReader
{
public:
  MemBitstreamReader(const uint8* buffer,uint32 len);

  inline uint32 GetBits (int nbits);
  inline uint32 PeekBits(int nbits);
  inline void   SkipBits(int nbits);
  inline void   SkipBitsFast(int nbits); /* Use ONLY when you called PeekBits() with at
					    least as many bits before! */

  inline uint32 AskBitsLeft() const; // Return number of bits that have still not been read.

  inline bool   eof() const;       // True iff current cursor position at or behind file end

private:
  uint64 d_buffer;
  uint32 d_bitsleft;

  const uint8* d_ptr;
  const uint8* d_endptr;

  void Refill();
};

#include "membitsread.icc"

#endif

--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.


SHELL = @SHELL@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

DESTDIR =

pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@

top_builddir = ../../..

ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@

NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
LIBTOOL = @LIBTOOL@
LIBVIDEOGFX_BINARY_AGE = @LIBVIDEOGFX_BINARY_AGE@
LIBVIDEOGFX_INTERFACE_AGE = @LIBVIDEOGFX_INTERFACE_AGE@
LIBVIDEOGFX_MAJOR_VERSION = @LIBVIDEOGFX_MAJOR_VERSION@
LIBVIDEOGFX_MICRO_VERSION = @LIBVIDEOGFX_MICRO_VERSION@
LIBVIDEOGFX_MINOR_VERSION = @LIBVIDEOGFX_MINOR_VERSION@
LIBVIDEOGFX_VERSION = @LIBVIDEOGFX_VERSION@
LN_S = @LN_S@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
X_LDFLAGS = @X_LDFLAGS@

libvideogfx_utility_bitstream_includedir =  	$(includedir)/libvideogfx/utility/bitstream


noinst_LTLIBRARIES = libvideogfx-utility-bitstream.la

libvideogfx_utility_bitstream_la_SOURCES =  	fastbitbuf.hh		fastbitbuf.icc		bitbuffer.hh 	bitbuffer.cc 	membitsread.cc		membitsread.hh		membitsread.icc


libvideogfx_utility_bitstream_include_HEADERS =  	bitbuffer.hh


INCLUDES =  	-I$(top_srcdir)

mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../../config.h
CONFIG_CLEAN_FILES = 
LTLIBRARIES =  $(noinst_LTLIBRARIES)


DEFS = @DEFS@ -I. -I$(srcdir) -I../../..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libvideogfx_utility_bitstream_la_LDFLAGS = 
libvideogfx_utility_bitstream_la_LIBADD = 
libvideogfx_utility_bitstream_la_OBJECTS =  bitbuffer.lo membitsread.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS =  $(libvideogfx_utility_bitstream_include_HEADERS)

DIST_COMMON =  Makefile.am Makefile.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = gtar
GZIP_ENV = --best
DEP_FILES =  .deps/bitbuffer.P .deps/membitsread.P
SOURCES = $(libvideogfx_utility_bitstream_la_SOURCES)
OBJECTS = $(libvideogfx_utility_bitstream_la_OBJECTS)

all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .lo .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
	cd $(top_srcdir) && $(AUTOMAKE) --gnu libvideogfx/utility/bitstream/Makefile

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
	cd $(top_builddir) \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status


mostlyclean-noinstLTLIBRARIES:

clean-noinstLTLIBRARIES:
	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)

distclean-noinstLTLIBRARIES:

maintainer-clean-noinstLTLIBRARIES:

.s.o:
	$(COMPILE) -c $<

.S.o:
	$(COMPILE) -c $<

mostlyclean-compile:
	-rm -f *.o core *.core

clean-compile:

distclean-compile:
	-rm -f *.tab.c

maintainer-clean-compile:

.s.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.S.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs

distclean-libtool:

maintainer-clean-libtool:

libvideogfx-utility-bitstream.la: $(libvideogfx_utility_bitstream_la_OBJECTS) $(libvideogfx_utility_bitstream_la_DEPENDENCIES)
	$(CXXLINK)  $(libvideogfx_utility_bitstream_la_LDFLAGS) $(libvideogfx_utility_bitstream_la_OBJECTS) $(libvideogfx_utility_bitstream_la_LIBADD) $(LIBS)
.cc.o:
	$(CXXCOMPILE) -c $<
.cc.lo:
	$(LTCXXCOMPILE) -c $<

install-libvideogfx_utility_bitstream_includeHEADERS: $(libvideogfx_utility_bitstream_include_HEADERS)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(libvideogfx_utility_bitstream_includedir)
	@list='$(libvideogfx_utility_bitstream_include_HEADERS)'; for p in $$list; do \
	  if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
	  echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libvideogfx_utility_bitstream_includedir)/$$p"; \
	  $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libvideogfx_utility_bitstream_includedir)/$$p; \
	done

uninstall-libvideogfx_utility_bitstream_includeHEADERS:
	@$(NORMAL_UNINSTALL)
	list='$(libvideogfx_utility_bitstream_include_HEADERS)'; for p in $$list; do \
	  rm -f $(DESTDIR)$(libvideogfx_utility_bitstream_includedir)/$$p; \
	done

tags: TAGS

ID: $(HEADERS) $(SOURCES) $(LISP)
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	here=`pwd` && cd $(srcdir) \
	  && mkid -f$$here/ID $$unique $(LISP)

TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
	tags=; \
	here=`pwd`; \
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)

mostlyclean-tags:

clean-tags:

distclean-tags:
	-rm -f TAGS ID

maintainer-clean-tags:

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = libvideogfx/utility/bitstream

distdir: $(DISTFILES)
	here=`cd $(top_builddir) && pwd`; \
	top_distdir=`cd $(top_distdir) && pwd`; \
	distdir=`cd $(distdir) && pwd`; \
	cd $(top_srcdir) \
	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu libvideogfx/utility/bitstream/Makefile
	@for file in $(DISTFILES); do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    cp -pr $$d/$$file $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done

DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)

-include $(DEP_FILES)

mostlyclean-depend:

clean-depend:

distclean-depend:
	-rm -rf .deps

maintainer-clean-depend:

%.o: %.c
	@echo '$(COMPILE) -c $<'; \
	$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.c
	@echo '$(LTCOMPILE) -c $<'; \
	$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp

%.o: %.cc
	@echo '$(CXXCOMPILE) -c $<'; \
	$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.cc
	@echo '$(LTCXXCOMPILE) -c $<'; \
	$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am

install-data-am: install-libvideogfx_utility_bitstream_includeHEADERS
install-data: install-data-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libvideogfx_utility_bitstream_includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
	$(mkinstalldirs)  $(DESTDIR)$(libvideogfx_utility_bitstream_includedir)


mostlyclean-generic:

clean-generic:

distclean-generic:
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*

maintainer-clean-generic:
mostlyclean-am:  mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
		mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
		mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am:  clean-noinstLTLIBRARIES clean-compile clean-libtool \
		clean-tags clean-depend clean-generic mostlyclean-am

clean: clean-am

distclean-am:  distclean-noinstLTLIBRARIES distclean-compile \
		distclean-libtool distclean-tags distclean-depend \
		distclean-generic clean-am
	-rm -f libtool

distclean: distclean-am

maintainer-clean-am:  maintainer-clean-noinstLTLIBRARIES \
		maintainer-clean-compile maintainer-clean-libtool \
		maintainer-clean-tags maintainer-clean-depend \
		maintainer-clean-generic distclean-am
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool \
uninstall-libvideogfx_utility_bitstream_includeHEADERS \
install-libvideogfx_utility_bitstream_includeHEADERS tags \
mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
distdir mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean


.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

--- NEW FILE: bitbuffer.hh ---
/********************************************************************************
  $Header: /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/utility/bitstream/bitbuffer.hh,v 1.1 2006-10-03 11:25:43 dslinux_amadeus Exp $

    Memory buffer that can be filled with bit-strings.
 +-------------------------------------------------------------------------------
 | $Log: bitbuffer.hh,v $
 | Revision 1.1  2006-10-03 11:25:43  dslinux_amadeus
 | adding pristine copy of pixil to HEAD so I can branch from it
 |
 | Revision 1.1.1.1  2003/09/10 20:09:24  jasonk
 |
 |
 | Revision 1.2  2001/02/01 17:19:09  farin
 | added WriteBool() method for convenience
 |
 | Revision 1.1  2000/12/14 18:13:46  farin
 | new BitBuffer class for bit-oriented output
 |
 ********************************************************************************
    Copyright (C) 2000 Dirk Farin (see the README for complete list of authors)

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_UTILITY_BITSTREAM_BITBUFFER_HH
#define LIBVIDEOGFX_UTILITY_BITSTREAM_BITBUFFER_HH

#include "libvideogfx/types.hh"


class BitBuffer
{
public:
   BitBuffer();
  ~BitBuffer();

  void WriteBits(uint32 bits,int nBits);       // input has to be right aligned
  void WriteBool(bool b) { WriteBits(b ? 1 : 0 , 1); }
  void WriteBitsMasked(uint32 bits,int nBits);
  void AlignToByte0(); // Fill 0-bits until a byte boundary is reached. 0-7 bits are inserted.

  void Flush(); // Fill 0-bits to next byte boundary and make all data available at the output buffer.
  uint8* AskBuffer() const { return d_buffer; }
  int    AskBufferSize() const { return d_bufferidx; }

private:
  uint8* d_buffer;
  int    d_bufferidx;

  int    d_buffersize;

  uint32 d_tmpbuf;
  int    d_freebits;

  void TmpToBuffer();
  void EnlargeIfFull();
};

#endif

--- NEW FILE: fastbitbuf.hh ---
/********************************************************************************
  libvideogfx/utility/bitstream/fastbitbuf.hh

  purpose:
   Implements very fast bit-access to an externally provided memory buffer.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de

  modifications:
   27/Sep/2000 - Dirk Farin
     - first implementation, based on ideas seen in "mpeg2dec"
 ********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_UTILITY_BITSTREAM_FASTBITBUF_HH
#define LIBVIDEOGFX_UTILITY_BITSTREAM_FASTBITBUF_HH

#include "libvideogfx/types.hh"

#include <iostream.h>

void ShowBits(uint32 bits,int nbits)
{
  for (int i=nbits-1;i>=0;i--)
    {
      if ((1<<i) & bits) cout << '1'; else cout << '0';
    }
}



#define NEEDBITS(bit_buf,bits) bs.LocalFill16Bits(bit_buf,bits)

// remove num valid bits from bit_buf
#define DUMPBITS(bit_buf,bits,num)      \
do {                                    \
    bit_buf <<= (num);                  \
    bits += (num);                      \
} while (0)

// take num bits from the high part of bit_buf and zero extend them
#define UBITS(bit_buf,num) (((uint32)(bit_buf)) >> (32 - (num)))

// take num bits from the high part of bit_buf and sign extend them
#define SBITS(bit_buf,num) (((int32)(bit_buf)) >> (32 - (num)))





class FastBitBuf
{
public:
  FastBitBuf(const uint8* buffer,uint32 len)
    : d_ptr(buffer), d_endptr(buffer+len),
      d_buffer(0), d_freebits(16)
  {
    Fill16Bits();
  }

  inline void MakeLocalCopy(uint32& buf,int& bits) { buf=d_buffer; bits=d_freebits; }
  inline void RestoreFromLocal(uint32 buf,int bits) { d_buffer=buf; d_freebits=bits; }
  inline void LocalFill16Bits(uint32& buf,int& bits)
  {
    if (bits >= 0)
      {
	buf |= ((((int)d_ptr[0])<<8)|d_ptr[1])<<bits;
	d_ptr+=2;
	bits-=16;
      }
  }

  inline uint32 GetNextWord()
  {
    uint32 val = (((int)d_ptr[0])<<8) | d_ptr[1];
    d_ptr+=2;
    return val;
  }

  inline uint32 Peek16BitsMSB()
  {
    return d_buffer;
  }

  inline uint32 PeekBitsFast(int nbits)
  {
    return UBITS(d_buffer,nbits);
  }

  inline void   SkipBitsFast(int nbits)
  {
    Assert(nbits<=16);
    Assert(16-d_freebits >= nbits);

    DUMPBITS(d_buffer,d_freebits,nbits);
  }

  inline void   Fill16Bits()
  {
    if (d_freebits >= 0)
      {
	d_buffer |= ((((int)d_ptr[0])<<8)|d_ptr[1])<<d_freebits;
	d_ptr+=2;
	d_freebits-=16;
      }
  }


  // ---------------- Slow methods for compatibility and non-time critical parts ---------------

  inline uint32 PeekBits(int nbits)
  {
    if(nbits>16)
      {
	uint32 copy_buffer = d_buffer;
	int copy_freebits = d_freebits;
	const uint8 * copy_ptr = d_ptr;

	uint32 bits = GetBits(16)<<(nbits-16);

	bits |= PeekBits(nbits-16);

	d_buffer=copy_buffer;
	d_freebits = copy_freebits;
	d_ptr = copy_ptr;

	return bits;
      }

    Fill16Bits();
    uint32 bits = d_buffer>>(32-nbits);
    return bits;
  }

  inline uint32 GetBits(int nbits)
  {
    if (nbits>16)
      {
	uint32 bits = GetBits(16)<<(nbits-16);
	bits |= GetBits(nbits-16);
	return bits;
      }

    uint32 bits = PeekBits(nbits);
    SkipBits(nbits);
    return bits;
  }

  inline void   SkipBits(int nbits)
  {
    if (nbits>16)
      {
	SkipBits(16);
	SkipBits(nbits-16);
	return;
      }

    Fill16Bits();

    d_buffer<<=nbits;
    d_freebits += nbits;
  }
  
  inline uint32 AskBitsLeft() const // Return number of bits that have still not been read.
  {
    return ((d_endptr-d_ptr)<<3) + 16-d_freebits;
  }

  inline bool   eof() const       // True iff current cursor position at or behind file end
  {
    return d_ptr >= d_endptr;
  }

public:
  uint32 d_buffer;
  int    d_freebits; // number of invalid bits in top 16 bits of buffer

private:
  const uint8* d_ptr;
  const uint8* d_endptr;
};

#endif

--- NEW FILE: bitbuffer.cc ---

#include "libvideogfx/utility/bitstream/bitbuffer.hh"
#include <assert.h>

const int InitialBufferSize = 1000;  // has to be an integer multiple of d_tmpbuf size.
const int BitsPerEntry = 32;
const int BytesPerEntry = BitsPerEntry/8;

BitBuffer::BitBuffer()
{
  d_buffer = new uint8[InitialBufferSize];
  d_buffersize = InitialBufferSize;
  d_bufferidx  = 0;
  d_freebits   = BitsPerEntry;
  d_tmpbuf     = 0;

  assert(BitsPerEntry%8 == 0);
  assert(sizeof(d_tmpbuf)*8==BitsPerEntry);
  assert(InitialBufferSize%sizeof(d_tmpbuf)==0);
}


BitBuffer::~BitBuffer()
{
  delete[] d_buffer;
}


void BitBuffer::WriteBitsMasked(uint32 bits,int nBits)
{
  uint32 mask=1;
  mask<<=nBits;
  mask--;

  WriteBits(bits & mask,nBits);
}


void BitBuffer::WriteBits(uint32 bits,int nBits)
{
  /*
    +------+----------------------+
    |XXXXXX|0000000000000000000000|
    +------+----------------------+
                d_freebits

    +----+------------------------+
    |0000|XXXXXXXXXXXXXXXXXXXXXXXX|
    +----+------------------------+
                   nBits         
   */

  if (d_freebits>=nBits)
    {
      // Neue Bits passen komplett in das aktuelle Feld hinein.

      uint32 aligned = bits;

      int nShiftLeft = d_freebits - nBits;

      if (nShiftLeft>0)
	{
	  aligned <<= nShiftLeft;
	  d_tmpbuf |= aligned;
	  d_freebits = nShiftLeft;
	}
      else
	{
	  d_tmpbuf |= aligned;

          TmpToBuffer();

          d_tmpbuf   = 0;
	  d_freebits = BitsPerEntry;
	}
    }
  else
    {
      // Neue Bits passen nicht mehr komplett in das aktuelle Feld.
      // Sie werden folglich in zwei Teile geteilt.

      uint32 rightpart = bits;   // Der Teil, der noch in das aktuelle Feld passt.
      uint32 leftpart  = bits;   // Der Rest, der in ein neues Feld kommt.

      int nShiftRight = nBits - d_freebits;
      if (nShiftRight != 0) rightpart >>= nShiftRight;

      d_tmpbuf |= rightpart;

      TmpToBuffer();

      int nShiftLeft = BitsPerEntry-nShiftRight;
      leftpart <<= nShiftLeft;
      d_tmpbuf = leftpart;

      d_freebits = nShiftLeft;
    }
}


void BitBuffer::AlignToByte0()
{
  d_freebits -= d_freebits%8;

  if (d_freebits==0)
    {
      TmpToBuffer();
      d_tmpbuf = 0;
      d_freebits = BitsPerEntry;
    }
}


void BitBuffer::Flush()
{
  AlignToByte0();

  EnlargeIfFull();

  assert(d_bufferidx+4 <= d_buffersize);

  while (d_freebits<BitsPerEntry)
    {
      d_buffer[d_bufferidx++] = (d_tmpbuf>>(BitsPerEntry-8));
      d_tmpbuf<<=8;
      d_freebits+=8;
    }

  assert(d_freebits == BitsPerEntry);
}


void BitBuffer::TmpToBuffer()
{
  EnlargeIfFull();

  assert(d_bufferidx+4 <= d_buffersize);
  
#ifdef WORDS_BIGENDIAN
  unsigned char* p = (unsigned char*)(&d_tmpbuf);
  for (int j=0;j<BytesPerEntry;j++)
    d_buffer[d_bufferidx++] = p[j];
#else
  unsigned char* p = (unsigned char*)(&d_tmpbuf);
  for (int j=BytesPerEntry-1;j>=0;j--)
    d_buffer[d_bufferidx++] = p[j];
#endif
}


void BitBuffer::EnlargeIfFull()
{
  if (d_bufferidx == d_buffersize)
    {
      uint8* newbuf = new uint8[d_buffersize*2];
      for (int i=0;i<d_buffersize;i++)
        newbuf[i]=d_buffer[i];
      
      d_buffersize *= 2;

      delete[] d_buffer;
      d_buffer = newbuf;
    }
}

--- NEW FILE: membitsread.icc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "config.h"

#include <assert.h>
#include <iostream.h>


inline uint32 MemBitstreamReader::GetBits (int n)
{
  if (n>d_bitsleft)
    Refill();

  uint32 val = d_buffer>>(64-n);
  d_buffer <<= n;
  d_bitsleft -= n;

  return val;
}


inline uint32 MemBitstreamReader::PeekBits(int n)
{
  if (n>d_bitsleft)
    Refill();

  uint32 val = d_buffer>>(64-n);

  return val;
}


inline void   MemBitstreamReader::SkipBits(int nbits)
{
  if (nbits>d_bitsleft)
    Refill();

  d_buffer<<=nbits;
  d_bitsleft-=nbits;
}

inline void   MemBitstreamReader::SkipBitsFast(int nbits)
{
  d_buffer<<=nbits;
  d_bitsleft-=nbits;
}


inline bool   MemBitstreamReader::eof() const
{
  return d_ptr >= d_endptr;
}


inline uint32 MemBitstreamReader::AskBitsLeft() const
{
  return ((d_endptr-d_ptr)<<3) + d_bitsleft;
}

inline void MemBitstreamReader::Refill()
{
#if WORDS_BIGENDIAN
  uint32 val = *((uint32*)d_ptr)++;

  uint64 val64 = val;
  val64 <<= 64-32-d_bitsleft;
  d_buffer |= val64;
  d_bitsleft += 32;
#else

#if CPU_x86
  uint32 val = *((uint32*)d_ptr);
  d_ptr+=4;

  __asm__("bswap %0" : "=r" (val) : "0" (val));

  uint64 val64 = val;
  val64 <<= 64-32-d_bitsleft;
  d_buffer |= val64;
  d_bitsleft += 32;
#else
  int shiftval = 64-8-d_bitsleft;

  while (shiftval>=0)
    {
      uint64 newval = *d_ptr++;
      newval <<= shiftval;
      d_buffer |= newval;
      shiftval  -=8;
   }

  d_bitsleft = 64-8 -shiftval;
#endif
#endif
}




More information about the dslinux-commit mailing list