Merge RF64 support.

This commit is contained in:
Erik de Castro Lopo 2008-10-14 09:28:53 +11:00
commit 132e08c26b
15 changed files with 640 additions and 34 deletions

View File

@ -167,8 +167,29 @@
* 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.
* src/rf64.c
Fixes to make sure all tests pass.
* tests/Makefile.am tests/string_test.c
Add string tests (not yet passing).
2008-08-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/rf64.c
First pass at writing RF64 now working.
2008-08-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-convert.c
Add SF_FORMAT_RF64 to format_map.
* src/common.h src/sndfile.c
More RF64 support code.
* examples/sndfile-bwf-set.c
Fix the month number in autogenerated date string and use hypen in date
instead of slash.
@ -180,6 +201,21 @@
When called with -i or -b option, operate on all files on command line, not
just the first.
2008-08-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/rf64.c
New file to handle RF64 (WAV like format supportting > 4Gig files).
* src/sndfile.h.in src/common.h src/sndfile.c src/Makefile.am
Hook the above into build so hacking can begin.
* src/pcm.c
Improve log message when pcm_init fails.
* src/sndfile-info.c
Only calculate and print 'Signal Max' if file is less than 10 megabytes in
length.
2008-08-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/string_test.c

View File

@ -82,6 +82,7 @@ static OUTPUT_FORMAT_MAP format_map [] =
{ "wve", 0, SF_FORMAT_WVE },
{ "oga", 0, SF_FORMAT_OGG },
{ "mpc", 0, SF_FORMAT_MPC2K },
{ "rf64", 0, SF_FORMAT_RF64 },
} ; /* format_map */
static int

View File

@ -257,10 +257,13 @@ info_dump (const char *filename)
printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ;
/* Do not use sf_signal_max because it doesn't work for non-seekable files . */
signal_max = get_signal_max (file) ;
decibels = calc_decibels (&sfinfo, signal_max) ;
printf ("Signal Max : %g (%4.2f dB)\n\n", signal_max, decibels) ;
if (sfinfo.frames < 10 * 1024 * 1024)
{ /* Do not use sf_signal_max because it doesn't work for non-seekable files . */
signal_max = get_signal_max (file) ;
decibels = calc_decibels (&sfinfo, signal_max) ;
printf ("Signal Max : %g (%4.2f dB)\n", signal_max, decibels) ;
} ;
putchar ('\n') ;
} ;
sf_close (file) ;

View File

@ -28,7 +28,7 @@ COMMON = common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
FILESPECIFIC = sndfile.c aiff.c au.c avr.c caf.c dwd.c flac.c g72x.c htk.c ircam.c \
macbinary3.c macos.c mat4.c mat5.c nist.c ogg.c paf.c pvf.c raw.c rx2.c sd2.c \
sds.c svx.c txw.c voc.c wve.c w64.c wav_w64.c wav.c xi.c mpc2k.c
sds.c svx.c txw.c voc.c wve.c w64.c wav_w64.c wav.c xi.c mpc2k.c rf64.c
# MinGW requires -no-undefined if a DLL is to be built.
libsndfile_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@

View File

@ -578,6 +578,8 @@ enum
SFE_VORBIS_ENCODER_BUG,
SFE_RF64_NOT_RF64,
SFE_MAX_ERROR /* This must be last in list. */
} ;
@ -713,6 +715,7 @@ int xi_open (SF_PRIVATE *psf) ;
int flac_open (SF_PRIVATE *psf) ;
int caf_open (SF_PRIVATE *psf) ;
int mpc2k_open (SF_PRIVATE *psf) ;
int rf64_open (SF_PRIVATE *psf) ;
/* In progress. Do not currently work. */

View File

@ -193,7 +193,7 @@ pcm_init (SF_PRIVATE *psf)
psf->read_double = pcm_read_lei2d ;
break ;
default :
psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\n") ;
psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\nbytewidth %d endian %d\n", psf->bytewidth, psf->endian) ;
return SFE_UNIMPLEMENTED ;
} ;
} ;
@ -258,7 +258,7 @@ pcm_init (SF_PRIVATE *psf)
break ;
default :
psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\n") ;
psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\nbytewidth %s endian %d\n", psf->bytewidth, psf->endian) ;
return SFE_UNIMPLEMENTED ;
} ;

488
src/rf64.c Normal file
View File

@ -0,0 +1,488 @@
/*
** Copyright (C) 2008 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2.1 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
** This format documented at:
** http://www.sr.se/utveckling/tu/bwf/prog/RF_64v1_4.pdf
*/
#include "sfconfig.h"
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
#include "wav_w64.h"
/*------------------------------------------------------------------------------
** Macros to handle big/little endian issues.
*/
#define RF64_MARKER MAKE_MARKER ('R', 'F', '6', '4')
#define FFFF_MARKER MAKE_MARKER (0xff, 0xff, 0xff, 0xff)
#define WAVE_MARKER MAKE_MARKER ('W', 'A', 'V', 'E')
#define ds64_MARKER MAKE_MARKER ('d', 's', '6', '4')
#define fmt_MARKER MAKE_MARKER ('f', 'm', 't', ' ')
#define fact_MARKER MAKE_MARKER ('f', 'a', 'c', 't')
#define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a')
/*------------------------------------------------------------------------------
** Typedefs.
*/
/*------------------------------------------------------------------------------
** Private static functions.
*/
static int rf64_read_header (SF_PRIVATE *psf) ;
static int rf64_write_header (SF_PRIVATE *psf, int calc_length) ;
static int rf64_close (SF_PRIVATE *psf) ;
/*------------------------------------------------------------------------------
** Public function.
*/
int
rf64_open (SF_PRIVATE *psf)
{ WAV_PRIVATE *wpriv ;
int subformat, error = 0 ;
if ((wpriv = calloc (1, sizeof (WAV_PRIVATE))) == NULL)
return SFE_MALLOC_FAILED ;
psf->container_data = wpriv ;
/* All RF64 files are little endian. */
psf->endian = SF_ENDIAN_LITTLE ;
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = rf64_read_header (psf)) != 0)
return error ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RF64)
return SFE_BAD_OPEN_FORMAT ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
if ((error = rf64_write_header (psf, SF_FALSE)))
return error ;
psf->write_header = rf64_write_header ;
} ;
psf->container_close = rf64_close ;
switch (subformat)
{ case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
case SF_FORMAT_PCM_32 :
error = pcm_init (psf) ;
break ;
case SF_FORMAT_ULAW :
error = ulaw_init (psf) ;
break ;
case SF_FORMAT_ALAW :
error = alaw_init (psf) ;
break ;
/* Lite remove start */
case SF_FORMAT_FLOAT :
error = float32_init (psf) ;
break ;
case SF_FORMAT_DOUBLE :
error = double64_init (psf) ;
break ;
/* Lite remove end */
default : return SFE_UNIMPLEMENTED ;
} ;
return error ;
} /* rf64_open */
/*------------------------------------------------------------------------------
*/
static int
rf64_read_header (SF_PRIVATE *psf)
{ WAV_PRIVATE *wpriv ;
sf_count_t riff_size, data_size ;
unsigned int size32 ;
int marker, marks [2], error, done = 0 ;
if ((wpriv = psf->container_data) == NULL)
return SFE_INTERNAL ;
/* Set position to start of file to begin reading header. */
psf_binheader_readf (psf, "pmmm", 0, &marker, marks, marks + 1) ;
if (marker != RF64_MARKER || marks [0] != FFFF_MARKER || marks [1] != WAVE_MARKER)
return SFE_RF64_NOT_RF64 ;
psf_log_printf (psf, "%M\n %M\n", RF64_MARKER, WAVE_MARKER) ;
while (! done)
{ psf_binheader_readf (psf, "em4", &marker, &size32) ;
switch (marker)
{ case ds64_MARKER :
psf_log_printf (psf, "%M : %u\n", marker, size32) ;
psf_binheader_readf (psf, "888", &riff_size, &data_size, &psf->sf.frames) ;
psf_log_printf (psf, " Riff size : %D\n Data size : %D\n Frames : %D\n",
riff_size, data_size, psf->sf.frames) ;
psf_binheader_readf (psf, "4", &size32) ;
psf_log_printf (psf, " Table len : %u\n", size32) ;
psf_binheader_readf (psf, "jm4", size32 + 4, &marker, &size32) ;
psf_log_printf (psf, "%M : %u\n", marker, size32) ;
if ((error = wav_w64_read_fmt_chunk (psf, size32)) != 0)
return error ;
psf->sf.format = SF_FORMAT_RF64 | (psf->sf.format & SF_FORMAT_SUBMASK) ;
break ;
case data_MARKER :
psf_log_printf (psf, "%M : %x\n", marker, size32) ;
psf->dataoffset = psf->headindex ;
done = SF_TRUE ;
break ;
default :
if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF)
&& isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF))
{ psf_binheader_readf (psf, "4", &size32) ;
psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, size32) ;
psf_binheader_readf (psf, "j", size32) ;
break ;
} ;
if (psf_ftell (psf) & 0x03)
{ psf_log_printf (psf, " Unknown chunk marker at position %d. Resynching.\n", size32 - 4) ;
psf_binheader_readf (psf, "j", -3) ;
break ;
} ;
psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 4) ;
done = SF_TRUE ;
break ;
} ;
} ;
psf_log_printf (psf, "End\n") ;
return 0 ;
} /* rf64_read_header */
/* known WAVEFORMATEXTENSIBLE GUIDS */
static const EXT_SUBFORMAT MSGUID_SUBTYPE_PCM =
{ 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
} ;
static const EXT_SUBFORMAT MSGUID_SUBTYPE_MS_ADPCM =
{ 0x00000002, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
} ;
static const EXT_SUBFORMAT MSGUID_SUBTYPE_IEEE_FLOAT =
{ 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
} ;
static const EXT_SUBFORMAT MSGUID_SUBTYPE_ALAW =
{ 0x00000006, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
} ;
static const EXT_SUBFORMAT MSGUID_SUBTYPE_MULAW =
{ 0x00000007, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
} ;
/*
** the next two are from
** http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html
*/
static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM =
{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 }
} ;
static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT =
{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 }
} ;
static int
wavex_write_fmt_chunk (SF_PRIVATE *psf)
{ WAV_PRIVATE *wpriv ;
int subformat, fmt_size, add_fact_chunk = 0 ;
if ((wpriv = psf->container_data) == NULL)
return SFE_INTERNAL ;
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
/* initial section (same for all, it appears) */
switch (subformat)
{ case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
case SF_FORMAT_PCM_32 :
case SF_FORMAT_FLOAT :
case SF_FORMAT_DOUBLE :
case SF_FORMAT_ULAW :
case SF_FORMAT_ALAW :
fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2 + 2 + 8 ;
/* fmt : format, channels, samplerate */
psf_binheader_writef (psf, "4224", fmt_size, WAVE_FORMAT_EXTENSIBLE, psf->sf.channels, psf->sf.samplerate) ;
/* fmt : bytespersec */
psf_binheader_writef (psf, "4", psf->sf.samplerate * psf->bytewidth * psf->sf.channels) ;
/* fmt : blockalign, bitwidth */
psf_binheader_writef (psf, "22", psf->bytewidth * psf->sf.channels, psf->bytewidth * 8) ;
/* cbSize 22 is sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX) */
psf_binheader_writef (psf, "2", 22) ;
/* wValidBitsPerSample, for our use same as bitwidth as we use it fully */
psf_binheader_writef (psf, "2", psf->bytewidth * 8) ;
/* For an Ambisonic file set the channel mask to zero.
** Otherwise use a default based on the channel count.
*/
if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE)
psf_binheader_writef (psf, "4", 0) ;
else
{ /*
** Ok some liberty is taken here to use the most commonly used channel masks
** instead of "no mapping". If you really want to use "no mapping" for 8 channels and less
** please don't use wavex. (otherwise we'll have to create a new SF_COMMAND)
*/
switch (psf->sf.channels)
{ case 1 : /* center channel mono */
psf_binheader_writef (psf, "4", 0x4) ;
break ;
case 2 : /* front left and right */
psf_binheader_writef (psf, "4", 0x1 | 0x2) ;
break ;
case 4 : /* Quad */
psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x10 | 0x20) ;
break ;
case 6 : /* 5.1 */
psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20) ;
break ;
case 8 : /* 7.1 */
psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80) ;
break ;
default : /* 0 when in doubt , use direct out, ie NO mapping*/
psf_binheader_writef (psf, "4", 0x0) ;
break ;
} ;
} ;
break ;
case SF_FORMAT_MS_ADPCM : /* Todo, GUID exists might have different header as per wav_write_header */
default :
return SFE_UNIMPLEMENTED ;
} ;
/* GUID section, different for each */
switch (subformat)
{ case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
case SF_FORMAT_PCM_32 :
wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
&MSGUID_SUBTYPE_PCM : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM) ;
break ;
case SF_FORMAT_FLOAT :
case SF_FORMAT_DOUBLE :
wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
&MSGUID_SUBTYPE_IEEE_FLOAT : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ;
break ;
case SF_FORMAT_ULAW :
wavex_write_guid (psf, &MSGUID_SUBTYPE_MULAW) ;
break ;
case SF_FORMAT_ALAW :
wavex_write_guid (psf, &MSGUID_SUBTYPE_ALAW) ;
break ;
case SF_FORMAT_MS_ADPCM : /* todo, GUID exists */
return SFE_UNIMPLEMENTED ;
wavex_write_guid (psf, &MSGUID_SUBTYPE_MS_ADPCM) ;
break ;
default : return SFE_UNIMPLEMENTED ;
} ;
if (add_fact_chunk)
psf_binheader_writef (psf, "tm48", fact_MARKER, 4, psf->sf.frames) ;
return 0 ;
} /* wavex_write_fmt_chunk */
static int
rf64_write_header (SF_PRIVATE *psf, int calc_length)
{ sf_count_t current ;
int error = 0, has_data = SF_FALSE ;
current = psf_ftell (psf) ;
if (psf->dataoffset > 0 && current > psf->dataoffset)
has_data = SF_TRUE ;
if (calc_length)
{ psf->filelength = psf_get_filelen (psf) ;
psf->datalength = psf->filelength - psf->dataoffset ;
if (psf->dataend)
psf->datalength -= psf->filelength - psf->dataend ;
if (psf->bytewidth > 0)
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
/* Reset the current header length to zero. */
psf->header [0] = 0 ;
psf->headindex = 0 ;
psf_fseek (psf, 0, SEEK_SET) ;
psf_binheader_writef (psf, "em4m", RF64_MARKER, 0xffffffff, WAVE_MARKER) ;
psf_binheader_writef (psf, "m488844", ds64_MARKER, 32, psf->filelength, psf->datalength, psf->sf.frames, 0, 0x005c0064) ;
/* WAVE and 'fmt ' markers. */
psf_binheader_writef (psf, "m", fmt_MARKER) ;
/* Write the 'fmt ' chunk. */
switch (psf->sf.format & SF_FORMAT_TYPEMASK)
{ case SF_FORMAT_WAV :
psf_log_printf (psf, "ooops SF_FORMAT_WAV\n") ;
return SFE_UNIMPLEMENTED ;
break ;
case SF_FORMAT_WAVEX :
case SF_FORMAT_RF64 :
if ((error = wavex_write_fmt_chunk (psf)) != 0)
return error ;
break ;
default :
return SFE_UNIMPLEMENTED ;
} ;
#if 0
/* The LIST/INFO chunk. */
if (psf->str_flags & SF_STR_LOCATE_START)
wav_write_strings (psf, SF_STR_LOCATE_START) ;
if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START)
{ psf_binheader_writef (psf, "m4", PEAK_MARKER, WAV_PEAK_CHUNK_SIZE (psf->sf.channels)) ;
psf_binheader_writef (psf, "44", 1, time (NULL)) ;
for (k = 0 ; k < psf->sf.channels ; k++)
psf_binheader_writef (psf, "ft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ;
} ;
if (psf->broadcast_info != NULL)
wav_write_bext_chunk (psf) ;
if (psf->instrument != NULL)
{ int tmp ;
double dtune = (double) (0x40000000) / 25.0 ;
psf_binheader_writef (psf, "m4", smpl_MARKER, 9 * 4 + psf->instrument->loop_count * 6 * 4) ;
psf_binheader_writef (psf, "44", 0, 0) ; /* Manufacturer zero is everyone */
tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */
psf_binheader_writef (psf, "44", tmp, psf->instrument->basenote) ;
tmp = (unsigned int) (psf->instrument->detune * dtune + 0.5) ;
psf_binheader_writef (psf, "4", tmp) ;
psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */
psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ;
for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
{ int type ;
type = psf->instrument->loops [tmp].mode ;
type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ;
psf_binheader_writef (psf, "44", tmp, type) ;
psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ;
psf_binheader_writef (psf, "44", 0, psf->instrument->loops [tmp].count) ;
} ;
} ;
if (psf->headindex + 8 < psf->dataoffset)
{ /* Add PAD data if necessary. */
k = psf->dataoffset - 16 - psf->headindex ;
psf_binheader_writef (psf, "m4z", PAD_MARKER, k, make_size_t (k)) ;
} ;
#endif
psf_binheader_writef (psf, "m4", data_MARKER, 0xffffffff) ;
psf_fwrite (psf->header, psf->headindex, 1, psf) ;
if (psf->error)
return psf->error ;
if (has_data && psf->dataoffset != psf->headindex)
{ printf ("Oooops : has_data && psf->dataoffset != psf->headindex\n") ;
return psf->error = SFE_INTERNAL ;
} ;
psf->dataoffset = psf->headindex ;
if (! has_data)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
else if (current > 0)
psf_fseek (psf, current, SEEK_SET) ;
return psf->error ;
} /* rf64_write_header */
static int
rf64_close (SF_PRIVATE *psf)
{
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ // rf64_write_tailer (psf) ;
psf->write_header (psf, SF_TRUE) ;
} ;
return 0 ;
} /* rf64_close */

View File

@ -251,6 +251,8 @@ ErrorStruct SndfileErrors [] =
{ SFE_VORBIS_ENCODER_BUG , "Error : Sample rate chosen is known to trigger a Vorbis encoder bug on this CPU." },
{ SFE_RF64_NOT_RF64 , "Error : Not an RF64 file." },
{ SFE_MAX_ERROR , "Maximum error number." },
{ SFE_MAX_ERROR + 1 , NULL }
} ;
@ -795,6 +797,18 @@ sf_format_check (const SF_INFO *info)
return 1 ;
break ;
case SF_FORMAT_RF64 :
if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU)
return 0 ;
if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16)
return 1 ;
if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32)
return 1 ;
if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW)
return 1 ;
if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
return 1 ;
break ;
default : break ;
} ;
@ -2300,6 +2314,9 @@ guess_file_type (SF_PRIVATE *psf)
if (buffer [0] == MAKE_MARKER ('2', 'B', 'I', 'T'))
return SF_FORMAT_AVR ;
if (buffer [0] == MAKE_MARKER ('R', 'F', '6', '4') && buffer [2] == MAKE_MARKER ('W', 'A', 'V', 'E'))
return SF_FORMAT_RF64 ;
/* This must be the second last one. */
if (psf->filelength > 0 && (format = try_resource_fork (psf, SFM_READ)) != 0)
return format ;
@ -2607,6 +2624,10 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
error = w64_open (psf) ;
break ;
case SF_FORMAT_RF64 :
error = rf64_open (psf) ;
break ;
/* Lite remove start */
case SF_FORMAT_PAF :
error = paf_open (psf) ;

View File

@ -69,6 +69,7 @@ enum
SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
/* Subtypes from here on. */

View File

@ -380,7 +380,7 @@ w64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
if (! psf->dataoffset)
return SFE_W64_NO_DATA ;
psf->endian = SF_ENDIAN_LITTLE ; /* All WAV files are little endian. */
psf->endian = SF_ENDIAN_LITTLE ; /* All W64 files are little endian. */
if (psf_ftell (psf) != psf->dataoffset)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;

View File

@ -189,9 +189,9 @@ endif
#===============================================================================
check: generic-tests wav-tests aiff-tests au-tests caf-tests raw-tests \
paf-tests svx-tests nist-tests ircam-tests voc-tests w64-tests mat4-tests \
mat5-tests pvf-tests xi-tests htk-tests avr-tests sds-tests sd2-tests \
flac-tests caf-tests wve-tests vorbis-tests mpc2k-tests io-tests
paf-tests svx-tests nist-tests ircam-tests voc-tests w64-tests rf64-tests \
mat4-tests mat5-tests pvf-tests xi-tests htk-tests avr-tests sds-tests \
sd2-tests flac-tests caf-tests wve-tests vorbis-tests mpc2k-tests io-tests
generic-tests : error_test ulaw_test alaw_test command_test floating_point_test \
pcm_test win32_ordinal_test external_libs_test $(CPP_TEST)
@ -244,6 +244,28 @@ wav-tests: write_read_test lossy_comp_test peak_chunk_test header_test misc_test
@echo " `./sfversion` passed tests on WAV files."
@echo "----------------------------------------------------------------------"
w64-tests: write_read_test lossy_comp_test misc_test
./write_read_test w64
./lossy_comp_test w64_ima
./lossy_comp_test w64_msadpcm
./lossy_comp_test w64_ulaw
./lossy_comp_test w64_alaw
./lossy_comp_test w64_gsm610
./header_test w64
./misc_test w64
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on W64 files."
@echo "----------------------------------------------------------------------"
rf64-tests: write_read_test misc_test
./write_read_test rf64
./header_test rf64
./misc_test rf64
./string_test rf64
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on RF64 files."
@echo "----------------------------------------------------------------------"
aiff-tests: write_read_test lossy_comp_test peak_chunk_test header_test misc_test aiff_rw_test
./write_read_test aiff
./lossy_comp_test aiff_ulaw
@ -296,35 +318,12 @@ raw-tests: write_read_test lossy_comp_test raw_test
@echo " `./sfversion` passed tests on RAW (header-less) files."
@echo "----------------------------------------------------------------------"
w64-tests: write_read_test lossy_comp_test misc_test
./write_read_test w64
./lossy_comp_test w64_ima
./lossy_comp_test w64_msadpcm
./lossy_comp_test w64_ulaw
./lossy_comp_test w64_alaw
./lossy_comp_test w64_gsm610
./header_test w64
./misc_test w64
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on W64 files."
@echo "----------------------------------------------------------------------"
wve-tests: lossy_comp_test
./lossy_comp_test wve
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on WVE files."
@echo "----------------------------------------------------------------------"
vorbis-tests: lossy_comp_test ogg_test vorbis_test
./ogg_test
./vorbis_test
./lossy_comp_test ogg_vorbis
./string_test ogg
./misc_test ogg
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on OGG/VORBIS files."
@echo "----------------------------------------------------------------------"
# Lite remove start
paf-tests: write_read_test misc_test
./write_read_test paf
@ -447,6 +446,16 @@ mpc2k-tests: write_read_test misc_test
@echo " `./sfversion` passed tests on MPC 2000 files."
@echo "----------------------------------------------------------------------"
vorbis-tests: lossy_comp_test ogg_test vorbis_test
./ogg_test
./vorbis_test
./lossy_comp_test ogg_vorbis
./string_test ogg
./misc_test ogg
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on OGG/VORBIS files."
@echo "----------------------------------------------------------------------"
# Lite remove end
io-tests: stdio_test stdin_test stdout_test pipe_test

View File

@ -156,6 +156,15 @@ main (int argc, char *argv [])
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "rf64"))
{ update_header_test ("header.rf64", SF_FORMAT_RF64) ;
update_seek_short_test ("header_short.rf64", SF_FORMAT_RF64) ;
update_seek_int_test ("header_int.rf64", SF_FORMAT_RF64) ;
update_seek_float_test ("header_float.rf64", SF_FORMAT_RF64) ;
update_seek_double_test ("header_double.rf64", SF_FORMAT_RF64) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "mat4"))
{ update_header_test ("header.mat4", SF_FORMAT_MAT4) ;
update_seek_short_test ("header_short.mat4", SF_FORMAT_MAT4) ;

View File

@ -138,6 +138,13 @@ main (int argc, char *argv [])
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "rf64"))
{ zero_data_test ("zerolen.rf64", SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
filesystem_full_test (SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
permission_test ("readonly.rf64", SF_FORMAT_W64) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "mat4"))
{ zero_data_test ("zerolen.mat4", SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ;
filesystem_full_test (SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ;

View File

@ -95,6 +95,16 @@ main (int argc, char *argv [])
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "rf64"))
{ puts ("\n\n **** String test not working yet for RF64 format. ****\n") ;
/*
string_start_end_test ("strings.rf64", SF_FORMAT_RF64) ;
string_multi_set_test ("multi.rf64", SF_FORMAT_RF64) ;
string_rdwr_test ("rdwr.rf64", SF_FORMAT_RF64) ;
*/
test_count++ ;
} ;
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;

View File

@ -85,6 +85,7 @@ main (int argc, char **argv)
printf (" w64 - Sonic Foundry's W64 file functions\n") ;
printf (" flac - test FLAC file functions\n") ;
printf (" mpc2k - test MPC 2000 file functions\n") ;
printf (" rf64 - test RF64 file functions\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@ -372,6 +373,23 @@ main (int argc, char **argv)
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "rf64"))
{ pcm_test_char ("char.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_U8, SF_FALSE) ;
pcm_test_short ("short.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_16, SF_FALSE) ;
pcm_test_24bit ("24bit.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_24, SF_FALSE) ;
pcm_test_int ("int.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_32, SF_FALSE) ;
/* Lite remove start */
pcm_test_float ("float.rf64" , SF_FORMAT_RF64 | SF_FORMAT_FLOAT , SF_FALSE) ;
pcm_test_double ("double.rf64" , SF_FORMAT_RF64 | SF_FORMAT_DOUBLE, SF_FALSE) ;
empty_file_test ("empty_char.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_U8) ;
empty_file_test ("empty_short.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ;
empty_file_test ("empty_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ;
/* Lite remove end */
test_count++ ;
} ;
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;