Index: Makefile
===================================================================
--- Makefile (nonexistent)
+++ Makefile (revision 5)
@@ -0,0 +1,506 @@
+# Copyright 1992-1996 by Jutta Degener and Carsten Bormann, Technische
+# Universitaet Berlin. See the accompanying file "COPYRIGHT" for
+# details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+
+# Machine- or installation dependent flags you should configure to port
+
+SASR = -DSASR
+######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
+
+# MULHACK = -DUSE_FLOAT_MUL
+######### Define this if your host multiplies floats faster than integers,
+######### e.g. on a SPARCstation.
+
+# FAST = -DFAST
+######### Define together with USE_FLOAT_MUL to enable the GSM library's
+######### approximation option for incorrect, but good-enough results.
+
+# LTP_CUT = -DLTP_CUT
+LTP_CUT =
+######### Define to enable the GSM library's long-term correlation
+######### approximation option---faster, but worse; works for
+######### both integer and floating point multiplications.
+######### This flag is still in the experimental stage.
+
+WAV49 = -DWAV49
+# WAV49 =
+######### Define to enable the GSM library's option to pack GSM frames
+######### in the style used by the WAV #49 format. If you want to write
+######### a tool that produces .WAV files which contain GSM-encoded data,
+######### define this, and read about the GSM_OPT_WAV49 option in the
+######### manual page on gsm_option(3).
+
+# Choose a compiler. The code works both with ANSI and K&R-C.
+# Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to
+# compile without, function prototypes in the header files.
+#
+# You can use the -DSTUPID_COMPILER to circumvent some compilers'
+# static limits regarding the number of subexpressions in a statement.
+
+# CC = cc
+# CCFLAGS = -c -DSTUPID_COMPILER
+
+# CC = /usr/lang/acc
+# CCFLAGS = -c -O
+
+CCFLAGS += -c -O2 -ansi -pedantic -DNeedFunctionPrototypes=1 -Wno-comment
+
+LD = $(CC)
+
+# LD = gcc
+# LDFLAGS =
+
+
+# If your compiler needs additional flags/libraries, regardless of
+# the source compiled, configure them here.
+
+# CCINC = -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include
+######### Includes needed by $(CC)
+
+# LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1
+######### Library paths needed by $(LD)
+
+# LDLIB = -lgcc
+######### Additional libraries needed by $(LD)
+
+
+# Where do you want to install libraries, binaries, a header file
+# and the manual pages?
+#
+# Leave INSTALL_ROOT empty (or just don't execute "make install") to
+# not install gsm and toast outside of this directory.
+
+INSTALL_ROOT =
+
+# Where do you want to install the gsm library, header file, and manpages?
+#
+# Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
+# this directory.
+
+GSM_INSTALL_ROOT = $(INSTALL_ROOT)
+GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
+GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
+GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
+
+
+# Where do you want to install the toast binaries and their manpage?
+#
+# Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
+# of this directory.
+
+TOAST_INSTALL_ROOT = $(INSTALL_ROOT)
+TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
+TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
+
+# Other tools
+
+SHELL = /bin/sh
+LN = ln -sf
+BASENAME = basename
+AR = ar
+ARFLAGS = cr
+RMFLAGS = -f
+FIND = find
+COMPRESS = gzip
+COMPRESSFLAGS =
+# RANLIB = true
+RANLIB = ranlib
+
+#
+# You shouldn't have to configure below this line if you're porting.
+#
+
+
+# Local Directories
+
+ROOT = .
+ADDTST = $(ROOT)/add-test
+TST = $(ROOT)/tst
+MAN = $(ROOT)/man
+BIN = $(ROOT)/bin
+SRC = $(ROOT)/src
+LIB = $(ROOT)/lib
+TLS = $(ROOT)/tls
+INC = $(ROOT)/inc
+
+# Flags
+
+# DEBUG = -DNDEBUG
+######### Remove -DNDEBUG to enable assertions.
+
+CFLAGS = $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \
+ $(WAV49) $(CCINC) -I$(INC)
+######### It's $(CC) $(CFLAGS)
+
+LFLAGS = $(LDFLAGS) $(LDINC)
+######### It's $(LD) $(LFLAGS)
+
+
+# Targets
+
+LIBGSM = $(LIB)/libgsm.a
+LIBGSMSO = $(LIB)/libgsm.so
+
+TOAST = $(BIN)/toast
+UNTOAST = $(BIN)/untoast
+TCAT = $(BIN)/tcat
+
+# Headers
+
+GSM_HEADERS = $(INC)/gsm.h
+
+HEADERS = $(INC)/proto.h \
+ $(INC)/unproto.h \
+ $(INC)/config.h \
+ $(INC)/private.h \
+ $(INC)/gsm.h \
+ $(INC)/toast.h \
+ $(TLS)/taste.h
+
+# Sources
+
+GSM_SOURCES = $(SRC)/add.c \
+ $(SRC)/code.c \
+ $(SRC)/debug.c \
+ $(SRC)/decode.c \
+ $(SRC)/long_term.c \
+ $(SRC)/lpc.c \
+ $(SRC)/preprocess.c \
+ $(SRC)/rpe.c \
+ $(SRC)/gsm_destroy.c \
+ $(SRC)/gsm_decode.c \
+ $(SRC)/gsm_encode.c \
+ $(SRC)/gsm_explode.c \
+ $(SRC)/gsm_implode.c \
+ $(SRC)/gsm_create.c \
+ $(SRC)/gsm_print.c \
+ $(SRC)/gsm_option.c \
+ $(SRC)/short_term.c \
+ $(SRC)/table.c
+
+TOAST_SOURCES = $(SRC)/toast.c \
+ $(SRC)/toast_lin.c \
+ $(SRC)/toast_ulaw.c \
+ $(SRC)/toast_alaw.c \
+ $(SRC)/toast_audio.c
+
+SOURCES = $(GSM_SOURCES) \
+ $(TOAST_SOURCES) \
+ $(ADDTST)/add_test.c \
+ $(TLS)/sour.c \
+ $(TLS)/ginger.c \
+ $(TLS)/sour1.dta \
+ $(TLS)/sour2.dta \
+ $(TLS)/bitter.c \
+ $(TLS)/bitter.dta \
+ $(TLS)/taste.c \
+ $(TLS)/sweet.c \
+ $(TST)/cod2lin.c \
+ $(TST)/cod2txt.c \
+ $(TST)/gsm2cod.c \
+ $(TST)/lin2cod.c \
+ $(TST)/lin2txt.c
+
+# Object files
+
+GSM_OBJECTS = $(SRC)/add.o \
+ $(SRC)/code.o \
+ $(SRC)/debug.o \
+ $(SRC)/decode.o \
+ $(SRC)/long_term.o \
+ $(SRC)/lpc.o \
+ $(SRC)/preprocess.o \
+ $(SRC)/rpe.o \
+ $(SRC)/gsm_destroy.o \
+ $(SRC)/gsm_decode.o \
+ $(SRC)/gsm_encode.o \
+ $(SRC)/gsm_explode.o \
+ $(SRC)/gsm_implode.o \
+ $(SRC)/gsm_create.o \
+ $(SRC)/gsm_print.o \
+ $(SRC)/gsm_option.o \
+ $(SRC)/short_term.o \
+ $(SRC)/table.o
+
+TOAST_OBJECTS = $(SRC)/toast.o \
+ $(SRC)/toast_lin.o \
+ $(SRC)/toast_ulaw.o \
+ $(SRC)/toast_alaw.o \
+ $(SRC)/toast_audio.o
+
+OBJECTS = $(GSM_OBJECTS) $(TOAST_OBJECTS)
+
+# Manuals
+
+GSM_MANUALS = $(MAN)/gsm.3 \
+ $(MAN)/gsm_explode.3 \
+ $(MAN)/gsm_option.3 \
+ $(MAN)/gsm_print.3
+
+TOAST_MANUALS = $(MAN)/toast.1
+
+MANUALS = $(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1
+
+# Other stuff in the distribution
+
+STUFF = ChangeLog \
+ INSTALL \
+ MACHINES \
+ MANIFEST \
+ Makefile \
+ README \
+ $(ADDTST)/add_test.dta \
+ $(TLS)/bitter.dta \
+ $(TST)/run
+
+
+# Install targets
+
+GSM_INSTALL_TARGETS = \
+ $(GSM_INSTALL_LIB)/libgsm.a \
+ $(GSM_INSTALL_LIB)/libgsm.so \
+ $(GSM_INSTALL_INC)/gsm.h \
+ $(GSM_INSTALL_MAN)/gsm.3 \
+ $(GSM_INSTALL_MAN)/gsm_explode.3 \
+ $(GSM_INSTALL_MAN)/gsm_option.3 \
+ $(GSM_INSTALL_MAN)/gsm_print.3
+
+TOAST_INSTALL_TARGETS = \
+ $(TOAST_INSTALL_BIN)/toast \
+ $(TOAST_INSTALL_BIN)/tcat \
+ $(TOAST_INSTALL_BIN)/untoast \
+ $(TOAST_INSTALL_MAN)/toast.1
+
+
+# Default rules
+
+.c.o:
+ $(CC) $(CFLAGS) $?
+ @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
+
+# Target rules
+
+all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
+ @-echo $(ROOT): Done.
+
+tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
+ @-echo tst: Done.
+
+addtst: $(ADDTST)/add $(ADDTST)/add_test.dta
+ $(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
+ @-echo addtst: Done.
+
+misc: $(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger \
+ $(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
+ @-echo misc: Done.
+
+install: toastinstall gsminstall
+ @-echo install: Done.
+
+
+# The basic API: libgsm
+
+$(LIBGSM): $(LIB) $(GSM_OBJECTS)
+ -rm $(RMFLAGS) $(LIBGSM)
+ $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
+ $(RANLIB) $(LIBGSM)
+
+$(LIBGSMSO): $(LIB) $(GSM_OBJECTS)
+ $(LD) -shared -Wl,-soname,libgsm.so.1 $(LDSOFLAGS) -o $@.1.0.22 $(GSM_OBJECTS)
+ $(LN) libgsm.so.1.0.22 $(LIBGSMSO).1
+ $(LN) libgsm.so.1.0.22 $(LIBGSMSO)
+
+# Toast, Untoast and Tcat -- the compress-like frontends to gsm.
+
+$(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSMSO)
+ $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
+
+$(UNTOAST): $(BIN) $(TOAST)
+ -rm $(RMFLAGS) $(UNTOAST)
+ ( cd $(BIN) ; $(LN) toast untoast )
+
+$(TCAT): $(BIN) $(TOAST)
+ -rm $(RMFLAGS) $(TCAT)
+ ( cd $(BIN) ; $(LN) toast tcat )
+
+
+# The local bin and lib directories
+
+$(BIN):
+ if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi
+
+$(LIB):
+ if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi
+
+
+# Installation
+
+gsminstall:
+ -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
+ make $(GSM_INSTALL_TARGETS) ; \
+ fi
+
+toastinstall:
+ -if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then \
+ make $(TOAST_INSTALL_TARGETS); \
+ fi
+
+gsmuninstall:
+ -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
+ rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \
+ fi
+
+toastuninstall:
+ -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \
+ rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
+ fi
+
+$(TOAST_INSTALL_BIN)/toast: $(TOAST)
+ -rm $(RMFLAGS) $@
+ cp $(TOAST) $@
+ chmod 755 $@
+
+$(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
+ -rm $(RMFLAGS) $@
+ $(LN) $? $@
+
+$(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
+ -rm $(RMFLAGS) $@
+ $(LN) $? $@
+
+$(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM)
+ -rm $(RMFLAGS) $@
+ cp $? $@
+ chmod 444 $@
+
+$(GSM_INSTALL_LIB)/libgsm.so: $(LIBGSMSO)
+ -rm $(RMFLAGS) $@ $@.1 $@.1.0.22
+ cp $?.1.0.22 $@.1.0.22
+ chmod 755 $@.1.0.22
+ $(LN) libgsm.so.1.0.22 $@
+ $(LN) libgsm.so.1.0.22 $@.1
+
+
+# Distribution
+
+dist: gsm-1.0.tar.gz
+ @echo dist: Done.
+
+$(ROOT)/gsm-1.0.tar.gz: $(STUFF) $(SOURCES) $(HEADERS) $(MANUALS)
+ ( cd $(ROOT)/..; \
+ tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST \
+ | sed '/^#/d'` \
+ ) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.gz
+
+# Clean
+
+uninstall: toastuninstall gsmuninstall
+ @-echo uninstall: Done.
+
+semi-clean:
+ -rm $(RMFLAGS) */*.o \
+ $(TST)/lin2cod $(TST)/lin2txt \
+ $(TST)/cod2lin $(TST)/cod2txt \
+ $(TST)/gsm2cod \
+ $(TST)/*.*.*
+ -$(FIND) . \( -name core -o -name foo \) \
+ -print | xargs rm $(RMFLAGS)
+
+clean: semi-clean
+ -rm $(RMFLAGS) $(LIBGSM) $(LIBGSMSO)* $(ADDTST)/add \
+ $(TOAST) $(TCAT) $(UNTOAST) \
+ $(ROOT)/gsm-1.0.tar.gz
+
+
+# Two tools that helped me generate gsm_encode.c and gsm_decode.c,
+# but aren't generally needed to port this.
+
+$(TLS)/sweet: $(TLS)/sweet.o $(TLS)/taste.o
+ $(LD) $(LFLAGS) -o $(TLS)/sweet \
+ $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
+
+$(TLS)/bitter: $(TLS)/bitter.o $(TLS)/taste.o
+ $(LD) $(LFLAGS) -o $(TLS)/bitter \
+ $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
+
+# A version of the same family that Jeff Chilton used to implement
+# the WAV #49 GSM format.
+
+$(TLS)/ginger: $(TLS)/ginger.o $(TLS)/taste.o
+ $(LD) $(LFLAGS) -o $(TLS)/ginger \
+ $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
+
+$(TLS)/sour: $(TLS)/sour.o $(TLS)/taste.o
+ $(LD) $(LFLAGS) -o $(TLS)/sour \
+ $(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
+
+# Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
+# basic arithmetic functions work as intended.
+
+$(ADDTST)/add: $(ADDTST)/add_test.o
+ $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
+
+
+# Various conversion programs between linear, text, .gsm and the code
+# format used by the tests we ran (.cod). We paid for the test data,
+# so I guess we can't just provide them with this package. Still,
+# if you happen to have them lying around, here's the code.
+#
+# You can use gsm2cod | cod2txt independently to look at what's
+# coded inside the compressed frames, although this shouldn't be
+# hard to roll on your own using the gsm_print() function from
+# the API.
+
+
+$(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run
+ ( cd $(TST); ./run )
+
+$(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM) $(LIBGSMSO)
+ $(LD) $(LFLAGS) -o $(TST)/lin2txt \
+ $(TST)/lin2txt.o $(LIBGSM) $(LIBGSMSO) $(LDLIB)
+
+$(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM) $(LIBGSMSO)
+ $(LD) $(LFLAGS) -o $(TST)/lin2cod \
+ $(TST)/lin2cod.o $(LIBGSM) $(LIBGSMSO) $(LDLIB)
+
+$(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM) $(LIBGSMSO)
+ $(LD) $(LFLAGS) -o $(TST)/gsm2cod \
+ $(TST)/gsm2cod.o $(LIBGSM) $(LIBGSMSO) $(LDLIB)
+
+$(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM) $(LIBGSMSO)
+ $(LD) $(LFLAGS) -o $(TST)/cod2txt \
+ $(TST)/cod2txt.o $(LIBGSM) $(LIBGSMSO) $(LDLIB)
+
+$(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM) $(LIBGSMSO)
+ $(LD) $(LFLAGS) -o $(TST)/cod2lin \
+ $(TST)/cod2lin.o $(LIBGSM) $(LIBGSMSO) $(LDLIB)
Index: man/gsm_option.3
===================================================================
--- man/gsm_option.3 (nonexistent)
+++ man/gsm_option.3 (revision 5)
@@ -0,0 +1,183 @@
+.\"
+.\" Copyright 1992-1995 by Jutta Degener and Carsten Bormann, Technische
+.\" Universitaet Berlin. See the accompanying file "COPYRIGHT" for
+.\" details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+.\"
+.PU
+.TH GSM_OPTION 3
+.SH NAME
+gsm_option \(em customizing the GSM 06.10 implementation
+.SH SYNOPSIS
+#include "gsm.h"
+.PP
+int gsm_option(handle, option, valueP);
+.br
+gsm handle;
+.br
+int option;
+.br
+int * valueP;
+.SH "DESCRIPTION"
+The gsm library is an implementation of the final draft GSM 06.10
+standard for full-rate speech transcoding, a lossy
+speech compression algorithm.
+.PP
+The gsm_option() function can be used to set and query various
+options or flags that are not needed for regular GSM 06.10 encoding
+or decoding, but might be of interest in special cases.
+.PP
+The second argument to gsm_option specifies what parameter
+should be changed or queried.
+The third argument is either a null pointer, in which case
+the current value of that parameter is returned;
+or it is a pointer to an integer containing the value
+you want to set, in which case the previous value will
+be returned.
+.PP
+The following options are defined:
+.PP
+.I GSM_OPT_VERBOSE
+Verbosity level.
+.br
+.in +5
+This option is only supported if the library was compiled
+with debugging turned on, and may be used by developers of
+compression algorithms to aid debugging.
+.br
+The verbosity level can be changed at any time during encoding or decoding.
+.in -5
+.sp
+.PP
+.I GSM_OPT_FAST
+Faster compression algorithm.
+.br
+.in +5
+This implementation offers a not strictly standard-compliant, but
+faster compression algorithm that is compatible with the regular
+method and does not noticably degrade audio quality.
+.br
+The value passed to
+.br
+.nf
+ gsm_option(handle, GSM_OPT_FAST, & value)
+.fi
+.br
+functions as a boolean flag; if it is zero, the regular algorithm
+will be used, if not, the faster version will be used.
+.br
+The availability of this option depends on the hardware used;
+if it is not available, gsm_option will return -1 on an attempt
+to set or query it.
+.br
+This option can be set any time during encoding or decoding.
+.in -5
+.ne 5
+.sp
+.PP
+.I GSM_OPT_LTP_CUT
+Enable, disable, or query the LTP cut-off optimization.
+.br
+.in +5
+During encoding, the search for the long-term correlation
+lag forms the bottleneck of the algorithm.
+The ltp-cut option enables an approximation that disregards most
+of the samples for purposes of finding that correlation,
+and hence speeds up the encoding at a noticable loss in quality.
+.br
+The value passed to
+.br
+.nf
+ gsm_option(handle, GSM_OPT_LTP_CUT, & value)
+.fi
+.br
+turns the optimization on if nonzero, and off if zero.
+.br
+This option can be set any time during encoding
+or decoding; it will only affect the encoding pass, not
+the decoding.
+.sp
+.PP
+.I GSM_OPT_WAV49
+WAV-style byte ordering.
+.br
+.in +5
+A WAV file of type #49 contains GSM 06.10-encoded frames.
+Unfortunately, the framing and code ordering of the WAV version
+are incompatible with the native ones of this GSM 06.10 library.
+The GSM_OPT_WAV49 option turns on a different packing
+algorithm that produces alternating frames of 32 and 33 bytes
+(or makes it consume alternating frames of 33 and 32 bytes, note
+the opposite order of the two numbers) which, when concatenated,
+can be used in the body of a WAV #49 frame.
+It is up to the user program to write a WAV header, if any;
+neither the library itself nor the toast program produce
+complete WAV files.
+.br
+The value passed to
+.br
+.nf
+ gsm_option(handle, GSM_OPT_WAV49, & value)
+.fi
+.br
+functions as a boolean flag; if it is zero, the library's native
+framing algorithm will be used, if nonzero, WAV-type packing is in effect.
+.br
+This option should be used before any frames are encoded.
+Whether or not it is supported at all depends on a
+compile-time switch, WAV49.
+Both option and compile time switch are new to the library
+as of patchlevel 9, and are considerably less tested than the
+well-worn rest of the it.
+.br
+Thanks to Jeff Chilton for the detective work and first free
+implementation of this version of the GSM 06.10 encoding.
+.sp
+.PP
+.I GSM_OPT_FRAME_CHAIN
+Query or set the chaining byte.
+.br
+.in +5
+Between the two frames of a WAV-style encoding, the GSM 06.10 library
+must keep track of one half-byte that is technically part of the first
+frame, but will be written as the first four bits of the second.
+This half-byte are the lowest four bits of the value returned by,
+and optionally set by,
+.br
+.nf
+ gsm_option(handle, GSM_OPT_FRAME_CHAIN, & value)
+.fi
+.br
+This option can be queried and set at any time.
+.sp
+.PP
+.I GSM_OPT_FRAME_INDEX
+Query or set the current frame's index in a format's
+alternating list of frames.
+.br
+.in +5
+The WAV #49 framing uses two alternating types of frames.
+Which type the next GSM-coded frame belongs to can be queried, or,
+when decoding, announced, using
+.br
+.nf
+ gsm_option(handle, GSM_OPT_FRAME_INDEX, & value)
+.fi
+.br
+For WAV-style framing, the value should be 0 or 1; the first frame
+of an encoding has an index of 0.
+At library initialization, the index is set to zero.
+.br
+The frame index can be queried and set at any time.
+Used in combination with the
+.IR GSM_OPT_FRAME_CHAIN ,
+option, it can be used to position on arbitrary GSM frames
+within a format like WAV #49 (not accounting for the lost
+internal GSM state).
+.in -5
+.SH "RETURN VALUE"
+gsm_option() returns -1 if an option is not supported, the
+previous value of the option otherwise.
+.SH BUGS
+Please direct bug reports to jutta@pobox.com and cabo@tzi.org.
+.SH "SEE ALSO"
+toast(1), gsm(3), gsm_explode(3), gsm_print(3)
Index: man
===================================================================
--- man (nonexistent)
+++ man (revision 5)
Property changes on: man
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: src/code.c
===================================================================
--- src/code.c (nonexistent)
+++ src/code.c (revision 5)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
+ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/code.c,v 1.3 1996/07/02 09:59:05 jutta Exp $ */
+
+#include "config.h"
+
+#ifdef HAS_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAS_STRING_H
+#include <string.h>
+#else
+# include "proto.h"
+ extern char * memcpy P((char *, char *, int));
+#endif
+
+#include "private.h"
+#include "gsm.h"
+#include "proto.h"
+
+/*
+ * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER
+ */
+
+void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),
+
+ struct gsm_state * S,
+
+ word * s, /* [0..159] samples IN */
+
+/*
+ * The RPE-LTD coder works on a frame by frame basis. The length of
+ * the frame is equal to 160 samples. Some computations are done
+ * once per frame to produce at the output of the coder the
+ * LARc[1..8] parameters which are the coded LAR coefficients and
+ * also to realize the inverse filtering operation for the entire
+ * frame (160 samples of signal d[0..159]). These parts produce at
+ * the output of the coder:
+ */
+
+ word * LARc, /* [0..7] LAR coefficients OUT */
+
+/*
+ * Procedure 4.2.11 to 4.2.18 are to be executed four times per
+ * frame. That means once for each sub-segment RPE-LTP analysis of
+ * 40 samples. These parts produce at the output of the coder:
+ */
+
+ word * Nc, /* [0..3] LTP lag OUT */
+ word * bc, /* [0..3] coded LTP gain OUT */
+ word * Mc, /* [0..3] RPE grid selection OUT */
+ word * xmaxc,/* [0..3] Coded maximum amplitude OUT */
+ word * xMc /* [13*4] normalized RPE samples OUT */
+)
+{
+ int k;
+ word * dp = S->dp0 + 120; /* [ -120...-1 ] */
+ word * dpp = dp; /* [ 0...39 ] */
+
+ word so[160];
+
+ Gsm_Preprocess (S, s, so);
+ Gsm_LPC_Analysis (S, so, LARc);
+ Gsm_Short_Term_Analysis_Filter (S, LARc, so);
+
+ for (k = 0; k <= 3; k++, xMc += 13) {
+
+ Gsm_Long_Term_Predictor ( S,
+ so+k*40, /* d [0..39] IN */
+ dp, /* dp [-120..-1] IN */
+ S->e + 5, /* e [0..39] OUT */
+ dpp, /* dpp [0..39] OUT */
+ Nc++,
+ bc++);
+
+ Gsm_RPE_Encoding ( S,
+ S->e + 5,/* e ][0..39][ IN/OUT */
+ xmaxc++, Mc++, xMc );
+ /*
+ * Gsm_Update_of_reconstructed_short_time_residual_signal
+ * ( dpp, S->e + 5, dp );
+ */
+
+ { register int i;
+ register longword ltmp;
+ for (i = 0; i <= 39; i++)
+ dp[ i ] = GSM_ADD( S->e[5 + i], dpp[i] );
+ }
+ dp += 40;
+ dpp += 40;
+
+ }
+ (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
+ 120 * sizeof(*S->dp0) );
+}
Index: src/toast.c
===================================================================
--- src/toast.c (nonexistent)
+++ src/toast.c (revision 5)
@@ -0,0 +1,797 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
+ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/toast.c,v 1.8 1996/07/02 10:41:04 jutta Exp $ */
+
+#include "toast.h"
+
+/* toast -- lossy sound compression using the gsm library.
+ */
+
+char * progname;
+
+int f_decode = 0; /* decode rather than encode (-d) */
+int f_cat = 0; /* write to stdout; implies -p (-c) */
+int f_force = 0; /* don't ask about replacements (-f) */
+int f_precious = 0; /* avoid deletion of original (-p) */
+int f_fast = 0; /* use faster fpt algorithm (-F) */
+int f_verbose = 0; /* debugging (-V) */
+int f_ltp_cut = 0; /* LTP cut-off margin (-C) */
+
+struct stat instat; /* stat (inname) */
+
+FILE *in, *out;
+char *inname, *outname;
+
+/*
+ * The function (*output)() writes a frame of 160 samples given as
+ * 160 signed 16 bit values (gsm_signals) to <out>.
+ * The function (*input)() reads one such frame from <in>.
+ * The function (*init_output)() begins output (e.g. writes a header).,
+ * The function (*init_input)() begins input (e.g. skips a header).
+ *
+ * There are different versions of input, output, init_input and init_output
+ * for different formats understood by toast; which ones are used
+ * depends on the command line arguments and, in their absence, the
+ * filename; the fallback is #defined in toast.h
+ *
+ * The specific implementations of input, output, init_input and init_output
+ * for a format `foo' live in toast_foo.c.
+ */
+
+int (*output ) P((gsm_signal *)),
+ (*input ) P((gsm_signal *));
+int (*init_input) P((void)),
+ (*init_output) P((void));
+
+static int generic_init P0() { return 0; } /* NOP */
+
+struct fmtdesc {
+
+ char * name, * longname, * suffix;
+
+ int (* init_input ) P((void)),
+ (* init_output) P((void));
+
+ int (* input ) P((gsm_signal * )),
+ (* output) P((gsm_signal * ));
+
+} f_audio = {
+ "audio",
+ "8 kHz, 8 bit u-law encoding with Sun audio header", ".au",
+ audio_init_input,
+ audio_init_output,
+ ulaw_input,
+ ulaw_output
+}, f_ulaw = {
+ "u-law", "plain 8 kHz, 8 bit u-law encoding", ".u",
+ generic_init,
+ generic_init,
+ ulaw_input,
+ ulaw_output
+
+}, f_alaw = {
+ "A-law", "8 kHz, 8 bit A-law encoding", ".A",
+ generic_init,
+ generic_init,
+ alaw_input,
+ alaw_output
+
+}, f_linear = {
+ "linear",
+ "16 bit (13 significant) signed 8 kHz signal", ".l",
+ generic_init,
+ generic_init,
+ linear_input,
+ linear_output
+};
+
+struct fmtdesc * alldescs[] = {
+ &f_audio,
+ &f_alaw,
+ &f_ulaw,
+ &f_linear,
+ (struct fmtdesc *)NULL
+};
+
+#define DEFAULT_FORMAT f_ulaw /* default audio format, others */
+ /* are: f_alaw,f_audio,f_linear */
+struct fmtdesc * f_format = 0;
+
+/*
+ * basename + suffix of a pathname
+ */
+static char * endname P1((name), char * name)
+{
+ if (name) {
+ char * s = strrchr(name, '/');
+ if (s && s[1]) name = s + 1;
+ }
+ return name;
+
+}
+
+/*
+ * Try to figure out what we're supposed to do from the argv[0], if
+ * any, and set the parameters accordingly.
+ */
+static void parse_argv0 P1((av0), char * av0 )
+{
+ int l;
+
+ progname = av0 = endname(av0 ? av0 : "toast");
+
+ /* If the name starts with `un', we want to decode, not code.
+ * If the name ends in `cat', we want to write to stdout,
+ * and decode as well.
+ */
+
+ if (!strncmp(av0, "un", 2)) f_decode = 1;
+ if ( (l = strlen(av0)) >= 3 /* strlen("cat") */
+ && !strcmp( av0 + l - 3, "cat" )) f_cat = f_decode = 1;
+}
+
+
+/*
+ * Check whether the name (possibly generated by appending
+ * .gsm to something else) is short enough for this system.
+ */
+static int length_okay P1((name), char * name)
+{
+ long max_filename_length = 0;
+ char * end;
+
+ /* If our _pathname_ is too long, we'll usually not be
+ * able to open the file at all -- don't worry about that.
+ *
+ * But if the _filename_ is too long, there is danger of
+ * silent truncation on some systems, which results
+ * in the target replacing the source!
+ */
+
+ if (!name) return 0;
+ end = endname(name);
+
+#ifdef NAME_MAX
+ max_filename_length = NAME_MAX;
+#else
+#ifdef _PC_NAME_MAX
+#ifdef USE_PATHCONF
+ { char * s, tmp;
+
+ /* s = dirname(name)
+ */
+ if ((s = end) > name) {
+ if (s > name + 1) s--;
+ tmp = s;
+ *s = 0;
+ }
+
+ errno = 0;
+ max_filename_length = pathconf(s > name ? name : ".",
+ _PC_NAME_MAX);
+ if (max_filename_length == -1 && errno) {
+ perror( s > name ? name : "." );
+ fprintf(stderr,
+ "%s: cannot get dynamic filename length limit for %s.\n",
+ progname, s > name ? name : ".");
+ return 0;
+ }
+ if (s > name) *s = tmp;
+ }
+#endif /* USE_PATHCONF */
+#endif /* _PC_NAME_MAX */
+#endif /* !NAME_MAX */
+
+ if (max_filename_length > 0 && strlen(end) > max_filename_length) {
+ fprintf(stderr,
+ "%s: filename \"%s\" is too long (maximum is %ld)\n",
+ progname, endname(name), max_filename_length );
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Return a pointer the suffix of a string, if any.
+ * A suffix alone has no suffix, an empty suffix can not be had.
+ */
+static char * suffix P2((name, suf), char *name, char * suf)
+{
+ size_t nlen = strlen(name);
+ size_t slen = strlen(suf);
+
+ if (!slen || nlen <= slen) return (char *)0;
+ name += nlen - slen;
+ return memcmp(name, suf, slen) ? (char *)0 : name;
+}
+
+
+static void catch_signals P1((fun), SIGHANDLER_T (*fun) ())
+{
+#ifdef SIGHUP
+ signal( SIGHUP, fun );
+#endif
+#ifdef SIGINT
+ signal( SIGINT, fun );
+#endif
+#ifdef SIGPIPE
+ signal( SIGPIPE, fun );
+#endif
+#ifdef SIGTERM
+ signal( SIGTERM, fun );
+#endif
+#ifdef SIGXFSZ
+ signal( SIGXFSZ, fun );
+#endif
+}
+
+static SIGHANDLER_T onintr P0()
+{
+ char * tmp = outname;
+
+#ifdef HAS_SYSV_SIGNALS
+ catch_signals( SIG_IGN );
+#endif
+
+ outname = (char *)0;
+ if (tmp) (void)unlink(tmp);
+
+ exit(1);
+}
+
+/*
+ * Allocate some memory and complain if it fails.
+ */
+static char * emalloc P1((len), size_t len)
+{
+ char * s;
+ if (!(s = malloc(len))) {
+ fprintf(stderr, "%s: failed to malloc %d bytes -- abort\n",
+ progname, (int)len);
+ onintr();
+ exit(1);
+ }
+ return s;
+}
+
+static char* normalname P3((name, want, cut), char *name, char *want,char *cut)
+{
+ size_t maxlen;
+ char * s, * p;
+
+ p = (char *)0;
+ if (!name) return p;
+
+ maxlen = strlen(name) + 1 + strlen(want) + strlen(cut);
+ p = strcpy(emalloc(maxlen), name);
+
+ if ((s = suffix(p, cut)) != 0) strcpy(s, want);
+ else if (*want && !suffix(p, want)) strcat(p, want);
+
+ return p;
+}
+
+/*
+ * Generate a `plain' (non-encoded) name from a given name.
+ */
+static char * plainname P1((name), char *name)
+{
+ return normalname(name, "", SUFFIX_TOASTED );
+}
+
+/*
+ * Generate a `code' name from a given name.
+ */
+static char * codename P1((name), char *name)
+{
+ return normalname( name, SUFFIX_TOASTED, "" );
+}
+
+/*
+ * If we're supposed to ask (fileno (stderr) is a tty, and f_force not
+ * set), ask the user whether to overwrite a file or not.
+ */
+static int ok_to_replace P1(( name ), char * name)
+{
+ int reply, c;
+
+ if (f_force) return 1; /* YES, do replace */
+ if (!isatty(fileno(stderr))) return 0; /* NO, don't replace */
+
+ fprintf(stderr,
+ "%s already exists; do you wish to overwrite %s (y or n)? ",
+ name, name);
+ fflush(stderr);
+
+ for (c = reply = getchar(); c != '\n' && c != EOF; c = getchar()) ;
+ if (reply == 'y') return 1;
+
+ fprintf(stderr, "\tnot overwritten\n");
+ return 0;
+}
+
+static void update_mode P0()
+{
+ if (!instat.st_nlink) return; /* couldn't stat in */
+
+#ifdef HAS_FCHMOD
+ if (fchmod(fileno(out), instat.st_mode & 07777)) {
+ perror(outname);
+ fprintf(stderr, "%s: could not change file mode of \"%s\"\n",
+ progname, outname);
+ }
+#else
+#ifdef HAS_CHMOD
+ if (outname && chmod(outname, instat.st_mode & 07777)) {
+ perror(outname);
+ fprintf(stderr, "%s: could not change file mode of \"%s\"\n",
+ progname, outname);
+ }
+#endif /* HAS_CHMOD */
+#endif /* HAS_FCHMOD */
+}
+
+static void update_own P0()
+{
+ if (!instat.st_nlink) return; /* couldn't stat in */
+#ifdef HAS_FCHOWN
+ (void)fchown(fileno(out), instat.st_uid, instat.st_gid);
+#else
+#ifdef HAS_CHOWN
+ (void)chown(outname, instat.st_uid, instat.st_gid);
+#endif /* HAS_CHOWN */
+#endif /* HAS_FCHOWN */
+}
+
+static void update_times P0()
+{
+ if (!instat.st_nlink) return; /* couldn't stat in */
+
+#ifdef HAS_UTIMES
+ if (outname) {
+ struct timeval tv[2];
+
+ tv[0].tv_sec = instat.st_atime;
+ tv[1].tv_sec = instat.st_mtime;
+ tv[0].tv_usec = tv[1].tv_usec = 0;
+ (void) utimes(outname, tv);
+ }
+#else
+#ifdef HAS_UTIME
+
+ if (outname) {
+
+#ifdef HAS_UTIMBUF
+ struct utimbuf ut;
+
+ ut.actime = instat.st_atime;
+ ut.modtime = instat.st_mtime;
+
+# ifdef HAS_UTIMEUSEC
+ ut.acusec = instat.st_ausec;
+ ut.modusec = instat.st_musec;
+# endif /* HAS_UTIMEUSEC */
+
+ (void) utime(outname, &ut);
+
+#else /* UTIMBUF */
+
+ time_t ut[2];
+
+ ut[0] = instat.st_atime;
+ ut[1] = instat.st_mtime;
+
+ (void) utime(outname, ut);
+
+#endif /* UTIMBUF */
+ }
+#endif /* HAS_UTIME */
+#endif /* HAS_UTIMES */
+}
+
+
+static int okay_as_input P3((name,f,st), char* name, FILE* f, struct stat * st)
+{
+# ifdef HAS_FSTAT
+ if (fstat(fileno(f), st) < 0)
+# else
+ if (stat(name, st) < 0)
+# endif
+ {
+ perror(name);
+ fprintf(stderr, "%s: cannot stat \"%s\"\n", progname, name);
+ return 0;
+ }
+
+ if (!S_ISREG(st->st_mode)) {
+ fprintf(stderr,
+ "%s: \"%s\" is not a regular file -- unchanged.\n",
+ progname, name);
+ return 0;
+ }
+ if (st->st_nlink > 1 && !f_cat && !f_precious) {
+ fprintf(stderr,
+ "%s: \"%s\" has %d other link%s -- unchanged.\n",
+ progname, name, (int)(st->st_nlink - 1),
+ "s" + (st->st_nlink <= 2));
+ return 0;
+ }
+ return 1;
+}
+
+static void prepare_io P1(( desc), struct fmtdesc * desc)
+{
+ output = desc->output;
+ input = desc->input;
+
+ init_input = desc->init_input;
+ init_output = desc->init_output;
+}
+
+static struct fmtdesc * grok_format P1((name), char * name)
+{
+ char * c;
+ struct fmtdesc ** f;
+
+ if (name) {
+ c = plainname(name);
+
+ for (f = alldescs; *f; f++) {
+ if ( (*f)->suffix
+ && *(*f)->suffix
+ && suffix(c, (*f)->suffix)) {
+
+ free(c);
+ return *f;
+ }
+ }
+
+ free(c);
+ }
+ return (struct fmtdesc *)0;
+}
+
+static int open_input P2((name, st), char * name, struct stat * st)
+{
+ struct fmtdesc * f = f_format;
+
+ st->st_nlink = 0; /* indicates `undefined' value */
+ if (!name) {
+ inname = (char *)NULL;
+ in = stdin;
+#ifdef HAS__FSETMODE
+ _fsetmode(in, "b");
+#endif
+ }
+ else {
+ if (f_decode) inname = codename(name);
+ else {
+ if (!f_cat && suffix(name, SUFFIX_TOASTED)) {
+ fprintf(stderr,
+ "%s: %s already has \"%s\" suffix -- unchanged.\n",
+ progname, name, SUFFIX_TOASTED );
+ return 0;
+ }
+ inname = strcpy(emalloc(strlen(name)+1), name);
+ }
+ if (!(in = fopen(inname, READ))) {
+ perror(inname); /* not guaranteed to be valid here */
+ fprintf(stderr, "%s: cannot open \"%s\" for reading\n",
+ progname, inname);
+ return 0;
+ }
+ if (!okay_as_input(inname, in, st)) return 0;
+ if (!f) f = grok_format(inname);
+ }
+ prepare_io( f ? f : & DEFAULT_FORMAT );
+ return 1;
+}
+
+static int open_output P1((name), char *name)
+{
+ if (!name || f_cat) {
+ out = stdout;
+ outname = (char *)NULL;
+#ifdef HAS__FSETMODE
+ _fsetmode(out, "b");
+#endif
+ }
+ else {
+ int outfd = -1;
+ char * o;
+
+ o = (*(f_decode ? plainname : codename))(name);
+ if (!length_okay(o)) return 0;
+ if ((outfd = open(o, O_WRITE_EXCL, 0666)) >= 0)
+ out = (FILE *)fdopen(outfd, WRITE);
+ else if (errno != EEXIST) out = (FILE *)NULL;
+ else if (ok_to_replace(o)) out = fopen(o, WRITE);
+ else return 0;
+
+ if (!out) {
+ perror(o);
+ fprintf(stderr,
+ "%s: can't open \"%s\" for writing\n",
+ progname, o);
+ if (outfd >= 0) (void)close(outfd);
+ return 0;
+ }
+
+ outname = o;
+ }
+ return 1;
+}
+
+static int process_encode P0()
+{
+ gsm r;
+ gsm_signal s[ 160 ];
+ gsm_frame d;
+
+ int cc;
+
+ if (!(r = gsm_create())) {
+ perror(progname);
+ return -1;
+ }
+ (void)gsm_option(r, GSM_OPT_FAST, &f_fast);
+ (void)gsm_option(r, GSM_OPT_VERBOSE, &f_verbose);
+ (void)gsm_option(r, GSM_OPT_LTP_CUT, &f_ltp_cut);
+
+ while ((cc = (*input)(s)) > 0) {
+ if (cc < sizeof(s) / sizeof(*s))
+ memset((char *)(s+cc), 0, sizeof(s)-(cc * sizeof(*s)));
+ gsm_encode(r, s, d);
+ if (fwrite((char *)d, sizeof(d), 1, out) != 1) {
+ perror(outname ? outname : "stdout");
+ fprintf(stderr, "%s: error writing to %s\n",
+ progname, outname ? outname : "stdout");
+ gsm_destroy(r);
+ return -1;
+ }
+ }
+ if (cc < 0) {
+ perror(inname ? inname : "stdin");
+ fprintf(stderr, "%s: error reading from %s\n",
+ progname, inname ? inname : "stdin");
+ gsm_destroy(r);
+ return -1;
+ }
+ gsm_destroy(r);
+
+ return 0;
+}
+
+static int process_decode P0()
+{
+ gsm r;
+ gsm_frame s;
+ gsm_signal d[ 160 ];
+
+ int cc;
+
+ if (!(r = gsm_create())) { /* malloc failed */
+ perror(progname);
+ return -1;
+ }
+ (void)gsm_option(r, GSM_OPT_FAST, &f_fast);
+ (void)gsm_option(r, GSM_OPT_VERBOSE, &f_verbose);
+
+ while ((cc = fread(s, 1, sizeof(s), in)) > 0) {
+
+ if (cc != sizeof(s)) {
+ if (cc >= 0) fprintf(stderr,
+ "%s: incomplete frame (%d byte%s missing) from %s\n",
+ progname, (int)(sizeof(s) - cc),
+ "s" + (sizeof(s) - cc == 1),
+ inname ? inname : "stdin" );
+ gsm_destroy(r);
+ errno = 0;
+ return -1;
+ }
+ if (gsm_decode(r, s, d)) {
+ fprintf(stderr, "%s: bad frame in %s\n",
+ progname, inname ? inname : "stdin");
+ gsm_destroy(r);
+ errno = 0;
+ return -1;
+ }
+
+ if ((*output)(d) < 0) {
+ perror(outname);
+ fprintf(stderr, "%s: error writing to %s\n",
+ progname, outname);
+ gsm_destroy(r);
+ return -1;
+ }
+ }
+
+ if (cc < 0) {
+ perror(inname ? inname : "stdin" );
+ fprintf(stderr, "%s: error reading from %s\n", progname,
+ inname ? inname : "stdin");
+ gsm_destroy(r);
+ return -1;
+ }
+
+ gsm_destroy(r);
+ return 0;
+}
+
+static int process P1((name), char * name)
+{
+ out = (FILE *)0;
+ in = (FILE *)0;
+
+ outname = (char *)0;
+ inname = (char *)0;
+
+ if (!open_input(name, &instat) || !open_output(name))
+ goto err;
+
+ if ((*(f_decode ? init_output : init_input))()) {
+ fprintf(stderr, "%s: error %s %s\n",
+ progname,
+ f_decode ? "writing header to" : "reading header from",
+ f_decode ? (outname ? outname : "stdout")
+ : (inname ? inname : "stdin"));
+ goto err;
+ }
+
+ if ((*(f_decode ? process_decode : process_encode))())
+ goto err;
+
+ if (fflush(out) < 0 || ferror(out)) {
+ perror(outname ? outname : "stdout");
+ fprintf(stderr, "%s: error writing \"%s\"\n", progname,
+ outname ? outname:"stdout");
+ goto err;
+ }
+
+ if (out != stdout) {
+
+ update_times();
+ update_mode ();
+ update_own ();
+
+ if (fclose(out) < 0) {
+ perror(outname);
+ fprintf(stderr, "%s: error writing \"%s\"\n",
+ progname, outname);
+ goto err;
+ }
+ if (outname != name) free(outname);
+ outname = (char *)0;
+ }
+ out = (FILE *)0;
+ if (in != stdin) {
+ (void)fclose(in), in = (FILE *)0;
+ if (!f_cat && !f_precious) {
+ if (unlink(inname) < 0) {
+ perror(inname);
+ fprintf(stderr,
+ "%s: source \"%s\" not deleted.\n",
+ progname, inname);
+ }
+ goto err;
+ }
+ if (inname != name) free(inname);
+ inname = (char *)0;
+ }
+ return 0;
+
+ /*
+ * Error handling and cleanup.
+ */
+err:
+ if (out && out != stdout) {
+ (void)fclose(out), out = (FILE *)0;
+ if (unlink(outname) < 0 && errno != ENOENT && errno != EINTR) {
+ perror(outname);
+ fprintf(stderr, "%s: could not unlink \"%s\"\n",
+ progname, outname);
+ }
+ }
+ if (in && in != stdin) (void)fclose(in), in = (FILE *)0;
+
+ if (inname && inname != name) free(inname);
+ if (outname && outname != name) free(outname);
+
+ return -1;
+}
+
+static void version P0()
+{
+ printf( "%s 1.0, version %s\n",
+ progname,
+ "$Id: toast.c,v 1.8 1996/07/02 10:41:04 jutta Exp $" );
+}
+
+static void help P0()
+{
+ printf("Usage: %s [-fcpdhvaulsFC] [files...]\n", progname);
+ printf("\n");
+
+ printf(" -f force Replace existing files without asking\n");
+ printf(" -c cat Write to stdout, do not remove source files\n");
+ printf(" -d decode Decode data (default is encode)\n");
+ printf(" -p precious Do not delete the source\n");
+ printf("\n");
+
+ printf(" -u u-law Force 8 kHz/8 bit u-law in/output format\n");
+ printf(" -s sun .au Force Sun .au u-law in/output format\n");
+ printf(" -a A-law Force 8 kHz/8 bit A-law in/output format\n");
+ printf(" -l linear Force 16 bit linear in/output format\n");
+ printf("\n");
+
+ printf(" -F fast Sacrifice conformance to performance\n");
+ printf(" -C cutoff Ignore most samples during LTP\n");
+ printf(" -v version Show version information\n");
+ printf(" -h help Print this text\n");
+ printf("\n");
+}
+
+
+static void set_format P1((f), struct fmtdesc * f)
+{
+ if (f_format && f_format != f) {
+ fprintf( stderr,
+ "%s: only one of -[uals] is possible (%s -h for help)\n",
+ progname, progname);
+ exit(1);
+ }
+
+ f_format = f;
+}
+
+int main P2((ac, av), int ac, char **av)
+{
+ int opt;
+ extern int optind;
+
+ parse_argv0(*av);
+
+ while ((opt = getopt(ac, av, "fcdpvhuaslVFC:")) != EOF) switch (opt) {
+
+ case 'd': f_decode = 1; break;
+ case 'f': f_force = 1; break;
+ case 'c': f_cat = 1; break;
+ case 'p': f_precious = 1; break;
+ case 'F': f_fast = 1; break;
+ case 'C': f_ltp_cut = 100; break;
+#ifndef NDEBUG
+ case 'V': f_verbose = 1; break; /* undocumented */
+#endif
+
+ case 'u': set_format( &f_ulaw ); break;
+ case 'l': set_format( &f_linear ); break;
+ case 'a': set_format( &f_alaw ); break;
+ case 's': set_format( &f_audio ); break;
+
+ case 'v': version(); exit(0);
+ case 'h': help(); exit(0);
+
+ default:
+ fprintf(stderr,
+ "Usage: %s [-fcpdhvuaslFC] [files...] (-h for help)\n",
+ progname);
+ exit(1);
+ }
+
+ f_precious |= f_cat;
+
+ av += optind;
+ ac -= optind;
+
+ catch_signals(onintr);
+
+ if (ac <= 0) process( (char *)0 );
+ else while (ac--) process( *av++ );
+
+ exit(0);
+}
Index: src
===================================================================
--- src (nonexistent)
+++ src (revision 5)
Property changes on: src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~