[xiph-cvs] cvs commit: w3d bitcoder.h makedepend
Holger Waechtler
holger at xiph.org
Mon Jun 25 00:57:09 PDT 2001
holger 01/06/25 00:57:09
Added: . bitcoder.h makedepend
Log:
Oooops, forgot to add these 2 files ...
Revision Changes Path
1.1 w3d/bitcoder.h
Index: bitcoder.h
===================================================================
#ifndef __BITCODER_H
#define __BITCODER_H
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#if defined(BITCODER)
#define OUTPUT_BIT(coder,bit) bitcoder_write_bit(coder,bit)
#define INPUT_BIT(coder) bitcoder_read_bit(coder)
#define OUTPUT_BIT_DIRECT(coder,bit) bitcoder_write_bit(coder,bit)
#define INPUT_BIT_DIRECT(coder) bitcoder_read_bit(coder)
#define ENTROPY_CODER BitCoderState
#define ENTROPY_ENCODER_INIT(coder,limit) bitcoder_encoder_init(coder,limit)
#define ENTROPY_ENCODER_DONE(coder) bitcoder_encoder_done(coder)
#define ENTROPY_ENCODER_FLUSH(coder) bitcoder_flush(coder)
#define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
bitcoder_decoder_init(coder,bitstream,limit)
#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
#define ENTROPY_CODER_IS_EMPTY(coder) bitcoder_is_empty (coder)
#define ENTROPY_CODER_BITSTREAM(coder) (coder)->bitstream
#endif
typedef struct {
uint32_t bit_count; /* number of valid bits in byte */
uint8_t byte; /* buffer to save bits */
uint32_t byte_count; /* number of bytes written */
uint8_t *bitstream;
uint32_t limit; /* don't write more bytes to bitstream ... */
} BitCoderState;
static inline
void bitcoder_encoder_init (BitCoderState *s, uint32_t limit)
{
s->bit_count = 0;
s->byte = 0;
s->byte_count = 0;
s->bitstream = (uint8_t*) malloc (limit);
s->limit = limit;
}
static inline
void bitcoder_encoder_done (BitCoderState *s)
{
free (s->bitstream);
}
static inline
void bitcoder_decoder_init (BitCoderState *s, uint8_t *bitstream, uint32_t limit)
{
s->bit_count = 0;
s->byte = 0;
s->byte_count = 0;
s->bitstream = bitstream;
s->limit = limit;
}
static inline
uint32_t bitcoder_flush (BitCoderState *s)
{
if (s->bit_count > 0 && s->byte_count < s->limit)
s->bitstream [s->byte_count++] = s->byte << (8 - s->bit_count);
//printf ("%s: %i bytes written.\n", __FUNCTION__, s->byte_count);
return s->byte_count;
}
static inline
int bitcoder_is_empty (BitCoderState *s)
{
if (!s->bitstream || s->byte_count >= s->limit)
return 1;
return 0;
}
static inline
void bitcoder_write_bit (BitCoderState *s, int bit)
{
s->byte <<= 1;
s->byte |= bit & 1;
s->bit_count++;
if (s->bit_count == 8 && s->byte_count < s->limit) {
s->bitstream [s->byte_count++] = s->byte;
s->bit_count = 0;
}
}
static inline
int bitcoder_read_bit (BitCoderState *s)
{
int ret;
if (s->bit_count == 0 && s->byte_count < s->limit) {
if (!s->bitstream)
return 0;
s->byte = s->bitstream [s->byte_count++];
s->bit_count = 8;
}
ret = s->byte >> 7;
s->byte <<= 1;
s->bit_count--;
return ret;
}
static inline
void bit_print (TYPE byte)
{
int bit = 8*sizeof(TYPE);
do {
bit--;
printf ((byte & (1 << bit)) ? "1" : "0");
} while (bit);
printf ("\n");
}
#endif
1.1 w3d/makedepend
Index: makedepend
===================================================================
#!/bin/sh
#
# $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $
#
# Do the equivalent of the 'makedepend' program, but do it right.
#
# Usage:
#
# makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
# [-o object-suffix]
#
# Notes:
#
# The C compiler used can be overridden with the environment
# variable "CC".
#
# The "-v" switch of the "makedepend" program is not supported.
#
#
# This script should
# work on both USG and BSD systems. However, when System V.4 comes out,
# USG users will probably have to change "silent" to "-s" instead of
# "-" (at least, that is what the documentation implies).
#
# $XFree86: xc/config/util/mdepend.cpp,v 3.3.2.3 2001/03/15 21:16:08 tsi Exp $
#
CC="gcc -E -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE "
ilent='-'
TMP=`pwd`/.mdep$$
CPPCMD=${TMP}a
DEPENDLINES=${TMP}b
TMPMAKEFILE=${TMP}c
MAGICLINE=${TMP}d
ARGS=${TMP}e
trap "rm -f ${TMP}*; exit 1" 1 2 15
trap "rm -f ${TMP}*; exit 0" 1 2 13
echo " \c" > $CPPCMD
if [ `wc -c < $CPPCMD` -eq 1 ]
then
c="\c"
n=
else
c=
n="-n"
fi
echo $n "$c" >$ARGS
files=
makefile=
magic_string='# DO NOT DELETE'
objsuffix='.o'
width=78
endmarker=""
verbose=n
append=n
while [ $# != 0 ]
do
if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then
endmarker=""
else
case "$1" in
-D*|-I*|-U*)
echo $n " '$1'$c" >> $ARGS
;;
-g|-O) # ignore so we can just pass $(CFLAGS) in
;;
*)
if [ "$endmarker"x = x ]; then
case "$1" in
-w)
width="$2"
shift
;;
-s)
magic_string="$2"
shift
;;
-f*)
if [ "$1" = "-f-" ]; then
makefile="-"
elif [ "$1" = "-f" ]; then
makefile="$2"
shift
else
echo "$1" | sed 's/^\-f//' >${TMP}arg
makefile="`cat ${TMP}arg`"
rm -f ${TMP}arg
fi
;;
-o)
objsuffix="$2"
shift
;;
--*)
echo "$1" | sed 's/^\-\-//' >${TMP}end
endmarker="`cat ${TMP}end`"
rm -f ${TMP}end
if [ "$endmarker"x = x ]; then
endmarker="--"
fi
;;
-v)
verbose="y"
;;
-a)
append="y"
;;
-cc)
CC="$2"
shift
;;
-*)
echo "Unknown option '$1' ignored" 1>&2
;;
*)
files="$files $1"
;;
esac
fi
;;
esac
fi
shift
done
echo ' $*' >> $ARGS
echo "#!/bin/sh" > $CPPCMD
echo "exec $CC `cat $ARGS`" >> $CPPCMD
chmod +x $CPPCMD
rm $ARGS
case "$makefile" in
'')
if [ -r makefile ]
then
makefile=makefile
elif [ -r Makefile ]
then
makefile=Makefile
else
echo 'no makefile or Makefile found' 1>&2
exit 1
fi
;;
-)
makefile=$TMPMAKEFILE
;;
esac
if [ "$verbose"x = "y"x ]; then
cat $CPPCMD
fi
echo '' > $DEPENDLINES
for i in $files
do
$CPPCMD $i | sed -n "/^#/s;^;$i ;p"
done | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' -e 's|"||g' -e 's| \./| |' | awk '{
if ($1 != $4 && $2 != "#ident" && $2 != "#pragma")
{
ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
print ofile, $4
}
}' | sort -u | awk '
{
newrec = rec " " $2
if ($1 != old1)
{
old1 = $1
if (rec != "")
print rec
rec = $1 ": " $2
}
else if (length (newrec) > '"$width"')
{
print rec
rec = $1 ": " $2
}
else
rec = newrec
}
END {
if (rec != "")
print rec
}' | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES
trap "" 1 2 13 15 # Now we are committed
case "$makefile" in
$TMPMAKEFILE)
;;
*)
rm -f $makefile.bak
cp $makefile $makefile.bak
echo "Appending dependencies to $makefile"
;;
esac
#
# If not -a, append the magic string and a blank line so that
# /^$magic_string/+1,\$d can be used to delete everything from after
# the magic string to the end of the file. Then, append a blank
# line again and then the dependencies.
#
if [ "$append" = "n" ]
then
cat >> $makefile << END_OF_APPEND
$magic_string
END_OF_APPEND
ed $silent $makefile << END_OF_ED_SCRIPT
/^$magic_string/+1,\$d
w
q
END_OF_ED_SCRIPT
echo '' >>$makefile
fi
cat $DEPENDLINES >>$makefile
case "$makefile" in
$TMPMAKEFILE)
cat $TMPMAKEFILE
;;
esac
rm -f ${TMP}*
exit 0
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list