소스 검색

Clarify usage of values within the CUE file parser and update test file.

saybur 2 년 전
부모
커밋
fe4f94e5b1
3개의 변경된 파일17개의 추가작업 그리고 14개의 파일을 삭제
  1. 4 4
      lib/CUEParser/src/CUEParser.cpp
  2. 7 5
      lib/CUEParser/src/CUEParser.h
  3. 6 5
      lib/CUEParser/test/CUEParser_test.cpp

+ 4 - 4
lib/CUEParser/src/CUEParser.cpp

@@ -62,7 +62,7 @@ const CUETrackInfo *CUEParser::next_track()
 
     bool got_track = false;
     bool got_data = false;
-    bool got_paused = false;
+    bool got_pause = false; // true if a period of silence (INDEX 00) was encountered for a track
     while(!(got_track && got_data) && start_line())
     {
         if (strncasecmp(m_parse_pos, "FILE ", 5) == 0)
@@ -86,7 +86,7 @@ const CUETrackInfo *CUEParser::next_track()
             m_track_info.track_start = 0;
             got_track = true;
             got_data = false;
-            got_paused = false;
+            got_pause = false;
         }
         else if (strncasecmp(m_parse_pos, "PREGAP ", 7) == 0)
         {
@@ -105,7 +105,7 @@ const CUETrackInfo *CUEParser::next_track()
             if (index == 0)
             {
                 m_track_info.track_start = time;
-                got_paused = true;
+                got_pause = true;
             }
             else if (index == 1)
             {
@@ -117,7 +117,7 @@ const CUETrackInfo *CUEParser::next_track()
         next_line();
     }
 
-    if (got_data && !got_paused)
+    if (got_data && !got_pause)
     {
         m_track_info.track_start = m_track_info.data_start;
     }

+ 7 - 5
lib/CUEParser/src/CUEParser.h

@@ -53,22 +53,24 @@ struct CUETrackInfo
     // Source file name and file type, and offset to start of track data in bytes.
     char filename[CUE_MAX_FILENAME+1];
     CUEFileMode file_mode;
-    uint64_t file_offset;
+    uint64_t file_offset; // corresponds to track_start below
 
     // Track number and mode in CD format
     int track_number;
     CUETrackMode track_mode;
 
-    // Sector length for this track in bytes in the file, or 0 for audio files
+    // Sector length for this track in bytes, assuming BINARY or MOTOROLA file modes.
     uint32_t sector_length;
 
-    // Unstored pregap length, in CD frames, or 0
+    // The CD frames of PREGAP time at the start of this track, or 0 if none are present.
+    // These frames of silence are not stored in the underlying data file.
     uint32_t unstored_pregap_length;
 
-    // LBA start position of the data area of this track (in CD frames)
+    // LBA start position of the data area (INDEX 01) of this track (in CD frames)
     uint32_t data_start;
 
-    // Track start, either pregap_start or if no pregap, data_start.
+    // LBA for the beginning of the track, which will be INDEX 00 if that is present.
+    // Otherwise this will be INDEX 01 matching data_start above.
     uint32_t track_start;
 };
 

+ 6 - 5
lib/CUEParser/test/CUEParser_test.cpp

@@ -67,17 +67,18 @@ FILE "Sound.wav" WAVE
     COMMENT("Test TRACK 03 (audio with index 0)");
     track = parser.next_track();
     TEST(track != NULL);
-    uint32_t start3 = ((7 * 60) + 55) * 75 + 65;
+    uint32_t start3_i0 = ((7 * 60) + 55) * 75 + 58;
+    uint32_t start3_i1 = ((7 * 60) + 55) * 75 + 65;
     if (track)
     {
         TEST(strcmp(track->filename, "Image Name.bin") == 0);
         TEST(track->file_mode == CUEFile_BINARY);
-        TEST(track->file_offset == 2048 * start2 + 2352 * (start3 - start2));
+        TEST(track->file_offset == 2048 * start2 + 2352 * (start3_i0 - start2));
         TEST(track->track_number == 3);
         TEST(track->track_mode == CUETrack_AUDIO);
         TEST(track->sector_length == 2352);
-        TEST(track->pregap_start == ((7 * 60) + 55) * 75 + 58);
-        TEST(track->data_start == start3);
+        TEST(track->track_start == start3_i0);
+        TEST(track->data_start == start3_i1);
     }
 
     COMMENT("Test TRACK 11 (audio from wav)");
@@ -91,7 +92,7 @@ FILE "Sound.wav" WAVE
         TEST(track->track_number == 11);
         TEST(track->track_mode == CUETrack_AUDIO);
         TEST(track->sector_length == 0);
-        TEST(track->pregap_start == 0);
+        TEST(track->track_start == 0);
         TEST(track->data_start == 2 * 75);
     }