mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Update minimum requirements and libs
This updates the minimum required cmake version and the libs that have updates for this. Ogg updated to master as of 20052025 Libsndfile updated to master as of 20052025 Opus minimum cmake version changed vorbis minimum cmake version changed
This commit is contained in:
parent
8756e35853
commit
700bf32a2a
130 changed files with 4380 additions and 48121 deletions
|
|
@ -26,6 +26,8 @@
|
|||
Copyright: (c) 2001-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
Copyright: (c) 2001-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "aglib.h"
|
||||
#include "ALACBitUtilities.h"
|
||||
#include "EndianPortable.h"
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@
|
|||
File: ALACDecoder.cpp
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alac_codec.h"
|
||||
|
|
@ -38,11 +41,6 @@
|
|||
#include "ALACBitUtilities.h"
|
||||
#include "EndianPortable.h"
|
||||
|
||||
typedef enum
|
||||
{ false = 0,
|
||||
true = 1
|
||||
} bool ;
|
||||
|
||||
// constants/data
|
||||
const uint32_t kMaxBitDepth = 32 ; // max allowed bit depth is 32
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@
|
|||
#define DebugMsg printf
|
||||
|
||||
// headers
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sfendian.h"
|
||||
|
|
@ -44,12 +47,6 @@
|
|||
#include "ALACAudioTypes.h"
|
||||
#include "EndianPortable.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
false = 0,
|
||||
true = 1
|
||||
} bool ;
|
||||
|
||||
static void GetConfig (ALAC_ENCODER *p, ALACSpecificConfig * config) ;
|
||||
|
||||
static int32_t EncodeStereo (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
Copyright: (c) 2004-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "matrixlib.h"
|
||||
#include "ALACAudioTypes.h"
|
||||
#include "shift.h"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
Copyright: (c) 2004-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "matrixlib.h"
|
||||
#include "ALACAudioTypes.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ g723_test (double margin)
|
|||
} ;
|
||||
} ;
|
||||
|
||||
printf ("\n\nMax error of %d at postion %d.\n", max_err, position) ;
|
||||
printf ("\n\nMax error of %d at position %d.\n", max_err, position) ;
|
||||
|
||||
for (k = 0 ; k < BUFFER_SIZE ; k++)
|
||||
{ if (error_function (data [k], orig [k], margin))
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
#define MAC6_MARKER (MAKE_MARKER ('M', 'A', 'C', '6'))
|
||||
#define ADP4_MARKER (MAKE_MARKER ('A', 'D', 'P', '4'))
|
||||
|
||||
/* Predfined chunk sizes. */
|
||||
/* Predefined chunk sizes. */
|
||||
#define SIZEOF_AIFF_COMM 18
|
||||
#define SIZEOF_AIFC_COMM_MIN 22
|
||||
#define SIZEOF_AIFC_COMM 24
|
||||
|
|
@ -1702,7 +1702,7 @@ static int
|
|||
aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
|
||||
{ const char * type_str ;
|
||||
basc_CHUNK bc ;
|
||||
int count ;
|
||||
sf_count_t count ;
|
||||
|
||||
count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
|
||||
count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@ alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size_out)
|
|||
plac = psf->codec_data ;
|
||||
info = plac->pakt_info ;
|
||||
|
||||
allocated = 100 + 2 * info->count ;
|
||||
allocated = 100 + 4 * info->count ;
|
||||
if ((data = calloc (1, allocated)) == NULL)
|
||||
return NULL ;
|
||||
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ static int
|
|||
au_read_header (SF_PRIVATE *psf)
|
||||
{ AU_FMT au_fmt ;
|
||||
int marker, dword ;
|
||||
sf_count_t data_end ;
|
||||
|
||||
memset (&au_fmt, 0, sizeof (au_fmt)) ;
|
||||
psf_binheader_readf (psf, "pm", 0, &marker) ;
|
||||
|
|
@ -317,14 +318,15 @@ au_read_header (SF_PRIVATE *psf)
|
|||
return SFE_AU_EMBED_BAD_LEN ;
|
||||
} ;
|
||||
|
||||
data_end = (sf_count_t) au_fmt.dataoffset + (sf_count_t) au_fmt.datasize ;
|
||||
if (psf->fileoffset > 0)
|
||||
{ psf->filelength = au_fmt.dataoffset + au_fmt.datasize ;
|
||||
{ psf->filelength = data_end ;
|
||||
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
|
||||
}
|
||||
else if (au_fmt.datasize == -1 || au_fmt.dataoffset + au_fmt.datasize == psf->filelength)
|
||||
else if (au_fmt.datasize == -1 || data_end == psf->filelength)
|
||||
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
|
||||
else if (au_fmt.dataoffset + au_fmt.datasize < psf->filelength)
|
||||
{ psf->filelength = au_fmt.dataoffset + au_fmt.datasize ;
|
||||
else if (data_end < psf->filelength)
|
||||
{ psf->filelength = data_end ;
|
||||
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ avr_read_header (SF_PRIVATE *psf)
|
|||
psf->endian = SF_ENDIAN_BIG ;
|
||||
|
||||
psf->dataoffset = AVR_HDR_SIZE ;
|
||||
psf->datalength = hdr.frames * (hdr.rez / 8) ;
|
||||
psf->datalength = (sf_count_t) hdr.frames * (hdr.rez / 8) ;
|
||||
|
||||
if (psf->fileoffset > 0)
|
||||
psf->filelength = AVR_HDR_SIZE + psf->datalength ;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2006-2017 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
|
|
@ -36,79 +36,91 @@
|
|||
# correct.
|
||||
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
import re, string, sys
|
||||
_whitespace_re = re.compile(r"\s+", re.MULTILINE)
|
||||
|
||||
_whitespace_re = re.compile ("\s+", re.MULTILINE)
|
||||
|
||||
def find_binheader_writefs (data):
|
||||
lst = re.findall ('psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*\"[^;]+;', data, re.MULTILINE)
|
||||
return [_whitespace_re.sub (" ", x) for x in lst]
|
||||
def find_binheader_writefs(data):
|
||||
lst = re.findall(
|
||||
r'psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*"[^;]+;', data, re.MULTILINE
|
||||
)
|
||||
return [_whitespace_re.sub(" ", x) for x in lst]
|
||||
|
||||
def find_format_string (s):
|
||||
fmt = re.search ('"([^"]+)"', s)
|
||||
|
||||
def find_format_string(s):
|
||||
fmt = re.search('"([^"]+)"', s)
|
||||
if not fmt:
|
||||
print ("Bad format in :\n\n\t%s\n\n" % s)
|
||||
sys.exit (1)
|
||||
fmt = fmt.groups ()
|
||||
if len (fmt) != 1:
|
||||
print ("Bad format in :\n\n\t%s\n\n" % s)
|
||||
sys.exit (1)
|
||||
return _whitespace_re.sub ("", fmt [0])
|
||||
print(f"Bad format in :\n\n\t{s}\n\n")
|
||||
sys.exit(1)
|
||||
fmt = fmt.groups()
|
||||
if len(fmt) != 1:
|
||||
print(f"Bad format in :\n\n\t{s}\n\n")
|
||||
sys.exit(1)
|
||||
return _whitespace_re.sub("", fmt[0])
|
||||
|
||||
def get_param_list (data):
|
||||
dlist = re.search ("\((.+)\)\s*;", data)
|
||||
dlist = dlist.groups ()[0]
|
||||
|
||||
def get_param_list(data):
|
||||
dlist = re.search(r"\((.+)\)\s*;", data)
|
||||
dlist = dlist.groups()[0]
|
||||
dlist = dlist.split(",")
|
||||
dlist = [x.strip() for x in dlist]
|
||||
return dlist [2:]
|
||||
return dlist[2:]
|
||||
|
||||
def handle_file (fname):
|
||||
|
||||
def handle_file(fname):
|
||||
errors = 0
|
||||
data = open (fname, "r").read ()
|
||||
data = open(fname, "r").read()
|
||||
|
||||
# return errors
|
||||
|
||||
writefs = find_binheader_writefs (data)
|
||||
writefs = find_binheader_writefs(data)
|
||||
for item in writefs:
|
||||
fmt = find_format_string (item)
|
||||
params = get_param_list (item)
|
||||
fmt = find_format_string(item)
|
||||
params = get_param_list(item)
|
||||
param_index = 0
|
||||
|
||||
# print item
|
||||
|
||||
for ch in fmt:
|
||||
if ch in 'Eet ':
|
||||
if ch in "Eet ":
|
||||
continue
|
||||
|
||||
if ch == 'b':
|
||||
if params [param_index][:4] == "BHWv" and params [param_index + 1][:4] == "BHWz":
|
||||
if ch == "b":
|
||||
if (
|
||||
params[param_index][:4] == "BHWv"
|
||||
and params[param_index + 1][:4] == "BHWz"
|
||||
):
|
||||
param_index += 2
|
||||
continue
|
||||
|
||||
if "BHW" + ch == params [param_index][:4]:
|
||||
if "BHW" + ch == params[param_index][:4]:
|
||||
param_index += 1
|
||||
continue
|
||||
|
||||
if errors == 0: sys.stdout.write ("\n")
|
||||
print ("\n%s: error for format specifier '%c' (index %d) in:\n %s\n" % (fname, ch, param_index, item))
|
||||
if errors == 0:
|
||||
sys.stdout.write("\n")
|
||||
print(
|
||||
f"\n{fname}: error for format specifier '{ch}' (index {param_index}) in:\n {item}\n"
|
||||
)
|
||||
errors += 1
|
||||
# Break out of 'for ch in fmt' loop
|
||||
break
|
||||
|
||||
return errors
|
||||
|
||||
#===============================================================================
|
||||
|
||||
if len (sys.argv) > 1:
|
||||
sys.stdout.write ("\n binheader_writef_check : ")
|
||||
sys.stdout.flush ()
|
||||
# ===============================================================================
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
sys.stdout.write("\n binheader_writef_check : ")
|
||||
sys.stdout.flush()
|
||||
errors = 0
|
||||
for fname in sys.argv [1:]:
|
||||
errors += handle_file (fname)
|
||||
for fname in sys.argv[1:]:
|
||||
errors += handle_file(fname)
|
||||
if errors > 0:
|
||||
print ("\nErrors : %d\n" % errors)
|
||||
sys.exit (1)
|
||||
|
||||
print ("ok\n")
|
||||
print(f"\nErrors : {errors}\n")
|
||||
sys.exit(1)
|
||||
|
||||
print("ok\n")
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
|
|
@ -990,6 +991,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
double *doubleptr ;
|
||||
char c ;
|
||||
int byte_count = 0, count = 0 ;
|
||||
int read_bytes = 0 ;
|
||||
|
||||
if (! format)
|
||||
return psf_ftell (psf) ;
|
||||
|
|
@ -998,6 +1000,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
|
||||
while ((c = *format++))
|
||||
{
|
||||
read_bytes = 0 ;
|
||||
if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
|
||||
break ;
|
||||
|
||||
|
|
@ -1014,7 +1017,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
read_bytes = header_read (psf, ucptr, sizeof (int)) ;
|
||||
*intptr = GET_MARKER (ucptr) ;
|
||||
break ;
|
||||
|
||||
|
|
@ -1022,7 +1025,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
|
||||
read_bytes = header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
|
||||
{ int k ;
|
||||
intdata = 0 ;
|
||||
for (k = 0 ; k < 16 ; k++)
|
||||
|
|
@ -1034,14 +1037,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case '1' :
|
||||
charptr = va_arg (argptr, char*) ;
|
||||
*charptr = 0 ;
|
||||
byte_count += header_read (psf, charptr, sizeof (char)) ;
|
||||
read_bytes = header_read (psf, charptr, sizeof (char)) ;
|
||||
break ;
|
||||
|
||||
case '2' : /* 2 byte value with the current endian-ness */
|
||||
shortptr = va_arg (argptr, unsigned short*) ;
|
||||
*shortptr = 0 ;
|
||||
ucptr = (unsigned char*) shortptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (short)) ;
|
||||
read_bytes = header_read (psf, ucptr, sizeof (short)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*shortptr = GET_BE_SHORT (ucptr) ;
|
||||
else
|
||||
|
|
@ -1051,7 +1054,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case '3' : /* 3 byte value with the current endian-ness */
|
||||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
byte_count += header_read (psf, sixteen_bytes, 3) ;
|
||||
read_bytes = header_read (psf, sixteen_bytes, 3) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*intptr = GET_BE_3BYTE (sixteen_bytes) ;
|
||||
else
|
||||
|
|
@ -1062,7 +1065,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
read_bytes = header_read (psf, ucptr, sizeof (int)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*intptr = psf_get_be32 (ucptr, 0) ;
|
||||
else
|
||||
|
|
@ -1072,7 +1075,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case '8' : /* 8 byte value with the current endian-ness */
|
||||
countptr = va_arg (argptr, sf_count_t *) ;
|
||||
*countptr = 0 ;
|
||||
byte_count += header_read (psf, sixteen_bytes, 8) ;
|
||||
read_bytes = header_read (psf, sixteen_bytes, 8) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
countdata = psf_get_be64 (sixteen_bytes, 0) ;
|
||||
else
|
||||
|
|
@ -1083,7 +1086,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case 'f' : /* Float conversion */
|
||||
floatptr = va_arg (argptr, float *) ;
|
||||
*floatptr = 0.0 ;
|
||||
byte_count += header_read (psf, floatptr, sizeof (float)) ;
|
||||
read_bytes = header_read (psf, floatptr, sizeof (float)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*floatptr = float32_be_read ((unsigned char*) floatptr) ;
|
||||
else
|
||||
|
|
@ -1093,7 +1096,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case 'd' : /* double conversion */
|
||||
doubleptr = va_arg (argptr, double *) ;
|
||||
*doubleptr = 0.0 ;
|
||||
byte_count += header_read (psf, doubleptr, sizeof (double)) ;
|
||||
read_bytes = header_read (psf, doubleptr, sizeof (double)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*doubleptr = double64_be_read ((unsigned char*) doubleptr) ;
|
||||
else
|
||||
|
|
@ -1117,7 +1120,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
charptr = va_arg (argptr, char*) ;
|
||||
count = va_arg (argptr, size_t) ;
|
||||
memset (charptr, 0, count) ;
|
||||
byte_count += header_read (psf, charptr, count) ;
|
||||
read_bytes = header_read (psf, charptr, count) ;
|
||||
break ;
|
||||
|
||||
case 'G' :
|
||||
|
|
@ -1128,7 +1131,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))
|
||||
break ;
|
||||
|
||||
byte_count += header_gets (psf, charptr, count) ;
|
||||
read_bytes = header_gets (psf, charptr, count) ;
|
||||
break ;
|
||||
|
||||
case 'z' :
|
||||
|
|
@ -1152,7 +1155,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case 'j' : /* Seek to position from current position. */
|
||||
count = va_arg (argptr, size_t) ;
|
||||
header_seek (psf, count, SEEK_CUR) ;
|
||||
byte_count += count ;
|
||||
read_bytes = count ;
|
||||
break ;
|
||||
|
||||
case '!' : /* Clear buffer, forcing re-read. */
|
||||
|
|
@ -1164,8 +1167,17 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
psf->error = SFE_INTERNAL ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
if (read_bytes > 0 && byte_count > (INT_MAX - read_bytes))
|
||||
{ psf_log_printf (psf, "Header size exceeds INT_MAX. Aborting.", c) ;
|
||||
psf->error = SFE_INTERNAL ;
|
||||
break ;
|
||||
} else
|
||||
{ byte_count += read_bytes ;
|
||||
} ;
|
||||
|
||||
} ; /*end while*/
|
||||
|
||||
va_end (argptr) ;
|
||||
|
||||
return byte_count ;
|
||||
|
|
@ -1761,18 +1773,14 @@ psf_f2i_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ dest [i] = 0x7FFFFFFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ dest [i] = 0x80000000 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
dest [i] = psf_lrintf (scaled_value) ;
|
||||
} ;
|
||||
|
|
@ -1782,7 +1790,7 @@ psf_f2i_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
|
||||
void
|
||||
psf_d2i_array (const double *src, int *dest, int count, int normalize)
|
||||
{ double normfact ;
|
||||
{ double normfact ;
|
||||
|
||||
normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
|
|
@ -1799,18 +1807,14 @@ psf_d2i_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ dest [i] = 0x7FFFFFFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ dest [i] = 0x80000000 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
dest [i] = psf_lrint (scaled_value) ;
|
||||
} ;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
#define SF_MAX_CHANNELS 1024
|
||||
|
||||
/*
|
||||
* Macros for spliting the format file of SF_INFO into container type,
|
||||
* Macros for splitting the format file of SF_INFO into container type,
|
||||
** codec type and endian-ness.
|
||||
*/
|
||||
#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK)
|
||||
|
|
@ -305,7 +305,7 @@ void *psf_memdup (const void *src, size_t n) ;
|
|||
int psf_isprint (int ch) ;
|
||||
|
||||
/*=======================================================================================
|
||||
** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
|
||||
** SF_PRIVATE struct - a pointer to this struct is passed back to the caller of the
|
||||
** sf_open_XXXX functions. The caller however has no knowledge of the struct's
|
||||
** contents.
|
||||
*/
|
||||
|
|
@ -402,7 +402,7 @@ typedef struct sf_private_tag
|
|||
|
||||
int scale_int_float ;
|
||||
|
||||
/* Vairables for handling pipes. */
|
||||
/* Variables for handling pipes. */
|
||||
int is_pipe ; /* True if file is a pipe. */
|
||||
sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ typedef struct sf_private_tag
|
|||
sf_count_t datalength ; /* Length in bytes of the audio data. */
|
||||
sf_count_t dataend ; /* Offset to file tailer. */
|
||||
|
||||
int blockwidth ; /* Size in bytes of one set of interleaved samples. */
|
||||
sf_count_t blockwidth ; /* Size in bytes of one set of interleaved samples. */
|
||||
int bytewidth ; /* Size in bytes of one sample (one channel). */
|
||||
|
||||
void *dither ;
|
||||
|
|
@ -947,7 +947,7 @@ int psf_find_write_chunk (WRITE_CHUNKS * pchk, const char * marker) ;
|
|||
**
|
||||
** See : http://www.gratisoft.us/todd/papers/strlcpy.html
|
||||
**
|
||||
** These functions are available on *BSD, but are not avaialble everywhere so we
|
||||
** These functions are available on *BSD, but are not available everywhere so we
|
||||
** implement them here.
|
||||
**
|
||||
** The argument order has been changed to that of strncpy/strncat to cause
|
||||
|
|
@ -964,7 +964,7 @@ void psf_strlcpy (char *dest, size_t n, const char *src) ;
|
|||
static inline int psf_lrintf (float x)
|
||||
{
|
||||
#ifdef USE_SSE2
|
||||
return _mm_cvtss_si32 (_mm_load_ss (&x)) ;
|
||||
return _mm_cvtss_si32 (_mm_load_ss (&x)) ;
|
||||
#else
|
||||
return lrintf (x) ;
|
||||
#endif
|
||||
|
|
@ -973,7 +973,7 @@ static inline int psf_lrintf (float x)
|
|||
static inline int psf_lrint (double x)
|
||||
{
|
||||
#ifdef USE_SSE2
|
||||
return _mm_cvtsd_si32 (_mm_load_sd (&x)) ;
|
||||
return _mm_cvtsd_si32 (_mm_load_sd (&x)) ;
|
||||
#else
|
||||
return lrint (x) ;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
/* Set to 1 if the compile is GNU GCC. */
|
||||
#cmakedefine01 COMPILER_IS_GCC
|
||||
|
||||
/* Target processor clips on negative float to int conversion. */
|
||||
#cmakedefine01 CPU_CLIPS_NEGATIVE
|
||||
|
||||
/* Target processor clips on positive float to int conversion. */
|
||||
#cmakedefine01 CPU_CLIPS_POSITIVE
|
||||
|
||||
/* Target processor is big endian. */
|
||||
#cmakedefine01 CPU_IS_BIG_ENDIAN
|
||||
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ double64_get_capability (SF_PRIVATE *psf)
|
|||
unsigned char c [8] ;
|
||||
} data ;
|
||||
|
||||
data.d = 1.234567890123456789 ; /* Some abitrary value. */
|
||||
data.d = 1.234567890123456789 ; /* Some arbitrary value. */
|
||||
|
||||
if (! psf->ieee_replace)
|
||||
{ /* If this test is true ints and floats are compatible and little endian. */
|
||||
|
|
@ -517,9 +517,9 @@ d2i_clip_array (const double *src, int count, int *dest, double scale)
|
|||
{ for (int i = 0 ; i < count ; i++)
|
||||
{ float tmp = scale * src [i] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
|
||||
if (tmp > (1.0 * INT_MAX))
|
||||
dest [i] = INT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
|
||||
else if (tmp < (-1.0 * INT_MAX))
|
||||
dest [i] = INT_MIN ;
|
||||
else
|
||||
dest [i] = psf_lrint (tmp) ;
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count)
|
|||
|
||||
if (bit_count < 0)
|
||||
{ get_dwm = SF_TRUE ;
|
||||
/* modify bit_count to ensure we have enought bits for finding dwm. */
|
||||
/* modify bit_count to ensure we have enough bits for finding dwm. */
|
||||
bit_count = pdwvw->dwm_maxsize ;
|
||||
} ;
|
||||
|
||||
|
|
@ -428,7 +428,7 @@ static void
|
|||
dwvw_encode_store_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int data, int new_bits)
|
||||
{ int byte ;
|
||||
|
||||
/* Shift the bits into the resevoir. */
|
||||
/* Shift the bits into the reservoir. */
|
||||
pdwvw->bits = arith_shift_left (pdwvw->bits, new_bits) | (data & (arith_shift_left (1, new_bits) - 1)) ;
|
||||
pdwvw->bit_count += new_bits ;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define SENSIBLE_SIZE (0x40000000)
|
||||
|
||||
/*
|
||||
** Neat solution to the Win32/OS2 binary file flage requirement.
|
||||
** Neat solution to the Win32/OS2 binary file flag requirement.
|
||||
** If O_BINARY isn't already defined by the inclusion of the system
|
||||
** headers, set it to zero.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ float32_get_capability (SF_PRIVATE *psf)
|
|||
unsigned char c [4] ;
|
||||
} data ;
|
||||
|
||||
data.f = (float) 1.23456789 ; /* Some abitrary value. */
|
||||
data.f = (float) 1.23456789 ; /* Some arbitrary value. */
|
||||
|
||||
if (! psf->ieee_replace)
|
||||
{ /* If this test is true ints and floats are compatible and little endian. */
|
||||
|
|
@ -468,9 +468,9 @@ f2i_clip_array (const float *src, int count, int *dest, float scale)
|
|||
{ for (int i = 0 ; i < count ; i++)
|
||||
{ float tmp = scale * src [i] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
|
||||
if (tmp > (1.0 * INT_MAX))
|
||||
dest [i] = INT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
|
||||
else if (tmp < (-1.0 * INT_MAX))
|
||||
dest [i] = INT_MIN ;
|
||||
else
|
||||
dest [i] = psf_lrintf (tmp) ;
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
|||
** to avoid having to branch when pulling apart the nibbles.
|
||||
*/
|
||||
count = ((samplesperblock - 2) | 7) + 2 ;
|
||||
pimasize = sizeof (IMA_ADPCM_PRIVATE) + psf->sf.channels * (blockalign + samplesperblock + sizeof(short) * count) ;
|
||||
pimasize = sizeof (IMA_ADPCM_PRIVATE) + psf->sf.channels * (blockalign + samplesperblock + sizeof (short) * count) ;
|
||||
|
||||
if (! (pima = calloc (1, pimasize)))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
|
@ -238,7 +238,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
|||
case SF_FORMAT_AIFF :
|
||||
psf_log_printf (psf, "still need to check block count\n") ;
|
||||
pima->decode_block = aiff_ima_decode_block ;
|
||||
psf->sf.frames = pima->samplesperblock * pima->blocks / pima->channels ;
|
||||
psf->sf.frames = (sf_count_t) pima->samplesperblock * pima->blocks / pima->channels ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
|
|
@ -262,9 +262,6 @@ aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
|
|||
int chan, k, diff, bytecode, predictor ;
|
||||
short step, stepindx, *sampledata ;
|
||||
|
||||
static int count = 0 ;
|
||||
count ++ ;
|
||||
|
||||
pima->blockcount += pima->channels ;
|
||||
pima->samplecount = 0 ;
|
||||
|
||||
|
|
@ -391,7 +388,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
|
|||
static int
|
||||
wavlike_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
|
||||
{ int chan, k, predictor, blockindx, indx, indxstart, diff ;
|
||||
short step, bytecode, stepindx [2] = { 0 };
|
||||
short step, bytecode, stepindx [2] = { 0 } ;
|
||||
|
||||
pima->blockcount ++ ;
|
||||
pima->samplecount = 0 ;
|
||||
|
|
@ -1005,4 +1002,3 @@ ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
|||
|
||||
return total ;
|
||||
} /* ima_write_d */
|
||||
|
||||
|
|
|
|||
|
|
@ -171,35 +171,35 @@ ircam_read_header (SF_PRIVATE *psf)
|
|||
switch (encoding)
|
||||
{ case IRCAM_PCM_16 :
|
||||
psf->bytewidth = 2 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_16 ;
|
||||
break ;
|
||||
|
||||
case IRCAM_PCM_32 :
|
||||
psf->bytewidth = 4 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_32 ;
|
||||
break ;
|
||||
|
||||
case IRCAM_FLOAT :
|
||||
psf->bytewidth = 4 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT ;
|
||||
break ;
|
||||
|
||||
case IRCAM_ALAW :
|
||||
psf->bytewidth = 1 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ALAW ;
|
||||
break ;
|
||||
|
||||
case IRCAM_ULAW :
|
||||
psf->bytewidth = 1 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ULAW ;
|
||||
break ;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ mat4_open (SF_PRIVATE *psf)
|
|||
|
||||
psf->container_close = mat4_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
switch (subformat)
|
||||
{ case SF_FORMAT_PCM_16 :
|
||||
|
|
@ -320,7 +320,7 @@ mat4_read_header (SF_PRIVATE *psf)
|
|||
psf->filelength - psf->dataoffset, psf->sf.channels * psf->sf.frames * psf->bytewidth) ;
|
||||
}
|
||||
else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth)
|
||||
psf->dataend = psf->dataoffset + rows * cols * psf->bytewidth ;
|
||||
psf->dataend = psf->dataoffset + (sf_count_t) rows * (sf_count_t) cols * psf->bytewidth ;
|
||||
|
||||
psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ;
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ mat5_open (SF_PRIVATE *psf)
|
|||
|
||||
psf->container_close = mat5_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
switch (subformat)
|
||||
{ case SF_FORMAT_PCM_U8 :
|
||||
|
|
|
|||
|
|
@ -48,36 +48,36 @@
|
|||
/* Variable names from ITU G.726 spec */
|
||||
struct nms_adpcm_state
|
||||
{ /* Log of the step size multiplier. Operated on by codewords. */
|
||||
int yl ;
|
||||
short yl ;
|
||||
|
||||
/* Quantizer step size multiplier. Generated from yl. */
|
||||
int y ;
|
||||
short y ;
|
||||
|
||||
/* Coefficents of the pole predictor */
|
||||
int a [2] ;
|
||||
/* Coefficients of the pole predictor */
|
||||
short a [2] ;
|
||||
|
||||
/* Coefficents of the zero predictor */
|
||||
int b [6] ;
|
||||
/* Coefficients of the zero predictor */
|
||||
short b [6] ;
|
||||
|
||||
/* Previous quantized deltas (multiplied by 2^14) */
|
||||
int d_q [7] ;
|
||||
short d_q [7] ;
|
||||
|
||||
/* d_q [x] + s_ez [x], used by the pole-predictor for signs only. */
|
||||
int p [3] ;
|
||||
short p [3] ;
|
||||
|
||||
/* Previous reconstructed signal values. */
|
||||
int s_r [2] ;
|
||||
short s_r [2] ;
|
||||
|
||||
/* Zero predictor components of the signal estimate. */
|
||||
int s_ez ;
|
||||
short s_ez ;
|
||||
|
||||
/* Signal estimate, (including s_ez). */
|
||||
int s_e ;
|
||||
short s_e ;
|
||||
|
||||
/* The most recent codeword (enc:generated, dec:inputted) */
|
||||
int Ik ;
|
||||
char Ik ;
|
||||
|
||||
int parity ;
|
||||
char parity ;
|
||||
|
||||
/*
|
||||
** Offset into code tables for the bitrate.
|
||||
|
|
@ -109,7 +109,7 @@ typedef struct
|
|||
} NMS_ADPCM_PRIVATE ;
|
||||
|
||||
/* Pre-computed exponential interval used in the antilog approximation. */
|
||||
static unsigned int table_expn [] =
|
||||
static unsigned short table_expn [] =
|
||||
{ 0x4000, 0x4167, 0x42d5, 0x444c, 0x45cb, 0x4752, 0x48e2, 0x4a7a,
|
||||
0x4c1b, 0x4dc7, 0x4f7a, 0x5138, 0x52ff, 0x54d1, 0x56ac, 0x5892,
|
||||
0x5a82, 0x5c7e, 0x5e84, 0x6096, 0x62b4, 0x64dd, 0x6712, 0x6954,
|
||||
|
|
@ -117,21 +117,21 @@ static unsigned int table_expn [] =
|
|||
} ;
|
||||
|
||||
/* Table mapping codewords to scale factor deltas. */
|
||||
static int table_scale_factor_step [] =
|
||||
static short table_scale_factor_step [] =
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x4b0, 0x0, 0x0, 0x0, /* 2-bit */
|
||||
-0x3c, 0x0, 0x90, 0x0, 0x2ee, 0x0, 0x898, 0x0, /* 3-bit */
|
||||
-0x30, 0x12, 0x6b, 0xc8, 0x188, 0x2e0, 0x551, 0x1150, /* 4-bit */
|
||||
} ;
|
||||
|
||||
/* Table mapping codewords to quantized delta interval steps. */
|
||||
static unsigned int table_step [] =
|
||||
static unsigned short table_step [] =
|
||||
{ 0x73F, 0, 0, 0, 0x1829, 0, 0, 0, /* 2-bit */
|
||||
0x3EB, 0, 0xC18, 0, 0x1581, 0, 0x226E, 0, /* 3-bit */
|
||||
0x20C, 0x635, 0xA83, 0xF12, 0x1418, 0x19E3, 0x211A, 0x2BBA, /* 4-bit */
|
||||
} ;
|
||||
|
||||
/* Binary search lookup table for quantizing using table_step. */
|
||||
static int table_step_search [] =
|
||||
static short table_step_search [] =
|
||||
{ 0, 0x1F6D, 0, -0x1F6D, 0, 0, 0, 0, /* 2-bit */
|
||||
0x1008, 0x1192, 0, -0x219A, 0x1656, -0x1656, 0, 0, /* 3-bit */
|
||||
0x872, 0x1277, -0x8E6, -0x232B, 0xD06, -0x17D7, -0x11D3, 0, /* 4-bit */
|
||||
|
|
@ -179,23 +179,23 @@ static sf_count_t nms_adpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
|||
** Maps [1,20480] to [1,1024] in an exponential relationship. This is
|
||||
** approximately ret = b^exp where b = e^(ln(1024)/ln(20480)) ~= 1.0003385
|
||||
*/
|
||||
static inline int
|
||||
nms_adpcm_antilog (int exp)
|
||||
{ int ret ;
|
||||
static inline short
|
||||
nms_adpcm_antilog (short exp)
|
||||
{ int_fast32_t r ;
|
||||
|
||||
ret = 0x1000 ;
|
||||
ret += (((exp & 0x3f) * 0x166b) >> 12) ;
|
||||
ret *= table_expn [(exp & 0x7c0) >> 6] ;
|
||||
ret >>= (26 - (exp >> 11)) ;
|
||||
r = 0x1000 ;
|
||||
r += (((int_fast32_t) (exp & 0x3f) * 0x166b) >> 12) ;
|
||||
r *= table_expn [(exp & 0x7c0) >> 6] ;
|
||||
r >>= (26 - (exp >> 11)) ;
|
||||
|
||||
return ret ;
|
||||
return (short) r ;
|
||||
} /* nms_adpcm_antilog */
|
||||
|
||||
static void
|
||||
nms_adpcm_update (struct nms_adpcm_state *s)
|
||||
{ /* Variable names from ITU G.726 spec */
|
||||
int a1ul ;
|
||||
int fa1 ;
|
||||
short a1ul, fa1 ;
|
||||
int_fast32_t se ;
|
||||
int i ;
|
||||
|
||||
/* Decay and Modify the scale factor in the log domain based on the codeword. */
|
||||
|
|
@ -206,7 +206,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
s->yl = 20480 ;
|
||||
s->y = nms_adpcm_antilog (s->yl) ;
|
||||
|
||||
/* Update the zero predictor coefficents. */
|
||||
/* Update the zero predictor coefficients. */
|
||||
for (i = 0 ; i < 6 ; i++)
|
||||
{ s->b [i] = (s->b [i] * 0xff) >> 8 ;
|
||||
if ((s->d_q [0] ^ s->d_q [i + 1]) >= 0)
|
||||
|
|
@ -215,14 +215,14 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
s->b [i] -= 128 ;
|
||||
}
|
||||
|
||||
/* Update the pole predictor coefficents. */
|
||||
/* Update the pole predictor coefficients. */
|
||||
fa1 = s->a [0] >> 5 ;
|
||||
if (fa1 < -256)
|
||||
fa1 = -256 ;
|
||||
else if (fa1 > 256)
|
||||
fa1 = 256 ;
|
||||
|
||||
s->a [0] = (0xff * s->a [0]) >> 8 ;
|
||||
s->a [0] = (s->a [0] * 0xff) >> 8 ;
|
||||
if (s->p [0] != 0 && s->p [1] != 0 && ((s->p [0] ^ s->p [1]) < 0))
|
||||
s->a [0] -= 192 ;
|
||||
else
|
||||
|
|
@ -230,7 +230,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
fa1 = -fa1 ;
|
||||
}
|
||||
|
||||
s->a [1] = fa1 + ((0xfe * s->a [1]) >> 8) ;
|
||||
s->a [1] = fa1 + ((s->a [1] * 0xfe) >> 8) ;
|
||||
if (s->p [0] != 0 && s->p [2] != 0 && ((s->p [0] ^ s->p [2]) < 0))
|
||||
s->a [1] -= 128 ;
|
||||
else
|
||||
|
|
@ -250,19 +250,18 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
s->a [0] = a1ul ;
|
||||
} ;
|
||||
|
||||
/* Compute the zero predictor estimate. Rotate past deltas too. */
|
||||
s->s_ez = 0 ;
|
||||
/* Compute the zero predictor estimate and rotate past deltas. */
|
||||
se = 0 ;
|
||||
for (i = 5 ; i >= 0 ; i--)
|
||||
{ s->s_ez += s->d_q [i] * s->b [i] ;
|
||||
{ se += (int_fast32_t) s->d_q [i] * s->b [i] ;
|
||||
s->d_q [i + 1] = s->d_q [i] ;
|
||||
} ;
|
||||
s->s_ez = se >> 14 ;
|
||||
|
||||
/* Compute the signal estimate. */
|
||||
s->s_e = s->a [0] * s->s_r [0] + s->a [1] * s->s_r [1] + s->s_ez ;
|
||||
|
||||
/* Return to scale */
|
||||
s->s_ez >>= 14 ;
|
||||
s->s_e >>= 14 ;
|
||||
/* Complete the signal estimate. */
|
||||
se += (int_fast32_t) s->a [0] * s->s_r [0] ;
|
||||
se += (int_fast32_t) s->a [1] * s->s_r [1] ;
|
||||
s->s_e = se >> 14 ;
|
||||
|
||||
/* Rotate members to prepare for next iteration. */
|
||||
s->s_r [1] = s->s_r [0] ;
|
||||
|
|
@ -274,7 +273,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
static int16_t
|
||||
nms_adpcm_reconstruct_sample (struct nms_adpcm_state *s, uint8_t I)
|
||||
{ /* Variable names from ITU G.726 spec */
|
||||
int dqx ;
|
||||
int_fast32_t dqx ;
|
||||
|
||||
/*
|
||||
** The ordering of the 12-bit right-shift is a precision loss. It agrees
|
||||
|
|
@ -308,17 +307,17 @@ nms_adpcm_codec_init (struct nms_adpcm_state *s, enum nms_enc_type type)
|
|||
/*
|
||||
** nms_adpcm_encode_sample()
|
||||
**
|
||||
** Encode a linear 16-bit pcm sample into a 2,3, or 4 bit NMS-ADPCM codeword
|
||||
** Encode a linear 16-bit pcm sample into a 2, 3, or 4 bit NMS-ADPCM codeword
|
||||
** using and updating the predictor state.
|
||||
*/
|
||||
static uint8_t
|
||||
nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl)
|
||||
{ /* Variable names from ITU G.726 spec */
|
||||
int d ;
|
||||
int_fast32_t d ;
|
||||
uint8_t I ;
|
||||
|
||||
/* Down scale the sample from 16 => ~14 bits. */
|
||||
sl = (sl * 0x1fdf) / 0x7fff ;
|
||||
sl = ((int_fast32_t) sl * 0x1fdf) / 0x7fff ;
|
||||
|
||||
/* Compute estimate, and delta from actual value */
|
||||
nms_adpcm_update (s) ;
|
||||
|
|
@ -407,7 +406,7 @@ nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl)
|
|||
*/
|
||||
static int16_t
|
||||
nms_adpcm_decode_sample (struct nms_adpcm_state *s, uint8_t I)
|
||||
{ int sl ;
|
||||
{ int_fast32_t sl ;
|
||||
|
||||
nms_adpcm_update (s) ;
|
||||
sl = nms_adpcm_reconstruct_sample (s, I) ;
|
||||
|
|
@ -1091,7 +1090,7 @@ nms_adpcm_init (SF_PRIVATE *psf)
|
|||
else
|
||||
pnms->blocks_total = psf->datalength / (pnms->shortsperblock * sizeof (short)) ;
|
||||
|
||||
psf->sf.frames = pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
|
||||
psf->sf.frames = (sf_count_t) pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
|
||||
psf->codec_close = nms_adpcm_close ;
|
||||
psf->seek = nms_adpcm_seek ;
|
||||
|
||||
|
|
|
|||
|
|
@ -211,12 +211,16 @@ ogg_read_first_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
|
|||
|
||||
int
|
||||
ogg_write_page (SF_PRIVATE *psf, ogg_page *page)
|
||||
{ int bytes ;
|
||||
{ int n ;
|
||||
|
||||
bytes = psf_fwrite (page->header, 1, page->header_len, psf) ;
|
||||
bytes += psf_fwrite (page->body, 1, page->body_len, psf) ;
|
||||
n = psf_fwrite (page->header, 1, page->header_len, psf) ;
|
||||
if (n == page->header_len)
|
||||
n += psf_fwrite (page->body, 1, page->body_len, psf) ;
|
||||
|
||||
return bytes == page->header_len + page->body_len ;
|
||||
if (n != page->body_len + page->header_len)
|
||||
return -1 ;
|
||||
|
||||
return n ;
|
||||
} /* ogg_write_page */
|
||||
|
||||
sf_count_t
|
||||
|
|
@ -383,7 +387,7 @@ ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
|
|||
/*
|
||||
** Unpack all the packets on the page. It is undocumented (like much of
|
||||
** libOgg behavior) but all packets from a page read into the stream are
|
||||
** guarenteed to remain valid in memory until a new page is read into the
|
||||
** guaranteed to remain valid in memory until a new page is read into the
|
||||
** stream.
|
||||
*/
|
||||
for (i = 1 ; ; i++)
|
||||
|
|
@ -819,7 +823,7 @@ ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata)
|
|||
break ;
|
||||
} ;
|
||||
|
||||
psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ;
|
||||
psf_log_printf (psf, "This Ogg bitstream contains some unknown data type.\n") ;
|
||||
return SFE_UNIMPLEMENTED ;
|
||||
} /* ogg_stream_classify */
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ int ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) ;
|
|||
|
||||
/*
|
||||
** Seek within the Ogg virtual bitstream for a page containing target_gp.
|
||||
** Preforms a bisection search. If not found exactly, the best result is
|
||||
** Performs a bisection search. If not found exactly, the best result is
|
||||
** returned in *best_gp. Found page is loaded into the virtual bitstream,
|
||||
** ready for unpacking. Arguments pcm_start and pcm_end are the highest and
|
||||
** lowest granule positions of the file. begin and end are the file offset
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
** - Samples shall refer to discrete PCM values, regardless of any channel
|
||||
** considerations. This is the same as what libsndfile calls samples.
|
||||
** - Samples/channel shall refer to groups of samples, one for each channel.
|
||||
** This is what Opus calles samples, and what libsndfile calles frames. It
|
||||
** This is what Opus calls samples, and what libsndfile calls frames. It
|
||||
** has the advantage that its name is also the formula to calculate it.
|
||||
**
|
||||
**
|
||||
|
|
@ -827,15 +827,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
|
||||
/* The first page MUST only contain the header, so flush it out now */
|
||||
ogg_stream_packetin (&odata->ostream, &op) ;
|
||||
for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
|
||||
{ if (! (nn = ogg_write_page (psf, &odata->opage)))
|
||||
while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
{ nn = ogg_write_page (psf, &odata->opage) ;
|
||||
if (nn < 0)
|
||||
{ psf_log_printf (psf, "Opus : Failed to write header!\n") ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
psf->dataoffset += nn ;
|
||||
}
|
||||
} ;
|
||||
|
||||
/*
|
||||
** Metadata Tags (manditory)
|
||||
|
|
@ -850,15 +851,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
vorbiscomment_write_tags (psf, &op, &opustags_ident, opus_get_version_string (), - (OGG_OPUS_COMMENT_PAD)) ;
|
||||
op.packetno = 2 ;
|
||||
ogg_stream_packetin (&odata->ostream, &op) ;
|
||||
for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
|
||||
{ if (! (nn = ogg_write_page (psf, &odata->opage)))
|
||||
while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
{ nn = ogg_write_page (psf, &odata->opage) ;
|
||||
if (nn < 0)
|
||||
{ psf_log_printf (psf, "Opus : Failed to write comments!\n") ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
psf->dataoffset += nn ;
|
||||
}
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* ogg_opus_write_header */
|
||||
|
|
@ -1132,7 +1134,8 @@ ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus)
|
|||
if (nbytes > 0)
|
||||
{ oopus->u.encode.last_segments -= ogg_page_segments (&odata->opage) ;
|
||||
oopus->pg_pos = oopus->pkt_pos ;
|
||||
ogg_write_page (psf, &odata->opage) ;
|
||||
if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
return -1 ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
|
|
@ -1448,7 +1451,7 @@ ogg_opus_analyze_file (SF_PRIVATE *psf)
|
|||
oopus->pkt_pos = oopus->pg_pos - gp ;
|
||||
}
|
||||
else if (gp < oopus->pg_pos)
|
||||
{ psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambigious) offset.\n") ;
|
||||
{ psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambiguous) offset.\n") ;
|
||||
return SFE_MALFORMED_FILE ;
|
||||
} ;
|
||||
oopus->u.decode.gp_start = oopus->pkt_pos ;
|
||||
|
|
@ -1511,7 +1514,7 @@ ogg_opus_null_read (SF_PRIVATE *psf, sf_count_t offset)
|
|||
return total ;
|
||||
/*
|
||||
** Ignore pre-skip skipping. The preskip was accounted for in the
|
||||
** arugment to offset, so we need to count it.
|
||||
** argument to offset, so we need to count it.
|
||||
*/
|
||||
oopus->loc = 0 ;
|
||||
} ;
|
||||
|
|
@ -1609,7 +1612,7 @@ ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
|||
|
||||
/* Figure out the current position granule pos. Use the start of the
|
||||
* current buffer, to avoid backwards seeking if the target is on the page
|
||||
* but before the current locaiton. */
|
||||
* but before the current location. */
|
||||
oopus->loc = 0 ;
|
||||
current_gp = oopus->pkt_pos - (uint64_t) (oopus->len * oopus->sr_factor) ;
|
||||
|
||||
|
|
@ -1644,7 +1647,7 @@ ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
|||
if (ret < 0)
|
||||
{ /*
|
||||
** Page seek failed, what to do? Could be bad data. We can
|
||||
** either fall-back to manual seeking or bail. Manaul seeking
|
||||
** either fall-back to manual seeking or bail. Manual seeking
|
||||
** from the beginning has the advantage of finding where the
|
||||
** file goes bad.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ vorbiscomment_read_tags (SF_PRIVATE *psf, ogg_packet *packet, vorbiscomment_iden
|
|||
|
||||
/*
|
||||
** The smallest possible header is the ident string length plus two 4-byte
|
||||
** integers, (vender string length, tags count.)
|
||||
** integers, (vendor string length, tags count.)
|
||||
*/
|
||||
if (packet->bytes < (ident ? ident->length : 0) + 4 + 4)
|
||||
return SFE_MALFORMED_FILE ;
|
||||
|
|
|
|||
|
|
@ -82,28 +82,6 @@
|
|||
/* How many seconds in the future to not bother bisection searching for. */
|
||||
#define VORBIS_SEEK_THRESHOLD 2
|
||||
|
||||
typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
|
||||
|
||||
static int vorbis_read_header (SF_PRIVATE *psf) ;
|
||||
static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||
static int vorbis_close (SF_PRIVATE *psf) ;
|
||||
static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
||||
static int vorbis_byterate (SF_PRIVATE *psf) ;
|
||||
static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ;
|
||||
static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ;
|
||||
static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ;
|
||||
static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
|
||||
static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
|
||||
|
||||
typedef struct
|
||||
{ int id ;
|
||||
const char *name ;
|
||||
|
|
@ -145,6 +123,45 @@ typedef struct
|
|||
sf_count_t last_page ;
|
||||
} VORBIS_PRIVATE ;
|
||||
|
||||
typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
|
||||
|
||||
static int vorbis_read_header (SF_PRIVATE *psf) ;
|
||||
static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||
static int vorbis_close (SF_PRIVATE *psf) ;
|
||||
static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
||||
static int vorbis_byterate (SF_PRIVATE *psf) ;
|
||||
static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ;
|
||||
static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ;
|
||||
static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ;
|
||||
static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
|
||||
static int vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) ;
|
||||
static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
|
||||
static void vorbis_log_error (SF_PRIVATE *psf, int error) ;
|
||||
|
||||
|
||||
static void
|
||||
vorbis_log_error(SF_PRIVATE *psf, int error) {
|
||||
switch (error)
|
||||
{ case 0: return;
|
||||
case OV_EIMPL: psf->error = SFE_UNIMPLEMENTED ; break ;
|
||||
case OV_ENOTVORBIS: psf->error = SFE_MALFORMED_FILE ; break ;
|
||||
case OV_EBADHEADER: psf->error = SFE_MALFORMED_FILE ; break ;
|
||||
case OV_EVERSION: psf->error = SFE_UNSUPPORTED_ENCODING ; break ;
|
||||
case OV_EFAULT:
|
||||
case OV_EINVAL:
|
||||
default: psf->error = SFE_INTERNAL ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
static int
|
||||
vorbis_read_header (SF_PRIVATE *psf)
|
||||
{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
|
|
@ -380,7 +397,6 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
{ ogg_packet header ;
|
||||
ogg_packet header_comm ;
|
||||
ogg_packet header_code ;
|
||||
int result ;
|
||||
|
||||
vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ;
|
||||
ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */
|
||||
|
|
@ -390,9 +406,9 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
/* This ensures the actual
|
||||
* audio data will start on a new page, as per spec
|
||||
*/
|
||||
while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0)
|
||||
{ ogg_write_page (psf, &odata->opage) ;
|
||||
} ;
|
||||
while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
|
|
@ -402,44 +418,25 @@ static int
|
|||
vorbis_close (SF_PRIVATE *psf)
|
||||
{ OGG_PRIVATE* odata = psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = psf->codec_data ;
|
||||
int ret = 0 ;
|
||||
|
||||
if (odata == NULL || vdata == NULL)
|
||||
return 0 ;
|
||||
|
||||
/* Clean up this logical bitstream ; before exit we shuld see if we're
|
||||
/* Clean up this logical bitstream ; before exit we should see if we're
|
||||
** followed by another [chained]. */
|
||||
|
||||
if (psf->file.mode == SFM_WRITE)
|
||||
{
|
||||
if (psf->write_current <= 0)
|
||||
vorbis_write_header (psf, 0) ;
|
||||
ret = vorbis_write_header (psf, 0) ;
|
||||
|
||||
vorbis_analysis_wrote (&vdata->vdsp, 0) ;
|
||||
while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
|
||||
{
|
||||
|
||||
/* analysis, assume we want to use bitrate management */
|
||||
vorbis_analysis (&vdata->vblock, NULL) ;
|
||||
vorbis_bitrate_addblock (&vdata->vblock) ;
|
||||
|
||||
while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
|
||||
{ /* weld the packet into the bitstream */
|
||||
ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
|
||||
|
||||
/* write out pages (if any) */
|
||||
while (!odata->eos)
|
||||
{ int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
if (result == 0) break ;
|
||||
ogg_write_page (psf, &odata->opage) ;
|
||||
|
||||
/* this could be set above, but for illustrative purposes, I do
|
||||
it here (to show that vorbis does know where the stream ends) */
|
||||
|
||||
if (ogg_page_eos (&odata->opage)) odata->eos = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == 0)
|
||||
{ /* A write of zero samples tells Vorbis the stream is done and to
|
||||
flush. */
|
||||
ret = vorbis_write_samples (psf, odata, vdata, 0) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
/* ogg_page and ogg_packet structs always point to storage in
|
||||
libvorbis. They are never freed or manipulated directly */
|
||||
|
|
@ -449,7 +446,7 @@ vorbis_close (SF_PRIVATE *psf)
|
|||
vorbis_comment_clear (&vdata->vcomment) ;
|
||||
vorbis_info_clear (&vdata->vinfo) ;
|
||||
|
||||
return 0 ;
|
||||
return ret ;
|
||||
} /* vorbis_close */
|
||||
|
||||
int
|
||||
|
|
@ -688,33 +685,40 @@ vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens)
|
|||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
static int
|
||||
vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames)
|
||||
{
|
||||
vorbis_analysis_wrote (&vdata->vdsp, in_frames) ;
|
||||
{ int ret ;
|
||||
|
||||
if ((ret = vorbis_analysis_wrote (&vdata->vdsp, in_frames)) != 0)
|
||||
return ret ;
|
||||
|
||||
/*
|
||||
** Vorbis does some data preanalysis, then divvies up blocks for
|
||||
** more involved (potentially parallel) processing. Get a single
|
||||
** block for encoding now.
|
||||
*/
|
||||
while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
|
||||
while ((ret = vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock)) == 1)
|
||||
{
|
||||
/* analysis, assume we want to use bitrate management */
|
||||
vorbis_analysis (&vdata->vblock, NULL) ;
|
||||
vorbis_bitrate_addblock (&vdata->vblock) ;
|
||||
if ((ret = vorbis_analysis (&vdata->vblock, NULL)) != 0)
|
||||
return ret ;
|
||||
if ((ret = vorbis_bitrate_addblock (&vdata->vblock)) != 0)
|
||||
return ret ;
|
||||
|
||||
while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
|
||||
while ((ret = vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) == 1)
|
||||
{
|
||||
/* weld the packet into the bitstream */
|
||||
ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
|
||||
if ((ret = ogg_stream_packetin (&odata->ostream, &odata->opacket)) != 0)
|
||||
return ret ;
|
||||
|
||||
/* write out pages (if any) */
|
||||
while (!odata->eos)
|
||||
{ int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
if (result == 0)
|
||||
{ ret = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
if (ret == 0)
|
||||
break ;
|
||||
ogg_write_page (psf, &odata->opage) ;
|
||||
|
||||
if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
return -1 ;
|
||||
|
||||
/* This could be set above, but for illustrative purposes, I do
|
||||
** it here (to show that vorbis does know where the stream ends) */
|
||||
|
|
@ -722,16 +726,22 @@ vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata
|
|||
odata->eos = 1 ;
|
||||
} ;
|
||||
} ;
|
||||
if (ret != 0)
|
||||
return ret ;
|
||||
} ;
|
||||
if (ret != 0)
|
||||
return ret ;
|
||||
|
||||
vdata->gp += in_frames ;
|
||||
|
||||
return 0 ;
|
||||
} /* vorbis_write_data */
|
||||
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
|
||||
{
|
||||
int i, m, j = 0 ;
|
||||
int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -740,14 +750,17 @@ vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) (ptr [j++]) / 32767.0f ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)))
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_s */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
|
||||
{ int i, m, j = 0 ;
|
||||
{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -756,14 +769,17 @@ vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)))
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_i */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
|
||||
{ int i, m, j = 0 ;
|
||||
{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -772,14 +788,17 @@ vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = ptr [j++] ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0)
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_f */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
|
||||
{ int i, m, j = 0 ;
|
||||
{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -788,7 +807,10 @@ vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) ptr [j++] ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0)
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_d */
|
||||
|
|
@ -884,7 +906,7 @@ vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp)
|
|||
return 0 ;
|
||||
|
||||
/* Search for a position a half large-block before our target. As Vorbis is
|
||||
** lapped, every sample position come from two blocks, the "left" half of
|
||||
** lapped, every sample position comes from two blocks, the "left" half of
|
||||
** one block and the "right" half of the previous block. The granule
|
||||
** position of an Ogg page of a Vorbis stream is the sample offset of the
|
||||
** last finished sample in the stream that can be decoded from a page. A
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ paf24_init (SF_PRIVATE *psf)
|
|||
(PAF24_BLOCK_SIZE + PAF24_SAMPLES_PER_BLOCK * sizeof (int)) ;
|
||||
|
||||
/*
|
||||
** Not exatly sure why this needs to be here but the tests
|
||||
** Not exactly sure why this needs to be here but the tests
|
||||
** fail without it.
|
||||
*/
|
||||
psf->last_op = 0 ;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ pcm_init (SF_PRIVATE *psf)
|
|||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
|
||||
chars = SF_CHARS_SIGNED ;
|
||||
|
|
@ -1782,20 +1782,20 @@ static void
|
|||
f2sc_clip_array (const float *src, signed char *dest, int count, int normalize)
|
||||
{ float normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 127 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = -128 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = psf_lrintf (scaled_value) >> 24 ;
|
||||
dest [i] = psf_lrintf (scaled_value) ;
|
||||
} ;
|
||||
} /* f2sc_clip_array */
|
||||
|
||||
|
|
@ -1841,20 +1841,20 @@ static void
|
|||
f2uc_clip_array (const float *src, unsigned char *dest, int count, int normalize)
|
||||
{ float normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 0xFF ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = (psf_lrintf (scaled_value) >> 24) + 128 ;
|
||||
dest [i] = psf_lrintf (scaled_value) + 128 ;
|
||||
} ;
|
||||
} /* f2uc_clip_array */
|
||||
|
||||
|
|
@ -1907,25 +1907,25 @@ f2bes_clip_array (const float *src, short *dest, int count, int normalize)
|
|||
float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [1] = 0xFF ;
|
||||
ucptr [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [1] = 0x00 ;
|
||||
ucptr [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [1] = value >> 16 ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
ucptr [1] = value ;
|
||||
ucptr [0] = value >> 8 ;
|
||||
} ;
|
||||
} /* f2bes_clip_array */
|
||||
|
||||
|
|
@ -1978,25 +1978,25 @@ f2les_clip_array (const float *src, short *dest, int count, int normalize)
|
|||
float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [0] = value >> 16 ;
|
||||
ucptr [1] = value >> 24 ;
|
||||
ucptr [0] = value ;
|
||||
ucptr [1] = value >> 8 ;
|
||||
} ;
|
||||
} /* f2les_clip_array */
|
||||
|
||||
|
|
@ -2047,31 +2047,27 @@ f2let_clip_array (const float *src, tribyte *dest, int count, int normalize)
|
|||
{ float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [0] = 0xFF ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [2] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [0] = 0x00 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [2] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
dest [i].bytes [0] = value >> 8 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [2] = value >> 24 ;
|
||||
dest [i].bytes [0] = value ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [2] = value >> 16 ;
|
||||
} ;
|
||||
} /* f2let_clip_array */
|
||||
|
||||
|
|
@ -2122,31 +2118,27 @@ f2bet_clip_array (const float *src, tribyte *dest, int count, int normalize)
|
|||
{ float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [0] = 0x7F ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [2] = 0xFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [0] = 0x80 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [2] = 0x00 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
dest [i].bytes [0] = value >> 24 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [2] = value >> 8 ;
|
||||
dest [i].bytes [0] = value >> 16 ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [2] = value ;
|
||||
} ;
|
||||
} /* f2bet_clip_array */
|
||||
|
||||
|
|
@ -2206,7 +2198,6 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= 1.0 * 0x7FFFFFFF)
|
||||
{ ucptr [0] = 0x7F ;
|
||||
ucptr [1] = 0xFF ;
|
||||
|
|
@ -2214,8 +2205,6 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0xFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [0] = 0x80 ;
|
||||
ucptr [1] = 0x00 ;
|
||||
|
|
@ -2223,7 +2212,6 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x00 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
|
|
@ -2289,7 +2277,6 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0xFF ;
|
||||
|
|
@ -2297,8 +2284,6 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x00 ;
|
||||
|
|
@ -2306,7 +2291,6 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [0] = value ;
|
||||
|
|
@ -2358,20 +2342,20 @@ static void
|
|||
d2sc_clip_array (const double *src, signed char *dest, int count, int normalize)
|
||||
{ double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 127 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = -128 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = psf_lrintf (scaled_value) >> 24 ;
|
||||
dest [i] = psf_lrintf (scaled_value) ;
|
||||
} ;
|
||||
} /* d2sc_clip_array */
|
||||
|
||||
|
|
@ -2417,20 +2401,20 @@ static void
|
|||
d2uc_clip_array (const double *src, unsigned char *dest, int count, int normalize)
|
||||
{ double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 255 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = (psf_lrint (src [i] * normfact) >> 24) + 128 ;
|
||||
dest [i] = psf_lrint (src [i] * normfact) + 128 ;
|
||||
} ;
|
||||
} /* d2uc_clip_array */
|
||||
|
||||
|
|
@ -2483,25 +2467,25 @@ d2bes_clip_array (const double *src, short *dest, int count, int normalize)
|
|||
double normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [1] = 0xFF ;
|
||||
ucptr [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [1] = 0x00 ;
|
||||
ucptr [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [1] = value >> 16 ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
ucptr [1] = value ;
|
||||
ucptr [0] = value >> 8 ;
|
||||
} ;
|
||||
} /* d2bes_clip_array */
|
||||
|
||||
|
|
@ -2554,25 +2538,25 @@ d2les_clip_array (const double *src, short *dest, int count, int normalize)
|
|||
int value ;
|
||||
double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [0] = value >> 16 ;
|
||||
ucptr [1] = value >> 24 ;
|
||||
ucptr [0] = value ;
|
||||
ucptr [1] = value >> 8 ;
|
||||
} ;
|
||||
} /* d2les_clip_array */
|
||||
|
||||
|
|
@ -2623,31 +2607,27 @@ d2let_clip_array (const double *src, tribyte *dest, int count, int normalize)
|
|||
{ int value ;
|
||||
double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [0] = 0xFF ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [2] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [0] = 0x00 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [2] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
dest [i].bytes [0] = value >> 8 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [2] = value >> 24 ;
|
||||
dest [i].bytes [0] = value ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [2] = value >> 16 ;
|
||||
} ;
|
||||
} /* d2let_clip_array */
|
||||
|
||||
|
|
@ -2698,31 +2678,27 @@ d2bet_clip_array (const double *src, tribyte *dest, int count, int normalize)
|
|||
{ int value ;
|
||||
double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [2] = 0xFF ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [2] = 0x00 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
dest [i].bytes [2] = value >> 8 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [0] = value >> 24 ;
|
||||
dest [i].bytes [2] = value ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [0] = value >> 16 ;
|
||||
} ;
|
||||
} /* d2bet_clip_array */
|
||||
|
||||
|
|
@ -2782,7 +2758,6 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ ucptr [3] = 0xFF ;
|
||||
ucptr [2] = 0xFF ;
|
||||
|
|
@ -2790,8 +2765,6 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [3] = 0x00 ;
|
||||
ucptr [2] = 0x00 ;
|
||||
|
|
@ -2799,7 +2772,6 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
|
|
@ -2865,7 +2837,6 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0xFF ;
|
||||
|
|
@ -2873,8 +2844,6 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x00 ;
|
||||
|
|
@ -2882,7 +2851,6 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [0] = value ;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
|
|||
} ;
|
||||
} ;
|
||||
|
||||
if (psf->filelength != riff_size + 8)
|
||||
if (psf->filelength - 8 != riff_size)
|
||||
psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ;
|
||||
else
|
||||
psf_log_printf (psf, " Riff size : %D\n", riff_size) ;
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
|
|||
|
||||
ucptr = psds->read_data + 5 ;
|
||||
for (k = 0 ; k < 120 ; k += 2)
|
||||
{ sample = arith_shift_left (ucptr [k], 25) + arith_shift_left (ucptr [k + 1], 18) ;
|
||||
{ sample = arith_shift_left (ucptr [k], 25) | arith_shift_left (ucptr [k + 1], 18) ;
|
||||
psds->read_samples [k / 2] = (int) (sample - 0x80000000) ;
|
||||
} ;
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
|
|||
|
||||
ucptr = psds->read_data + 5 ;
|
||||
for (k = 0 ; k < 120 ; k += 3)
|
||||
{ sample = (((uint32_t) ucptr [k]) << 25) + (ucptr [k + 1] << 18) + (ucptr [k + 2] << 11) ;
|
||||
{ sample = (((uint32_t) ucptr [k]) << 25) | (ucptr [k + 1] << 18) | (ucptr [k + 2] << 11) ;
|
||||
psds->read_samples [k / 3] = (int) (sample - 0x80000000) ;
|
||||
} ;
|
||||
|
||||
|
|
@ -542,7 +542,7 @@ sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
|
|||
|
||||
ucptr = psds->read_data + 5 ;
|
||||
for (k = 0 ; k < 120 ; k += 4)
|
||||
{ sample = (((uint32_t) ucptr [k]) << 25) + (ucptr [k + 1] << 18) + (ucptr [k + 2] << 11) + (ucptr [k + 3] << 4) ;
|
||||
{ sample = (((uint32_t) ucptr [k]) << 25) | (ucptr [k + 1] << 18) | (ucptr [k + 2] << 11) | (ucptr [k + 3] << 4) ;
|
||||
psds->read_samples [k / 4] = (int) (sample - 0x80000000) ;
|
||||
} ;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@
|
|||
#define HAVE_ALSA_ASOUNDLIB_H 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SNDIO_H
|
||||
#define HAVE_SNDIO_H 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BYTESWAP_H
|
||||
#define HAVE_BYTESWAP_H 0
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ SNDFILE*
|
|||
sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data)
|
||||
{ SF_PRIVATE *psf ;
|
||||
|
||||
/* Make sure we have a valid set ot virtual pointers. */
|
||||
/* Make sure we have a valid set of virtual pointers. */
|
||||
if (sfvirtual->get_filelen == NULL)
|
||||
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
||||
snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_get_filelen in SF_VIRTUAL_IO struct.\n") ;
|
||||
|
|
@ -658,7 +658,7 @@ sf_format_check (const SF_INFO *info)
|
|||
|
||||
/* This is the place where each file format can check if the supplied
|
||||
** SF_INFO struct is valid.
|
||||
** Return 0 on failure, 1 ons success.
|
||||
** Return 0 on failure, 1 on success.
|
||||
*/
|
||||
|
||||
if (info->channels < 1 || info->channels > SF_MAX_CHANNELS)
|
||||
|
|
@ -1112,7 +1112,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
|||
|
||||
format = SF_CODEC (psf->sf.format) ;
|
||||
|
||||
/* Only files containg the following data types support the PEAK chunk. */
|
||||
/* Only files containing the following data types support the PEAK chunk. */
|
||||
if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE)
|
||||
return SF_FALSE ;
|
||||
|
||||
|
|
@ -1522,7 +1522,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
|
|||
** used with SEEK_SET.
|
||||
*/
|
||||
switch (whence)
|
||||
{ /* The SEEK_SET behaviour is independant of mode. */
|
||||
{ /* The SEEK_SET behaviour is independent of mode. */
|
||||
case SEEK_SET :
|
||||
case SEEK_SET | SFM_READ :
|
||||
case SEEK_SET | SFM_WRITE :
|
||||
|
|
|
|||
|
|
@ -845,7 +845,7 @@ Detailed description of new data blocks (VOC files version 1.20 and above):
|
|||
|
||||
(Source is fax from Barry Boone at Creative Labs, 405/742-6622)
|
||||
|
||||
BLOCK 8 - digitized sound attribute extension, must preceed block 1.
|
||||
BLOCK 8 - digitized sound attribute extension, must precede block 1.
|
||||
Used to define stereo, 8 bit audio
|
||||
BYTE bBlockID; // = 8
|
||||
BYTE nBlockLen[3]; // 3 byte length
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ w64_open (SF_PRIVATE *psf)
|
|||
|
||||
/*
|
||||
** At this point we don't know the file length so set it stupidly high, but not
|
||||
** so high that it triggers undefined behaviour whan something is added to it.
|
||||
** so high that it triggers undefined behaviour when something is added to it.
|
||||
*/
|
||||
psf->filelength = SF_COUNT_MAX - 10000 ;
|
||||
psf->datalength = psf->filelength ;
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ wav_open (SF_PRIVATE *psf)
|
|||
} ;
|
||||
|
||||
#if (ENABLE_EXPERIMENTAL_CODE == 0)
|
||||
/* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarentee that
|
||||
/* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarantee that
|
||||
** such a file written by libsndfile would have the same length when opened again.
|
||||
*/
|
||||
if (subformat == SF_FORMAT_MPEG_LAYER_III)
|
||||
|
|
@ -1537,7 +1537,7 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen)
|
|||
**
|
||||
** 0x01 On: One Shot Off: Loop
|
||||
** 0x02 On: Root note is Set Off: No root
|
||||
** 0x04 On: Stretch is On, Off: Strech is OFF
|
||||
** 0x04 On: Stretch is On, Off: Stretch is OFF
|
||||
** 0x08 On: Disk Based Off: Ram based
|
||||
** 0x10 On: ?????????? Off: ????????? (Acidizer puts that ON)
|
||||
**
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static const struct chanmap_s
|
|||
{ int id ;
|
||||
const char * name ;
|
||||
} channel_mask_bits [] =
|
||||
{ /* WAVEFORMATEXTENSIBLE doesn't distuingish FRONT_LEFT from LEFT */
|
||||
{ /* WAVEFORMATEXTENSIBLE doesn't distinguish FRONT_LEFT from LEFT */
|
||||
{ SF_CHANNEL_MAP_LEFT, "L" },
|
||||
{ SF_CHANNEL_MAP_RIGHT, "R" },
|
||||
{ SF_CHANNEL_MAP_CENTER, "C" },
|
||||
|
|
@ -161,7 +161,7 @@ wavlike_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
|
|||
{ psf_log_printf (psf, " Bit Width : 24\n") ;
|
||||
|
||||
psf_log_printf (psf, "\n"
|
||||
" Ambiguous information in 'fmt ' chunk. Possibile file types:\n"
|
||||
" Ambiguous information in 'fmt ' chunk. Possible file types:\n"
|
||||
" 0) Invalid IEEE float file generated by Syntrillium's Cooledit!\n"
|
||||
" 1) File generated by ALSA's arecord containing 24 bit samples in 32 bit containers.\n"
|
||||
" 2) 24 bit file with incorrect Block Align value.\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue