libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] Fedora bug report concerning CD-TEXT


From: Thomas Schmitt
Subject: Re: [Libcdio-devel] Fedora bug report concerning CD-TEXT
Date: Thu, 31 Mar 2016 14:55:33 +0200

Hi,

some investigation results:
----------------------------------------------------------------------

Interpretation of TAB character in text categories of CD-TEXT is not
implemented. Our cheat sheet
  http://libburnia-project.org/browser/libburn/trunk/doc/cdtext.txt
says:

  If a text of a track (pack types 0x80 to 0x85 and 0x8e) repeats identically
  for the next track, then it may be represented by a TAB character (ASCII 9)
  for single byte texts, and two TAB characters for double byte texts.
  (This should be used because 256 * 12 bytes is few space for 99 tracks.)

The misattribution of the uninterpreted TAB for track 2 to the text
for track 3 is caused by the demand in cdtext.c that a text must have
more than one character. I do not see a reason why 1 should not suffice.
At least i can get the TAB attributed to track 2 by this change:

--- ./lib/driver/cdtext.c.orig  2014-09-24 22:53:52.000000000 +0200
+++ ./lib/driver/cdtext.c       2016-03-31 11:30:15.776935711 +0200
@@ -650,7 +650,7 @@ cdtext_data_init(cdtext_t *p_cdtext, uin
             buffer[i_buf++] = pack.text[j];
             if(pack.db_chars)
               buffer[i_buf++] = pack.text[j+1];
-          } else if(i_buf > 1) {
+          } else if(i_buf > 0) {
             buffer[i_buf++] = 0;
             if(pack.db_chars)
               buffer[i_buf++] = 0;


I wrote:
> > Further, the TAB repetition mechanism seems not to be implemented:

Leon Merten Lohse wrote:
> Correct. I am going to implement it, though. Give me a couple of days.

Well, your mail reached me only after i implemented a rough sketch.

Copying of previous text on TAB is probably best implemented in
cdtext_set(). I am now testing.
The diff is very ugly. So i post the current experimental state:

void
cdtext_set(cdtext_t *p_cdtext, cdtext_field_t key, const uint8_t *value,
           track_t track, const char *charset)
{
  char *textpt;
  int repeatable_text = 0;

  if (NULL == value || key == CDTEXT_FIELD_INVALID
      || CDIO_CD_MAX_TRACKS < track)
    return;

  /* free old memory */
  if (p_cdtext->block[p_cdtext->block_i].track[track].field[key])
    free(p_cdtext->block[p_cdtext->block_i].track[track].field[key]);

  if (key == CDTEXT_FIELD_TITLE || key == CDTEXT_FIELD_PERFORMER ||
      key == CDTEXT_FIELD_SONGWRITER || key == CDTEXT_FIELD_COMPOSER ||
      key == CDTEXT_FIELD_ARRANGER || key == CDTEXT_FIELD_MESSAGE ||
      key == CDTEXT_FIELD_UPC_EAN || key == CDTEXT_FIELD_ISRC)
    repeatable_text = 1;

  if (repeatable_text && value[0] == 9 && value[1] == 0 && track > 0) {
    /* single ASCII TAB */

    /* >>> Care for double-byte double TABs */

    /* repeat text of previous track */
    if (p_cdtext->block[p_cdtext->block_i].track[track - 1].field[key] != NULL)
      textpt = strdup(
               p_cdtext->block[p_cdtext->block_i].track[track - 1].field[key]);
    else
      textpt = NULL;
  } else if (NULL != charset) {
    /* recode to UTF-8 */
    cdio_utf8_t *utf8_str = NULL;
    cdio_charset_to_utf8((const char*) value, strlen((const char*)value),
                        &utf8_str, charset);
    textpt = (char *)utf8_str;
  } else {
    textpt = strdup((const char *)value);
  }
  p_cdtext->block[p_cdtext->block_i].track[track].field[key] = textpt;
}

The function does not know whether double byte characters are stored
in value. It could only try to interpret charset.
So i propose to add a function parameter "double_byte"

  void
  cdtext_set(cdtext_t *p_cdtext, cdtext_field_t key, const uint8_t *value,
             track_t track, const char *charset, int double_byte)

Changing "track_t track" to "cdtext_pack_t pack" would be more elegant
but would only work if we increment the track number inside cdtext_pack_t
when we fix the problem of "The Hunt":

@@ -689,6 +702,7 @@ cdtext_data_init(cdtext_t *p_cdtext, uin
                 break;
             }
             i_buf = 0;
+            pack.i_track++;
 

----------------------------------------------------------------------

I wonder why  test/cdtext.right  does not show an ARRANGER of track 2
in english and in german, although  test/data/cdtext.cdt  has no TABs
as abbreviation in the 0x84 packs.

----------------------------------------------------------------------

Now for the missing texts for track 3 in block 1 (german):

Leon got the right ideas:
> Are you sure that nightcats_ii_en_de.cdt has the correct charset?
> My bet is, that this comes from the encoding issue where iconv fails.

My automatically generated template for file  katzenmusik_ii.v07t 
was wrong. It said
  Text Code           = ASCII
and
  Track 03 Artist     = Mia Kätzchen
where "ä" is encoded as 0xe4 (i.e. ISO 8859-1 small umlaut ae).

I now see the bug in libburn/cdtext.c : burn_make_v07t().
The character set code of the first block is used for the subsequent
blocks too.
In  test/data/cdtext.cdt  the character code for block 0 is 1 = ASCII
and the code for block 1 is 0 = ISO 8859-1.

I fixed the problem in libburn and in  katzenmusik_ii.v07t .
The freshly burnt CD does not show iconv warnings any more.

----------------------------------------------------------------------

So now i i have:

  nightcats_ii.v07t
  katzenmusik_ii.v07t
  nightcats_ii_en_de.cdt
  nightcats_ii.right

The file  nightcats_ii.right  for now is unedited output from
  ./src/cd-info --no-header /dev/sr4
of a CD that has nightcats_ii_en_de.cdt as CD-TEXT packs.
It differs from  test/cdtext.right  by 30+ extra lines before
  "Disc mode is listed as: CD-DA"
and it shows ISRC which test/cdtext.right does not.
It has
  Last CD Session LSN: 0
  audio status: invalid
where test/cdtext.right has
  Last CD Session LSN: not supported by drive/driver
  audio status: not implemented


Now what to do next with these files ?
Tar up and send where ?


Rocky Bernstein wrote:
> My heartfelt thanks to both Leon and Thomas for picking this up and
> running with it.

I'm acting purely selfish. The bug harvest is rich.
I found 3 in libcdio and 3 in libburn up to now.
So special thanks to James for bringing up the topic of CD-TEXT.


Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]