Commit f86b1a33 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

Wave64 patch from Janne Hyvrinen <cse@sci.fi>.

GUID had one word incorrectly in little endian order.
parent ca7a3cb8
......@@ -615,12 +615,12 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin
break;
case FORMAT_WAVE64:
/* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */
if(flac__utils_fwrite("\x72\x69\x66\x66\x2E\x91\xCF\x11\xD6\xA5\x28\xDB\x04\xC1\x00\x00", 1, 16, f) != 16)
if(flac__utils_fwrite("\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 1, 16, f) != 16)
return false;
if(!write_little_endian_uint64(f, iff_size))
return false;
/* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
if(flac__utils_fwrite("\x77\x61\x76\x65\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
if(flac__utils_fwrite("\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
return false;
break;
case FORMAT_RF64:
......@@ -676,7 +676,7 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin
}
else { /* Wave64 */
/* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
if(flac__utils_fwrite("\x66\x6D\x74\x20\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
if(flac__utils_fwrite("\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
return false;
/* chunk size (+16+8 for GUID and size fields) */
if(!write_little_endian_uint64(f, 16+8+(is_waveformatextensible?40:16)))
......@@ -706,7 +706,7 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin
}
else { /* Wave64 */
/* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
if(flac__utils_fwrite("\x64\x61\x74\x61\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
if(flac__utils_fwrite("\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
return false;
/* +16+8 for GUID and size fields */
if(!write_little_endian_uint64(f, 16+8 + data_size))
......
......@@ -186,7 +186,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio
if(e->format == FORMAT_WAVE64) {
/*
* lookahead[] already has "riff\x2E\x91\xCF\x11\xD6\xA5\x28\xDB", skip over remaining header
* lookahead[] already has "riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB", skip over remaining header
*/
if(!fskip_ahead(e->fin, 16+8+16-12)) { /* riff GUID + riff size + WAVE GUID - lookahead */
flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over remaining \"riff\" header\n", e->inbasefilename);
......@@ -252,7 +252,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio
}
else if(
!memcmp(chunk_id, "fmt ", 4) &&
(e->format!=FORMAT_WAVE64 || !memcmp(chunk_id, "fmt \xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 16))
(e->format!=FORMAT_WAVE64 || !memcmp(chunk_id, "fmt \xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16))
) { /* format chunk */
FLAC__uint16 x;
FLAC__uint32 xx, data_bytes;
......@@ -528,7 +528,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio
}
else if(
!memcmp(chunk_id, "data", 4) &&
(e->format!=FORMAT_WAVE64 || !memcmp(chunk_id, "data\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 16))
(e->format!=FORMAT_WAVE64 || !memcmp(chunk_id, "data\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16))
) { /* data chunk */
FLAC__uint32 xx;
FLAC__uint64 data_bytes;
......
......@@ -333,9 +333,9 @@ static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char
if(
fread(buffer, 1, 40, f) < 40 ||
/* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */
memcmp(buffer, "\x72\x69\x66\x66\x2E\x91\xCF\x11\xD6\xA5\x28\xDB\x04\xC1\x00\x00", 16) ||
memcmp(buffer, "\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 16) ||
/* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
memcmp(buffer+24, "\x77\x61\x76\x65\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 16)
memcmp(buffer+24, "\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)
) {
if(error) *error = "unsupported Wave64 layout (002)";
return false;
......@@ -364,7 +364,7 @@ static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char
if(size & 7)
size = (size+7) & (~((FLAC__uint64)7));
/* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
if(!memcmp(buffer, "\x66\x6D\x74\x20\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 16)) {
if(!memcmp(buffer, "\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) {
if(fm->format_block) {
if(error) *error = "invalid Wave64 file: multiple \"fmt \" chunks (005)";
return false;
......@@ -376,7 +376,7 @@ static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char
fm->format_block = fm->num_blocks;
}
/* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
else if(!memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 16)) {
else if(!memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) {
if(fm->audio_block) {
if(error) *error = "invalid Wave64 file: multiple \"data\" chunks (007)";
return false;
......@@ -387,7 +387,7 @@ static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char
}
fm->audio_block = fm->num_blocks;
}
if(!append_block_(fm, offset, memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 16)? (FLAC__uint32)size : 16+8, error))
if(!append_block_(fm, offset, memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)? (FLAC__uint32)size : 16+8, error))
return false;
/* skip to next chunk */
if(fseeko(f, size-24, SEEK_CUR) < 0) {
......
......@@ -1729,7 +1729,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
input_format = FORMAT_WAVE;
else if(!memcmp(lookahead, "RF64", 4) && !memcmp(lookahead+8, "WAVE", 4))
input_format = FORMAT_RF64;
else if(!memcmp(lookahead, "riff\x2E\x91\xCF\x11\xD6\xA5\x28\xDB", 12)) /* just check 1st 12 bytes of GUID */
else if(!memcmp(lookahead, "riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB", 12)) /* just check 1st 12 bytes of GUID */
input_format = FORMAT_WAVE64;
else if(!memcmp(lookahead, "FORM", 4) && !memcmp(lookahead+8, "AIFF", 4))
input_format = FORMAT_AIFF;
......
......@@ -730,7 +730,7 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig
break;
case 2:
/* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */
if(fwrite("\x72\x69\x66\x66\x2E\x91\xCF\x11\xD6\xA5\x28\xDB\x04\xC1\x00\x00", 1, 16, f) < 16)
if(fwrite("\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 1, 16, f) < 16)
goto foo;
/* +(16+8) for RIFF GUID + size */
/* +16 for WAVE GUID */
......@@ -739,7 +739,7 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig
if(!write_little_endian_uint64(f, (16+8) + 16 + 16+8+(waveformatextensible?40:16) + (16+8) + padded_size))
goto foo;
/* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
if(fwrite("\x77\x61\x76\x65\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) < 16)
if(fwrite("\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) < 16)
goto foo;
break;
default:
......@@ -769,7 +769,7 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig
}
else { /* wave64 */
/* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
if(fwrite("\x66\x6D\x74\x20\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) < 16)
if(fwrite("\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) < 16)
goto foo;
/* chunk size (+16+8 for GUID and size fields) */
if(!write_little_endian_uint64(f, 16+8+(waveformatextensible?40:16)))
......@@ -807,7 +807,7 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig
}
else { /* wave64 */
/* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
if(fwrite("\x64\x61\x74\x61\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
if(fwrite("\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16)
goto foo;
/* +16+8 for GUID and size fields */
if(!write_little_endian_uint64(f, 16+8 + true_size))
......@@ -923,26 +923,26 @@ static FLAC__bool generate_wackywav64s(void)
FILE *f;
FLAC__byte wav[] = {
0x72,0x69,0x66,0x66,0x2E,0x91,0xCF,0x11, /* RIFF GUID */
0xD6,0xA5,0x28,0xDB,0x04,0xC1,0x00,0x00,
0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00,
152, 0, 0, 0, 0, 0, 0, 0,
0x77,0x61,0x76,0x65,0xF3,0xAC,0xD3,0x11, /* WAVE GUID */
0xD1,0x8C,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
0x6A,0x75,0x6E,0x6B,0xF3,0xAC,0xD3,0x11, /* junk GUID */
0xD1,0x8C,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
32, 0, 0, 0 , 0, 0, 0, 0,
'b', 'l', 'a', 'h', 'b', 'l', 'a', 'h',
0x66,0x6D,0x74,0x20,0xF3,0xAC,0xD3,0x11, /* fmt GUID */
0xD1,0x8C,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
40, 0, 0, 0 , 0, 0, 0, 0,
1, 0, 1, 0,0x44,0xAC, 0, 0,
0x88,0x58,0x01, 0, 2, 0, 16, 0,
0x64,0x61,0x74,0x61,0xF3,0xAC,0xD3,0x11, /* data GUID */
0xD1,0x8C,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
40, 0, 0, 0 , 0, 0, 0, 0,
0, 0, 1, 0, 4, 0, 9, 0,
16, 0, 25, 0, 36, 0, 49, 0,
0x6A,0x75,0x6E,0x6B,0xF3,0xAC,0xD3,0x11, /* junk GUID */
0xD1,0x8C,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A,
32, 0, 0, 0 , 0, 0, 0, 0,
'b', 'l', 'a', 'h', 'b', 'l', 'a', 'h'
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment