be more precise in long long int literal specification for ANSI compilers (gcc3 requires an LL suffix on literals that do not fit in an int
This commit is contained in:
parent
2af08da5e5
commit
49623ea2d0
@ -92,6 +92,13 @@ static const unsigned FLAC__BITBUFFER_DEFAULT_CAPACITY = ((65536 - 64) * 8) / FL
|
||||
#endif
|
||||
#define max(x,y) ((x)>(y)?(x):(y))
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
#ifndef FLaC__INLINE
|
||||
#define FLaC__INLINE
|
||||
#endif
|
||||
@ -647,22 +654,22 @@ FLAC__bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 va
|
||||
{
|
||||
static const FLAC__uint64 mask[] = {
|
||||
0,
|
||||
0x0000000000000001, 0x0000000000000003, 0x0000000000000007, 0x000000000000000F,
|
||||
0x000000000000001F, 0x000000000000003F, 0x000000000000007F, 0x00000000000000FF,
|
||||
0x00000000000001FF, 0x00000000000003FF, 0x00000000000007FF, 0x0000000000000FFF,
|
||||
0x0000000000001FFF, 0x0000000000003FFF, 0x0000000000007FFF, 0x000000000000FFFF,
|
||||
0x000000000001FFFF, 0x000000000003FFFF, 0x000000000007FFFF, 0x00000000000FFFFF,
|
||||
0x00000000001FFFFF, 0x00000000003FFFFF, 0x00000000007FFFFF, 0x0000000000FFFFFF,
|
||||
0x0000000001FFFFFF, 0x0000000003FFFFFF, 0x0000000007FFFFFF, 0x000000000FFFFFFF,
|
||||
0x000000001FFFFFFF, 0x000000003FFFFFFF, 0x000000007FFFFFFF, 0x00000000FFFFFFFF,
|
||||
0x00000001FFFFFFFF, 0x00000003FFFFFFFF, 0x00000007FFFFFFFF, 0x0000000FFFFFFFFF,
|
||||
0x0000001FFFFFFFFF, 0x0000003FFFFFFFFF, 0x0000007FFFFFFFFF, 0x000000FFFFFFFFFF,
|
||||
0x000001FFFFFFFFFF, 0x000003FFFFFFFFFF, 0x000007FFFFFFFFFF, 0x00000FFFFFFFFFFF,
|
||||
0x00001FFFFFFFFFFF, 0x00003FFFFFFFFFFF, 0x00007FFFFFFFFFFF, 0x0000FFFFFFFFFFFF,
|
||||
0x0001FFFFFFFFFFFF, 0x0003FFFFFFFFFFFF, 0x0007FFFFFFFFFFFF, 0x000FFFFFFFFFFFFF,
|
||||
0x001FFFFFFFFFFFFF, 0x003FFFFFFFFFFFFF, 0x007FFFFFFFFFFFFF, 0x00FFFFFFFFFFFFFF,
|
||||
0x01FFFFFFFFFFFFFF, 0x03FFFFFFFFFFFFFF, 0x07FFFFFFFFFFFFFF, 0x0FFFFFFFFFFFFFFF,
|
||||
0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF
|
||||
FLAC__U64L(0x0000000000000001), FLAC__U64L(0x0000000000000003), FLAC__U64L(0x0000000000000007), FLAC__U64L(0x000000000000000F),
|
||||
FLAC__U64L(0x000000000000001F), FLAC__U64L(0x000000000000003F), FLAC__U64L(0x000000000000007F), FLAC__U64L(0x00000000000000FF),
|
||||
FLAC__U64L(0x00000000000001FF), FLAC__U64L(0x00000000000003FF), FLAC__U64L(0x00000000000007FF), FLAC__U64L(0x0000000000000FFF),
|
||||
FLAC__U64L(0x0000000000001FFF), FLAC__U64L(0x0000000000003FFF), FLAC__U64L(0x0000000000007FFF), FLAC__U64L(0x000000000000FFFF),
|
||||
FLAC__U64L(0x000000000001FFFF), FLAC__U64L(0x000000000003FFFF), FLAC__U64L(0x000000000007FFFF), FLAC__U64L(0x00000000000FFFFF),
|
||||
FLAC__U64L(0x00000000001FFFFF), FLAC__U64L(0x00000000003FFFFF), FLAC__U64L(0x00000000007FFFFF), FLAC__U64L(0x0000000000FFFFFF),
|
||||
FLAC__U64L(0x0000000001FFFFFF), FLAC__U64L(0x0000000003FFFFFF), FLAC__U64L(0x0000000007FFFFFF), FLAC__U64L(0x000000000FFFFFFF),
|
||||
FLAC__U64L(0x000000001FFFFFFF), FLAC__U64L(0x000000003FFFFFFF), FLAC__U64L(0x000000007FFFFFFF), FLAC__U64L(0x00000000FFFFFFFF),
|
||||
FLAC__U64L(0x00000001FFFFFFFF), FLAC__U64L(0x00000003FFFFFFFF), FLAC__U64L(0x00000007FFFFFFFF), FLAC__U64L(0x0000000FFFFFFFFF),
|
||||
FLAC__U64L(0x0000001FFFFFFFFF), FLAC__U64L(0x0000003FFFFFFFFF), FLAC__U64L(0x0000007FFFFFFFFF), FLAC__U64L(0x000000FFFFFFFFFF),
|
||||
FLAC__U64L(0x000001FFFFFFFFFF), FLAC__U64L(0x000003FFFFFFFFFF), FLAC__U64L(0x000007FFFFFFFFFF), FLAC__U64L(0x00000FFFFFFFFFFF),
|
||||
FLAC__U64L(0x00001FFFFFFFFFFF), FLAC__U64L(0x00003FFFFFFFFFFF), FLAC__U64L(0x00007FFFFFFFFFFF), FLAC__U64L(0x0000FFFFFFFFFFFF),
|
||||
FLAC__U64L(0x0001FFFFFFFFFFFF), FLAC__U64L(0x0003FFFFFFFFFFFF), FLAC__U64L(0x0007FFFFFFFFFFFF), FLAC__U64L(0x000FFFFFFFFFFFFF),
|
||||
FLAC__U64L(0x001FFFFFFFFFFFFF), FLAC__U64L(0x003FFFFFFFFFFFFF), FLAC__U64L(0x007FFFFFFFFFFFFF), FLAC__U64L(0x00FFFFFFFFFFFFFF),
|
||||
FLAC__U64L(0x01FFFFFFFFFFFFFF), FLAC__U64L(0x03FFFFFFFFFFFFFF), FLAC__U64L(0x07FFFFFFFFFFFFFF), FLAC__U64L(0x0FFFFFFFFFFFFFFF),
|
||||
FLAC__U64L(0x1FFFFFFFFFFFFFFF), FLAC__U64L(0x3FFFFFFFFFFFFFFF), FLAC__U64L(0x7FFFFFFFFFFFFFFF), FLAC__U64L(0xFFFFFFFFFFFFFFFF)
|
||||
};
|
||||
unsigned n, k;
|
||||
|
||||
@ -691,7 +698,7 @@ FLAC__bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 va
|
||||
k = bits - FLAC__BITS_PER_BLURB;
|
||||
bb->buffer[bb->blurbs++] = (FLAC__blurb)(val >> k);
|
||||
/* we know k < 64 so no need to protect against the gcc bug mentioned above */
|
||||
val &= (~(0xffffffffffffffff << k));
|
||||
val &= (~(FLAC__U64L(0xffffffffffffffff) << k));
|
||||
bits -= FLAC__BITS_PER_BLURB;
|
||||
}
|
||||
}
|
||||
@ -701,7 +708,7 @@ FLAC__bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 va
|
||||
bb->buffer[bb->blurbs] <<= n;
|
||||
bb->buffer[bb->blurbs] |= (val >> k);
|
||||
/* we know n > 0 so k < 64 so no need to protect against the gcc bug mentioned above */
|
||||
val &= (~(0xffffffffffffffff << k));
|
||||
val &= (~(FLAC__U64L(0xffffffffffffffff) << k));
|
||||
bits -= n;
|
||||
bb->bits += n;
|
||||
if(bb->bits == FLAC__BITS_PER_BLURB) {
|
||||
@ -1241,7 +1248,7 @@ FLAC__bool FLAC__bitbuffer_write_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 v
|
||||
FLAC__ASSERT(0 != bb);
|
||||
FLAC__ASSERT(0 != bb->buffer);
|
||||
|
||||
FLAC__ASSERT(!(val & 0xFFFFFFF000000000)); /* this version only handles 36 bits */
|
||||
FLAC__ASSERT(!(val & FLAC__U64L(0xFFFFFFF000000000))); /* this version only handles 36 bits */
|
||||
|
||||
if(val < 0x80) {
|
||||
return FLAC__bitbuffer_write_raw_uint32(bb, (FLAC__uint32)val, 8);
|
||||
@ -2473,7 +2480,7 @@ FLAC__bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *v
|
||||
i = 6;
|
||||
}
|
||||
else {
|
||||
*val = 0xffffffffffffffff;
|
||||
*val = FLAC__U64L(0xffffffffffffffff);
|
||||
return true;
|
||||
}
|
||||
for( ; i; i--) {
|
||||
@ -2482,7 +2489,7 @@ FLAC__bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *v
|
||||
if(raw)
|
||||
raw[(*rawlen)++] = (FLAC__byte)x;
|
||||
if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */
|
||||
*val = 0xffffffffffffffff;
|
||||
*val = FLAC__U64L(0xffffffffffffffff);
|
||||
return true;
|
||||
}
|
||||
v <<= 6;
|
||||
|
@ -44,6 +44,13 @@
|
||||
#endif
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
/* VERSION should come from configure */
|
||||
FLAC_API const char *FLAC__VERSION_STRING = VERSION;
|
||||
|
||||
@ -74,7 +81,7 @@ FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64;
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */
|
||||
|
||||
FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = 0xffffffffffffffff;
|
||||
FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff);
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */
|
||||
|
@ -37,6 +37,13 @@
|
||||
#include "protected/stream_decoder.h"
|
||||
#include "private/md5.h"
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Private class method prototypes
|
||||
@ -853,7 +860,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
|
||||
FLAC__int64 pos = -1, last_pos = -1;
|
||||
int i, lower_seek_point = -1, upper_seek_point = -1;
|
||||
unsigned approx_bytes_per_frame;
|
||||
FLAC__uint64 last_frame_sample = 0xffffffffffffffff;
|
||||
FLAC__uint64 last_frame_sample = FLAC__U64L(0xffffffffffffffff);
|
||||
FLAC__bool needs_seek;
|
||||
const FLAC__uint64 total_samples = decoder->private_->stream_info.total_samples;
|
||||
const unsigned min_blocksize = decoder->private_->stream_info.min_blocksize;
|
||||
|
@ -52,6 +52,13 @@
|
||||
#endif
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Private static data
|
||||
@ -1696,7 +1703,7 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
||||
if(blocksize_hint && is_known_variable_blocksize_stream) {
|
||||
if(!FLAC__bitbuffer_read_utf8_uint64(decoder->private_->input, &xx, read_callback_, decoder, raw_header, &raw_header_len))
|
||||
return false; /* the read_callback_ sets the state for us */
|
||||
if(xx == 0xffffffffffffffff) { /* i.e. non-UTF8 code... */
|
||||
if(xx == FLAC__U64L(0xffffffffffffffff)) { /* i.e. non-UTF8 code... */
|
||||
decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
|
||||
decoder->private_->cached = true;
|
||||
decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER, decoder->private_->client_data);
|
||||
|
@ -48,6 +48,13 @@
|
||||
#endif
|
||||
#define min(x,y) ((x)<(y)?(x):(y))
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
extern void FLAC_XMMS__file_info_box(char *filename);
|
||||
|
||||
typedef struct {
|
||||
@ -549,7 +556,7 @@ void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMeta
|
||||
file_info_struct *file_info = (file_info_struct *)client_data;
|
||||
(void)decoder;
|
||||
if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
|
||||
FLAC__ASSERT(metadata->data.stream_info.total_samples < 0x100000000); /* this plugin can only handle < 4 gigasamples */
|
||||
FLAC__ASSERT(metadata->data.stream_info.total_samples < FLAC__U64L(0x100000000)); /* this plugin can only handle < 4 gigasamples */
|
||||
file_info->total_samples = (unsigned)(metadata->data.stream_info.total_samples&0xffffffff);
|
||||
file_info->bits_per_sample = metadata->data.stream_info.bits_per_sample;
|
||||
file_info->channels = metadata->data.stream_info.channels;
|
||||
|
@ -46,6 +46,13 @@
|
||||
#define FLAC__INLINE
|
||||
#endif
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__I64L(x) x
|
||||
#else
|
||||
#define FLAC__I64L(x) x##LL
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* the following is based on parts of dither.c
|
||||
@ -232,7 +239,7 @@ static FLAC__INLINE FLAC__int64 dither_output_(DitherContext *d, FLAC__bool do_d
|
||||
double doubletmp, Sum2;
|
||||
FLAC__int64 val;
|
||||
|
||||
#define ROUND64(x) ( doubletmp = (x) + d->Add + (FLAC__int64)0x001FFFFD80000000L, *(FLAC__int64*)(&doubletmp) - (FLAC__int64)0x433FFFFD80000000L )
|
||||
#define ROUND64(x) ( doubletmp = (x) + d->Add + (FLAC__int64)FLAC__I64L(0x001FFFFD80000000), *(FLAC__int64*)(&doubletmp) - (FLAC__int64)FLAC__I64L(0x433FFFFD80000000) )
|
||||
|
||||
if(do_dithering) {
|
||||
if(shapingtype == 0) {
|
||||
|
@ -21,6 +21,13 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* for memcmp() */
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WATCHOUT! Since FLAC__BitBuffer is a private structure, we use a copy of
|
||||
* the definition here to get at the internals. Make sure this is kept up
|
||||
@ -174,7 +181,7 @@ FLAC__bool test_bitbuffer()
|
||||
FLAC__bitbuffer_write_zeroes(bb, 4) &&
|
||||
FLAC__bitbuffer_write_raw_uint32(bb, 0x3, 2) &&
|
||||
FLAC__bitbuffer_write_zeroes(bb, 8) &&
|
||||
FLAC__bitbuffer_write_raw_uint64(bb, 0xaaaaaaaadeadbeef, 64) &&
|
||||
FLAC__bitbuffer_write_raw_uint64(bb, FLAC__U64L(0xaaaaaaaadeadbeef), 64) &&
|
||||
FLAC__bitbuffer_write_raw_uint32(bb, 0xace, 12)
|
||||
;
|
||||
if(!ok) {
|
||||
@ -674,7 +681,7 @@ FLAC__bool test_bitbuffer()
|
||||
|
||||
printf("testing utf8_uint64(0x0000000FFFFFFFFF)... ");
|
||||
FLAC__bitbuffer_clear(bb);
|
||||
FLAC__bitbuffer_write_utf8_uint64(bb, 0x0000000FFFFFFFFF);
|
||||
FLAC__bitbuffer_write_utf8_uint64(bb, FLAC__U64L(0x0000000FFFFFFFFF));
|
||||
ok = bb->total_bits == 56 && bb->buffer[0] == 0xFE && bb->buffer[1] == 0xBF && bb->buffer[2] == 0xBF && bb->buffer[3] == 0xBF && bb->buffer[4] == 0xBF && bb->buffer[5] == 0xBF && bb->buffer[6] == 0xBF;
|
||||
printf("%s\n", ok?"OK":"FAILED");
|
||||
if(!ok) {
|
||||
|
Loading…
Reference in New Issue
Block a user