void mutils__init_metadata_blocks( FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata *padding, FLAC__StreamMetadata *seektable, FLAC__StreamMetadata *application1, FLAC__StreamMetadata *application2, FLAC__StreamMetadata *vorbiscomment, FLAC__StreamMetadata *cuesheet, FLAC__StreamMetadata *picture, FLAC__StreamMetadata *unknown ) { /* most of the actual numbers and data in the blocks don't matter, we just want to make sure the decoder parses them correctly remember, the metadata interface gets tested after the decoders, so we do all the metadata manipulation here without it. */ /* min/max_framesize and md5sum don't get written at first, so we have to leave them 0 */ streaminfo->is_last = false; streaminfo->type = FLAC__METADATA_TYPE_STREAMINFO; streaminfo->length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; streaminfo->data.stream_info.min_blocksize = 576; streaminfo->data.stream_info.max_blocksize = 576; streaminfo->data.stream_info.min_framesize = 0; streaminfo->data.stream_info.max_framesize = 0; streaminfo->data.stream_info.sample_rate = 44100; streaminfo->data.stream_info.channels = 1; streaminfo->data.stream_info.bits_per_sample = 8; streaminfo->data.stream_info.total_samples = 0; memset(streaminfo->data.stream_info.md5sum, 0, 16); padding->is_last = false; padding->type = FLAC__METADATA_TYPE_PADDING; padding->length = 1234; seektable->is_last = false; seektable->type = FLAC__METADATA_TYPE_SEEKTABLE; seektable->data.seek_table.num_points = 2; seektable->length = seektable->data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; seektable->data.seek_table.points = malloc_or_die_(seektable->data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint)); seektable->data.seek_table.points[0].sample_number = 0; seektable->data.seek_table.points[0].stream_offset = 0; seektable->data.seek_table.points[0].frame_samples = streaminfo->data.stream_info.min_blocksize; seektable->data.seek_table.points[1].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; seektable->data.seek_table.points[1].stream_offset = 1000; seektable->data.seek_table.points[1].frame_samples = streaminfo->data.stream_info.min_blocksize; application1->is_last = false; application1->type = FLAC__METADATA_TYPE_APPLICATION; application1->length = 8; memcpy(application1->data.application.id, "\xfe\xdc\xba\x98", 4); application1->data.application.data = malloc_or_die_(4); memcpy(application1->data.application.data, "\xf0\xe1\xd2\xc3", 4); application2->is_last = false; application2->type = FLAC__METADATA_TYPE_APPLICATION; application2->length = 4; memcpy(application2->data.application.id, "\x76\x54\x32\x10", 4); application2->data.application.data = 0; { const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING); vorbiscomment->is_last = false; vorbiscomment->type = FLAC__METADATA_TYPE_VORBIS_COMMENT; vorbiscomment->length = (4 + vendor_string_length) + 4 + (4 + 5) + (4 + 0); vorbiscomment->data.vorbis_comment.vendor_string.length = vendor_string_length; vorbiscomment->data.vorbis_comment.vendor_string.entry = malloc_or_die_(vendor_string_length+1); memcpy(vorbiscomment->data.vorbis_comment.vendor_string.entry, FLAC__VENDOR_STRING, vendor_string_length+1); vorbiscomment->data.vorbis_comment.num_comments = 2; vorbiscomment->data.vorbis_comment.comments = malloc_or_die_(vorbiscomment->data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry)); vorbiscomment->data.vorbis_comment.comments[0].length = 5; vorbiscomment->data.vorbis_comment.comments[0].entry = malloc_or_die_(5+1); memcpy(vorbiscomment->data.vorbis_comment.comments[0].entry, "ab=cd", 5+1); vorbiscomment->data.vorbis_comment.comments[1].length = 0; vorbiscomment->data.vorbis_comment.comments[1].entry = 0; } cuesheet->is_last = false; cuesheet->type = FLAC__METADATA_TYPE_CUESHEET; cuesheet->length = /* cuesheet guts */ ( 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 */ 3 * ( FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN ) / 8 + /* 3 index points */ 3 * ( FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN + FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN + FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN ) / 8 ; 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 = 2 * 44100; cuesheet->data.cue_sheet.is_cd = true; cuesheet->data.cue_sheet.num_tracks = 3; cuesheet->data.cue_sheet.tracks = calloc_or_die_(cuesheet->data.cue_sheet.num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)); 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; cuesheet->data.cue_sheet.tracks[0].pre_emphasis = 1; cuesheet->data.cue_sheet.tracks[0].num_indices = 2; 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 = 123 * 588; cuesheet->data.cue_sheet.tracks[0].indices[1].number = 1; 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; cuesheet->data.cue_sheet.tracks[1].pre_emphasis = 0; cuesheet->data.cue_sheet.tracks[1].num_indices = 1; 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; picture->is_last = false; picture->type = FLAC__METADATA_TYPE_PICTURE; picture->length = ( FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* will add the length for the string later */ FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* will add the length for the string later */ FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN /* will add the length for the data later */ ) / 8 ; picture->data.picture.type = FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; picture->data.picture.mime_type = strdup_or_die_("image/jpeg"); picture->length += strlen(picture->data.picture.mime_type); picture->data.picture.description = (FLAC__byte*)strdup_or_die_("desc"); picture->length += strlen((const char *)picture->data.picture.description); picture->data.picture.width = 300; picture->data.picture.height = 300; picture->data.picture.depth = 24; picture->data.picture.colors = 0; picture->data.picture.data = (FLAC__byte*)strdup_or_die_("SOMEJPEGDATA"); picture->data.picture.data_length = strlen((const char *)picture->data.picture.data); picture->length += picture->data.picture.data_length; unknown->is_last = true; unknown->type = 126; unknown->length = 8; unknown->data.unknown.data = malloc_or_die_(unknown->length); memcpy(unknown->data.unknown.data, "\xfe\xdc\xba\x98\xf0\xe1\xd2\xc3", unknown->length); }
static void init_metadata_blocks_() { /* most of the actual numbers and data in the blocks don't matter, we just want to make sure the decoder parses them correctly remember, the metadata interface gets tested after the decoders, so we do all the metadata manipulation here without it. */ /* min/max_framesize and md5sum don't get written at first, so we have to leave them 0 */ streaminfo_.is_last = false; streaminfo_.type = FLAC__METADATA_TYPE_STREAMINFO; streaminfo_.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; streaminfo_.data.stream_info.min_blocksize = 576; streaminfo_.data.stream_info.max_blocksize = 576; streaminfo_.data.stream_info.min_framesize = 0; streaminfo_.data.stream_info.max_framesize = 0; streaminfo_.data.stream_info.sample_rate = 44100; streaminfo_.data.stream_info.channels = 1; streaminfo_.data.stream_info.bits_per_sample = 8; streaminfo_.data.stream_info.total_samples = 0; memset(streaminfo_.data.stream_info.md5sum, 0, 16); padding_.is_last = false; padding_.type = FLAC__METADATA_TYPE_PADDING; padding_.length = 1234; seektable_.is_last = false; seektable_.type = FLAC__METADATA_TYPE_SEEKTABLE; seektable_.data.seek_table.num_points = 2; seektable_.length = seektable_.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; seektable_.data.seek_table.points = malloc_or_die_(seektable_.data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint)); seektable_.data.seek_table.points[0].sample_number = 0; seektable_.data.seek_table.points[0].stream_offset = 0; seektable_.data.seek_table.points[0].frame_samples = streaminfo_.data.stream_info.min_blocksize; seektable_.data.seek_table.points[1].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; seektable_.data.seek_table.points[1].stream_offset = 1000; seektable_.data.seek_table.points[1].frame_samples = streaminfo_.data.stream_info.min_blocksize; application1_.is_last = false; application1_.type = FLAC__METADATA_TYPE_APPLICATION; application1_.length = 8; memcpy(application1_.data.application.id, "\xfe\xdc\xba\x98", 4); application1_.data.application.data = malloc_or_die_(4); memcpy(application1_.data.application.data, "\xf0\xe1\xd2\xc3", 4); application2_.is_last = false; application2_.type = FLAC__METADATA_TYPE_APPLICATION; application2_.length = 4; memcpy(application2_.data.application.id, "\x76\x54\x32\x10", 4); application2_.data.application.data = 0; { const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING); vorbiscomment_.is_last = true; vorbiscomment_.type = FLAC__METADATA_TYPE_VORBIS_COMMENT; vorbiscomment_.length = (4 + vendor_string_length) + 4 + (4 + 5) + (4 + 0); vorbiscomment_.data.vorbis_comment.vendor_string.length = vendor_string_length; vorbiscomment_.data.vorbis_comment.vendor_string.entry = malloc_or_die_(vendor_string_length); memcpy(vorbiscomment_.data.vorbis_comment.vendor_string.entry, FLAC__VENDOR_STRING, vendor_string_length); vorbiscomment_.data.vorbis_comment.num_comments = 2; vorbiscomment_.data.vorbis_comment.comments = malloc_or_die_(vorbiscomment_.data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry)); vorbiscomment_.data.vorbis_comment.comments[0].length = 5; vorbiscomment_.data.vorbis_comment.comments[0].entry = malloc_or_die_(5); memcpy(vorbiscomment_.data.vorbis_comment.comments[0].entry, "ab=cd", 5); vorbiscomment_.data.vorbis_comment.comments[1].length = 0; vorbiscomment_.data.vorbis_comment.comments[1].entry = 0; } }