mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
FLAC: Prepare 1.4.3 lib files for inclusion in the JUCE build
This commit is contained in:
parent
fef3160a5b
commit
31e4779b46
15 changed files with 135 additions and 201 deletions
|
|
@ -33,6 +33,10 @@
|
|||
#ifndef FLAC__ALL_H
|
||||
#define FLAC__ALL_H
|
||||
|
||||
#ifndef FLAC__HAS_OGG
|
||||
#define FLAC__HAS_OGG 0
|
||||
#endif
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#include "assert.h"
|
||||
|
|
|
|||
|
|
@ -41,11 +41,14 @@
|
|||
* before #including this file, otherwise SIZE_MAX might not be defined
|
||||
*/
|
||||
|
||||
#include <limits.h> /* for SIZE_MAX */
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
|
||||
#endif
|
||||
#include <stdlib.h> /* for size_t, malloc(), etc */
|
||||
// JUCE: removed as JUCE already includes standard headers and including
|
||||
// these in FlacNamespace will cause problems
|
||||
|
||||
//#include <limits.h> /* for SIZE_MAX */
|
||||
//#if HAVE_STDINT_H
|
||||
//#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
|
||||
//#endif
|
||||
//#include <stdlib.h> /* for size_t, malloc(), etc */
|
||||
#include "compat.h"
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
|
|
|
|||
|
|
@ -173,10 +173,13 @@
|
|||
#ifdef _WIN32
|
||||
/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */
|
||||
|
||||
#if 0
|
||||
#include "win_utf8_io.h"
|
||||
#define flac_printf printf_utf8
|
||||
#define flac_fprintf fprintf_utf8
|
||||
#define flac_vfprintf vfprintf_utf8
|
||||
#endif
|
||||
|
||||
#define flac_fopen fopen_utf8
|
||||
#define flac_chmod chmod_utf8
|
||||
#define flac_utime utime_utf8
|
||||
|
|
@ -234,7 +237,7 @@ extern "C" {
|
|||
int flac_snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FLAC__SHARE__COMPAT_H */
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ struct FLAC__BitReader {
|
|||
|
||||
static inline void crc16_update_word_(FLAC__BitReader *br, brword word)
|
||||
{
|
||||
register uint32_t crc = br->read_crc16;
|
||||
uint32_t crc = br->read_crc16;
|
||||
|
||||
for ( ; br->crc16_align < FLAC__BITS_PER_WORD ; br->crc16_align += 8) {
|
||||
uint32_t shift = FLAC__BITS_PER_WORD - 8 - br->crc16_align ;
|
||||
|
|
@ -167,7 +167,7 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
|||
/* first shift the unconsumed buffer data toward the front as much as possible */
|
||||
if(br->consumed_words > 0) {
|
||||
/* invalidate last seen framesync */
|
||||
br->last_seen_framesync = -1;
|
||||
br->last_seen_framesync = (uint32_t) -1;
|
||||
|
||||
crc16_update_block_(br); /* CRC consumed words */
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
|||
|
||||
FLAC__BitReader *FLAC__bitreader_new(void)
|
||||
{
|
||||
FLAC__BitReader *br = calloc(1, sizeof(FLAC__BitReader));
|
||||
FLAC__BitReader *br = (FLAC__BitReader*) calloc(1, sizeof(FLAC__BitReader));
|
||||
|
||||
/* calloc() implies:
|
||||
memset(br, 0, sizeof(FLAC__BitReader));
|
||||
|
|
@ -290,14 +290,14 @@ FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__BitReaderReadCallback
|
|||
br->words = br->bytes = 0;
|
||||
br->consumed_words = br->consumed_bits = 0;
|
||||
br->capacity = FLAC__BITREADER_DEFAULT_CAPACITY;
|
||||
br->buffer = malloc(sizeof(brword) * br->capacity);
|
||||
br->buffer = (brword*) malloc(sizeof(brword) * br->capacity);
|
||||
if(br->buffer == 0)
|
||||
return false;
|
||||
br->read_callback = rcb;
|
||||
br->client_data = cd;
|
||||
br->read_limit_set = false;
|
||||
br->read_limit = -1;
|
||||
br->last_seen_framesync = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
br->last_seen_framesync = (uint32_t) -1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -315,8 +315,8 @@ void FLAC__bitreader_free(FLAC__BitReader *br)
|
|||
br->read_callback = 0;
|
||||
br->client_data = 0;
|
||||
br->read_limit_set = false;
|
||||
br->read_limit = -1;
|
||||
br->last_seen_framesync = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
br->last_seen_framesync = (uint32_t) -1;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br)
|
||||
|
|
@ -324,8 +324,8 @@ FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br)
|
|||
br->words = br->bytes = 0;
|
||||
br->consumed_words = br->consumed_bits = 0;
|
||||
br->read_limit_set = false;
|
||||
br->read_limit = -1;
|
||||
br->last_seen_framesync = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
br->last_seen_framesync = (uint32_t) -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ void FLAC__bitreader_set_limit(FLAC__BitReader *br, uint32_t limit)
|
|||
void FLAC__bitreader_remove_limit(FLAC__BitReader *br)
|
||||
{
|
||||
br->read_limit_set = false;
|
||||
br->read_limit = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
}
|
||||
|
||||
uint32_t FLAC__bitreader_limit_remaining(FLAC__BitReader *br)
|
||||
|
|
@ -412,7 +412,7 @@ uint32_t FLAC__bitreader_limit_remaining(FLAC__BitReader *br)
|
|||
}
|
||||
void FLAC__bitreader_limit_invalidate(FLAC__BitReader *br)
|
||||
{
|
||||
br->read_limit = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits)
|
||||
|
|
@ -434,7 +434,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *va
|
|||
|
||||
if(br->read_limit_set && br->read_limit < (uint32_t)-1){
|
||||
if(br->read_limit < bits) {
|
||||
br->read_limit = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
|
@ -622,7 +622,7 @@ FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, u
|
|||
|
||||
if(br->read_limit_set && br->read_limit < (uint32_t)-1){
|
||||
if(br->read_limit < nvals*8){
|
||||
br->read_limit = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -667,7 +667,7 @@ FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, F
|
|||
|
||||
if(br->read_limit_set && br->read_limit < (uint32_t)-1){
|
||||
if(br->read_limit < nvals*8){
|
||||
br->read_limit = -1;
|
||||
br->read_limit = (uint32_t) -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, uint32_t bits_to_add)
|
|||
FLAC__ASSERT(new_capacity > bw->capacity);
|
||||
FLAC__ASSERT(new_capacity >= bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD));
|
||||
|
||||
new_buffer = safe_realloc_nofree_mul_2op_(bw->buffer, sizeof(bwword), /*times*/new_capacity);
|
||||
new_buffer = (bwword*) safe_realloc_nofree_mul_2op_(bw->buffer, sizeof(bwword), /*times*/new_capacity);
|
||||
if(new_buffer == 0)
|
||||
return false;
|
||||
bw->buffer = new_buffer;
|
||||
|
|
@ -156,7 +156,7 @@ FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, uint32_t bits_to_add)
|
|||
|
||||
FLAC__BitWriter *FLAC__bitwriter_new(void)
|
||||
{
|
||||
FLAC__BitWriter *bw = calloc(1, sizeof(FLAC__BitWriter));
|
||||
FLAC__BitWriter *bw = (FLAC__BitWriter*) calloc(1, sizeof(FLAC__BitWriter));
|
||||
/* note that calloc() sets all members to 0 for us */
|
||||
return bw;
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw)
|
|||
|
||||
bw->words = bw->bits = 0;
|
||||
bw->capacity = FLAC__BITWRITER_DEFAULT_CAPACITY;
|
||||
bw->buffer = malloc(sizeof(bwword) * bw->capacity);
|
||||
bw->buffer = (bwword*) malloc(sizeof(bwword) * bw->capacity);
|
||||
if(bw->buffer == 0)
|
||||
return false;
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bit
|
|||
|
||||
static inline FLAC__bool FLAC__bitwriter_write_raw_uint32_nocheck(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits)
|
||||
{
|
||||
register uint32_t left;
|
||||
uint32_t left;
|
||||
|
||||
/* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
|
||||
FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ static const uint32_t FLAC__CPUINFO_X86_CPUID_FMA = 0x00001000;
|
|||
static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX2 = 0x00000020;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_BMI2 = 0x00000100;
|
||||
|
||||
#if FLAC__AVX_SUPPORTED
|
||||
static uint32_t
|
||||
cpu_xgetbv_x86(void)
|
||||
{
|
||||
|
|
@ -91,6 +92,7 @@ cpu_xgetbv_x86(void)
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32_t
|
||||
cpu_have_cpuid(void)
|
||||
|
|
@ -128,7 +130,7 @@ cpu_have_cpuid(void)
|
|||
}
|
||||
|
||||
static void
|
||||
cpuinfo_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx)
|
||||
cpuinfo_x86([[maybe_unused]] FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx)
|
||||
{
|
||||
#if defined _MSC_VER
|
||||
int cpuinfo[4];
|
||||
|
|
@ -160,7 +162,9 @@ static void
|
|||
x86_cpu_info (FLAC__CPUInfo *info)
|
||||
{
|
||||
#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN && !defined FLAC__NO_ASM
|
||||
#if FLAC__AVX_SUPPORTED
|
||||
FLAC__bool x86_osxsave = false;
|
||||
#endif
|
||||
FLAC__bool os_avx = false;
|
||||
FLAC__uint32 flags_eax, flags_ebx, flags_ecx, flags_edx;
|
||||
|
||||
|
|
@ -181,19 +185,19 @@ x86_cpu_info (FLAC__CPUInfo *info)
|
|||
info->x86.sse41 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE41) ? true : false;
|
||||
info->x86.sse42 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE42) ? true : false;
|
||||
|
||||
if (FLAC__AVX_SUPPORTED) {
|
||||
#if (FLAC__AVX_SUPPORTED)
|
||||
x86_osxsave = (flags_ecx & FLAC__CPUINFO_X86_CPUID_OSXSAVE) ? true : false;
|
||||
info->x86.avx = (flags_ecx & FLAC__CPUINFO_X86_CPUID_AVX ) ? true : false;
|
||||
info->x86.fma = (flags_ecx & FLAC__CPUINFO_X86_CPUID_FMA ) ? true : false;
|
||||
cpuinfo_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_AVX2 ) ? true : false;
|
||||
info->x86.bmi2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_BMI2 ) ? true : false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined FLAC__CPU_IA32
|
||||
dfprintf(stderr, "CPU info (IA-32):\n");
|
||||
dfprintf(stderr, "CPU info (IA-32):\n", "");
|
||||
#else
|
||||
dfprintf(stderr, "CPU info (x86-64):\n");
|
||||
dfprintf(stderr, "CPU info (x86-64):\n", "");
|
||||
#endif
|
||||
dfprintf(stderr, " CMOV ....... %c\n", info->x86.cmov ? 'Y' : 'n');
|
||||
dfprintf(stderr, " MMX ........ %c\n", info->x86.mmx ? 'Y' : 'n');
|
||||
|
|
@ -214,9 +218,11 @@ x86_cpu_info (FLAC__CPUInfo *info)
|
|||
/*
|
||||
* now have to check for OS support of AVX instructions
|
||||
*/
|
||||
if (FLAC__AVX_SUPPORTED && info->x86.avx && x86_osxsave && (cpu_xgetbv_x86() & 0x6) == 0x6) {
|
||||
#if FLAC__AVX_SUPPORTED
|
||||
if (info->x86.avx && x86_osxsave && (cpu_xgetbv_x86() & 0x6) == 0x6) {
|
||||
os_avx = true;
|
||||
}
|
||||
#endif
|
||||
if (os_avx) {
|
||||
dfprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -592,9 +592,9 @@ FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_s
|
|||
FLAC__ASSERT(0 != object);
|
||||
|
||||
if(object->capacity_by_order < max_partition_order || object->parameters == NULL || object->raw_bits == NULL) {
|
||||
if(0 == (object->parameters = safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order))))
|
||||
if(0 == (object->parameters = (uint32_t*) safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order))))
|
||||
return false;
|
||||
if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order))))
|
||||
if(0 == (object->raw_bits = (uint32_t*) safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order))))
|
||||
return false;
|
||||
memset(object->raw_bits, 0, sizeof(uint32_t)*(1 << max_partition_order));
|
||||
object->capacity_by_order = max_partition_order;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static inline uint32_t FLAC__clz_uint32(FLAC__uint32 v)
|
|||
#elif defined(_MSC_VER)
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse(&idx, v);
|
||||
_BitScanReverse((unsigned long*) &idx, v);
|
||||
return idx ^ 31U;
|
||||
}
|
||||
#else
|
||||
|
|
@ -107,7 +107,7 @@ static inline uint32_t FLAC__clz_uint64(FLAC__uint64 v)
|
|||
#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64))
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse64(&idx, v);
|
||||
_BitScanReverse64((unsigned long*) &idx, v);
|
||||
return idx ^ 63U;
|
||||
}
|
||||
#else
|
||||
|
|
@ -161,7 +161,7 @@ static inline uint32_t FLAC__bitmath_ilog2(FLAC__uint32 v)
|
|||
#elif defined(_MSC_VER)
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse(&idx, v);
|
||||
_BitScanReverse((unsigned long*) &idx, v);
|
||||
return idx;
|
||||
}
|
||||
#else
|
||||
|
|
@ -178,7 +178,7 @@ static inline uint32_t FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
|
|||
#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64))
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse64(&idx, v);
|
||||
_BitScanReverse64((unsigned long*) &idx, v);
|
||||
return idx;
|
||||
}
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -59,102 +59,6 @@
|
|||
#define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if FLAC__HAS_X86INTRIN
|
||||
/* SSE intrinsics support by ICC/MSVC/GCC */
|
||||
#if defined __INTEL_COMPILER
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#if (__INTEL_COMPILER >= 1000) /* Intel C++ Compiler 10.0 */
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#define FLAC__SSE4_2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef FLAC__USE_AVX
|
||||
#if (__INTEL_COMPILER >= 1110) /* Intel C++ Compiler 11.1 */
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#endif
|
||||
#if (__INTEL_COMPILER >= 1300) /* Intel C++ Compiler 13.0 */
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#endif
|
||||
#elif defined __clang__ && __has_attribute(__target__) /* clang */
|
||||
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#define FLAC__SSE4_2_SUPPORTED 1
|
||||
#ifdef FLAC__USE_AVX
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#define FLAC__BMI2_SUPPORTED 1
|
||||
#endif
|
||||
#elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */
|
||||
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#define FLAC__SSE4_2_SUPPORTED 1
|
||||
#ifdef FLAC__USE_AVX
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#define FLAC__BMI2_SUPPORTED 1
|
||||
#endif
|
||||
#elif defined _MSC_VER
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#if (_MSC_VER >= 1500) /* MS Visual Studio 2008 */
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#define FLAC__SSE4_2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef FLAC__USE_AVX
|
||||
#if (_MSC_FULL_VER >= 160040219) /* MS Visual Studio 2010 SP1 */
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#endif
|
||||
#if (_MSC_VER >= 1700) /* MS Visual Studio 2012 */
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
#ifdef __SSE__
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE2__
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSSE3__
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE4_1__
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE4_2__
|
||||
#define FLAC__SSE4_2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef FLAC__USE_AVX
|
||||
#ifdef __AVX__
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __AVX2__
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __FMA__
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#endif
|
||||
#endif /* compiler version */
|
||||
#endif /* intrinsics support */
|
||||
|
||||
|
||||
#ifndef FLAC__AVX_SUPPORTED
|
||||
#define FLAC__AVX_SUPPORTED 0
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
*/
|
||||
static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
|
||||
{
|
||||
register FLAC__uint32 a, b, c, d;
|
||||
FLAC__uint32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
|
|
@ -500,8 +500,8 @@ FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const
|
|||
return false;
|
||||
|
||||
if (ctx->capacity < bytes_needed) {
|
||||
if (0 == (ctx->internal_buf.p8 = safe_realloc_(ctx->internal_buf.p8, bytes_needed))) {
|
||||
if (0 == (ctx->internal_buf.p8 = safe_malloc_(bytes_needed))) {
|
||||
if (0 == (ctx->internal_buf.p8 = (FLAC__byte*) safe_realloc_(ctx->internal_buf.p8, bytes_needed))) {
|
||||
if (0 == (ctx->internal_buf.p8 = (FLAC__byte*) safe_malloc_(bytes_needed))) {
|
||||
ctx->capacity = 0;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 *
|
|||
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
pu = (FLAC__int32*) FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32
|
|||
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
pu = (FLAC__uint32*) FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ FLAC__bool FLAC__memory_alloc_aligned_int64_array(size_t elements, FLAC__int64 *
|
|||
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
pu = (FLAC__int64*) FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64
|
|||
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
pu = (FLAC__uint64*) FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **u
|
|||
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
pu = (FLAC__real*) FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' };
|
|||
***********************************************************************/
|
||||
|
||||
static void set_defaults_(FLAC__StreamDecoder *decoder);
|
||||
static FILE *get_binary_stdin_(void);
|
||||
//static FILE *get_binary_stdin_(void);
|
||||
static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps);
|
||||
static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id);
|
||||
static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder);
|
||||
|
|
@ -107,11 +107,11 @@ static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__u
|
|||
#if FLAC__HAS_OGG
|
||||
static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample);
|
||||
#endif
|
||||
static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
|
||||
static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
|
||||
//static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
//static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
//static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
//static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
|
||||
//static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
|
|
@ -246,18 +246,18 @@ FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void)
|
|||
|
||||
FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */
|
||||
|
||||
decoder = calloc(1, sizeof(FLAC__StreamDecoder));
|
||||
decoder = (FLAC__StreamDecoder*) calloc(1, sizeof(FLAC__StreamDecoder));
|
||||
if(decoder == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
decoder->protected_ = calloc(1, sizeof(FLAC__StreamDecoderProtected));
|
||||
decoder->protected_ = (FLAC__StreamDecoderProtected*) calloc(1, sizeof(FLAC__StreamDecoderProtected));
|
||||
if(decoder->protected_ == 0) {
|
||||
free(decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
decoder->private_ = calloc(1, sizeof(FLAC__StreamDecoderPrivate));
|
||||
decoder->private_ = (FLAC__StreamDecoderPrivate*) calloc(1, sizeof(FLAC__StreamDecoderPrivate));
|
||||
if(decoder->private_ == 0) {
|
||||
free(decoder->protected_);
|
||||
free(decoder);
|
||||
|
|
@ -273,7 +273,7 @@ FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void)
|
|||
}
|
||||
|
||||
decoder->private_->metadata_filter_ids_capacity = 16;
|
||||
if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) {
|
||||
if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*) malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) {
|
||||
FLAC__bitreader_delete(decoder->private_->input);
|
||||
free(decoder->private_);
|
||||
free(decoder->protected_);
|
||||
|
|
@ -355,8 +355,10 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
|
|||
if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
|
||||
return FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
|
||||
|
||||
if(FLAC__HAS_OGG == 0 && is_ogg)
|
||||
#if FLAC__HAS_OGG == 0
|
||||
if(is_ogg)
|
||||
return FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
|
||||
#endif
|
||||
|
||||
if(
|
||||
0 == read_callback ||
|
||||
|
|
@ -470,6 +472,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
|
|||
);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static FLAC__StreamDecoderInitStatus init_FILE_internal_(
|
||||
FLAC__StreamDecoder *decoder,
|
||||
FILE *file,
|
||||
|
|
@ -594,6 +597,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
|
|||
{
|
||||
return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true);
|
||||
}
|
||||
#endif
|
||||
|
||||
FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
|
|
@ -723,7 +727,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__
|
|||
FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids);
|
||||
|
||||
if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) {
|
||||
if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) {
|
||||
if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*) safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -782,7 +786,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__S
|
|||
FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids);
|
||||
|
||||
if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) {
|
||||
if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) {
|
||||
if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*) safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1225,6 +1229,7 @@ void set_defaults_(FLAC__StreamDecoder *decoder)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* This will forcibly set stdin to binary mode (for OSes that require it)
|
||||
*/
|
||||
|
|
@ -1242,6 +1247,7 @@ FILE *get_binary_stdin_(void)
|
|||
|
||||
return stdin;
|
||||
}
|
||||
#endif
|
||||
|
||||
FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps)
|
||||
{
|
||||
|
|
@ -1277,7 +1283,7 @@ FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_
|
|||
* in front (at negative indices) for alignment purposes;
|
||||
* we use 4 to keep the data well-aligned.
|
||||
*/
|
||||
tmp = safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/);
|
||||
tmp = (FLAC__int32*) safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/);
|
||||
if(tmp == 0) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
|
|
@ -1292,7 +1298,7 @@ FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_
|
|||
}
|
||||
|
||||
if(bps == 32) {
|
||||
decoder->private_->side_subframe = safe_malloc_mul_2op_p(sizeof(FLAC__int64), /*times (*/size);
|
||||
decoder->private_->side_subframe = (FLAC__int64*) safe_malloc_mul_2op_p(sizeof(FLAC__int64), /*times (*/size);
|
||||
if(decoder->private_->side_subframe == NULL) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
|
|
@ -1465,7 +1471,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
|
|||
case FLAC__METADATA_TYPE_APPLICATION:
|
||||
/* remember, we read the ID already */
|
||||
if(real_length > 0) {
|
||||
if(0 == (block.data.application.data = malloc(real_length))) {
|
||||
if(0 == (block.data.application.data = (FLAC__byte*) malloc(real_length))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
ok = false;
|
||||
}
|
||||
|
|
@ -1493,7 +1499,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
|
|||
break;
|
||||
default:
|
||||
if(real_length > 0) {
|
||||
if(0 == (block.data.unknown.data = malloc(real_length))) {
|
||||
if(0 == (block.data.unknown.data = (FLAC__byte*) malloc(real_length))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
ok = false;
|
||||
}
|
||||
|
|
@ -1667,7 +1673,7 @@ FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_
|
|||
decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOINT_LENGTH;
|
||||
|
||||
/* use realloc since we may pass through here several times (e.g. after seeking) */
|
||||
if(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->private_->seek_table.data.seek_table.points, decoder->private_->seek_table.data.seek_table.num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)))) {
|
||||
if(0 == (decoder->private_->seek_table.data.seek_table.points = (FLAC__StreamMetadata_SeekPoint*) safe_realloc_mul_2op_(decoder->private_->seek_table.data.seek_table.points, decoder->private_->seek_table.data.seek_table.num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1710,7 +1716,7 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
|
|||
}
|
||||
else
|
||||
length -= obj->vendor_string.length;
|
||||
if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) {
|
||||
if (0 == (obj->vendor_string.entry = (FLAC__byte*) safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1730,7 +1736,7 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
|
|||
return false;
|
||||
}
|
||||
if (obj->num_comments > 0) {
|
||||
if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
|
||||
if (0 == (obj->comments = (FLAC__StreamMetadata_VorbisComment_Entry*) safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
|
||||
obj->num_comments = 0;
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
|
|
@ -1758,7 +1764,7 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
|
|||
}
|
||||
else
|
||||
length -= obj->comments[i].length;
|
||||
if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) {
|
||||
if (0 == (obj->comments[i].entry = (FLAC__byte*) safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
obj->num_comments = i;
|
||||
return false;
|
||||
|
|
@ -1821,7 +1827,7 @@ FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMet
|
|||
obj->num_tracks = x;
|
||||
|
||||
if(obj->num_tracks > 0) {
|
||||
if(0 == (obj->tracks = safe_calloc_(obj->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) {
|
||||
if(0 == (obj->tracks = (FLAC__StreamMetadata_CueSheet_Track*) safe_calloc_(obj->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1854,7 +1860,7 @@ FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMet
|
|||
track->num_indices = (FLAC__byte)x;
|
||||
|
||||
if(track->num_indices > 0) {
|
||||
if(0 == (track->indices = safe_calloc_(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)))) {
|
||||
if(0 == (track->indices = (FLAC__StreamMetadata_CueSheet_Index*) safe_calloc_(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1891,7 +1897,7 @@ FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMeta
|
|||
if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TYPE_LEN))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
if(x < FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED)
|
||||
obj->type = x;
|
||||
obj->type = (FLAC__StreamMetadata_Picture_Type) x;
|
||||
else
|
||||
obj->type = FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER;
|
||||
|
||||
|
|
@ -1902,7 +1908,7 @@ FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMeta
|
|||
FLAC__bitreader_limit_invalidate(decoder->private_->input);
|
||||
return false;
|
||||
}
|
||||
if(0 == (obj->mime_type = safe_malloc_add_2op_(x, /*+*/1))) {
|
||||
if(0 == (obj->mime_type = (char*) safe_malloc_add_2op_(x, /*+*/1))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1919,7 +1925,7 @@ FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMeta
|
|||
FLAC__bitreader_limit_invalidate(decoder->private_->input);
|
||||
return false;
|
||||
}
|
||||
if(0 == (obj->description = safe_malloc_add_2op_(x, /*+*/1))) {
|
||||
if(0 == (obj->description = (FLAC__byte*) safe_malloc_add_2op_(x, /*+*/1))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1952,7 +1958,7 @@ FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMeta
|
|||
FLAC__bitreader_limit_invalidate(decoder->private_->input);
|
||||
return false;
|
||||
}
|
||||
if(0 == (obj->data = safe_malloc_(obj->data_length))) {
|
||||
if(0 == (obj->data = (FLAC__byte*) safe_malloc_(obj->data_length))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2043,7 +2049,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
|
|||
uint32_t channel;
|
||||
uint32_t i;
|
||||
uint32_t frame_crc; /* the one we calculate from the input stream */
|
||||
FLAC__uint32 x;
|
||||
FLAC__uint32 x{};
|
||||
|
||||
*got_a_frame = false;
|
||||
decoder->private_->side_subframe_in_use = false;
|
||||
|
|
@ -2166,7 +2172,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
|
|||
empty_frame.header = decoder->private_->last_frame.header;
|
||||
empty_frame.footer.crc = 0;
|
||||
for(i = 0; i < empty_frame.header.channels; i++) {
|
||||
empty_buffer[i] = safe_calloc_(empty_frame.header.blocksize, sizeof(FLAC__int32));
|
||||
empty_buffer[i] = (FLAC__int32*) safe_calloc_(empty_frame.header.blocksize, sizeof(FLAC__int32));
|
||||
if(empty_buffer[i] == NULL) {
|
||||
for(i = 0; i < empty_frame.header.channels; i++)
|
||||
if(empty_buffer[i] != NULL)
|
||||
|
|
@ -3658,6 +3664,7 @@ FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
|
||||
{
|
||||
(void)client_data;
|
||||
|
|
@ -3729,3 +3736,4 @@ FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_d
|
|||
|
||||
return feof(decoder->private_->file)? true : false;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -319,11 +319,11 @@ static FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamD
|
|||
static void verify_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
|
||||
static void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||
|
||||
static FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
static FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
|
||||
static FILE *get_binary_stdout_(void);
|
||||
//static FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
//static FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
//static FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
//static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
|
||||
//static FILE *get_binary_stdout_(void);
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
|
@ -538,18 +538,18 @@ FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void)
|
|||
|
||||
FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */
|
||||
|
||||
encoder = calloc(1, sizeof(FLAC__StreamEncoder));
|
||||
encoder = (FLAC__StreamEncoder*) calloc(1, sizeof(FLAC__StreamEncoder));
|
||||
if(encoder == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
encoder->protected_ = calloc(1, sizeof(FLAC__StreamEncoderProtected));
|
||||
encoder->protected_ = (FLAC__StreamEncoderProtected*) calloc(1, sizeof(FLAC__StreamEncoderProtected));
|
||||
if(encoder->protected_ == 0) {
|
||||
free(encoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
encoder->private_ = calloc(1, sizeof(FLAC__StreamEncoderPrivate));
|
||||
encoder->private_ = (FLAC__StreamEncoderPrivate*) calloc(1, sizeof(FLAC__StreamEncoderPrivate));
|
||||
if(encoder->private_ == 0) {
|
||||
free(encoder->protected_);
|
||||
free(encoder);
|
||||
|
|
@ -663,8 +663,10 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_(
|
|||
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED;
|
||||
|
||||
if(FLAC__HAS_OGG == 0 && is_ogg)
|
||||
#if FLAC__HAS_OGG == 0
|
||||
if(is_ogg)
|
||||
return FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
|
||||
#endif
|
||||
|
||||
if(0 == write_callback || (seek_callback && 0 == tell_callback))
|
||||
return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS;
|
||||
|
|
@ -1135,7 +1137,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_(
|
|||
*/
|
||||
encoder->private_->verify.input_fifo.size = encoder->protected_->blocksize+OVERREAD_;
|
||||
for(i = 0; i < encoder->protected_->channels; i++) {
|
||||
if(0 == (encoder->private_->verify.input_fifo.data[i] = safe_malloc_mul_2op_p(sizeof(FLAC__int32), /*times*/encoder->private_->verify.input_fifo.size))) {
|
||||
if(0 == (encoder->private_->verify.input_fifo.data[i] = (FLAC__int32*) safe_malloc_mul_2op_p(sizeof(FLAC__int32), /*times*/encoder->private_->verify.input_fifo.size))) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
|
||||
return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
|
||||
}
|
||||
|
|
@ -1324,6 +1326,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(
|
|||
);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static FLAC__StreamEncoderInitStatus init_FILE_internal_(
|
||||
FLAC__StreamEncoder *encoder,
|
||||
FILE *file,
|
||||
|
|
@ -1463,6 +1466,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(
|
|||
{
|
||||
return init_file_internal_(encoder, filename, progress_callback, client_data, /*is_ogg=*/true);
|
||||
}
|
||||
#endif
|
||||
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)
|
||||
{
|
||||
|
|
@ -1942,7 +1946,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__Stream
|
|||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
value = flac_min(value, (FLAC__U64L(1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN) - 1);
|
||||
value = flac_min(value, (FLAC__uint64)((FLAC__U64L(1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN) - 1));
|
||||
encoder->protected_->total_samples_estimate = value;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1966,7 +1970,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encod
|
|||
}
|
||||
if(num_blocks) {
|
||||
FLAC__StreamMetadata **m;
|
||||
if(0 == (m = safe_malloc_mul_2op_p(sizeof(m[0]), /*times*/num_blocks)))
|
||||
if(0 == (m = (FLAC__StreamMetadata**) safe_malloc_mul_2op_p(sizeof(m[0]), /*times*/num_blocks)))
|
||||
return false;
|
||||
memcpy(m, metadata, sizeof(m[0]) * num_blocks);
|
||||
encoder->protected_->metadata = m;
|
||||
|
|
@ -2700,8 +2704,8 @@ FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC
|
|||
FLAC__bitwriter_clear(encoder->private_->frame);
|
||||
|
||||
if(samples > 0) {
|
||||
encoder->private_->streaminfo.data.stream_info.min_framesize = flac_min(bytes, encoder->private_->streaminfo.data.stream_info.min_framesize);
|
||||
encoder->private_->streaminfo.data.stream_info.max_framesize = flac_max(bytes, encoder->private_->streaminfo.data.stream_info.max_framesize);
|
||||
encoder->private_->streaminfo.data.stream_info.min_framesize = flac_min((uint32_t) bytes, encoder->private_->streaminfo.data.stream_info.min_framesize);
|
||||
encoder->private_->streaminfo.data.stream_info.max_framesize = flac_max((uint32_t) bytes, encoder->private_->streaminfo.data.stream_info.max_framesize);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -2726,7 +2730,7 @@ FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const
|
|||
* Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets.
|
||||
*/
|
||||
if(samples == 0) {
|
||||
FLAC__MetadataType type = (buffer[0] & 0x7f);
|
||||
FLAC__MetadataType type = (FLAC__MetadataType) (buffer[0] & 0x7f);
|
||||
if(type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
encoder->protected_->streaminfo_offset = output_position;
|
||||
else if(type == FLAC__METADATA_TYPE_SEEKTABLE && encoder->protected_->seektable_offset == 0)
|
||||
|
|
@ -3515,7 +3519,7 @@ FLAC__bool process_subframe_(
|
|||
uint32_t i;
|
||||
signal_is_constant = true;
|
||||
if(subframe_bps <= 32){
|
||||
const FLAC__int32 *integer_signal_ = integer_signal;
|
||||
const FLAC__int32 *integer_signal_ = (FLAC__int32*) integer_signal;
|
||||
for(i = 1; i < frame_header->blocksize; i++) {
|
||||
if(integer_signal_[0] != integer_signal_[i]) {
|
||||
signal_is_constant = false;
|
||||
|
|
@ -3524,7 +3528,7 @@ FLAC__bool process_subframe_(
|
|||
}
|
||||
}
|
||||
else {
|
||||
const FLAC__int64 *integer_signal_ = integer_signal;
|
||||
const FLAC__int64 *integer_signal_ = (FLAC__int64*) integer_signal;
|
||||
for(i = 1; i < frame_header->blocksize; i++) {
|
||||
if(integer_signal_[0] != integer_signal_[i]) {
|
||||
signal_is_constant = false;
|
||||
|
|
@ -3722,9 +3726,9 @@ FLAC__bool apply_apodization_(FLAC__StreamEncoder *encoder,
|
|||
if(apply_apodization_state->b == 1) {
|
||||
/* window full subblock */
|
||||
if(subframe_bps <= 32)
|
||||
FLAC__lpc_window_data(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize);
|
||||
FLAC__lpc_window_data((const FLAC__int32*) integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize);
|
||||
else
|
||||
FLAC__lpc_window_data_wide(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize);
|
||||
FLAC__lpc_window_data_wide((const FLAC__int64*) integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize);
|
||||
encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, blocksize, (*max_lpc_order_this_apodization)+1, apply_apodization_state->autoc);
|
||||
if(apply_apodization_state->current_apodization->type == FLAC__APODIZATION_SUBDIVIDE_TUKEY){
|
||||
uint32_t i;
|
||||
|
|
@ -3750,9 +3754,9 @@ FLAC__bool apply_apodization_(FLAC__StreamEncoder *encoder,
|
|||
if(!(apply_apodization_state->c % 2)) {
|
||||
/* on even c, evaluate the (c/2)th partial window of size blocksize/b */
|
||||
if(subframe_bps <= 32)
|
||||
FLAC__lpc_window_data_partial(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize, blocksize/apply_apodization_state->b/2, (apply_apodization_state->c/2*blocksize)/apply_apodization_state->b);
|
||||
FLAC__lpc_window_data_partial((const FLAC__int32*) integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize, blocksize/apply_apodization_state->b/2, (apply_apodization_state->c/2*blocksize)/apply_apodization_state->b);
|
||||
else
|
||||
FLAC__lpc_window_data_partial_wide(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize, blocksize/apply_apodization_state->b/2, (apply_apodization_state->c/2*blocksize)/apply_apodization_state->b);
|
||||
FLAC__lpc_window_data_partial_wide((const FLAC__int64*) integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize, blocksize/apply_apodization_state->b/2, (apply_apodization_state->c/2*blocksize)/apply_apodization_state->b);
|
||||
encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, blocksize/apply_apodization_state->b, (*max_lpc_order_this_apodization)+1, apply_apodization_state->autoc);
|
||||
}
|
||||
else {
|
||||
|
|
@ -4068,11 +4072,11 @@ uint32_t evaluate_verbatim_subframe_(
|
|||
|
||||
if(subframe_bps <= 32){
|
||||
subframe->data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32;
|
||||
subframe->data.verbatim.data.int32 = signal;
|
||||
subframe->data.verbatim.data.int32 = (const FLAC__int32*) signal;
|
||||
}
|
||||
else {
|
||||
subframe->data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT64;
|
||||
subframe->data.verbatim.data.int64 = signal;
|
||||
subframe->data.verbatim.data.int64 = (const FLAC__int64*) signal;
|
||||
}
|
||||
|
||||
estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + (blocksize * subframe_bps);
|
||||
|
|
@ -4319,14 +4323,14 @@ static inline uint32_t count_rice_bits_in_partition_(
|
|||
)
|
||||
{
|
||||
return (uint32_t)(flac_min( // To make sure the return value doesn't overflow
|
||||
FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */
|
||||
(uint32_t) (FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */
|
||||
(1+rice_parameter) * partition_samples + /* 1 for unary stop bit + rice_parameter for the binary portion */
|
||||
(
|
||||
rice_parameter?
|
||||
(abs_residual_partition_sum >> (rice_parameter-1)) /* rice_parameter-1 because the real coder sign-folds instead of using a sign bit */
|
||||
: (abs_residual_partition_sum << 1) /* can't shift by negative number, so reverse */
|
||||
)
|
||||
- (partition_samples >> 1),UINT32_MAX));
|
||||
- (partition_samples >> 1)),UINT32_MAX));
|
||||
/* -(partition_samples>>1) to subtract out extra contributions to the abs_residual_partition_sum.
|
||||
* The actual number of bits used is closer to the sum(for all i in the partition) of abs(residual[i])>>(rice_parameter-1)
|
||||
* By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out.
|
||||
|
|
@ -4635,6 +4639,7 @@ void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDeco
|
|||
encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
|
||||
}
|
||||
|
||||
#if 0
|
||||
FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
|
||||
{
|
||||
(void)client_data;
|
||||
|
|
@ -4736,3 +4741,4 @@ FILE *get_binary_stdout_(void)
|
|||
|
||||
return stdout;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue