Merge from -mdev.

This commit is contained in:
Erik de Castro Lopo 2008-09-04 09:44:38 +10:00
commit d12d93f7be
41 changed files with 352 additions and 279 deletions

View File

@ -39,13 +39,13 @@ examples/generate
examples/list_formats
examples/make_sine
examples/sfprocess
examples/sndfile-bwf-get
examples/sndfile-bwf-set
examples/sndfile-cmp
examples/sndfile-convert
examples/sndfile-data-trim
examples/sndfile-info
examples/sndfile-jackplay
examples/sndfile-metadata-get
examples/sndfile-metadata-set
examples/sndfile-play
examples/sndfilehandle
libsndfile-1.0.*

View File

@ -1,5 +1,35 @@
2008-09-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h
Add macros SF_CONTAINER, SF_CODEC and SF_ENDIAN useful for splitting format
field of SF_INFO into component parts.
* src/*.c
Use new macros everywhere it is appropriate.
2008-09-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-bwf-set.c
Massive reworking.
2008-08-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-bwf-set.c
Add --info-auto-create-date command line option.
* examples/sndfile-metadata-set.c examples/sndfile-metadata-get.c
examples/Makefile.am examples/test-sndfile-bwf-set.py
Rename sndfile-bwf-(set|get).c to sndfile-metadata-(set|get).c.
Change command line args.
2008-08-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav.c
Allow 'PAD ' chunk to be modified in RDWR mode.
* src/sndfile.h.in src/sndfile.c
Add handling (incomplete) for SFC_SET_ADD_HEADER_PAD_CHUNK.
* tests/Makefile.am tests/write_read_test.tpl tests/header_test.tpl
tests/misc_test.c
Add tests for RF64.

View File

@ -1,13 +1,13 @@
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-jackplay sndfile-cmp \
sndfile-bwf-set sndfile-bwf-get
sndfile-metadata-set sndfile-metadata-get
noinst_PROGRAMS = make_sine sfprocess list_formats generate sndfilehandle
# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
# compiler.
EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-bwf-set.py
EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
@ -31,11 +31,11 @@ sndfile_convert_LDADD = $(SNDFILEDIR)/libsndfile.la
sndfile_cmp_SOURCES = sndfile-cmp.c
sndfile_cmp_LDADD = $(SNDFILEDIR)/libsndfile.la
sndfile_bwf_set_SOURCES = sndfile-bwf-set.c copy_data.c copy_data.h
sndfile_bwf_set_LDADD = $(SNDFILEDIR)/libsndfile.la
sndfile_metadata_set_SOURCES = sndfile-metadata-set.c copy_data.c copy_data.h
sndfile_metadata_set_LDADD = $(SNDFILEDIR)/libsndfile.la
sndfile_bwf_get_SOURCES = sndfile-bwf-get.c
sndfile_bwf_get_LDADD = $(SNDFILEDIR)/libsndfile.la
sndfile_metadata_get_SOURCES = sndfile-metadata-get.c
sndfile_metadata_get_LDADD = $(SNDFILEDIR)/libsndfile.la
make_sine_SOURCES = make_sine.c
make_sine_LDADD = $(SNDFILEDIR)/libsndfile.la

View File

@ -112,7 +112,7 @@ process_args (SNDFILE * file, const SF_BROADCAST_INFO * binfo, int argc, char *
{ const char * str ;
int k, do_all = 0 ;
#define HANDLE_BINFO_ARG(cmd,name,field) \
#define HANDLE_BEXT_ARG(cmd,name,field) \
if (do_all || strcmp (argv [k], cmd) == 0) \
{ printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \
if (! do_all) \
@ -130,17 +130,17 @@ process_args (SNDFILE * file, const SF_BROADCAST_INFO * binfo, int argc, char *
{ if (do_all || strcmp (argv [k], "--all") == 0)
do_all = 1 ;
HANDLE_BINFO_ARG ("--description", "Description", description) ;
HANDLE_BINFO_ARG ("--originator", "Originator", originator) ;
HANDLE_BINFO_ARG ("--orig-ref", "Origination ref", originator_reference) ;
HANDLE_BINFO_ARG ("--umid", "UMID", umid) ;
HANDLE_BINFO_ARG ("--orig-date", "Origination date", origination_date) ;
HANDLE_BINFO_ARG ("--orig-time", "Origination time", origination_time) ;
HANDLE_BINFO_ARG ("--coding-hist", "Coding history", coding_history) ;
HANDLE_BEXT_ARG ("--bext-description", "Description", description) ;
HANDLE_BEXT_ARG ("--bext-originator", "Originator", originator) ;
HANDLE_BEXT_ARG ("--bext-orig-ref", "Origination ref", originator_reference) ;
HANDLE_BEXT_ARG ("--bext-umid", "UMID", umid) ;
HANDLE_BEXT_ARG ("--bext-orig-date", "Origination date", origination_date) ;
HANDLE_BEXT_ARG ("--bext-orig-time", "Origination time", origination_time) ;
HANDLE_BEXT_ARG ("--bext-coding-hist", "Coding history", coding_history) ;
HANDLE_STR_ARG ("--info-name", "Name", SF_STR_TITLE) ;
HANDLE_STR_ARG ("--info-artist", "Artist", SF_STR_ARTIST) ;
HANDLE_STR_ARG ("--info-create-date", "Create date", SF_STR_DATE) ;
HANDLE_STR_ARG ("--str-name", "Name", SF_STR_TITLE) ;
HANDLE_STR_ARG ("--str-artist", "Artist", SF_STR_ARTIST) ;
HANDLE_STR_ARG ("--str-create-date", "Create date", SF_STR_DATE) ;
if (! do_all)
printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;

View File

@ -51,7 +51,19 @@ typedef struct
{ const char * name ;
const char * artist ;
const char * create_date ;
} TEMP_INFO ;
/* Stuff to go in the 'bext' chunk of WAV files. */
int has_bext_fields ;
int coding_hist_append ;
const char * description ;
const char * originator ;
const char * originator_reference ;
const char * origination_date ;
const char * origination_time ;
const char * umid ;
const char * coding_history ;
} INFO ;
@ -59,21 +71,20 @@ static void usage_exit (const char *progname, int exit_code) ;
static void missing_param (const char * option) ;
static void read_localtime (struct tm * timedata) ;
static void apply_changes (const char * filenames [2], const SF_BROADCAST_INFO * binfo, int coding_hist_append, const TEMP_INFO * info) ;
static void merge_broadcast_info (SF_BROADCAST_INFO * binfo, const SF_BROADCAST_INFO * new_binfo, int coding_hist_append) ;
static void update_strings (SNDFILE * file, const TEMP_INFO * new_tinfo) ;
static void apply_changes (const char * filenames [2], const INFO * info) ;
static int merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const INFO * info) ;
static void update_strings (SNDFILE * outfile, const INFO * info) ;
static int has_bext_fields_set (const INFO * info) ;
int
main (int argc, char *argv [])
{ SF_BROADCAST_INFO binfo ;
TEMP_INFO temp_info ;
{ INFO info ;
struct tm timedata ;
const char *progname ;
const char * filenames [2] = { NULL, NULL } ;
int k, coding_hist_append = 0 ;
int k ;
/* Store the program name. */
progname = strrchr (argv [0], '/') ;
@ -84,8 +95,7 @@ main (int argc, char *argv [])
usage_exit (progname, 0) ;
/* Clear set all fields of the struct to zero bytes. */
memset (&binfo, 0, sizeof (binfo)) ;
memset (&temp_info, 0, sizeof (temp_info)) ;
memset (&info, 0, sizeof (info)) ;
/* Get the time in case we need it later. */
read_localtime (&timedata) ;
@ -103,120 +113,126 @@ main (int argc, char *argv [])
continue ;
} ;
if (strcmp (argv [k], "--description") == 0)
if (strcmp (argv [k], "--bext-description") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.description, argv [k], sizeof (binfo.description)) ;
info.description = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--originator") == 0)
if (strcmp (argv [k], "--bext-originator") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.originator, argv [k], sizeof (binfo.originator)) ;
info.originator = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--orig-ref") == 0)
if (strcmp (argv [k], "--bext-orig-ref") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.originator_reference, argv [k], sizeof (binfo.originator_reference)) ;
info.originator_reference = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--umid") == 0)
if (strcmp (argv [k], "--bext-umid") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.umid, argv [k], sizeof (binfo.umid)) ;
info.umid = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--orig-date") == 0)
if (strcmp (argv [k], "--bext-orig-date") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.origination_date, argv [k], sizeof (binfo.origination_date)) ;
info.origination_date = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--orig-time") == 0)
if (strcmp (argv [k], "--bext-orig-time") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.origination_time, argv [k], sizeof (binfo.origination_time)) ;
info.origination_time = argv [k] ;
puts (info.origination_time) ;
continue ;
} ;
if (strcmp (argv [k], "--coding-hist") == 0)
if (strcmp (argv [k], "--bext-coding-hist") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.coding_history, argv [k], sizeof (binfo.coding_history)) ;
binfo.coding_history_size = sizeof (binfo.coding_history) ;
info.coding_history = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--coding-hist-append") == 0)
if (strcmp (argv [k], "--bext-coding-hist-append") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
strncpy (binfo.coding_history, argv [k], sizeof (binfo.coding_history)) ;
binfo.coding_history_size = sizeof (binfo.coding_history) ;
coding_hist_append = 1 ;
info.coding_history = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--info-name") == 0)
if (strcmp (argv [k], "--str-name") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
temp_info.name = argv [k] ;
info.name = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--info-artist") == 0)
if (strcmp (argv [k], "--str-artist") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
temp_info.artist = argv [k] ;
info.artist = argv [k] ;
continue ;
} ;
if (strcmp (argv [k], "--info-create-date") == 0)
if (strcmp (argv [k], "--str-create-date") == 0)
{ k ++ ;
if (k == argc) missing_param (argv [k - 1]) ;
temp_info.create_date = argv [k] ;
info.create_date = argv [k] ;
continue ;
} ;
/* Following options do not take an argument. */
if (strcmp (argv [k], "--auto-time-date") == 0)
if (strcmp (argv [k], "--bext-auto-time-date") == 0)
{ char tmp [20] ;
snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
strncpy (binfo.origination_time, tmp, sizeof (binfo.origination_time)) ;
info.origination_time = strdup (tmp) ;
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
strncpy (binfo.origination_date, tmp, sizeof (binfo.origination_date)) ;
info.origination_date = strdup (tmp) ;
continue ;
} ;
if (strcmp (argv [k], "--auto-time") == 0)
if (strcmp (argv [k], "--bext-auto-time") == 0)
{ char tmp [20] ;
snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
strncpy (binfo.origination_time, tmp, sizeof (binfo.origination_time)) ;
info.origination_time = strdup (tmp) ;
continue ;
} ;
if (strcmp (argv [k], "--auto-date") == 0)
if (strcmp (argv [k], "--bext-auto-date") == 0)
{ char tmp [20] ;
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
strncpy (binfo.origination_date, tmp, sizeof (binfo.origination_date)) ;
info.origination_date = strdup (tmp) ;
continue ;
} ;
if (strcmp (argv [k], "--str-auto-create-date") == 0)
{ char tmp [20] ;
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
info.create_date = strdup (tmp) ;
continue ;
} ;
@ -224,6 +240,9 @@ main (int argc, char *argv [])
usage_exit (progname, 1) ;
} ;
/* Find out if any of the 'bext' fields are set. */
info.has_bext_fields = has_bext_fields_set (&info) ;
if (filenames [0] == NULL)
{ printf ("Error : No input file specificed.\n\n") ;
exit (1) ;
@ -234,7 +253,7 @@ main (int argc, char *argv [])
exit (1) ;
} ;
apply_changes (filenames, &binfo, coding_hist_append, &temp_info) ;
apply_changes (filenames, &info) ;
return 0 ;
} /* main */
@ -260,6 +279,18 @@ missing_param (const char * option)
/*==============================================================================
*/
static int
has_bext_fields_set (const INFO * info)
{
if (info->description || info->originator || info->originator_reference)
return 1 ;
if (info->origination_date || info->origination_time || info->umid || info->coding_history)
return 1 ;
return 0 ;
} /* has_bext_fields_set */
static void
read_localtime (struct tm * timedata)
{ time_t current ;
@ -281,15 +312,14 @@ read_localtime (struct tm * timedata)
} /* read_localtime */
static void
apply_changes (const char * filenames [2], const SF_BROADCAST_INFO * new_binfo, int coding_hist_append, const TEMP_INFO * new_tinfo)
apply_changes (const char * filenames [2], const INFO * info)
{ SNDFILE *infile = NULL, *outfile = NULL ;
SF_INFO sfinfo ;
SF_BROADCAST_INFO binfo ;
TEMP_INFO tinfo ;
int error_code = 0, infileminor ;
INFO tmpinfo ;
int error_code = 0 ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
memset (&tinfo, 0, sizeof (tinfo)) ;
memset (&tmpinfo, 0, sizeof (tmpinfo)) ;
if (filenames [1] == NULL)
infile = outfile = sf_open (filenames [0], SFM_RDWR, &sfinfo) ;
@ -313,13 +343,50 @@ apply_changes (const char * filenames [2], const SF_BROADCAST_INFO * new_binfo,
goto cleanup_exit ;
} ;
if ((SF_FORMAT_TYPEMASK & sfinfo.format) != SF_FORMAT_WAV)
{ printf ("Error : This is not a WAV file and hence broadcast info cannot be added to it.\n\n") ;
error_code = 1 ;
if (info->has_bext_fields && merge_broadcast_info (infile, outfile, sfinfo.format, info))
{ error_code = 1 ;
goto cleanup_exit ;
} ;
infileminor = SF_FORMAT_SUBMASK & sfinfo.format ;
update_strings (outfile, info) ;
if (infile != outfile)
{ int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ;
/* If the input file is not the same as the output file, copy the data. */
if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
else
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
} ;
cleanup_exit :
if (outfile != NULL && outfile != infile)
sf_close (outfile) ;
if (infile != NULL)
sf_close (infile) ;
if (error_code)
exit (error_code) ;
return ;
} /* apply_changes */
static int
merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const INFO * info)
{ SF_BROADCAST_INFO binfo ;
int infileminor ;
memset (&binfo, 0, sizeof (binfo)) ;
if ((SF_FORMAT_TYPEMASK & format) != SF_FORMAT_WAV)
{ printf ("Error : This is not a WAV file and hence broadcast info cannot be added to it.\n\n") ;
return 1 ;
} ;
infileminor = SF_FORMAT_SUBMASK & format ;
switch (infileminor)
{ case SF_FORMAT_PCM_16 :
@ -343,62 +410,13 @@ apply_changes (const char * filenames [2], const SF_BROADCAST_INFO * new_binfo,
" have a 'bext' chunk to modify. The solution is to specify both\n"
" input and output files on the command line.\n\n"
) ;
error_code = 1 ;
goto cleanup_exit ;
return 1 ;
} ;
memset (&binfo, 0, sizeof (binfo)) ;
} ;
/* Merge and write broadcast info. */
merge_broadcast_info (&binfo, new_binfo, coding_hist_append) ;
if (sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
printf ("Error : Setting of broadcast info chunks failed.\n\n") ;
/* Grab the strings from the existing file. */
tinfo.name = sf_get_string (infile, SF_STR_TITLE) ;
tinfo.artist = sf_get_string (infile, SF_STR_ARTIST) ;
tinfo.create_date = sf_get_string (infile, SF_STR_DATE) ;
/* If the input and output files are different we merge the strings and
** then clear the old versions.
*/
tinfo.name = new_tinfo->name ? new_tinfo->name : tinfo.name ;
tinfo.artist = new_tinfo->artist ? new_tinfo->artist : tinfo.artist ;
tinfo.create_date = new_tinfo->create_date ? new_tinfo->create_date : tinfo.create_date ;
update_strings (outfile, &tinfo) ;
if (infile != outfile)
{ /* If the input file is not the same as the output file, copy the data. */
if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
else
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
} ;
cleanup_exit :
if (outfile != NULL && outfile != infile)
sf_close (outfile) ;
if (infile != NULL)
sf_close (infile) ;
if (error_code)
exit (error_code) ;
return ;
} /* apply_changes */
static void
merge_broadcast_info (SF_BROADCAST_INFO * binfo, const SF_BROADCAST_INFO * new_binfo, int coding_hist_append)
{
#define REPLACE_IF_NEW(x) \
if (strlen (new_binfo->x) > 0) \
memcpy (binfo->x, new_binfo->x, sizeof (binfo->x)) ;
if (info->x != NULL) \
memcpy (binfo.x, info->x, sizeof (binfo.x)) ;
REPLACE_IF_NEW (description) ;
REPLACE_IF_NEW (originator) ;
@ -408,35 +426,39 @@ merge_broadcast_info (SF_BROADCAST_INFO * binfo, const SF_BROADCAST_INFO * new_b
REPLACE_IF_NEW (umid) ;
/* Special case for coding_history because we may want to append. */
if (strlen (new_binfo->coding_history) > 0)
{ if (coding_hist_append)
{ int slen = strlen (binfo->coding_history) ;
if (info->coding_history != NULL)
{ if (info->coding_hist_append)
{ int slen = strlen (binfo.coding_history) ;
while (slen > 1 && isspace (binfo->coding_history [slen - 1]))
while (slen > 1 && isspace (binfo.coding_history [slen - 1]))
slen -- ;
binfo->coding_history [slen++] = '\n' ;
memcpy (binfo->coding_history + slen, new_binfo->coding_history, sizeof (binfo->coding_history) - slen) ;
binfo.coding_history [slen++] = '\n' ;
memcpy (binfo.coding_history + slen, info->coding_history, sizeof (binfo.coding_history) - slen) ;
}
else
{ memcpy (binfo->coding_history, new_binfo->coding_history, sizeof (binfo->coding_history)) ;
binfo->coding_history_size = sizeof (binfo->coding_history) ;
{ memcpy (binfo.coding_history, info->coding_history, sizeof (binfo.coding_history)) ;
binfo.coding_history_size = sizeof (binfo.coding_history) ;
} ;
} ;
if (sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
printf ("Error : Setting of broadcast info chunks failed.\n\n") ;
return 0 ;
} /* merge_broadcast_info*/
static void
update_strings (SNDFILE * file, const TEMP_INFO * new_tinfo)
update_strings (SNDFILE * outfile, const INFO * info)
{
if (new_tinfo->name != NULL)
sf_set_string (file, SF_STR_TITLE, new_tinfo->name) ;
if (info->name != NULL)
sf_set_string (outfile, SF_STR_TITLE, info->name) ;
if (new_tinfo->artist != NULL)
sf_set_string (file, SF_STR_ARTIST, new_tinfo->artist) ;
if (info->artist != NULL)
sf_set_string (outfile, SF_STR_ARTIST, info->artist) ;
if (new_tinfo->create_date != NULL)
sf_set_string (file, SF_STR_DATE, new_tinfo->create_date) ;
if (info->create_date != NULL)
sf_set_string (outfile, SF_STR_DATE, info->create_date) ;
} /* update_strings */

View File

@ -30,7 +30,7 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Simple test script for the sndfile-bwf-set program.
# Simple test script for the sndfile-metadata-set program.
import commands, os, sys
import time, datetime
@ -39,7 +39,7 @@ def print_test_name (name):
print " %-30s :" % name,
def assert_info (filename, arg, value):
cmd = "./sndfile-bwf-get %s %s" % (arg, filename)
cmd = "./sndfile-metadata-get %s %s" % (arg, filename)
status, output = commands.getstatusoutput (cmd)
if status:
print "\n\nError : command '%s' should not have failed." % cmd
@ -58,7 +58,7 @@ def check_executable (name):
def test_empty_fail ():
print_test_name ("Empty fail test")
cmd = "./sndfile-bwf-set --description Alpha sine.wav"
cmd = "./sndfile-metadata-set --bext-description Alpha sine.wav"
status, output = commands.getstatusoutput (cmd)
if not status:
print "\n\nError : command '%s' should have failed." % cmd
@ -66,17 +66,17 @@ def test_empty_fail ():
def test_copy ():
print_test_name ("Copy test")
cmd = "./sndfile-bwf-set --description \"First Try\" sine.wav output.wav"
cmd = "./sndfile-metadata-set --bext-description \"First Try\" sine.wav output.wav"
status, output = commands.getstatusoutput (cmd)
if status:
print "\n\nError : command '%s' should not have failed." % cmd
assert_info ("output.wav", "--description", "First Try")
assert_info ("output.wav", "--bext-description", "First Try")
print "ok"
def test_update (tests):
print_test_name ("Update test")
for arg, value in tests:
cmd = "./sndfile-bwf-set %s \"%s\" output.wav" % (arg, value)
cmd = "./sndfile-metadata-set %s \"%s\" output.wav" % (arg, value)
status, output = commands.getstatusoutput (cmd)
if status:
print "\n\nError : command '%s' should not have failed." % cmd
@ -91,12 +91,12 @@ def test_post_mod (tests):
def test_auto_date ():
print_test_name ("Auto date test")
cmd = "./sndfile-bwf-set --auto-time-date sine.wav date-time.wav"
cmd = "./sndfile-metadata-set --bext-auto-time-date sine.wav date-time.wav"
status, output = commands.getstatusoutput (cmd)
if status:
print "\n\nError : command '%s' should not have failed." % cmd
target = datetime.date.today ().__str__ ()
assert_info ("date-time.wav", "--orig-date", target)
assert_info ("date-time.wav", "--bext-orig-date", target)
print "ok"
@ -105,7 +105,7 @@ def test_auto_date ():
if os.path.isdir ("examples"):
os.chdir ("examples")
for f in [ "sndfile-bwf-set", "sndfile-bwf-get", "make_sine" ]:
for f in [ "sndfile-metadata-set", "sndfile-metadata-get", "make_sine" ]:
check_executable (f)
os.system ("./make_sine")
@ -119,16 +119,16 @@ test_empty_fail ()
test_copy ()
tests = [
("--description", "Alpha"), ("--originator", "Beta"), ("--orig-ref", "Charlie"),
("--umid", "Delta"), ("--orig-date", "2001-10-01"), ("--orig-time", "01:02:03"),
("--info-name", "Echo"), ("--info-artist", "Fox trot")
("--bext-description", "Alpha"), ("--bext-originator", "Beta"), ("--bext-orig-ref", "Charlie"),
("--bext-umid", "Delta"), ("--bext-orig-date", "2001-10-01"), ("--bext-orig-time", "01:02:03"),
("--str-name", "Echo"), ("--str-artist", "Fox trot")
]
test_auto_date ()
test_update (tests)
test_post_mod (tests)
test_update ([ ("--info-artist", "Fox") ])
test_update ([ ("--str-artist", "Fox") ])
print ""

View File

@ -226,7 +226,7 @@ aiff_open (SF_PRIVATE *psf)
memset (&comm_fmt, 0, sizeof (comm_fmt)) ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if ((psf->container_data = calloc (1, sizeof (AIFF_PRIVATE))) == NULL)
return SFE_MALLOC_FAILED ;
@ -241,7 +241,7 @@ aiff_open (SF_PRIVATE *psf)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AIFF)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AIFF)
return SFE_BAD_OPEN_FORMAT ;
if (psf->mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE))
@ -268,7 +268,7 @@ aiff_open (SF_PRIVATE *psf)
psf->container_close = aiff_close ;
psf->command = aiff_command ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_U8 :
error = pcm_init (psf) ;
break ;
@ -1118,7 +1118,7 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length)
return err ;
} ;
endian = psf->sf.format & SF_FORMAT_ENDMASK ;
endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && endian == SF_ENDIAN_CPU)
endian = SF_ENDIAN_LITTLE ;
@ -1126,7 +1126,7 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length)
bit_width = psf->bytewidth * 8 ;
comm_frames = (psf->sf.frames > 0xFFFFFFFF) ? 0xFFFFFFFF : psf->sf.frames ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :

View File

@ -111,13 +111,13 @@ au_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AU)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AU)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
{ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_LITTLE ;
else if (psf->endian != SF_ENDIAN_LITTLE)
@ -215,7 +215,7 @@ au_write_header (SF_PRIVATE *psf, int calc_length)
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
encoding = au_format_to_encoding (psf->sf.format & SF_FORMAT_SUBMASK) ;
encoding = au_format_to_encoding (SF_CODEC (psf->sf.format)) ;
if (! encoding)
return (psf->error = SFE_BAD_OPEN_FORMAT) ;
@ -352,7 +352,7 @@ au_read_header (SF_PRIVATE *psf)
psf_log_printf (psf, " Encoding : %d => ", au_fmt.encoding) ;
psf->sf.format = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->sf.format = SF_ENDIAN (psf->sf.format) ;
switch (au_fmt.encoding)
{ case AU_ENCODING_ULAW_8 :

View File

@ -85,11 +85,11 @@ avr_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AVR)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AVR)
return SFE_BAD_OPEN_FORMAT ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
{ psf->endian = SF_ENDIAN (psf->sf.format) ;
psf->endian = SF_ENDIAN_BIG ;
if (avr_write_header (psf, SF_FALSE))
@ -215,7 +215,7 @@ avr_write_header (SF_PRIVATE *psf, int calc_length)
psf_binheader_writef (psf, "Emz22", TWOBIT_MARKER, make_size_t (8),
psf->sf.channels == 2 ? 0xFFFF : 0, psf->bytewidth * 8) ;
sign = ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_U8) ? 0 : 0xFFFF ;
sign = ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_U8) ? 0 : 0xFFFF ;
psf_binheader_writef (psf, "E222", sign, 0, 0xFFFF) ;
psf_binheader_writef (psf, "E4444", psf->sf.samplerate, psf->sf.frames, 0, 0) ;

View File

@ -87,7 +87,7 @@ broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, un
break ;
} ;
switch (format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (format))
{ case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_S8 :
width = 8 ;

View File

@ -103,13 +103,13 @@ caf_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
format = psf->sf.format & SF_FORMAT_TYPEMASK ;
format = SF_CONTAINER (psf->sf.format) ;
if (format != SF_FORMAT_CAF)
return SFE_BAD_OPEN_FORMAT ;
@ -400,9 +400,9 @@ caf_write_header (SF_PRIVATE *psf, int calc_length)
double64_be_write (1.0 * psf->sf.samplerate, psf->u.ucbuf) ;
psf_binheader_writef (psf, "b", psf->u.ucbuf, make_size_t (8)) ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU))
psf->endian = SF_ENDIAN_BIG ;

View File

@ -225,8 +225,8 @@ int
psf_get_format_info (SF_FORMAT_INFO *data)
{ int k, format ;
if (data->format & SF_FORMAT_TYPEMASK)
{ format = data->format & SF_FORMAT_TYPEMASK ;
if (SF_CONTAINER (data->format))
{ format = SF_CONTAINER (data->format) ;
for (k = 0 ; k < (SIGNED_SIZEOF (major_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)) ; k++)
{ if (format == major_formats [k].format)
@ -235,8 +235,8 @@ psf_get_format_info (SF_FORMAT_INFO *data)
} ;
} ;
}
else if (data->format & SF_FORMAT_SUBMASK)
{ format = data->format & SF_FORMAT_SUBMASK ;
else if (SF_CODEC (data->format))
{ format = SF_CODEC (data->format) ;
for (k = 0 ; k < (SIGNED_SIZEOF (subtype_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)) ; k++)
{ if (format == subtype_formats [k].format)

View File

@ -1321,7 +1321,7 @@ psf_rand_int32 (void)
const char *
str_of_major_format (int format)
{ switch (format & SF_FORMAT_TYPEMASK)
{ switch (SF_CONTAINER (format))
{ CASE_NAME (SF_FORMAT_WAV) ;
CASE_NAME (SF_FORMAT_AIFF) ;
CASE_NAME (SF_FORMAT_AU) ;
@ -1354,7 +1354,7 @@ str_of_major_format (int format)
const char *
str_of_minor_format (int format)
{ switch (format & SF_FORMAT_SUBMASK)
{ switch (SF_CODEC (format))
{ CASE_NAME (SF_FORMAT_PCM_S8) ;
CASE_NAME (SF_FORMAT_PCM_16) ;
CASE_NAME (SF_FORMAT_PCM_24) ;

View File

@ -104,6 +104,15 @@
#define SF_MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/*
* Macros for spliting the format file of SF_INFI into contrainer type,
** codec type and endian-ness.
*/
#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK)
#define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK)
#define SF_ENDIAN(x) ((x) & SF_FORMAT_ENDMASK)
enum
{ /* PEAK chunk location. */
SF_PEAK_START = 42,

View File

@ -128,7 +128,7 @@ dither_init (SF_PRIVATE *psf, int mode)
if (pdither == NULL)
return SFE_MALLOC_FAILED ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_DOUBLE :
case SF_FORMAT_FLOAT :
pdither->read_int = psf->read_int ;
@ -153,7 +153,7 @@ dither_init (SF_PRIVATE *psf, int mode)
if (pdither == NULL)
return SFE_MALLOC_FAILED ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_DOUBLE :
case SF_FORMAT_FLOAT :
pdither->write_int = psf->write_int ;
@ -219,7 +219,7 @@ dither_write_short (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
return 0 ;
} ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_DPCM_8 :
@ -259,7 +259,7 @@ dither_write_int (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
return 0 ;
} ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
@ -304,7 +304,7 @@ dither_write_float (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
return 0 ;
} ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
@ -348,7 +348,7 @@ dither_write_double (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
return 0 ;
} ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :

View File

@ -76,14 +76,14 @@ dwd_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_DWD)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_DWD)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{
/*-psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
/*-psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_LITTLE ;
else if (psf->endian != SF_ENDIAN_LITTLE)

View File

@ -628,10 +628,10 @@ flac_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_FLAC)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;
@ -723,7 +723,7 @@ flac_enc_init (SF_PRIVATE *psf)
psf_fseek (psf, 0, SEEK_SET) ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
bps = 8 ;
break ;
@ -934,7 +934,7 @@ flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = s2flac8_array ;
break ;
@ -976,7 +976,7 @@ flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = i2flac8_array ;
break ;
@ -1018,7 +1018,7 @@ flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = (psf->add_clipping) ? f2flac8_clip_array : f2flac8_array ;
break ;
@ -1150,7 +1150,7 @@ flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = (psf->add_clipping) ? d2flac8_clip_array : d2flac8_array ;
break ;

View File

@ -90,7 +90,7 @@ g72x_init (SF_PRIVATE * psf)
pg72x->block_curr = 0 ;
pg72x->sample_curr = 0 ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_G721_32 :
codec = G721_32_BITS_PER_SAMPLE ;
bytesperblock = G721_32_BYTES_PER_BLOCK ;

View File

@ -105,7 +105,7 @@ Need separate gsm_data structs for encode and decode.
if ((pgsm610->gsm_data = gsm_create ()) == NULL)
return SFE_MALLOC_FAILED ;
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
case SF_FORMAT_W64 :
@ -387,8 +387,8 @@ gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
pgsm610->blockcount = 0 ;
gsm_init (pgsm610->gsm_data) ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
(psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_W64)
if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAV ||
(SF_CONTAINER (psf->sf.format)) == SF_FORMAT_W64)
gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ;
pgsm610->decode_block (psf, pgsm610) ;

View File

@ -60,10 +60,10 @@ htk_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_HTK)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_HTK)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;

View File

@ -204,7 +204,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
else
pima->blocks = psf->datalength / pima->blocksize ;
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_W64 :
count = 2 * (pima->blocksize - 4 * pima->channels) / pima->channels + 1 ;
@ -813,7 +813,7 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign)
pima->samplecount = 0 ;
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_W64 :
pima->encode_block = wav_w64_ima_encode_block ;

View File

@ -85,13 +85,13 @@ ircam_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_IRCAM)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_IRCAM)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)
psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
@ -249,7 +249,7 @@ ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
current = psf_ftell (psf) ;
/* This also sets psf->endian. */
encoding = get_encoding (psf->sf.format & SF_FORMAT_SUBMASK) ;
encoding = get_encoding (SF_CODEC (psf->sf.format)) ;
if (encoding == 0)
return SFE_BAD_OPEN_FORMAT ;

View File

@ -81,16 +81,16 @@ mat4_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_MAT4)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MAT4)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
psf->endian = SF_ENDIAN_LITTLE ;
else if (CPU_IS_BIG_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
@ -162,7 +162,7 @@ mat4_write_header (SF_PRIVATE *psf, int calc_length)
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
encoding = mat4_format_to_encoding (psf->sf.format & SF_FORMAT_SUBMASK, psf->endian) ;
encoding = mat4_format_to_encoding (SF_CODEC (psf->sf.format), psf->endian) ;
if (encoding == -1)
return SFE_BAD_OPEN_FORMAT ;

View File

@ -91,16 +91,16 @@ mat5_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_MAT5)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MAT5)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
psf->endian = SF_ENDIAN_LITTLE ;
else if (CPU_IS_BIG_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
@ -174,7 +174,7 @@ mat5_write_header (SF_PRIVATE *psf, int calc_length)
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_U8 :
encoding = MAT5_TYPE_UCHAR ;
break ;

View File

@ -71,10 +71,10 @@ mpc2k_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_MPC2K)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MPC2K)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (mpc2k_write_header (psf, SF_FALSE))

View File

@ -66,10 +66,10 @@ new_open (SF_PRIVATE *psf)
if ((error = new_read_header (psf)))
return error ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WVE)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
return error ;
} /* new_open */

View File

@ -63,10 +63,10 @@ nist_open (SF_PRIVATE *psf)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_NIST)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_NIST)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)
psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
@ -81,7 +81,7 @@ nist_open (SF_PRIVATE *psf)
psf->container_close = nist_close ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
error = pcm_init (psf) ;
break ;
@ -307,7 +307,7 @@ nist_write_header (SF_PRIVATE *psf, int calc_length)
psf_asciiheader_printf (psf, "channel_count -i %d\n", psf->sf.channels) ;
psf_asciiheader_printf (psf, "sample_rate -i %d\n", psf->sf.samplerate) ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
psf_asciiheader_printf (psf, "sample_coding -s3 pcm\n") ;
psf_asciiheader_printf (psf, "sample_n_bytes -i 1\n"

View File

@ -113,13 +113,13 @@ paf_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PAF)
return SFE_BAD_OPEN_FORMAT ;
endian = psf->sf.format & SF_FORMAT_ENDMASK ;
endian = SF_ENDIAN (psf->sf.format) ;
/* PAF is by default big endian. */
psf->endian = SF_ENDIAN_BIG ;
@ -282,7 +282,7 @@ paf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
psf->dataoffset = PAF_HEADER_LENGTH ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
paf_format = PAF_PCM_S8 ;
break ;

View File

@ -127,9 +127,9 @@ pcm_init (SF_PRIVATE *psf)
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_S8)
if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
chars = SF_CHARS_SIGNED ;
else if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_U8)
else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_U8)
chars = SF_CHARS_UNSIGNED ;
if (CPU_IS_BIG_ENDIAN)

View File

@ -56,10 +56,10 @@ pvf_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PVF)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PVF)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;

View File

@ -31,9 +31,9 @@ int
raw_open (SF_PRIVATE *psf)
{ int subformat, error = SFE_NO_ERROR ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU))
psf->endian = SF_ENDIAN_BIG ;

View File

@ -118,12 +118,12 @@ sd2_open (SF_PRIVATE *psf)
goto error_cleanup ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SD2)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SD2)
{ error = SFE_BAD_OPEN_FORMAT ;
goto error_cleanup ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
psf->dataoffset = 0 ;
/* Only open and write the resource in RDWR mode is its current length is zero. */

View File

@ -116,7 +116,7 @@ sds_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SDS)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SDS)
return SFE_BAD_OPEN_FORMAT ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
@ -360,7 +360,7 @@ sds_write_header (SF_PRIVATE *psf, int calc_length)
psf_binheader_writef (psf, "E211", 0xF07E, 0, 1) ;
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
psds->bitwidth = 8 ;
break ;

View File

@ -332,7 +332,7 @@ SNDFILE*
sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc)
{ SF_PRIVATE *psf ;
if ((sfinfo->format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2)
if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_SD2)
{ sf_errno = SFE_SD2_FD_DISALLOWED ;
return NULL ;
} ;
@ -533,8 +533,8 @@ int
sf_format_check (const SF_INFO *info)
{ int subformat, endian ;
subformat = info->format & SF_FORMAT_SUBMASK ;
endian = info->format & SF_FORMAT_ENDMASK ;
subformat = SF_CODEC (info->format) ;
endian = SF_ENDIAN (info->format) ;
/* This is the place where each file format can check if the suppiled
** SF_INFO struct is valid.
@ -547,7 +547,7 @@ sf_format_check (const SF_INFO *info)
if (info->samplerate < 0)
return 0 ;
switch (info->format & SF_FORMAT_TYPEMASK)
switch (SF_CONTAINER (info->format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
/* WAV now allows both endian, RIFF or RIFX (little or big respectively) */
@ -919,13 +919,13 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
return old_value ;
case SFC_SET_ADD_PEAK_CHUNK :
{ int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
{ int format = SF_CONTAINER (psf->sf.format) ;
/* Only WAV and AIFF support the PEAK chunk. */
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX && format != SF_FORMAT_AIFF)
return SF_FALSE ;
format = psf->sf.format & SF_FORMAT_SUBMASK ;
format = SF_CODEC (psf->sf.format) ;
/* Only files containg the following data types support the PEAK chunk. */
if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE)
@ -953,6 +953,9 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
psf->write_header (psf, SF_TRUE) ;
return datasize ;
case SFC_SET_ADD_HEADER_PAD_CHUNK :
return SF_FALSE ;
case SFC_GET_LOG_INFO :
if (data == NULL)
return SFE_BAD_CONTROL_CMD ;
@ -1053,7 +1056,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
case SFC_SET_RAW_START_OFFSET :
if (data == NULL || datasize != sizeof (sf_count_t))
return (psf->error = SFE_BAD_CONTROL_CMD) ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW)
return (psf->error = SFE_BAD_CONTROL_CMD) ;
psf->dataoffset = *((sf_count_t*) data) ;
@ -1071,9 +1074,9 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
/* Lite remove start */
case SFC_TEST_IEEE_FLOAT_REPLACE :
psf->ieee_replace = (datasize) ? SF_TRUE : SF_FALSE ;
if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_FLOAT)
float32_init (psf) ;
else if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DOUBLE)
else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DOUBLE)
double64_init (psf) ;
else
return (psf->error = SFE_BAD_CONTROL_CMD) ;
@ -1096,7 +1099,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
return SF_TRUE ;
case SFC_SET_BROADCAST_INFO :
{ int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
{ int format = SF_CONTAINER (psf->sf.format) ;
/* Only WAV supports the BEXT (Broadcast) chunk. */
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
@ -2182,7 +2185,7 @@ format_from_extension (SF_PRIVATE *psf)
}
/* For RAW files, make sure the dataoffset if set correctly. */
if ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW)
if ((SF_CONTAINER (format)) == SF_FORMAT_RAW)
psf->dataoffset = 0 ;
return format ;
@ -2314,9 +2317,9 @@ validate_sfinfo (SF_INFO *sfinfo)
return 0 ;
if (sfinfo->channels < 1)
return 0 ;
if ((sfinfo->format & SF_FORMAT_TYPEMASK) == 0)
if ((SF_CONTAINER (sfinfo->format)) == 0)
return 0 ;
if ((sfinfo->format & SF_FORMAT_SUBMASK) == 0)
if ((SF_CODEC (sfinfo->format)) == 0)
return 0 ;
if (sfinfo->sections < 1)
return 0 ;
@ -2451,7 +2454,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
sfinfo->seekable = 0 ;
if (mode == SFM_READ)
{ if ((sfinfo->format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW)
{ if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_RAW)
{ if (sf_format_check (sfinfo) == 0)
{ error = SFE_RAW_BAD_FORMAT ;
goto error_exit ;
@ -2528,11 +2531,11 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
{ /* If the file is being opened for write or RDWR and the file is currently
** empty, then the SF_INFO struct must contain valid data.
*/
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == 0)
if ((SF_CONTAINER (psf->sf.format)) == 0)
{ error = SFE_ZERO_MAJOR_FORMAT ;
goto error_exit ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == 0)
if ((SF_CONTAINER (psf->sf.format)) == 0)
{ error = SFE_ZERO_MINOR_FORMAT ;
goto error_exit ;
} ;
@ -2542,7 +2545,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
goto error_exit ;
} ;
}
else if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW)
else if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW)
{ /* If type RAW has not been specified then need to figure out file type. */
psf->sf.format = guess_file_type (psf) ;
@ -2554,7 +2557,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
psf->last_op = psf->mode ;
/* Set bytewidth if known. */
switch (psf->sf.format & SF_FORMAT_SUBMASK)
switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_ULAW :
@ -2583,7 +2586,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
} ;
/* Call the initialisation function for the relevant file type. */
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
error = wav_open (psf) ;
@ -2704,7 +2707,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
goto error_exit ;
/* For now, check whether embedding is supported. */
format = psf->sf.format & SF_FORMAT_TYPEMASK ;
format = SF_CONTAINER (psf->sf.format) ;
if (psf->fileoffset > 0 &&
(format != SF_FORMAT_WAV) && (format != SF_FORMAT_WAVEX) &&
(format != SF_FORMAT_AIFF) && (format != SF_FORMAT_AU)

View File

@ -154,6 +154,7 @@ enum
SFC_GET_MAX_ALL_CHANNELS = 0x1045,
SFC_SET_ADD_PEAK_CHUNK = 0x1050,
SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051,
SFC_UPDATE_HEADER_NOW = 0x1060,
SFC_SET_UPDATE_HEADER_AUTO = 0x1061,
@ -190,7 +191,7 @@ enum
SFC_WAVEX_SET_AMBISONIC = 0x1200,
SFC_WAVEX_GET_AMBISONIC = 0x1201,
SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
/* Following commands for testing only. */
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,

View File

@ -99,10 +99,10 @@ svx_open (SF_PRIVATE *psf)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SVX)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SVX)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (psf->endian == SF_ENDIAN_LITTLE || (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU))
return SFE_BAD_ENDIAN ;

View File

@ -112,10 +112,10 @@ voc_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_VOC)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_VOC)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_LITTLE ;
@ -428,7 +428,7 @@ voc_write_header (SF_PRIVATE *psf, int calc_length)
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
/* Reset the current header length to zero. */
psf->header [0] = 0 ;
psf->headindex = 0 ;

View File

@ -115,10 +115,10 @@ w64_open (SF_PRIVATE *psf)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_W64)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_W64)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
@ -401,7 +401,7 @@ w64_write_header (SF_PRIVATE *psf, int calc_length)
/* riff marker, length, wave and 'fmt ' markers. */
psf_binheader_writef (psf, "eh8hh", riff_MARKER16, psf->filelength, wave_MARKER16, fmt_MARKER16) ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
switch (subformat)
{ case SF_FORMAT_PCM_U8 :

View File

@ -190,7 +190,7 @@ wav_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
@ -198,14 +198,14 @@ wav_open (SF_PRIVATE *psf)
wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
format = psf->sf.format & SF_FORMAT_TYPEMASK ;
format = SF_CONTAINER (psf->sf.format) ;
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
return SFE_BAD_OPEN_FORMAT ;
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
/* RIFF WAVs are little-endian, RIFX WAVs are big-endian, default to little */
psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_BIG_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_BIG ;
else if (psf->endian != SF_ENDIAN_BIG)
@ -577,10 +577,19 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
return error ;
break ;
case PAD_MARKER :
/*
We can eat into a 'PAD ' chunk if we need to.
parsestage |= HAVE_other ;
*/
psf_binheader_readf (psf, "4", &dword) ;
psf_log_printf (psf, "%M : %u\n", marker, dword) ;
dword += (dword & 1) ;
psf_binheader_readf (psf, "j", dword) ;
break ;
case iXML_MARKER : /* See http://en.wikipedia.org/wiki/IXML */
case strc_MARKER : /* Multiple of 32 bytes. */
case afsp_MARKER :
case clm_MARKER :
case elmo_MARKER :
@ -589,7 +598,6 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
case plst_MARKER :
case DISP_MARKER :
case MEXT_MARKER :
case PAD_MARKER :
parsestage |= HAVE_other ;
psf_binheader_readf (psf, "4", &dword) ;
@ -718,7 +726,7 @@ static int
wav_write_fmt_chunk (SF_PRIVATE *psf)
{ int subformat, fmt_size, add_fact_chunk = 0 ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
switch (subformat)
{ case SF_FORMAT_PCM_U8 :
@ -880,7 +888,7 @@ wavex_write_fmt_chunk (SF_PRIVATE *psf)
if ((wpriv = psf->container_data) == NULL)
return SFE_INTERNAL ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
/* initial section (same for all, it appears) */
switch (subformat)
@ -1039,7 +1047,7 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
psf_binheader_writef (psf, "mm", WAVE_MARKER, fmt_MARKER) ;
/* Write the 'fmt ' chunk. */
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
if ((error = wav_write_fmt_chunk (psf)) != 0)
return error ;
@ -1093,9 +1101,9 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
} ;
} ;
if (psf->headindex + 8 < psf->dataoffset)
if (psf->headindex + 16 < psf->dataoffset)
{ /* Add PAD data if necessary. */
k = psf->dataoffset - 16 - psf->headindex ;
k = psf->dataoffset - (psf->headindex + 16) ;
psf_binheader_writef (psf, "m4z", PAD_MARKER, k, make_size_t (k)) ;
} ;
@ -1226,7 +1234,7 @@ wav_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize)
switch (command)
{ case SFC_WAVEX_SET_AMBISONIC :
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAVEX)
if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAVEX)
{ if (datasize == SF_AMBISONIC_NONE)
wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
else if (datasize == SF_AMBISONIC_B_FORMAT)

View File

@ -64,7 +64,7 @@ wve_open (SF_PRIVATE *psf)
} ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WVE)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;

View File

@ -80,10 +80,10 @@ xi_open (SF_PRIVATE *psf)
return error ;
} ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_XI)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_XI)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_LITTLE ;
@ -246,7 +246,7 @@ dpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DPCM_16)
if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DPCM_16)
{ total = offset ;
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
while (total > 0)