1) cdtext objects are no longer associated with a track but with the disc.
2) - cdio_get_cdtext no longer takes track as an argument - cdtext_get, cdtext_get_const, cdtext_set require track argument 3) Language, Genre, Genre Code and Encoding Fields are now properly parsed and stored in the cdtext object 4) Added public function cdio_get_cdtext_raw to extract the binary CD-Text 5) Added CDTEXTFILE keyword logic in cue sheet parser. Parses binary/raw CD-Text files 6) Added cdtext_genre2str to convert genre code 7) altered the example programs, test drivers, cdda-player and cd-info to work with these changes 8) Added test case 9) A few smaller changes A disc either holds CD-Text for all the tracks or does not hold any. Therefore a CD-Text object for the whole disc seems more natural to me. It also enables us to store global fields, like genre, encoding, language. Patch was tested on GNU/Linux 32 bit running Gentoo.
This commit is contained in:
1
lib/driver/image/.gitignore
vendored
Normal file
1
lib/driver/image/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/*~
|
||||
@@ -87,8 +87,6 @@ _init_bincue (_img_private_t *p_env)
|
||||
p_env->psz_mcn = NULL;
|
||||
p_env->disc_mode = CDIO_DISC_MODE_NO_INFO;
|
||||
|
||||
cdtext_init (&(p_env->gen.cdtext));
|
||||
|
||||
lead_lsn = get_disc_last_lsn_bincue( (_img_private_t *) p_env);
|
||||
|
||||
if (-1 == lead_lsn) return false;
|
||||
@@ -268,8 +266,6 @@ parse_cuefile (_img_private_t *cd, const char *psz_cue_name)
|
||||
if (cd) {
|
||||
cd->gen.i_tracks=0;
|
||||
cd->gen.i_first_track=1;
|
||||
cd->gen.b_cdtext_init = true;
|
||||
cd->gen.b_cdtext_error = false;
|
||||
cd->psz_mcn=NULL;
|
||||
}
|
||||
|
||||
@@ -326,6 +322,52 @@ parse_cuefile (_img_private_t *cd, const char *psz_cue_name)
|
||||
} else {
|
||||
goto not_in_global_section;
|
||||
}
|
||||
|
||||
/* CDTEXTFILE "<filename>" */
|
||||
} else if (0 == strcmp ("CDTEXTFILE", psz_keyword)) {
|
||||
if(NULL != (psz_field = strtok (NULL, "\"\t\n\r"))) {
|
||||
if (cd) {
|
||||
uint8_t cdt_data[MAX_CDTEXT_DATA_LENGTH+4];
|
||||
int size;
|
||||
int i;
|
||||
CdioDataSource_t *source;
|
||||
|
||||
if(NULL == (source = cdio_stdio_new(psz_field))) {
|
||||
cdio_log (log_level, "%s line %d: can't open file `%s' for reading", psz_cue_name, i_line, psz_field);
|
||||
goto err_exit;
|
||||
}
|
||||
size = cdio_stream_read(source, cdt_data, MAX_CDTEXT_DATA_LENGTH, 1);
|
||||
|
||||
if (size < 4) {
|
||||
cdio_log (log_level, "%s line %d: file `%s' is too small to contain CD-TEXT", psz_cue_name, i_line, psz_field);
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* prepend data length if not yet present */
|
||||
if (cdt_data[0] >= 0x80) {
|
||||
for(i=size-1; i >=0; i--)
|
||||
cdt_data[i+4] = cdt_data[i];
|
||||
|
||||
cdt_data[0] = (size+2) << 8;
|
||||
cdt_data[1] = (size+2) & 0xff;
|
||||
cdt_data[2] = 0x00;
|
||||
cdt_data[3] = 0x00;
|
||||
}
|
||||
|
||||
/* init cdtext */
|
||||
if (NULL == cd->gen.cdtext) {
|
||||
cd->gen.cdtext = malloc(sizeof(cdtext_t));
|
||||
cdtext_init (cd->gen.cdtext);
|
||||
}
|
||||
|
||||
if(!cdtext_data_init(cd->gen.cdtext, cdt_data))
|
||||
cdio_log (log_level, "%s line %d: failed to parse CD-TEXT file `%s'", psz_cue_name, i_line, psz_field);
|
||||
|
||||
cdio_stdio_destroy (source);
|
||||
}
|
||||
} else {
|
||||
goto format_error;
|
||||
}
|
||||
|
||||
/* FILE "<filename>" <BINARY|WAVE|other?> */
|
||||
} else if (0 == strcmp ("FILE", psz_keyword)) {
|
||||
@@ -357,7 +399,6 @@ parse_cuefile (_img_private_t *cd, const char *psz_cue_name)
|
||||
this_track->track_num = cd->gen.i_tracks;
|
||||
this_track->num_indices = 0;
|
||||
b_first_index_for_track = false;
|
||||
cdtext_init (&(cd->gen.cdtext_track[cd->gen.i_tracks]));
|
||||
cd->gen.i_tracks++;
|
||||
}
|
||||
i++;
|
||||
@@ -728,18 +769,15 @@ parse_cuefile (_img_private_t *cd, const char *psz_cue_name)
|
||||
/* CD-Text */
|
||||
} else if ( CDTEXT_INVALID !=
|
||||
(cdtext_key = cdtext_is_keyword (psz_keyword)) ) {
|
||||
if (-1 == i) {
|
||||
if (cd) {
|
||||
cdtext_set (cdtext_key,
|
||||
strtok (NULL, "\"\t\n\r"),
|
||||
&(cd->gen.cdtext));
|
||||
}
|
||||
} else {
|
||||
if (cd) {
|
||||
cdtext_set (cdtext_key, strtok (NULL, "\"\t\n\r"),
|
||||
&(cd->gen.cdtext_track[i]));
|
||||
}
|
||||
}
|
||||
if (cd) {
|
||||
if (NULL == cd->gen.cdtext) {
|
||||
cd->gen.cdtext = malloc(sizeof(cdtext_t));
|
||||
cdtext_init (cd->gen.cdtext);
|
||||
}
|
||||
cdtext_set (cdtext_key,
|
||||
(-1 == i ? 0 : cd->gen.i_first_track + i + 1),
|
||||
strtok (NULL, "\"\t\n\r"), cd->gen.cdtext);
|
||||
}
|
||||
|
||||
/* unrecognized line */
|
||||
} else {
|
||||
@@ -1138,7 +1176,8 @@ cdio_open_cue (const char *psz_cue_name)
|
||||
_funcs.eject_media = _eject_media_image;
|
||||
_funcs.free = _free_image;
|
||||
_funcs.get_arg = _get_arg_image;
|
||||
_funcs.get_cdtext = get_cdtext_generic;
|
||||
_funcs.get_cdtext = _get_cdtext_image;
|
||||
_funcs.get_cdtext_raw = NULL;
|
||||
_funcs.get_devices = cdio_get_devices_bincue;
|
||||
_funcs.get_default_device = cdio_get_default_device_bincue;
|
||||
_funcs.get_disc_last_lsn = get_disc_last_lsn_bincue;
|
||||
|
||||
@@ -108,8 +108,6 @@ _init_cdrdao (_img_private_t *env)
|
||||
env->psz_mcn = NULL;
|
||||
env->disc_mode = CDIO_DISC_MODE_NO_INFO;
|
||||
|
||||
cdtext_init (&(env->gen.cdtext));
|
||||
|
||||
/* Read in TOC sheet. */
|
||||
if ( !parse_tocfile(env, env->psz_cue_name) ) return false;
|
||||
|
||||
@@ -292,7 +290,6 @@ parse_tocfile (_img_private_t *cd, const char *psz_cue_name)
|
||||
}
|
||||
|
||||
if (cd) {
|
||||
cd->gen.b_cdtext_init = true;
|
||||
cd->gen.b_cdtext_error = false;
|
||||
}
|
||||
|
||||
@@ -375,7 +372,6 @@ parse_tocfile (_img_private_t *cd, const char *psz_cue_name)
|
||||
/* TRACK <track-mode> [<sub-channel-mode>] */
|
||||
} else if (0 == strcmp ("TRACK", psz_keyword)) {
|
||||
i++;
|
||||
if (NULL != cd) cdtext_init (&(cd->gen.cdtext_track[i]));
|
||||
if (NULL != (psz_field = strtok (NULL, " \t\n\r"))) {
|
||||
if (0 == strcmp ("AUDIO", psz_field)) {
|
||||
if (NULL != cd) {
|
||||
@@ -911,19 +907,16 @@ parse_tocfile (_img_private_t *cd, const char *psz_cue_name)
|
||||
if (i_cdtext_nest > 0) i_cdtext_nest--;
|
||||
} else if ( CDTEXT_INVALID !=
|
||||
(cdtext_key = cdtext_is_keyword (psz_keyword)) ) {
|
||||
if (-1 == i) {
|
||||
if (NULL != cd) {
|
||||
cdtext_set (cdtext_key,
|
||||
strtok (NULL, "\"\t\n\r"),
|
||||
&(cd->gen.cdtext));
|
||||
}
|
||||
} else {
|
||||
if (NULL != cd) {
|
||||
cdtext_set (cdtext_key,
|
||||
strtok (NULL, "\"\t\n\r"),
|
||||
&(cd->gen.cdtext_track[i]));
|
||||
}
|
||||
}
|
||||
if (NULL != cd) {
|
||||
if (NULL == cd->gen.cdtext) {
|
||||
cd->gen.cdtext = malloc(sizeof(cdtext_t));
|
||||
cdtext_init (cd->gen.cdtext);
|
||||
}
|
||||
cdtext_set (cdtext_key,
|
||||
(-1 == i ? 0 : cd->gen.i_first_track + i + 1),
|
||||
strtok (NULL, "\"\t\n\r"),
|
||||
cd->gen.cdtext);
|
||||
}
|
||||
|
||||
/* unrecognized line */
|
||||
} else {
|
||||
@@ -1261,7 +1254,8 @@ cdio_open_cdrdao (const char *psz_cue_name)
|
||||
_funcs.eject_media = _eject_media_image;
|
||||
_funcs.free = _free_image;
|
||||
_funcs.get_arg = _get_arg_image;
|
||||
_funcs.get_cdtext = get_cdtext_generic;
|
||||
_funcs.get_cdtext = _get_cdtext_image;
|
||||
_funcs.get_cdtext_raw = NULL;
|
||||
_funcs.get_devices = cdio_get_devices_cdrdao;
|
||||
_funcs.get_default_device = cdio_get_default_device_cdrdao;
|
||||
_funcs.get_disc_last_lsn = get_disc_last_lsn_cdrdao;
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "cdio_assert.h"
|
||||
#include "_cdio_stdio.h"
|
||||
#include "nrg.h"
|
||||
#include "cdtext_private.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: nrg.c,v 1.31 2008/04/21 18:30:22 karl Exp $";
|
||||
|
||||
@@ -431,7 +432,6 @@ parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
|
||||
}
|
||||
if (0 == disc_mode) {
|
||||
for (i=0; i<p_env->gen.i_tracks; i++) {
|
||||
cdtext_init (&(p_env->gen.cdtext_track[i]));
|
||||
p_env->tocent[i].track_format= track_format;
|
||||
p_env->tocent[i].datastart = 0;
|
||||
p_env->tocent[i].track_green = false;
|
||||
@@ -446,7 +446,6 @@ parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
|
||||
}
|
||||
} else if (2 == disc_mode) {
|
||||
for (i=0; i<p_env->gen.i_tracks; i++) {
|
||||
cdtext_init (&(p_env->gen.cdtext_track[i]));
|
||||
p_env->tocent[i].track_green = true;
|
||||
p_env->tocent[i].track_format= track_format;
|
||||
p_env->tocent[i].datasize = CDIO_CD_FRAMESIZE;
|
||||
@@ -749,7 +748,15 @@ parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
|
||||
uint8_t *wdata = (uint8_t *) chunk->data;
|
||||
int len = UINT32_FROM_BE (chunk->len);
|
||||
cdio_assert (len % sizeof (CDText_data_t) == 0);
|
||||
cdtext_data_init (&p_env->gen, p_env->gen.i_first_track, &wdata[-4], len, set_cdtext_field_generic);
|
||||
p_env->gen.cdtext = malloc(sizeof(cdtext_t));
|
||||
cdtext_init (p_env->gen.cdtext);
|
||||
if(!cdtext_data_init (p_env->gen.cdtext, &wdata[-4]))
|
||||
{
|
||||
cdtext_destroy(p_env->gen.cdtext);
|
||||
free(p_env->gen.cdtext);
|
||||
p_env->gen.cdtext = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -777,7 +784,6 @@ parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
|
||||
p_env->tocent[p_env->gen.i_tracks-1].sec_count =
|
||||
cdio_lsn_to_lba(p_env->size - p_env->tocent[p_env->gen.i_tracks-1].start_lba);
|
||||
|
||||
p_env->gen.b_cdtext_init = true;
|
||||
p_env->gen.b_cdtext_error = false;
|
||||
p_env->gen.toc_init = true;
|
||||
free(footer_buf);
|
||||
@@ -804,8 +810,6 @@ _init_nrg (_img_private_t *p_env)
|
||||
p_env->psz_mcn = NULL;
|
||||
p_env->disc_mode = CDIO_DISC_MODE_NO_INFO;
|
||||
|
||||
cdtext_init (&(p_env->gen.cdtext));
|
||||
|
||||
if ( !parse_nrg (p_env, p_env->gen.source_name, CDIO_LOG_WARN) ) {
|
||||
cdio_warn ("image file %s is not a Nero image",
|
||||
p_env->gen.source_name);
|
||||
@@ -1276,7 +1280,8 @@ cdio_open_nrg (const char *psz_source)
|
||||
_funcs.eject_media = _eject_media_nrg;
|
||||
_funcs.free = _free_nrg;
|
||||
_funcs.get_arg = _get_arg_image;
|
||||
_funcs.get_cdtext = get_cdtext_generic;
|
||||
_funcs.get_cdtext = _get_cdtext_image;
|
||||
_funcs.get_cdtext_raw = NULL;
|
||||
_funcs.get_devices = cdio_get_devices_nrg;
|
||||
_funcs.get_default_device = cdio_get_default_device_nrg;
|
||||
_funcs.get_disc_last_lsn = get_disc_last_lsn_nrg;
|
||||
|
||||
Reference in New Issue
Block a user