From 6321bbc0f88eee05370733c47e4e252e88d673c6 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 8 Jan 2012 13:23:16 +0000 Subject: [PATCH] Implemented track number starts > 1 with .cue and v07t.txt files --- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/doc/cdtext.txt | 32 +++++++++---- libburn/trunk/libburn/cdtext.c | 56 +++++++++-------------- libburn/trunk/libburn/libburn.h | 2 +- libburn/trunk/libburn/structure.c | 23 ++++++---- 5 files changed, 59 insertions(+), 56 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index c67fb5fe..48aff1c5 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2012.01.07.190901" +#define Cdrskin_timestamP "2012.01.08.132304" diff --git a/libburn/trunk/doc/cdtext.txt b/libburn/trunk/doc/cdtext.txt index 2ae37155..935b8c91 100644 --- a/libburn/trunk/doc/cdtext.txt +++ b/libburn/trunk/doc/cdtext.txt @@ -453,6 +453,13 @@ There is a reader for Sony Input Sheet Version 0.7T: int burn_session_input_sheet_v07t(struct burn_session *session, char *path, int block, int flag); +CD-TEXT can be read from a CDRWIN cue sheet file which defines the tracks +of a session + + int burn_session_by_cue_file(struct burn_session *session, + char *path, int fifo_size, struct burn_source **fifo, + unsigned char **text_packs, int *num_packs, int flag); + The session and track attributes can then be converted into an array of text packs by: @@ -485,12 +492,22 @@ and for removing attached attributes: int burn_track_dispose_cdtext(struct burn_track *t, int block); -CD-TEXT can be read from a CDRWIN cue sheet file which defines the tracks -of a session - int burn_session_by_cue_file(struct burn_session *session, - char *path, int fifo_size, struct burn_source **fifo, - unsigned char **text_packs, int *num_packs, int flag); +UPC/EAN and ISRC not only affect CD-TEXT but also information that is written +along with the tracks in Q sub-channel. These can be influenced by +burn_session_input_sheet_v07t(), burn_session_by_cue_file() and by + + void burn_write_opts_set_mediacatalog(struct burn_write_opts *opts, + unsigned char mediacatalog[13]); + + void burn_write_opts_set_has_mediacatalog(struct burn_write_opts *opts, + int has_mediacatalog); + + void burn_track_set_isrc(struct burn_track *t, char *country, char *owner, + unsigned char year, unsigned int serial); + + int burn_track_set_isrc_string(struct burn_track *t, char isrc[13], + int flag); ------------------------------------------------------------------------------- @@ -572,11 +589,6 @@ If a track attribute is set, but the corresponding session attribute is not defined or defined with empty text, then the session attribute gets attached as empty test. (Normally empty content is ignored.) -libburn will always start track numbering by 1. So it adjusts all track -numbers from the input sheet file by subtracting (First Track Number - 1). -libburn ignores Last Track number because it will always write its own first -and last track numbers to pack type 0x8f. - Example cdrskin run with three tracks: diff --git a/libburn/trunk/libburn/cdtext.c b/libburn/trunk/libburn/cdtext.c index 6f2e16da..35176f62 100755 --- a/libburn/trunk/libburn/cdtext.c +++ b/libburn/trunk/libburn/cdtext.c @@ -36,6 +36,7 @@ struct burn_pack_cursor { int td_used; int hiseq[8]; int pack_count[16]; + int track_offset; }; @@ -196,13 +197,10 @@ static int burn_create_bl_size_packs(int block, unsigned char *char_codes, { int i, ret; unsigned char payload[12]; - /* Normal is track_offset = 0. - But if the CUE sheet supports offset, then it is needed here too */ - int track_offset = 0; payload[0] = char_codes[block]; - payload[1] = 1 + track_offset; - payload[2] = num_tracks + track_offset; + payload[1] = crs->track_offset; + payload[2] = num_tracks + crs->track_offset - 1; payload[3] = copyrights[block]; for (i = 0; i < 8; i++) payload[i + 4] = crs->pack_count[i]; @@ -318,9 +316,6 @@ static int burn_create_tybl_s_packs(struct burn_session *s, { int i, ret, idx, double_byte, use_tab; struct burn_cdtext *cdt; - /* Normal is track_offset = 0. - But if the CUE sheet supports offset, then it is needed here too */ - int track_offset = 0; cdt = s->cdtext[block]; idx = pack_type - Libburn_pack_type_basE; @@ -347,7 +342,7 @@ static int burn_create_tybl_s_packs(struct burn_session *s, else use_tab = 0; ret = burn_create_tybl_t_packs(s->track[i], - i + 1 + track_offset, pack_type, + i + crs->track_offset, pack_type, block, crs, use_tab); if (ret <= 0) return ret; @@ -375,6 +370,7 @@ int burn_cdtext_from_session(struct burn_session *s, *num_packs = 0; } memset(&crs, 0, sizeof(struct burn_pack_cursor)); + crs.track_offset = s->firsttrack; BURN_ALLOC_MEM(crs.packs, unsigned char, Libburn_leadin_cdtext_packs_maX * 18); @@ -627,7 +623,7 @@ int burn_session_input_sheet_v07t(struct burn_session *session, char *path, int block, int flag) { int ret = 0, num_tracks, char_codes[8], copyrights[8], languages[8], i; - int genre_code = -1, track_offset = 1, length, pack_type, tno; + int genre_code = -1, track_offset = 1, length, pack_type, tno, tnum; int session_attr_seen[16], track_attr_seen[16]; int int0x00 = 0x00, int0x01 = 0x01; struct stat stbuf; @@ -865,15 +861,10 @@ bad_tno:; ret = 0; goto ex; } else { track_offset = ret; - if (ret != 1) { - sprintf(msg, - "First Track Number '%s' will be mapped to 1", - payload); - libdax_msgs_submit(libdax_messenger,-1, - 0x00020195, LIBDAX_MSGS_SEV_WARNING, - LIBDAX_MSGS_PRIO_HIGH, - burn_printify(msg), 0, 0); - } + ret = burn_session_set_start_tno(session, + track_offset, 0); + if (ret <= 0) + goto ex; } } else if (strcmp(line, "Last Track Number") == 0) { @@ -890,18 +881,13 @@ bad_tno:; } else if (strncmp(line, "Track ", 6) == 0) { tno = -1; sscanf(line + 6, "%d", &tno); - if (tno < 0 || tno - track_offset < 0 || + if (tno < 1 || tno - track_offset < 0 || tno - track_offset >= num_tracks) { track_txt[0] = line[6]; track_txt[1] = line[7]; track_txt[2] = 0; bad_track_no:; - if (track_offset != 1) - sprintf(msg, - "Inappropriate v07t Track number '%.3900s' (mapped to %2.2d)", - track_txt, tno - track_offset + 1); - else - sprintf(msg, + sprintf(msg, "Inappropriate v07t Track number '%.3900s'", track_txt); sprintf(msg + strlen(msg), @@ -914,7 +900,7 @@ bad_track_no:; burn_printify(msg), 0, 0); ret = 0; goto ex; } - tno -= track_offset; + tnum = tno - track_offset; if (strcmp(line, "0x80") == 0 || strcmp(line + 9, "Title") == 0) @@ -939,7 +925,7 @@ bad_track_no:; pack_type = 0x8e; if (!(flag & 2)) { ret = burn_track_set_isrc_string( - tracks[tno], payload, 0); + tracks[tnum], payload, 0); if (ret <= 0) goto ex; } @@ -953,8 +939,8 @@ bad_track_no:; burn_printify(msg), 0, 0); ret = 0; goto ex; } - ret = v07t_cdtext_to_track(tracks[tno], block, payload, - &int0x00, pack_type, "", 0); + ret = v07t_cdtext_to_track(tracks[tnum], block, + payload, &int0x00, pack_type, "", 0); if (ret <= 0) goto ex; track_attr_seen[pack_type - 0x80] = 1; @@ -963,22 +949,22 @@ bad_track_no:; /* Track variation of UPC EAN = 0x8e */ tno = -1; sscanf(line + 5, "%d", &tno); - if (tno < 0 || tno - track_offset < 0 || + if (tno <= 0 || tno - track_offset < 0 || tno - track_offset >= num_tracks) { track_txt[0] = line[5]; track_txt[1] = line[6]; track_txt[2] = 0; goto bad_track_no; } - tno -= track_offset; + tnum = tno - track_offset; if (!(flag & 2)) { ret = burn_track_set_isrc_string( - tracks[tno], payload, 0); + tracks[tnum], payload, 0); if (ret <= 0) goto ex; } - ret = v07t_cdtext_to_track(tracks[tno], block, payload, - &int0x00, 0x8e, "", 0); + ret = v07t_cdtext_to_track(tracks[tnum], block, + payload, &int0x00, 0x8e, "", 0); if (ret <= 0) goto ex; track_attr_seen[0xe] = 1; diff --git a/libburn/trunk/libburn/libburn.h b/libburn/trunk/libburn/libburn.h index 45fba815..322a47a0 100644 --- a/libburn/trunk/libburn/libburn.h +++ b/libburn/trunk/libburn/libburn.h @@ -1871,7 +1871,7 @@ int burn_disc_remove_session(struct burn_disc *d, struct burn_session *s); >>> supported FILE types: BINARY MOTOROLA WAVE >>> supported TRACK datatypes: AUDIO MODE1/2048 >>> ignored commands: POSTGAP PREGAP ->>> not allowed: mixing of ADUIO and MODE1/2048 +>>> not allowed: mixing of AUDIO and MODE1/2048 >>> not allowed: unsupported FILE types >>> not allowed: unsupported TRACK datatypes >>> diff --git a/libburn/trunk/libburn/structure.c b/libburn/trunk/libburn/structure.c index c158b3e5..0291793c 100644 --- a/libburn/trunk/libburn/structure.c +++ b/libburn/trunk/libburn/structure.c @@ -1073,6 +1073,7 @@ struct burn_cue_file_cursor { int swap_audio_bytes; int no_cdtext; int no_catalog_isrc; + int start_track_no; struct burn_source *offst_source; int current_file_ba; struct burn_track *prev_track; @@ -1104,6 +1105,7 @@ static int cue_crs_new(struct burn_cue_file_cursor **reply, int flag) crs->swap_audio_bytes = 0; crs->no_cdtext = 0; crs->no_catalog_isrc = 0; + crs->start_track_no = 1; crs->offst_source = NULL; crs->current_file_ba = -1000000000; crs->prev_track = NULL; @@ -1236,14 +1238,18 @@ static int cue_attach_track(struct burn_session *session, 0, 0); return 0; } - if (crs->track_no > 1 && session->tracks == 0) { - - /* >>> ??? implement ? */; - - libdax_msgs_submit(libdax_messenger, -1, 0x00020195, - LIBDAX_MSGS_SEV_WARNING, LIBDAX_MSGS_PRIO_HIGH, - "In cue sheet file: TRACK numbering does not start with 01", - 0, 0); + if (session->tracks == 0) { + crs->start_track_no = crs->track_no; + ret = burn_session_set_start_tno(session, crs->track_no, 0); + if (ret <= 0) + return ret; + } + if (session->tracks + crs->start_track_no - 1 > 99) { + libdax_msgs_submit(libdax_messenger, -1, 0x0002019b, + LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, + "CD track number exceeds 99", + 0, 0); + return 0; } ret = burn_session_add_track(session, crs->track, BURN_POS_END); if (ret <= 0) @@ -1312,7 +1318,6 @@ static int cue_open_audioxtr(char *path, struct burn_cue_file_cursor *crs, BURN_ALLOC_MEM(msg, char, 4096); - /* >>> obtain fd by libdax_audioxtr */; ret= libdax_audioxtr_new(&xtr, path, 0); if (ret <= 0) return ret;