[vlc-commits] [Git][videolan/vlc][master] 5 commits: cdrom: don't eat the next line after we read the cue file mode

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Sep 9 14:16:53 UTC 2021



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d18fd89b by Steve Lhomme at 2021-09-09T13:56:41+00:00
cdrom: don't eat the next line after we read the cue file mode

- - - - -
8df1e10a by Steve Lhomme at 2021-09-09T13:56:41+00:00
cdrom: read the track type (audio or data) from the cuesheet

We look for:
[ ]+TRACK dd AUDIO
[ ]+TRACK dd
[ ]+TRACK dd (anything)

Set the LeadOut type to the same type as the last track.

Fixes #26036

- - - - -
810e150c by Steve Lhomme at 2021-09-09T13:56:41+00:00
cdda: fix shift for possible Mode 2 track at the start

- - - - -
93476b94 by Steve Lhomme at 2021-09-09T13:56:41+00:00
cdrom: add known subcode values

As found in libcdio.

- - - - -
47abb6ad by Steve Lhomme at 2021-09-09T13:56:41+00:00
cdda: report the total usable track in the metadata

In mixed-mode CDs, the tracks before the first and after the last are not
usuable as audio that, so we don't let the underlying format bleed into the
metadata info.

- - - - -


3 changed files:

- modules/access/cdda.c
- modules/access/vcd/cdrom.c
- modules/access/vcd/cdrom.h


Changes:

=====================================
modules/access/cdda.c
=====================================
@@ -256,13 +256,13 @@ static int TOC_GetAudioRange(vcddev_toc_t *p_toc,
     int i_last = p_toc->i_last_track;
     for(int i=i_first; i<p_toc->i_tracks; i++)
     {
-        if((p_toc->p_sectors[i - 1].i_control & CD_ROM_DATA_FLAG) == 0)
+        if((p_toc->p_sectors[i - 1].i_control & CD_ROM_SUBCODE_DATA) == 0)
             break;
         i_first++;
     }
     for(int i=i_last; i > 0; i--)
     {
-        if((p_toc->p_sectors[i - 1].i_control & CD_ROM_DATA_FLAG) == 0)
+        if((p_toc->p_sectors[i - 1].i_control & CD_ROM_SUBCODE_DATA) == 0)
             break;
         i_last--;
     }
@@ -677,24 +677,21 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
     const vcddev_toc_t *p_toc = sys->p_toc;
 
     /* Build title table */
-    const int i_start_cddb_offset = sys->i_cdda_first - sys->p_toc->i_first_track;
+    const int cdda_offset = sys->i_cdda_first - p_toc->i_first_track;
     for (int i = 0; i < sys->i_cdda_tracks; i++)
     {
-        if(i < i_start_cddb_offset)
-            continue;
-
-        msg_Dbg(access, "track[%d] start=%d", i, p_toc->p_sectors[i].i_lba);
+        msg_Dbg(access, "track[%d] start=%d", i, p_toc->p_sectors[i + cdda_offset].i_lba);
 
         /* Initial/default name */
         char *name;
 
         if (unlikely(asprintf(&name, _("Audio CD - Track %02i"),
-                              i - i_start_cddb_offset + 1 ) == -1))
+                              i + 1 ) == -1))
             name = NULL;
 
         /* Create playlist items */
-        int i_first_sector = p_toc->p_sectors[i].i_lba;
-        int i_last_sector = p_toc->p_sectors[i + 1].i_lba;
+        int i_first_sector = p_toc->p_sectors[i + cdda_offset].i_lba;
+        int i_last_sector = p_toc->p_sectors[i + cdda_offset + 1].i_lba;
         if(sys->i_cdda_first + i == sys->i_cdda_last &&
            p_toc->i_last_track > sys->i_cdda_last)
             i_last_sector -= CD_ROM_XA_INTERVAL;
@@ -717,8 +714,7 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
             free(opt);
         }
 
-        if (likely(asprintf(&opt, "cdda-first-sector=%i",
-                            p_toc->p_sectors[i].i_lba) != -1))
+        if (likely(asprintf(&opt, "cdda-first-sector=%i", i_first_sector) != -1))
         {
             input_item_AddOption(item, opt, VLC_INPUT_OPTION_TRUSTED);
             free(opt);
@@ -836,7 +832,7 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
         char num[4];
         if(snprintf(num, sizeof (num), "%u", i + 1) < 4)
             input_item_SetTrackNum(item, num);
-        snprintf(num, sizeof (num), "%u", p_toc->i_tracks);
+        snprintf(num, sizeof (num), "%u", p_toc->i_last_track - p_toc->i_first_track);
         input_item_SetTrackTotal(item, num);
 
         input_item_node_AppendItem(node, item);


=====================================
modules/access/vcd/cdrom.c
=====================================
@@ -840,7 +840,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
     p_vcddev->i_vcdimage_handle = vlc_open( psz_vcdfile,
                                     O_RDONLY | O_NONBLOCK | O_BINARY );
 
-    while( fgets( line, 1024, cuefile ) && !b_found )
+    while( !b_found && fgets( line, 1024, cuefile ) )
     {
         /* We have a cue file, but no valid vcd file yet */
         char filename[1024];
@@ -883,12 +883,31 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
      * about the cuefile */
     p_toc->i_tracks = 0;
 
+    int track_subcodes = CD_ROM_SUBCODE_NONE;
+
     while( fgets( line, 1024, cuefile ) && p_toc->i_tracks < INT_MAX-1 )
     {
         /* look for a TRACK line */
-        char psz_dummy[10];
-        if( !sscanf( line, "%9s", psz_dummy ) || strcmp(psz_dummy, "TRACK") )
+        unsigned track_num;
+        char psz_track_type[32];
+        const char *track_start = strstr(line, "TRACK ");
+        if( track_start == NULL )
+            continue;
+        track_start += 6; // skip the "TRACK " part
+        int i = sscanf( track_start, "%u %31s", &track_num, psz_track_type );
+        if( i != 2 ) // no type set: assume audio track
+            psz_track_type[0] = '\0';
+        if( i<=0 )
+            i = sscanf( track_start, "%u", &track_num);
+        if( i<=0 )
             continue;
+        if ( psz_track_type[0] && strcmp(psz_track_type,"AUDIO")!=0)
+        {
+            msg_Dbg( p_this, "detected %s track %02u", psz_track_type, track_num);
+            track_subcodes = CD_ROM_SUBCODE_DATA;
+        }
+        else
+            track_subcodes = CD_ROM_SUBCODE_NONE;
 
         /* look for an INDEX line */
         while( fgets( line, 1024, cuefile ) )
@@ -905,7 +924,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
                 goto error;
             p_toc->p_sectors = buf;
             p_toc->p_sectors[p_toc->i_tracks].i_lba = MSF_TO_LBA(i_min, i_sec, i_frame);
-            p_toc->p_sectors[p_toc->i_tracks].i_control = 0x00;
+            p_toc->p_sectors[p_toc->i_tracks].i_control = track_subcodes;
             msg_Dbg( p_this, "vcd track %i begins at sector:%i",
                      p_toc->i_tracks, p_toc->p_sectors[p_toc->i_tracks].i_lba );
             p_toc->i_tracks++;
@@ -921,10 +940,9 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
     p_toc->p_sectors = buf;
     p_toc->p_sectors[p_toc->i_tracks].i_lba =
             lseek(p_vcddev->i_vcdimage_handle, 0, SEEK_END) / VCD_SECTOR_SIZE;
-    p_toc->p_sectors[p_toc->i_tracks].i_control = 0x00;
-    msg_Dbg( p_this, "vcd track %i, begins at sector:%i",
-             p_toc->i_tracks, p_toc->p_sectors[p_toc->i_tracks].i_lba );
-    p_toc->i_tracks++;
+    p_toc->p_sectors[p_toc->i_tracks].i_control = track_subcodes;
+    msg_Dbg( p_this, "vcd tracks end at sector:%i",
+             p_toc->p_sectors[p_toc->i_tracks].i_lba );
     p_toc->i_first_track = 1;
     p_toc->i_last_track = p_toc->i_tracks;
     i_ret = 0;


=====================================
modules/access/vcd/cdrom.h
=====================================
@@ -43,7 +43,12 @@ enum {
 #define CD_ROM_XA_INTERVAL ((60 + 90 + 2) * CD_ROM_XA_FRAMES)
 
 /* Subcode control flag */
-#define CD_ROM_DATA_FLAG    0x04
+#define CD_ROM_SUBCODE_NONE           0x00
+#define CD_ROM_SUBCODE_PRE_EMPHASIS   0x01
+#define CD_ROM_SUBCODE_COPY_PERMITTED 0x02
+#define CD_ROM_SUBCODE_DATA           0x04
+#define CD_ROM_SUBCODE_4CH            0x08
+#define CD_ROM_SUBCODE_SCMS           0x10
 
 /* size of a CD sector */
 #define CD_SECTOR_SIZE      CD_ROM_MODE1_DATA_SIZE



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f7f22ceab18f30e1022869106a5fc638377d7135...47abb6adea5d6b1e7e12b9a8fc772adc34c62bc6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f7f22ceab18f30e1022869106a5fc638377d7135...47abb6adea5d6b1e7e12b9a8fc772adc34c62bc6
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list