mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-10 16:43:33 +02:00
Update twolame to 0.3.13.
This commit is contained in:
10
lib-src/twolame/tests/Makefile.am
Normal file
10
lib-src/twolame/tests/Makefile.am
Normal file
@@ -0,0 +1,10 @@
|
||||
dist_check_SCRIPTS = test.pl
|
||||
dist_check_DATA = testcase-44100.wav testcase-22050.wav
|
||||
|
||||
TESTS = $(dist_check_SCRIPTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
TWOLAME_CMD="$(top_builddir)/frontend/twolame" \
|
||||
STWOLAME_CMD="$(top_builddir)/simplefrontend/stwolame" \
|
||||
perl -w -Mstrict -MTest::Harness -e "runtests(@ARGV)"
|
||||
|
||||
CLEANFILES = *.mp2 *.raw
|
443
lib-src/twolame/tests/Makefile.in
Normal file
443
lib-src/twolame/tests/Makefile.in
Normal file
@@ -0,0 +1,443 @@
|
||||
# Makefile.in generated by automake 1.10.2 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 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.
|
||||
|
||||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = tests
|
||||
DIST_COMMON = $(dist_check_DATA) $(dist_check_SCRIPTS) \
|
||||
$(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/build-scripts/libtool.m4 \
|
||||
$(top_srcdir)/build-scripts/ltoptions.m4 \
|
||||
$(top_srcdir)/build-scripts/ltsugar.m4 \
|
||||
$(top_srcdir)/build-scripts/ltversion.m4 \
|
||||
$(top_srcdir)/build-scripts/lt~obsolete.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/libtwolame/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_ASCIIDOC = @PATH_ASCIIDOC@
|
||||
PATH_DOXYGEN = @PATH_DOXYGEN@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PATH_XMLTO = @PATH_XMLTO@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
|
||||
SNDFILE_LIBS = @SNDFILE_LIBS@
|
||||
STRIP = @STRIP@
|
||||
TWOLAME_BIN = @TWOLAME_BIN@
|
||||
TWOLAME_SO_VERSION = @TWOLAME_SO_VERSION@
|
||||
VERSION = @VERSION@
|
||||
WARNING_CFLAGS = @WARNING_CFLAGS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
dist_check_SCRIPTS = test.pl
|
||||
dist_check_DATA = testcase-44100.wav testcase-22050.wav
|
||||
TESTS = $(dist_check_SCRIPTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
TWOLAME_CMD="$(top_builddir)/frontend/twolame" \
|
||||
STWOLAME_CMD="$(top_builddir)/simplefrontend/stwolame" \
|
||||
perl -w -Mstrict -MTest::Harness -e "runtests(@ARGV)"
|
||||
|
||||
CLEANFILES = *.mp2 *.raw
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu tests/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
ctags: CTAGS
|
||||
CTAGS:
|
||||
|
||||
|
||||
check-TESTS: $(TESTS)
|
||||
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
|
||||
srcdir=$(srcdir); export srcdir; \
|
||||
list=' $(TESTS) '; \
|
||||
if test -n "$$list"; then \
|
||||
for tst in $$list; do \
|
||||
if test -f ./$$tst; then dir=./; \
|
||||
elif test -f $$tst; then dir=; \
|
||||
else dir="$(srcdir)/"; fi; \
|
||||
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*[\ \ ]$$tst[\ \ ]*) \
|
||||
xpass=`expr $$xpass + 1`; \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "XPASS: $$tst"; \
|
||||
;; \
|
||||
*) \
|
||||
echo "PASS: $$tst"; \
|
||||
;; \
|
||||
esac; \
|
||||
elif test $$? -ne 77; then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*[\ \ ]$$tst[\ \ ]*) \
|
||||
xfail=`expr $$xfail + 1`; \
|
||||
echo "XFAIL: $$tst"; \
|
||||
;; \
|
||||
*) \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "FAIL: $$tst"; \
|
||||
;; \
|
||||
esac; \
|
||||
else \
|
||||
skip=`expr $$skip + 1`; \
|
||||
echo "SKIP: $$tst"; \
|
||||
fi; \
|
||||
done; \
|
||||
if test "$$all" -eq 1; then \
|
||||
tests="test"; \
|
||||
All=""; \
|
||||
else \
|
||||
tests="tests"; \
|
||||
All="All "; \
|
||||
fi; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
if test "$$xfail" -eq 0; then \
|
||||
banner="$$All$$all $$tests passed"; \
|
||||
else \
|
||||
if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
|
||||
banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
|
||||
fi; \
|
||||
else \
|
||||
if test "$$xpass" -eq 0; then \
|
||||
banner="$$failed of $$all $$tests failed"; \
|
||||
else \
|
||||
if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
|
||||
banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dashes="$$banner"; \
|
||||
skipped=""; \
|
||||
if test "$$skip" -ne 0; then \
|
||||
if test "$$skip" -eq 1; then \
|
||||
skipped="($$skip test was not run)"; \
|
||||
else \
|
||||
skipped="($$skip tests were not run)"; \
|
||||
fi; \
|
||||
test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
|
||||
dashes="$$skipped"; \
|
||||
fi; \
|
||||
report=""; \
|
||||
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
|
||||
report="Please report to $(PACKAGE_BUGREPORT)"; \
|
||||
test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
|
||||
dashes="$$report"; \
|
||||
fi; \
|
||||
dashes=`echo "$$dashes" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
test -z "$$skipped" || echo "$$skipped"; \
|
||||
test -z "$$report" || echo "$$report"; \
|
||||
echo "$$dashes"; \
|
||||
test "$$failed" -eq 0; \
|
||||
else :; fi
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(dist_check_SCRIPTS) \
|
||||
$(dist_check_DATA)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
|
||||
check: check-am
|
||||
all-am: Makefile
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: all all-am check check-TESTS check-am clean clean-generic \
|
||||
clean-libtool distclean distclean-generic distclean-libtool \
|
||||
distdir dvi dvi-am html html-am info info-am install \
|
||||
install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
uninstall uninstall-am
|
||||
|
||||
# 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:
|
351
lib-src/twolame/tests/test.pl
Executable file
351
lib-src/twolame/tests/test.pl
Executable file
@@ -0,0 +1,351 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
use Test::More tests => 77;
|
||||
|
||||
my $TWOLAME_CMD = $ENV{TWOLAME_CMD} || "../frontend/twolame";
|
||||
my $STWOLAME_CMD = $ENV{STWOLAME_CMD} || "../simplefrontend/stwolame";
|
||||
die "Error: twolame command not found: $TWOLAME_CMD" unless (-e $TWOLAME_CMD);
|
||||
die "Error: stwolame command not found: $STWOLAME_CMD" unless (-e $STWOLAME_CMD);
|
||||
|
||||
|
||||
my $encoding_parameters = [
|
||||
{
|
||||
# Test Case 1 (default settings)
|
||||
'input_filename' => 'testcase-44100.wav',
|
||||
'input_md5sum' => 'f50499fded70a74c810dbcadb3f28062',
|
||||
'bitrate' => 192,
|
||||
'samplerate' => 44100,
|
||||
'version' => '1',
|
||||
'mode' => 'stereo',
|
||||
'psycmode' => 3,
|
||||
'original' => 1,
|
||||
'copyright' => 0,
|
||||
'padding' => 0,
|
||||
'protect' => 0,
|
||||
'deemphasis' => 'n',
|
||||
'total_frames' => 22,
|
||||
'total_bytes' => 13772,
|
||||
'total_samples' => 25344,
|
||||
'output_md5sum' => '956f85e3647314750a1d3ed3fbf81ae3'
|
||||
},
|
||||
{
|
||||
# Test Case 2 (toolame 0.2l default settings)
|
||||
'input_filename' => 'testcase-44100.wav',
|
||||
'input_md5sum' => 'f50499fded70a74c810dbcadb3f28062',
|
||||
'bitrate' => 192,
|
||||
'samplerate' => 44100,
|
||||
'version' => '1',
|
||||
'mode' => 'joint',
|
||||
'psycmode' => 1,
|
||||
'original' => 0,
|
||||
'copyright' => 0,
|
||||
'padding' => 1,
|
||||
'protect' => 0,
|
||||
'deemphasis' => 'n',
|
||||
'total_frames' => 22,
|
||||
'total_bytes' => 13792,
|
||||
'total_samples' => 25344,
|
||||
'output_md5sum' => 'fef3bb4926978e56822d33eaa89208d2'
|
||||
},
|
||||
{
|
||||
# Test Case 3 (MPEG-2 test)
|
||||
'input_filename' => 'testcase-22050.wav',
|
||||
'input_md5sum' => 'a5ec3077c2138a1023bcd980aec8e4b4',
|
||||
'bitrate' => 32,
|
||||
'samplerate' => 22050,
|
||||
'version' => '2',
|
||||
'mode' => 'mono',
|
||||
'psycmode' => 4,
|
||||
'original' => 0,
|
||||
'copyright' => 1,
|
||||
'padding' => 1,
|
||||
'protect' => 0,
|
||||
'deemphasis' => '5',
|
||||
'total_frames' => 11,
|
||||
'total_bytes' => 2298,
|
||||
'total_samples' => 12672,
|
||||
'output_md5sum' => '3175f5332040aaad42b00823cd1ec913'
|
||||
},
|
||||
{
|
||||
# Test Case 4 (error protection test)
|
||||
'input_filename' => 'testcase-44100.wav',
|
||||
'input_md5sum' => 'f50499fded70a74c810dbcadb3f28062',
|
||||
'bitrate' => 192,
|
||||
'samplerate' => 44100,
|
||||
'version' => '1',
|
||||
'mode' => 'stereo',
|
||||
'psycmode' => 3,
|
||||
'original' => 1,
|
||||
'copyright' => 0,
|
||||
'padding' => 0,
|
||||
'protect' => 1,
|
||||
'deemphasis' => 'n',
|
||||
'total_frames' => 22,
|
||||
'total_bytes' => 13772,
|
||||
'total_samples' => 25344,
|
||||
'output_md5sum' => '7e7aa8e3cfafdd1cd2eda53a9ab8bef3'
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
my $count = 1;
|
||||
foreach my $params (@$encoding_parameters) {
|
||||
my $INPUT_FILENAME = input_filepath($params->{input_filename});
|
||||
my $OUTPUT_FILENAME = "testcase-$count.mp2";
|
||||
|
||||
die "Input file does not exist: $INPUT_FILENAME" unless (-e $INPUT_FILENAME);
|
||||
is(md5_file($INPUT_FILENAME), $params->{input_md5sum}, "[$count] MD5sum of $INPUT_FILENAME");
|
||||
|
||||
my $result = system($TWOLAME_CMD,
|
||||
'--quiet',
|
||||
'--bitrate', $params->{bitrate},
|
||||
'--mode', $params->{mode},
|
||||
'--psyc-mode', $params->{psycmode},
|
||||
$params->{copyright} ? '--copyright' : '--non-copyright',
|
||||
$params->{original} ? '--original' : '--non-original',
|
||||
$params->{protect} ? '--protect' : '',
|
||||
$params->{padding} ? '--padding' : '',
|
||||
'--deemphasis', $params->{deemphasis},
|
||||
$INPUT_FILENAME, $OUTPUT_FILENAME
|
||||
);
|
||||
|
||||
is($result, 0, "[$count] twolame response code");
|
||||
|
||||
my $info = mpeg_audio_info($OUTPUT_FILENAME);
|
||||
is($info->{syncword}, 0xff, "[$count] MPEG Audio Header - Sync Word");
|
||||
is($info->{version}, $params->{version}, "[$count] MPEG Audio Header - Version");
|
||||
is($info->{layer}, 2, "[$count] MPEG Audio Header - Layer");
|
||||
is($info->{mode}, $params->{mode}, "[$count] MPEG Audio Header - Mode");
|
||||
is($info->{samplerate}, $params->{samplerate}, "[$count] MPEG Audio Header - Sample Rate");
|
||||
is($info->{bitrate}, $params->{bitrate}, "[$count] MPEG Audio Header - Bitrate");
|
||||
is($info->{copyright}, $params->{copyright}, "[$count] MPEG Audio Header - Copyright Flag");
|
||||
is($info->{original}, $params->{original}, "[$count] MPEG Audio Header - Original Flag");
|
||||
is($info->{protect}, $params->{protect}, "[$count] MPEG Audio Header - Error Protection Flag");
|
||||
is($info->{deemphasis}, $params->{deemphasis}, "[$count] MPEG Audio Header - De-emphasis");
|
||||
|
||||
# FIXME: test that CRC is correct
|
||||
|
||||
is($info->{total_frames}, $params->{total_frames}, "[$count] total number of frames");
|
||||
is($info->{total_bytes}, $params->{total_bytes}, "[$count] total number of bytes");
|
||||
is($info->{total_samples}, $params->{total_samples}, "[$count] total number of samples");
|
||||
|
||||
is(filesize($OUTPUT_FILENAME), $params->{total_bytes}, , "[$count] file size of output file");
|
||||
is(md5_file($OUTPUT_FILENAME), $params->{output_md5sum}, "[$count] md5sum of output file");
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
# Test encoding from STDIN
|
||||
SKIP: {
|
||||
my $result = system("which sndfile-convert > /dev/null");
|
||||
skip("sndfile-convert is not available", 5) unless ($result == 0);
|
||||
|
||||
my $INPUT_FILENAME = input_filepath('testcase-44100.wav');
|
||||
$result = system("sndfile-convert -pcm16 $INPUT_FILENAME testcase.raw");
|
||||
is($result, 0, "sndfile-convert to raw response code");
|
||||
|
||||
my $OUTPUT_FILENAME = 'testcase-stdin.mp2';
|
||||
$result = system("$TWOLAME_CMD --quiet --raw-input - $OUTPUT_FILENAME < testcase.raw");
|
||||
is($result, 0, "converting from STDIN - response code");
|
||||
|
||||
my $info = mpeg_audio_info($OUTPUT_FILENAME);
|
||||
is($info->{total_frames}, 22, "converting from STDIN - total number of frames");
|
||||
is($info->{total_bytes}, 13772, "converting from STDIN - total number of bytes");
|
||||
is(md5_file($OUTPUT_FILENAME), '956f85e3647314750a1d3ed3fbf81ae3', "converting from STDIN - md5sum of output file");
|
||||
}
|
||||
|
||||
|
||||
# Test encoding using the simplefrontend
|
||||
{
|
||||
my $INPUT_FILENAME = input_filepath('testcase-44100.wav');
|
||||
my $OUTPUT_FILENAME = 'testcase-simple.mp2';
|
||||
my $result = system("../simplefrontend/stwolame $INPUT_FILENAME $OUTPUT_FILENAME");
|
||||
is($result, 0, "converting using simplefrontend - response code");
|
||||
|
||||
my $info = mpeg_audio_info($OUTPUT_FILENAME);
|
||||
is($info->{total_frames}, 22, "converting using simplefrontend - total number of frames");
|
||||
is($info->{total_bytes}, 13772, "converting using simplefrontend - total number of bytes");
|
||||
is(md5_file($OUTPUT_FILENAME), '956f85e3647314750a1d3ed3fbf81ae3', "converting using simplefrontend - md5sum of output file");
|
||||
}
|
||||
|
||||
|
||||
## END OF TESTS ##
|
||||
|
||||
sub input_filepath {
|
||||
# Input test data files are in the same directory as the test script
|
||||
my ($filename) = @_;
|
||||
my $filepath = __FILE__;
|
||||
$filepath =~ s/test.pl/$filename/;
|
||||
return $filepath;
|
||||
}
|
||||
|
||||
sub filesize {
|
||||
return (stat(@_))[7];
|
||||
}
|
||||
|
||||
sub md5_file {
|
||||
my ($filename) = @_;
|
||||
|
||||
my $ctx = Digest::MD5->new;
|
||||
|
||||
open(FILE, $filename) or die "Failed to open file: $filename ($!)";
|
||||
$ctx->addfile(*FILE);
|
||||
close(FILE);
|
||||
|
||||
return $ctx->hexdigest;
|
||||
}
|
||||
|
||||
sub mpeg_audio_info {
|
||||
my ($filename) = @_;
|
||||
my $info = undef;
|
||||
|
||||
open(MPAFILE, $filename) or die "Failed to open file: $filename ($!)";
|
||||
|
||||
until (eof(MPAFILE)) {
|
||||
my $header = '';
|
||||
my $bytes = read(MPAFILE, $header, 4);
|
||||
if ($bytes != 4) {
|
||||
warn "Failed to read MPEG Audio header";
|
||||
last;
|
||||
}
|
||||
|
||||
my $frame_info = parse_mpeg_header($header);
|
||||
if ($frame_info->{syncword} != 0xff) {
|
||||
warn "Lost MPEG Audio header sync";
|
||||
last;
|
||||
}
|
||||
|
||||
# Now read in the rest of the frame
|
||||
my $buffer = '';
|
||||
my $remaining = ($frame_info->{framesize}-4);
|
||||
$bytes = read(MPAFILE, $buffer, $remaining);
|
||||
if ($bytes != $remaining) {
|
||||
warn "Failed to read remaining buts of MPEG Audio frame";
|
||||
last;
|
||||
}
|
||||
|
||||
if ($frame_info->{protect}) {
|
||||
$frame_info->{crc} = unpack('n', $buffer);
|
||||
}
|
||||
|
||||
$info = $frame_info unless ($info);
|
||||
$info->{total_frames} += 1;
|
||||
$info->{total_samples} += $frame_info->{samples};
|
||||
$info->{total_bytes} += $frame_info->{framesize};
|
||||
};
|
||||
|
||||
close(MPAFILE);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
sub parse_mpeg_header {
|
||||
my ($buffer) = @_;
|
||||
my $header = unpack('N', $buffer);
|
||||
my $info = {};
|
||||
|
||||
my $bitrate_table = [
|
||||
[ # MPEG 1
|
||||
[0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448], # Layer 1
|
||||
[0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384], # Layer 2
|
||||
[0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320] # Layer 3
|
||||
],
|
||||
[ # MPEG 2
|
||||
[0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256], # Layer 1
|
||||
[0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160], # Layer 2
|
||||
[0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160] # Layer 3
|
||||
],
|
||||
[ # MPEG 2.5
|
||||
[0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256], # Layer 1
|
||||
[0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160], # Layer 2
|
||||
[0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160] # Layer 3
|
||||
]
|
||||
];
|
||||
|
||||
my $samplerate_table = [
|
||||
[ 44100, 48000, 32000 ], # MPEG 1
|
||||
[ 22050, 24000, 16000 ], # MPEG 2
|
||||
[ 11025, 12000, 8000 ] # MPEG 2.5
|
||||
];
|
||||
|
||||
$info->{syncword} = ($header >> 23) & 0xff;
|
||||
|
||||
my $version = (($header >> 19) & 0x03);
|
||||
if ($version == 0x00) {
|
||||
$info->{version} = '2.5'; # MPEG 2.5
|
||||
} elsif ($version == 0x02) {
|
||||
$info->{version} = '2'; # MPEG 2
|
||||
} elsif ($version == 0x03) {
|
||||
$info->{version} = '1'; # MPEG 1
|
||||
} else {
|
||||
$info->{version} = undef;
|
||||
}
|
||||
|
||||
$info->{layer} = 4-(($header >> 17) & 0x03);
|
||||
if ($info->{layer}==4) {
|
||||
$info->{layer} = 0;
|
||||
}
|
||||
|
||||
$info->{protect} = (($header >> 16) & 0x01) ? 0 : 1;
|
||||
$info->{padding} = ($header >> 9) & 0x01;
|
||||
$info->{extension} = ($header >> 8) & 0x01;
|
||||
$info->{mode_ext} = ($header >> 4) & 0x03;
|
||||
$info->{copyright} = ($header >> 3) & 0x01;
|
||||
$info->{original} = ($header >> 2) & 0x01;
|
||||
|
||||
my $bitrate_index = ($header >> 12) & 0x0F;
|
||||
my $samplerate_index = ($header >> 10) & 0x03;
|
||||
if ($info->{layer} && $info->{version}) {
|
||||
$info->{bitrate} = $bitrate_table->[$info->{version}-1]->[$info->{layer}-1][$bitrate_index];
|
||||
$info->{samplerate} = $samplerate_table->[$info->{version}-1]->[$samplerate_index];
|
||||
} else {
|
||||
$info->{bitrate} = undef;
|
||||
$info->{samplerate} = undef;
|
||||
}
|
||||
|
||||
my $deemphasis = $header & 0x03;
|
||||
if ($deemphasis == 0) {
|
||||
$info->{deemphasis} = 'n'; # None
|
||||
} elsif ($deemphasis == 1) {
|
||||
$info->{deemphasis} = '5'; # 50/15 ms
|
||||
} elsif ($deemphasis == 3) {
|
||||
$info->{deemphasis} = 'c'; # CCITT J.17
|
||||
} else {
|
||||
$info->{deemphasis} = undef;
|
||||
}
|
||||
|
||||
my $mode = ($header >> 6) & 0x03;
|
||||
if ($mode == 0) {
|
||||
$info->{mode} = 'stereo';
|
||||
} elsif ($mode == 1) {
|
||||
$info->{mode} = 'joint';
|
||||
} elsif ($mode == 2) {
|
||||
$info->{mode} = 'dual';
|
||||
} elsif ($mode == 3) {
|
||||
$info->{mode} = 'mono';
|
||||
} else {
|
||||
$info->{mode} = undef;
|
||||
}
|
||||
|
||||
if ($info->{layer} == '1') {
|
||||
$info->{samples} = 384;
|
||||
} elsif ($info->{layer} == '2') {
|
||||
$info->{samples} = 1152;
|
||||
} elsif ($info->{layer} == '3') {
|
||||
$info->{samples} = ($info->{version} eq '1') ? 1152 : 576;
|
||||
}
|
||||
|
||||
if ($info->{samplerate}) {
|
||||
$info->{framesize} = int(($info->{samples} * $info->{bitrate} * 1000 / $info->{samplerate}) / 8 + $info->{padding});
|
||||
} else {
|
||||
$info->{framesize} = undef;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
BIN
lib-src/twolame/tests/testcase-22050.wav
Normal file
BIN
lib-src/twolame/tests/testcase-22050.wav
Normal file
Binary file not shown.
BIN
lib-src/twolame/tests/testcase-44100.wav
Normal file
BIN
lib-src/twolame/tests/testcase-44100.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user