add "is_cd" flag to CUESHEET everywhere

This commit is contained in:
Josh Coalson 2002-12-05 06:37:46 +00:00
parent b96199d2ac
commit 8f0c71b877
21 changed files with 106 additions and 32 deletions

View File

@ -719,7 +719,15 @@
</TR>
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
&lt;259*8&gt;
&lt;1&gt;
</TD>
<TD>
<TT>1</TT> if the CUESHEET corresponds to a Compact Disc, else <TT>0</TT>.
</TD>
</TR>
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
&lt;7+258*8&gt;
</TD>
<TD>
Reserved. All bits must be set to zero.

View File

@ -663,12 +663,14 @@ namespace FLAC {
const char *get_media_catalog_number() const;
FLAC__uint64 get_lead_in() const;
bool get_is_cd() const;
unsigned get_num_tracks() const;
Track get_track(unsigned i) const;
void set_media_catalog_number(const char value[128]);
void set_lead_in(FLAC__uint64 value);
void set_is_cd(bool value);
void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);

View File

@ -658,13 +658,15 @@ extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_
typedef struct {
char media_catalog_number[129]; /*@@@@ in the stream, the media_catalog_number will be 128 alphanumeric ascii characters; unused digits are padded out to the right with NUL characters. in memory, the 129th character will be guaranteed to be a null character so that the whole string is always a valid C string. CD-DA: 13 ascii digits ('0'-'9') plus 116 trailing '\0' characters */
FLAC__uint64 lead_in; /*@@@@ length of lead-in in samples; required to compute some versions of CD TOC hashes; CD-DA says the lead-in must be digital silence and rippers don't save it by convention, so TRACK 00 is disallowed and instead we store only the length. The lead-in is the number of samples up to the first index point of the first track, \b not INDEX 01 of the first track. This is so applications can correctly compute a CD-DA TOC equivalent even when there is TRACK 01 INDEX 00 data. */
FLAC__bool is_cd; /* \c true if CUESHEET corresponds to a Compact Disc, else \c false */
unsigned num_tracks;
FLAC__StreamMetadata_CueSheet_Track *tracks;
} FLAC__StreamMetadata_CueSheet;
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == @@@@259*8 (bits) */
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == @@@@7+258*8 (bits) */
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */

View File

@ -33,7 +33,7 @@ void grabbag__cuesheet_frame_to_msf(unsigned frame, unsigned *minutes, unsigned
FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference, FLAC__bool is_cdda);
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference);
#ifdef __cplusplus
}

View File

@ -830,6 +830,12 @@ namespace FLAC {
return object_->data.cue_sheet.lead_in;
}
bool CueSheet::get_is_cd() const
{
FLAC__ASSERT(is_valid());
return object_->data.cue_sheet.is_cd? true : false;
}
unsigned CueSheet::get_num_tracks() const
{
FLAC__ASSERT(is_valid());
@ -857,6 +863,12 @@ namespace FLAC {
object_->data.cue_sheet.lead_in = value;
}
void CueSheet::set_is_cd(bool value)
{
FLAC__ASSERT(is_valid());
object_->data.cue_sheet.is_cd = value;
}
void CueSheet::set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index)
{
FLAC__ASSERT(is_valid());

View File

@ -81,7 +81,8 @@ FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 259*8; /* bits @@@@259 */
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits @@@@258 */
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */

View File

@ -1610,7 +1610,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_(FILE *fil
FLAC__byte buffer[1024]; /* MSVC needs a constant expression so we put a magic number and assert */
FLAC__ASSERT(0 != file);
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN/8 <= sizeof(buffer));
FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN)/8 <= sizeof(buffer));
FLAC__ASSERT(sizeof(FLAC__uint64) <= sizeof(buffer));
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0);
@ -1624,10 +1624,11 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_(FILE *fil
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
block->lead_in = unpack_uint64_(buffer, len);
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN % 8 == 0);
len = FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN / 8;
FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) % 8 == 0);
len = (FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) / 8;
if(fread(buffer, 1, len, file) != len)
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
block->is_cd = buffer[0]&0x80? true : false;
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN % 8 == 0);
len = FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN / 8;
@ -1825,7 +1826,7 @@ FLAC__Metadata_SimpleIteratorStatus write_metadata_block_data_cuesheet_(FILE *fi
FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64));
FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN/8);
FLAC__ASSERT(sizeof(buffer) >= (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)/8);
FLAC__ASSERT(sizeof(buffer) >= (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)/8);
FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN/8);
FLAC__ASSERT(0 != file);
@ -1841,9 +1842,11 @@ FLAC__Metadata_SimpleIteratorStatus write_metadata_block_data_cuesheet_(FILE *fi
if(fwrite(buffer, 1, len, file) != len)
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN % 8 == 0);
len = FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN / 8;
FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) % 8 == 0);
len = (FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) / 8;
memset(buffer, 0, len);
if(block->is_cd)
buffer[0] |= 0x80;
if(fwrite(buffer, 1, len, file) != len)
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;

View File

@ -207,6 +207,7 @@ static void cuesheet_calculate_length_(FLAC__StreamMetadata *object)
object->length = (
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8;
@ -586,6 +587,9 @@ static FLAC__bool compare_block_data_cuesheet_(const FLAC__StreamMetadata_CueShe
if(block1->lead_in != block2->lead_in)
return false;
if(block1->is_cd != block2->is_cd)
return false;
if(block1->num_tracks != block2->num_tracks)
return false;

View File

@ -1132,6 +1132,10 @@ FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMet
if(!FLAC__bitbuffer_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
obj->is_cd = x? true : false;
if(!FLAC__bitbuffer_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */

View File

@ -680,7 +680,7 @@ FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_init(FLAC__StreamEncoder
metadata_has_vorbis_comment = true;
}
else if(encoder->protected_->metadata[i]->type == FLAC__METADATA_TYPE_CUESHEET) {
if(!FLAC__format_cuesheet_is_legal(&encoder->protected_->metadata[i]->data.cue_sheet, /*check_cd_da_subset=*/false, /*violation=*/0))
if(!FLAC__format_cuesheet_is_legal(&encoder->protected_->metadata[i]->data.cue_sheet, encoder->protected_->metadata[i]->data.cue_sheet.is_cd, /*violation=*/0))
return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_METADATA;
}
}

View File

@ -125,6 +125,8 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
return false;
if(!FLAC__bitbuffer_write_raw_uint64(bb, metadata->data.cue_sheet.lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN))
return false;
if(!FLAC__bitbuffer_write_raw_uint32(bb, metadata->data.cue_sheet.is_cd? 1 : 0, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN))
return false;
if(!FLAC__bitbuffer_write_zeroes(bb, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN))
return false;
if(!FLAC__bitbuffer_write_raw_uint32(bb, metadata->data.cue_sheet.num_tracks, FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN))
@ -163,6 +165,7 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
FLAC__ASSERT(0);
}
FLAC__ASSERT(FLAC__bitbuffer_is_byte_aligned(bb));
return true;
}

View File

@ -590,6 +590,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
case FLAC__METADATA_TYPE_CUESHEET:
PPR; printf(" media catalog number: %s\n", block->data.cue_sheet.media_catalog_number);
PPR; printf(" lead-in: %llu\n", block->data.cue_sheet.lead_in);
PPR; printf(" is CD: %s\n", block->data.cue_sheet.is_cd? "true":"false");
PPR; printf(" number of tracks: %u\n", block->data.cue_sheet.num_tracks);
for(i = 0; i < block->data.cue_sheet.num_tracks; i++) {
const FLAC__StreamMetadata_CueSheet_Track *track = block->data.cue_sheet.tracks+i;
@ -606,7 +607,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
if(!is_leadout) {
PPR; printf(" ISRC: %s\n", track->isrc);
PPR; printf(" type: %s\n", track->type == 1? "DATA" : "AUDIO");
PPR; printf(" pre-emphasis: %s\n", track->pre_emphasis? "true" : "false");
PPR; printf(" pre-emphasis: %s\n", track->pre_emphasis? "true":"false");
PPR; printf(" number of index points: %u\n", track->num_indices);
for(j = 0; j < track->num_indices; j++) {
const FLAC__StreamMetadata_CueSheet_Index *index = track->indices+j;

View File

@ -23,7 +23,7 @@
#include <string.h>
static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, Argument_AddSeekpoint *add_seekpoint_link);
static FLAC__bool export_cs_to(const char *filename, FLAC__StreamMetadata *cuesheet, const char *cs_filename);
static FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename);
FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
{
@ -149,7 +149,7 @@ FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet,
return true;
}
FLAC__bool export_cs_to(const char *filename, FLAC__StreamMetadata *cuesheet, const char *cs_filename)
FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename)
{
FILE *f;
@ -167,7 +167,7 @@ FLAC__bool export_cs_to(const char *filename, FLAC__StreamMetadata *cuesheet, co
return false;
}
grabbag__cuesheet_emit(f, cuesheet, "\"dummy.wav\" WAVE", /*@@@@is_cdda=*/true);
grabbag__cuesheet_emit(f, cuesheet, "\"dummy.wav\" WAVE");
if(f != stdout)
fclose(f);

View File

@ -187,6 +187,7 @@ static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message,
FLAC__StreamMetadata_CueSheet *cs = &cuesheet->data.cue_sheet;
cs->lead_in = is_cdda? 2 * 44100 /* The default lead-in size for CD-DA */ : 0;
cs->is_cd = is_cdda;
while(0 != fgets(buffer, sizeof(buffer), file)) {
(*last_line_read)++;
@ -509,7 +510,7 @@ FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_mes
return cuesheet;
}
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference, FLAC__bool is_cdda)
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference)
{
const FLAC__StreamMetadata_CueSheet *cs;
unsigned track_num, index_num;
@ -538,7 +539,7 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co
const FLAC__StreamMetadata_CueSheet_Index *index = track->indices + index_num;
fprintf(file, " INDEX %02u ", (unsigned)index->number);
if(is_cdda) {
if(cs->is_cd) {
const unsigned logical_frame = (track->offset + index->offset) / (44100 / 75);
unsigned m, s, f;
grabbag__cuesheet_frame_to_msf(logical_frame, &m, &s, &f);

View File

@ -62,7 +62,7 @@ static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64
fprintf(stderr, "can't open file %s for writing\n", tmpfilename);
return 255;
}
grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE", is_cdda);
grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE");
fclose(fout);
/*
@ -91,7 +91,7 @@ static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64
fprintf(stderr, "can't open file %s for writing\n", tmpfilename);
return 255;
}
grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE", is_cdda);
grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE");
fclose(fout);
return 0;
@ -125,4 +125,3 @@ int main(int argc, char *argv[])
return do_cuesheet(argv[1], is_cdda, lead_out_offset);
}
FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);

View File

@ -138,6 +138,7 @@ static void init_metadata_blocks_()
(
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8 +
@ -162,6 +163,7 @@ static void init_metadata_blocks_()
cuesheet_.data.cue_sheet.media_catalog_number[0] = 'j';
cuesheet_.data.cue_sheet.media_catalog_number[1] = 'C';
cuesheet_.data.cue_sheet.lead_in = 159;
cuesheet_.data.cue_sheet.is_cd = true;
cuesheet_.data.cue_sheet.num_tracks = 2;
cuesheet_.data.cue_sheet.tracks = (FLAC__StreamMetadata_CueSheet_Track*)malloc_or_die_(cuesheet_.data.cue_sheet.num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track));
cuesheet_.data.cue_sheet.tracks[0].offset = 1;
@ -1166,6 +1168,7 @@ bool test_metadata_object_cuesheet()
expected_length = (
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8;
@ -1254,6 +1257,11 @@ bool test_metadata_object_cuesheet()
return die_("value mismatch, expected 0");
printf("OK\n");
printf("testing CueSheet::get_is_cd()... ");
if(block.get_is_cd())
return die_("value mismatch, expected false");
printf("OK\n");
printf("testing CueSheet::get_num_tracks()... ");
if(block.get_num_tracks() != 0)
return die_("value mismatch, expected 0");
@ -1276,6 +1284,12 @@ bool test_metadata_object_cuesheet()
return die_("value mismatch");
printf("OK\n");
printf("testing CueSheet::set_is_cd()... ");
block.set_is_cd(true);
if(!block.get_is_cd())
return die_("value mismatch");
printf("OK\n");
printf("testing CueSheet::insert_track()... +\n");
printf(" CueSheet::get_track()... ");
if(!block.insert_track(0, track0))

View File

@ -192,11 +192,12 @@ static void init_metadata_blocks_()
(
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8 +
/* 2 tracks */
2 * (
3 * (
FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN +
FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN +
@ -215,10 +216,11 @@ static void init_metadata_blocks_()
memset(cuesheet_.data.cue_sheet.media_catalog_number, 0, sizeof(cuesheet_.data.cue_sheet.media_catalog_number));
cuesheet_.data.cue_sheet.media_catalog_number[0] = 'j';
cuesheet_.data.cue_sheet.media_catalog_number[1] = 'C';
cuesheet_.data.cue_sheet.lead_in = 159;
cuesheet_.data.cue_sheet.num_tracks = 2;
cuesheet_.data.cue_sheet.lead_in = 2 * 44100;
cuesheet_.data.cue_sheet.is_cd = true;
cuesheet_.data.cue_sheet.num_tracks = 3;
cuesheet_.data.cue_sheet.tracks = malloc_or_die_(cuesheet_.data.cue_sheet.num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track));
cuesheet_.data.cue_sheet.tracks[0].offset = 1;
cuesheet_.data.cue_sheet.tracks[0].offset = 0;
cuesheet_.data.cue_sheet.tracks[0].number = 1;
memcpy(cuesheet_.data.cue_sheet.tracks[0].isrc, "ACBDE1234567", sizeof(cuesheet_.data.cue_sheet.tracks[0].isrc));
cuesheet_.data.cue_sheet.tracks[0].type = 0;
@ -227,9 +229,9 @@ static void init_metadata_blocks_()
cuesheet_.data.cue_sheet.tracks[0].indices = malloc_or_die_(cuesheet_.data.cue_sheet.tracks[0].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index));
cuesheet_.data.cue_sheet.tracks[0].indices[0].offset = 0;
cuesheet_.data.cue_sheet.tracks[0].indices[0].number = 0;
cuesheet_.data.cue_sheet.tracks[0].indices[1].offset = 1234567890;
cuesheet_.data.cue_sheet.tracks[0].indices[1].offset = 123 * 588;
cuesheet_.data.cue_sheet.tracks[0].indices[1].number = 1;
cuesheet_.data.cue_sheet.tracks[1].offset = 12345678901;
cuesheet_.data.cue_sheet.tracks[1].offset = 1234 * 588;
cuesheet_.data.cue_sheet.tracks[1].number = 2;
memcpy(cuesheet_.data.cue_sheet.tracks[1].isrc, "ACBDE7654321", sizeof(cuesheet_.data.cue_sheet.tracks[1].isrc));
cuesheet_.data.cue_sheet.tracks[1].type = 1;
@ -238,6 +240,9 @@ static void init_metadata_blocks_()
cuesheet_.data.cue_sheet.tracks[1].indices = malloc_or_die_(cuesheet_.data.cue_sheet.tracks[1].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index));
cuesheet_.data.cue_sheet.tracks[1].indices[0].offset = 0;
cuesheet_.data.cue_sheet.tracks[1].indices[0].number = 1;
cuesheet_.data.cue_sheet.tracks[2].offset = 12345 * 588;
cuesheet_.data.cue_sheet.tracks[2].number = 170;
cuesheet_.data.cue_sheet.tracks[2].num_indices = 0;
}
static void free_metadata_blocks_()

View File

@ -182,11 +182,12 @@ static void init_metadata_blocks_()
(
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8 +
/* 2 tracks */
2 * (
3 * (
FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN +
FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN +
@ -205,10 +206,11 @@ static void init_metadata_blocks_()
memset(cuesheet_.data.cue_sheet.media_catalog_number, 0, sizeof(cuesheet_.data.cue_sheet.media_catalog_number));
cuesheet_.data.cue_sheet.media_catalog_number[0] = 'j';
cuesheet_.data.cue_sheet.media_catalog_number[1] = 'C';
cuesheet_.data.cue_sheet.lead_in = 159;
cuesheet_.data.cue_sheet.num_tracks = 2;
cuesheet_.data.cue_sheet.lead_in = 2 * 44100;
cuesheet_.data.cue_sheet.is_cd = true;
cuesheet_.data.cue_sheet.num_tracks = 3;
cuesheet_.data.cue_sheet.tracks = malloc_or_die_(cuesheet_.data.cue_sheet.num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track));
cuesheet_.data.cue_sheet.tracks[0].offset = 1;
cuesheet_.data.cue_sheet.tracks[0].offset = 0;
cuesheet_.data.cue_sheet.tracks[0].number = 1;
memcpy(cuesheet_.data.cue_sheet.tracks[0].isrc, "ACBDE1234567", sizeof(cuesheet_.data.cue_sheet.tracks[0].isrc));
cuesheet_.data.cue_sheet.tracks[0].type = 0;
@ -217,9 +219,9 @@ static void init_metadata_blocks_()
cuesheet_.data.cue_sheet.tracks[0].indices = malloc_or_die_(cuesheet_.data.cue_sheet.tracks[0].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index));
cuesheet_.data.cue_sheet.tracks[0].indices[0].offset = 0;
cuesheet_.data.cue_sheet.tracks[0].indices[0].number = 0;
cuesheet_.data.cue_sheet.tracks[0].indices[1].offset = 1234567890;
cuesheet_.data.cue_sheet.tracks[0].indices[1].offset = 123 * 588;
cuesheet_.data.cue_sheet.tracks[0].indices[1].number = 1;
cuesheet_.data.cue_sheet.tracks[1].offset = 12345678901;
cuesheet_.data.cue_sheet.tracks[1].offset = 1234 * 588;
cuesheet_.data.cue_sheet.tracks[1].number = 2;
memcpy(cuesheet_.data.cue_sheet.tracks[1].isrc, "ACBDE7654321", sizeof(cuesheet_.data.cue_sheet.tracks[1].isrc));
cuesheet_.data.cue_sheet.tracks[1].type = 1;
@ -228,6 +230,9 @@ static void init_metadata_blocks_()
cuesheet_.data.cue_sheet.tracks[1].indices = malloc_or_die_(cuesheet_.data.cue_sheet.tracks[1].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index));
cuesheet_.data.cue_sheet.tracks[1].indices[0].offset = 0;
cuesheet_.data.cue_sheet.tracks[1].indices[0].number = 1;
cuesheet_.data.cue_sheet.tracks[2].offset = 12345 * 588;
cuesheet_.data.cue_sheet.tracks[2].number = 170;
cuesheet_.data.cue_sheet.tracks[2].num_indices = 0;
}
static void free_metadata_blocks_()

View File

@ -263,6 +263,7 @@ static void cs_calc_len_(FLAC__StreamMetadata *block)
block->length = (
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8;
@ -1148,6 +1149,7 @@ FLAC__bool test_metadata_object()
expected_length = (
FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
) / 8;

View File

@ -227,6 +227,10 @@ FLAC__bool compare_block_data_cuesheet_(const FLAC__StreamMetadata_CueSheet *blo
printf("FAILED, lead_in mismatch, expected %llu, got %llu\n", block->lead_in, blockcopy->lead_in);
return false;
}
if(blockcopy->is_cd != block->is_cd) {
printf("FAILED, is_cd mismatch, expected %u, got %u\n", (unsigned)block->is_cd, (unsigned)blockcopy->is_cd);
return false;
}
if(blockcopy->num_tracks != block->num_tracks) {
printf("FAILED, num_tracks mismatch, expected %u, got %u\n", block->num_tracks, blockcopy->num_tracks);
return false;

View File

@ -227,6 +227,10 @@ FLAC__bool compare_block_data_cuesheet_(const FLAC__StreamMetadata_CueSheet *blo
printf("FAILED, lead_in mismatch, expected %llu, got %llu\n", block->lead_in, blockcopy->lead_in);
return false;
}
if(blockcopy->is_cd != block->is_cd) {
printf("FAILED, is_cd mismatch, expected %u, got %u\n", (unsigned)block->is_cd, (unsigned)blockcopy->is_cd);
return false;
}
if(blockcopy->num_tracks != block->num_tracks) {
printf("FAILED, num_tracks mismatch, expected %u, got %u\n", block->num_tracks, blockcopy->num_tracks);
return false;