trunk/3rdparty/libflac/src/libFLAC/cpu.c
| r242844 | r242845 | |
| 29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | | #if HAVE_CONFIG_H |
| 32 | #ifdef HAVE_CONFIG_H |
| 33 | 33 | # include <config.h> |
| 34 | 34 | #endif |
| 35 | 35 | |
| r242844 | r242845 | |
| 86 | 86 | /* how to get sysctlbyname()? */ |
| 87 | 87 | #endif |
| 88 | 88 | |
| 89 | #if defined(FLAC__CPU_IA32) && !defined(FLAC__NO_ASM) && defined (FLAC__HAS_NASM) |
| 89 | 90 | /* these are flags in EDX of CPUID AX=00000001 */ |
| 90 | 91 | static const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000; |
| 91 | 92 | static const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000; |
| r242844 | r242845 | |
| 95 | 96 | /* these are flags in ECX of CPUID AX=00000001 */ |
| 96 | 97 | static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001; |
| 97 | 98 | static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200; |
| 99 | #ifdef FLAC__USE_3DNOW |
| 98 | 100 | /* these are flags in EDX of CPUID AX=80000001 */ |
| 99 | 101 | static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW = 0x80000000; |
| 100 | 102 | static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW = 0x40000000; |
| 101 | 103 | static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX = 0x00400000; |
| 104 | #endif |
| 105 | #endif |
| 102 | 106 | |
| 103 | 107 | |
| 104 | 108 | /* |
trunk/3rdparty/libflac/src/libFLAC/format.c
| r242844 | r242845 | |
| 29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | | #if HAVE_CONFIG_H |
| 32 | #ifdef HAVE_CONFIG_H |
| 33 | 33 | # include <config.h> |
| 34 | 34 | #endif |
| 35 | 35 | |
| r242844 | r242845 | |
| 581 | 581 | FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits)); |
| 582 | 582 | |
| 583 | 583 | if(object->capacity_by_order < max_partition_order) { |
| 584 | | if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned)*(1 << max_partition_order)))) |
| 584 | if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned)*((unsigned long long)1 << max_partition_order)))) |
| 585 | 585 | return false; |
| 586 | | if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order)))) |
| 586 | if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned)*((unsigned long long)1 << max_partition_order)))) |
| 587 | 587 | return false; |
| 588 | | memset(object->raw_bits, 0, sizeof(unsigned)*(1 << max_partition_order)); |
| 588 | memset(object->raw_bits, 0, sizeof(unsigned)*((unsigned long long)1 << max_partition_order)); |
| 589 | 589 | object->capacity_by_order = max_partition_order; |
| 590 | 590 | } |
| 591 | 591 | |
trunk/3rdparty/libflac/src/libFLAC/include/private/memory.h
| r242844 | r242845 | |
| 45 | 45 | * Use free() on this address to deallocate. |
| 46 | 46 | */ |
| 47 | 47 | void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); |
| 48 | | FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); |
| 49 | | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); |
| 50 | | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); |
| 51 | | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); |
| 48 | FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); |
| 49 | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); |
| 50 | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); |
| 51 | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); |
| 52 | 52 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 53 | | FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); |
| 53 | FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); |
| 54 | 54 | #endif |
| 55 | 55 | |
| 56 | 56 | #endif |
trunk/3rdparty/libflac/src/libFLAC/lpc.c
| r242844 | r242845 | |
| 29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | | #if HAVE_CONFIG_H |
| 32 | #ifdef HAVE_CONFIG_H |
| 33 | 33 | # include <config.h> |
| 34 | 34 | #endif |
| 35 | 35 | |
| r242844 | r242845 | |
| 60 | 60 | out[i] = in[i] * window[i]; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | #if defined(__GNUC__) && defined(__i386__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) |
| 64 | __attribute__((optimize("O0"))) |
| 65 | #endif |
| 63 | 66 | void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) |
| 64 | 67 | { |
| 65 | 68 | /* a readable, but slower, version */ |
| r242844 | r242845 | |
| 88 | 91 | * this version tends to run faster because of better data locality |
| 89 | 92 | * ('data_len' is usually much larger than 'lag') |
| 90 | 93 | */ |
| 91 | | FLAC__real d; |
| 94 | FLAC__real d, tmp; |
| 92 | 95 | unsigned sample, coeff; |
| 93 | 96 | const unsigned limit = data_len - lag; |
| 94 | 97 | |
| r242844 | r242845 | |
| 99 | 102 | autoc[coeff] = 0.0; |
| 100 | 103 | for(sample = 0; sample <= limit; sample++) { |
| 101 | 104 | d = data[sample]; |
| 102 | | for(coeff = 0; coeff < lag; coeff++) |
| 103 | | autoc[coeff] += d * data[sample+coeff]; |
| 105 | for(coeff = 0; coeff < lag; coeff++) { |
| 106 | tmp = d * data[sample+coeff]; |
| 107 | autoc[coeff] += tmp; |
| 108 | } |
| 104 | 109 | } |
| 105 | 110 | for(; sample < data_len; sample++) { |
| 106 | 111 | d = data[sample]; |
| 107 | | for(coeff = 0; coeff < data_len - sample; coeff++) |
| 108 | | autoc[coeff] += d * data[sample+coeff]; |
| 112 | for(coeff = 0; coeff < data_len - sample; coeff++) { |
| 113 | tmp = d * data[sample+coeff]; |
| 114 | autoc[coeff] += tmp; |
| 115 | } |
| 109 | 116 | } |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | 119 | void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]) |
| 113 | 120 | { |
| 114 | 121 | unsigned i, j; |
| 115 | | FLAC__double r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER]; |
| 122 | FLAC__double r, err, lpc[FLAC__MAX_LPC_ORDER]; |
| 116 | 123 | |
| 117 | 124 | FLAC__ASSERT(0 != max_order); |
| 118 | 125 | FLAC__ASSERT(0 < *max_order); |
| r242844 | r242845 | |
| 126 | 133 | r = -autoc[i+1]; |
| 127 | 134 | for(j = 0; j < i; j++) |
| 128 | 135 | r -= lpc[j] * autoc[i-j]; |
| 129 | | ref[i] = (r/=err); |
| 136 | r/=err; |
| 130 | 137 | |
| 131 | 138 | /* Update LPC coefficients and total error. */ |
| 132 | 139 | lpc[i]=r; |
trunk/3rdparty/libflac/src/libFLAC/memory.c
| r242844 | r242845 | |
| 29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | | #if HAVE_CONFIG_H |
| 32 | #ifdef HAVE_CONFIG_H |
| 33 | 33 | # include <config.h> |
| 34 | 34 | #endif |
| 35 | 35 | |
| r242844 | r242845 | |
| 71 | 71 | return x; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | | FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer) |
| 74 | FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer) |
| 75 | 75 | { |
| 76 | 76 | FLAC__int32 *pu; /* unaligned pointer */ |
| 77 | 77 | union { /* union needed to comply with C99 pointer aliasing rules */ |
| r242844 | r242845 | |
| 84 | 84 | FLAC__ASSERT(0 != aligned_pointer); |
| 85 | 85 | FLAC__ASSERT(unaligned_pointer != aligned_pointer); |
| 86 | 86 | |
| 87 | | if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 87 | if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 88 | 88 | return false; |
| 89 | 89 | |
| 90 | | pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * (size_t)elements, &u.pv); |
| 90 | pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); |
| 91 | 91 | if(0 == pu) { |
| 92 | 92 | return false; |
| 93 | 93 | } |
| r242844 | r242845 | |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer) |
| 103 | |
| 104 | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer) |
| 104 | 105 | { |
| 105 | 106 | FLAC__uint32 *pu; /* unaligned pointer */ |
| 106 | 107 | union { /* union needed to comply with C99 pointer aliasing rules */ |
| r242844 | r242845 | |
| 113 | 114 | FLAC__ASSERT(0 != aligned_pointer); |
| 114 | 115 | FLAC__ASSERT(unaligned_pointer != aligned_pointer); |
| 115 | 116 | |
| 116 | | if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 117 | if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 117 | 118 | return false; |
| 118 | 119 | |
| 119 | 120 | pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); |
| r242844 | r242845 | |
| 129 | 130 | } |
| 130 | 131 | } |
| 131 | 132 | |
| 132 | | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer) |
| 133 | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer) |
| 133 | 134 | { |
| 134 | 135 | FLAC__uint64 *pu; /* unaligned pointer */ |
| 135 | 136 | union { /* union needed to comply with C99 pointer aliasing rules */ |
| r242844 | r242845 | |
| 142 | 143 | FLAC__ASSERT(0 != aligned_pointer); |
| 143 | 144 | FLAC__ASSERT(unaligned_pointer != aligned_pointer); |
| 144 | 145 | |
| 145 | | if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 146 | if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 146 | 147 | return false; |
| 147 | 148 | |
| 148 | 149 | pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); |
| r242844 | r242845 | |
| 158 | 159 | } |
| 159 | 160 | } |
| 160 | 161 | |
| 161 | | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer) |
| 162 | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer) |
| 162 | 163 | { |
| 163 | 164 | unsigned *pu; /* unaligned pointer */ |
| 164 | 165 | union { /* union needed to comply with C99 pointer aliasing rules */ |
| r242844 | r242845 | |
| 171 | 172 | FLAC__ASSERT(0 != aligned_pointer); |
| 172 | 173 | FLAC__ASSERT(unaligned_pointer != aligned_pointer); |
| 173 | 174 | |
| 174 | | if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 175 | if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 175 | 176 | return false; |
| 176 | 177 | |
| 177 | 178 | pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); |
| r242844 | r242845 | |
| 189 | 190 | |
| 190 | 191 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 191 | 192 | |
| 192 | | FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer) |
| 193 | FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer) |
| 193 | 194 | { |
| 194 | 195 | FLAC__real *pu; /* unaligned pointer */ |
| 195 | 196 | union { /* union needed to comply with C99 pointer aliasing rules */ |
| r242844 | r242845 | |
| 202 | 203 | FLAC__ASSERT(0 != aligned_pointer); |
| 203 | 204 | FLAC__ASSERT(unaligned_pointer != aligned_pointer); |
| 204 | 205 | |
| 205 | | if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 206 | if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ |
| 206 | 207 | return false; |
| 207 | 208 | |
| 208 | 209 | pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); |
trunk/3rdparty/libflac/src/libFLAC/stream_decoder.c
| r242844 | r242845 | |
| 29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | | #if HAVE_CONFIG_H |
| 32 | #ifdef HAVE_CONFIG_H |
| 33 | 33 | # include <config.h> |
| 34 | 34 | #endif |
| 35 | 35 | |
| r242844 | r242845 | |
| 46 | 46 | #include <string.h> /* for memset/memcpy() */ |
| 47 | 47 | #include <sys/stat.h> /* for stat() */ |
| 48 | 48 | #include <sys/types.h> /* for off_t */ |
| 49 | | #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ |
| 50 | | #if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */ |
| 49 | #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ /* @@@ [2G limit] */ |
| 50 | #ifndef fseeko |
| 51 | 51 | #define fseeko fseek |
| 52 | #endif |
| 53 | #ifndef ftello |
| 52 | 54 | #define ftello ftell |
| 53 | 55 | #endif |
| 54 | 56 | #endif |
| r242844 | r242845 | |
| 1467 | 1469 | block.is_last = is_last; |
| 1468 | 1470 | block.type = (FLAC__MetadataType)type; |
| 1469 | 1471 | block.length = length; |
| 1472 | memset(&block.data, 0, sizeof(block.data)); |
| 1470 | 1473 | |
| 1471 | 1474 | if(type == FLAC__METADATA_TYPE_APPLICATION) { |
| 1472 | 1475 | if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)) |
trunk/3rdparty/libflac/src/libFLAC/stream_encoder.c
| r242844 | r242845 | |
| 29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | | #if HAVE_CONFIG_H |
| 32 | #ifdef HAVE_CONFIG_H |
| 33 | 33 | # include <config.h> |
| 34 | 34 | #endif |
| 35 | 35 | |
| r242844 | r242845 | |
| 46 | 46 | #include <stdlib.h> /* for malloc() */ |
| 47 | 47 | #include <string.h> /* for memcpy() */ |
| 48 | 48 | #include <sys/types.h> /* for off_t */ |
| 49 | | #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ |
| 50 | | #if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */ |
| 49 | #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ /* @@@ [2G limit] */ |
| 50 | #ifndef fseeko |
| 51 | 51 | #define fseeko fseek |
| 52 | #endif |
| 53 | #ifndef ftello |
| 52 | 54 | #define ftello ftell |
| 53 | 55 | #endif |
| 54 | 56 | #endif |
| r242844 | r242845 | |
| 3750 | 3752 | |
| 3751 | 3753 | /* save best parameters and raw_bits */ |
| 3752 | 3754 | FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(prc, max(6, best_partition_order)); |
| 3753 | | memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(unsigned)*(1<<(best_partition_order))); |
| 3755 | memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(unsigned)*((unsigned long long)1<<(best_partition_order))); |
| 3754 | 3756 | if(do_escape_coding) |
| 3755 | | memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*(1<<(best_partition_order))); |
| 3757 | memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*((unsigned long long)1<<(best_partition_order))); |
| 3756 | 3758 | /* |
| 3757 | 3759 | * Now need to check if the type should be changed to |
| 3758 | 3760 | * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the |