1 /* 2 $Id$ 3 4 Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> 5 (C) 2000 Jens B. Jorgensen <jbj1@ultraemail.net> 6 (C) 2005 Rocky Bernstein <rocky@gnu.org> 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24 #ifndef __VCD_FILES_PRIVATE_H__ 25 #define __VCD_FILES_PRIVATE_H__ 26 27 #include <libvcd/files.h> 28 #include <libvcd/types.h> 29 30 /* random note: most stuff is big endian here */ 31 32 #define ENTRIES_ID_VCD "ENTRYVCD" 33 #define ENTRIES_ID_VCD3 "ENTRYSVD" 34 #define ENTRIES_ID_SVCD "ENTRYVCD" /* not ENTRYSVD! */ 35 36 #define ENTRIES_VERSION_VCD 0x01 37 #define ENTRIES_SPTAG_VCD 0x00 38 39 #define ENTRIES_VERSION_VCD11 0x01 40 #define ENTRIES_SPTAG_VCD11 0x00 41 42 #define ENTRIES_VERSION_VCD2 0x02 43 #define ENTRIES_SPTAG_VCD2 0x00 44 45 #define ENTRIES_VERSION_SVCD 0x01 46 #define ENTRIES_SPTAG_SVCD 0x00 47 48 #define ENTRIES_VERSION_HQVCD 0x01 49 #define ENTRIES_SPTAG_HQVCD 0x00 50 51 PRAGMA_BEGIN_PACKED 52 53 typedef struct _EntriesVcd_tag { 54 char ID[8]; /**< "ENTRYVCD" or "ENTRYSVD" */ 55 uint8_t version; /**< 0x02 --- VCD2.0 56 0x01 --- SVCD, should be 57 same as version in 58 INFO.SVD */ 59 uint8_t sys_prof_tag; /**< 0x01 if VCD1.1 60 0x00 else */ 61 uint16_t entry_count; /**< 1 <= tracks <= 500 */ 62 struct { /* all fields are BCD */ 63 track_t n; /* cd track no 2 <= n <= 99 */ 64 msf_t msf; 65 } GNUC_PACKED entry[MAX_ENTRIES]; 66 uint8_t reserved2[36]; /* RESERVED, must be 0x00 */ 67 } GNUC_PACKED _EntriesVcd_t; /* sector 00:04:01 */ 68 69 #define EntriesVcd_t_SIZEOF ISO_BLOCKSIZE 70 71 72 #define INFO_ID_VCD "VIDEO_CD" 73 #define INFO_ID_SVCD "SUPERVCD" 74 #define INFO_ID_HQVCD "HQ-VCD " 75 76 #define INFO_VERSION_VCD 0x01 77 #define INFO_SPTAG_VCD 0x00 78 79 #define INFO_VERSION_VCD11 0x01 80 #define INFO_SPTAG_VCD11 0x01 81 82 #define INFO_VERSION_VCD2 0x02 83 #define INFO_SPTAG_VCD2 0x00 84 85 #define INFO_VERSION_SVCD 0x01 86 #define INFO_SPTAG_SVCD 0x00 87 88 #define INFO_VERSION_HQVCD 0x01 89 #define INFO_SPTAG_HQVCD 0x01 90 91 #define INFO_OFFSET_MULT 0x08 92 93 /** InfoStatusFlags: this one-byte field describes certain 94 characteristics of the disc */ 95 96 typedef struct { 97 #if defined(BITFIELD_LSBF) 98 bool reserved1 : 1; /* Reserved, must be zero */ 99 bitfield_t restriction : 2; /* restriction, eg. "unsuitable 100 for kids": 101 0x0 ==> unrestricted, 102 0x1 ==> restricted category 1, 103 0x2 ==> restricted category 2, 104 0x3 ==> restricted category 3 */ 105 bool special_info : 1; /**< Special Information is 106 encoded 107 in the pictures */ 108 bool user_data_cc : 1; /**< MPEG User Data is used 109 for Closed Caption */ 110 bool use_lid2 : 1; /**< If == 1 and the PSD is 111 interpreted and the next 112 disc has the same album 113 id then start the next 114 disc at List ID #2, 115 otherwise List ID #1 */ 116 bool use_track3 : 1; /**< If == 1 and the PSD is 117 not interpreted and 118 next disc has same album 119 id, then start next disc 120 with track 3, otherwise 121 start with track 2 */ 122 bool pbc_x : 1; /**< extended PBC available */ 123 #else 124 bool pbc_x : 1; 125 bool use_track3 : 1; 126 bool use_lid2 : 1; 127 bool user_data_cc : 1; 128 bool special_info : 1; 129 bitfield_t restriction : 2; 130 bool reserved1 : 1; 131 #endif 132 } GNUC_PACKED InfoStatusFlags_t; 133 134 #define InfoStatusFlags_t_SIZEOF 1 135 136 enum { 137 VCD_FILES_VIDEO_NOSTREAM = 0, 138 VCD_FILES_VIDEO_NTSC_STILL = 1, 139 VCD_FILES_VIDEO_NTSC_STILL2 = 2, 140 VCD_FILES_VIDEO_NTSC_MOTION = 3, 141 VCD_FILES_VIDEO_PAL_STILL = 5, 142 VCD_FILES_VIDEO_PAL_STILL2 = 6, 143 VCD_FILES_VIDEO_PAL_MOTION = 7 144 }; 145 146 typedef struct 147 { 148 #if defined(BITFIELD_LSBF) 149 bitfield_t audio_type : 2; /**< Audio characteristics: 150 0x0 - No MPEG audio stream 151 0x1 - One MPEG1 or MPEG2 audio 152 stream without extension 153 0x2 - Two MPEG1 or MPEG2 audio 154 streams without extension 155 0x3 - One MPEG2 multi-channel 156 audio stream w/ extension*/ 157 bitfield_t video_type : 3; /**< Video characteristics: 158 0x0 - No MPEG video data 159 0x1 - NTSC still picture 160 0x2 - Reserved (NTSC hires?) 161 0x3 - NTSC motion picture 162 0x4 - Reserved 163 0x5 - PAL still picture 164 0x6 - Reserved (PAL hires?) 165 0x7 - PAL motion picture */ 166 bool item_cont : 1; /**< Indicates segment is 167 continuation 168 0x0 - 1st or only segment of item 169 0x1 - 2nd or later 170 segment of item */ 171 bitfield_t ogt : 2; /**< 0x0 - no OGT substream 172 0x1 - sub-stream 0 available 173 0x2 - sub-stream 0 & 1 174 available 175 0x3 - all OGT sub-substreams 176 available */ 177 #else 178 bitfield_t ogt : 2; 179 bool item_cont : 1; 180 bitfield_t video_type : 3; 181 bitfield_t audio_type : 2; 182 #endif 183 } GNUC_PACKED InfoSpiContents_t; 184 185 #define InfoSpiContents_t_SIZEOF 1 186 187 typedef struct _InfoVcd_tag { 188 char ID[8]; /**< const "VIDEO_CD" for 189 VCD, "SUPERVCD" or 190 "HQ-VCD " for SVCD */ 191 uint8_t version; /**< 0x02 -- VCD2.0, 192 0x01 for SVCD and VCD1.x */ 193 uint8_t sys_prof_tag; /**< System Profile Tag, used 194 to define the set of 195 mandatory parts to be 196 applied for compatibility; 197 0x00 for "SUPERVCD", 198 0x01 for "HQ-VCD ", 199 0x0n for VCDx.n */ 200 char album_desc[16]; /**< album identification/desc. */ 201 uint16_t vol_count; /**< number of volumes in album */ 202 uint16_t vol_id; /**< number id of this volume in album */ 203 uint8_t pal_flags[13]; /**< bitset of 98 PAL(=set)/NTSC flags */ 204 InfoStatusFlags_t flags; /**< status flags bit field */ 205 uint32_t psd_size; /**< size of PSD.VCD file */ 206 msf_t first_seg_addr; /**< first segment addresses, 207 coded BCD The location 208 of the first sector of 209 the Segment Play Item 210 Area, in the form 211 mm:ss:00. Must be 212 00:00:00 if the PSD size 213 is 0. */ 214 uint8_t offset_mult; /**< offset multiplier, must be 8 */ 215 uint16_t lot_entries; /**< offsets in lot */ 216 uint16_t item_count; /**< segments used for segmentitems */ 217 InfoSpiContents_t spi_contents[MAX_SEGMENTS]; /**< The next 1980 bytes 218 contain one byte for each 219 possible segment play item. 220 Each byte indicates 221 contents. */ 222 223 uint16_t playing_time[5]; /**< in seconds */ 224 char reserved[2]; /**< Reserved, must be zero */ 225 } GNUC_PACKED _InfoVcd_t; 226 227 #define InfoVcd_t_SIZEOF ISO_BLOCKSIZE 228 229 /** LOT.VCD 230 This optional file is only necessary if the PSD size is not zero. 231 This List ID Offset Table allows you to start playing the PSD from 232 lists other than the default List ID number. This table has a fixed length 233 of 32 sectors and maps List ID numbers into List Offsets. It's got 234 an entry for each List ID Number with the 16-bit offset. Note that 235 List ID 1 has an offset of 0x0000. All unused or non-user-accessible 236 entries must be 0xffff. */ 237 238 #define LOT_VCD_OFFSETS ((1 << 15)-1) 239 240 typedef struct _LotVcd_tag { 241 uint16_t reserved; /* Reserved, must be zero */ 242 uint16_t offset[LOT_VCD_OFFSETS]; /* offset given in 8 byte units */ 243 } GNUC_PACKED _LotVcd_t; 244 245 #define LotVcd_t_SIZEOF (32*ISO_BLOCKSIZE) 246 247 /** PSD.VCD 248 The PSD controls the "user interaction" mode which can be used to make 249 menus, etc. The PSD contains a set of Lists. Each List defines a set of 250 Items which are played in sequence. An Item can be an mpeg track (in whole 251 or part) or a Segment Play Item which can subsequently be mpeg video 252 with or without audio, one more more mpeg still pictures (with or without 253 audio) or mpeg audio only. 254 255 The Selection List defines the action to be taken in response to a set 256 of defined user actions: Next, Previous, Default Select, Numeric, Return. 257 258 The End List terminates the control flow or switches to the next 259 disc volume. 260 261 Each list has a unique list id number. The first must be 1, the others can 262 be anything (up to 32767). 263 264 References to PSD list addresses are expressed as an offset into the PSD 265 file. The offset indicated in the file must be multiplied by the Offset 266 Multiplier found in the info file (although this seems to always have to 267 be 8). Unused areas are filled with zeros. List ID 1 starts at offset 0. 268 */ 269 270 /* ...difficult to represent as monolithic C struct... */ 271 272 typedef struct { 273 uint8_t type; /* PSD_TYPE_END_LIST */ 274 uint8_t next_disc; /* 0x00 to stop PBC or 0xnn to switch to disc no nn */ 275 uint16_t change_pic; /* 0 or 1000..2979, should be still image */ 276 uint8_t reserved[4]; /* padded with 0x00 */ 277 } GNUC_PACKED PsdEndListDescriptor_t; 278 279 #define PsdEndListDescriptor_t_SIZEOF 8 280 281 typedef struct { 282 #if defined(BITFIELD_LSBF) 283 bool SelectionAreaFlag : 1; 284 bool CommandListFlag : 1; 285 bitfield_t reserved : 6; 286 #else 287 bitfield_t reserved : 6; 288 bool CommandListFlag : 1; 289 bool SelectionAreaFlag : 1; 290 #endif 291 } GNUC_PACKED PsdSelectionListFlags_t; 292 293 #define PsdSelectionListFlags_t_SIZEOF 1 294 295 typedef struct _PsdSelectionListDescriptor_tag { 296 uint8_t type; 297 PsdSelectionListFlags_t flags; 298 uint8_t nos; 299 uint8_t bsn; 300 uint16_t lid; 301 uint16_t prev_ofs; 302 uint16_t next_ofs; 303 uint16_t return_ofs; 304 uint16_t default_ofs; 305 uint16_t timeout_ofs; 306 uint8_t totime; 307 uint8_t loop; 308 uint16_t itemid; 309 uint16_t ofs[EMPTY_ARRAY_SIZE]; /* variable length */ 310 /* PsdSelectionListDescriptorExtended */ 311 } GNUC_PACKED _PsdSelectionListDescriptor_t; 312 313 #define PsdSelectionListDescriptor_t_SIZEOF 20 314 315 typedef struct { 316 struct psd_area_t prev_area; 317 struct psd_area_t next_area; 318 struct psd_area_t return_area; 319 struct psd_area_t default_area; 320 struct psd_area_t area[EMPTY_ARRAY_SIZE]; /* variable length */ 321 } GNUC_PACKED PsdSelectionListDescriptorExtended_t; 322 323 #define PsdSelectionListDescriptorExtended_t_SIZEOF 16 324 325 typedef struct { 326 uint8_t type; 327 uint16_t command_count; 328 uint16_t lid; 329 uint16_t command[EMPTY_ARRAY_SIZE]; /* variable length */ 330 } GNUC_PACKED PsdCommandListDescriptor_t; 331 332 #define PsdCommandListDescriptor_t_SIZEOF 5 333 334 typedef struct _PsdPlayListDescriptor_tag { 335 uint8_t type; 336 uint8_t noi; /**< number of items */ 337 uint16_t lid; /**< list id: high-bit means this list is rejected in 338 the LOT (also, can't use 0) */ 339 uint16_t prev_ofs; /**< previous list offset (0xffff disables) */ 340 uint16_t next_ofs; /**< next list offset (0xffff disables) */ 341 uint16_t return_ofs; /**< return list offset (0xffff disables) */ 342 uint16_t ptime; /**< play time in 1/15 s, 0x0000 meaning full item */ 343 uint8_t wtime; /**< delay after, in seconds, if 1 <= wtime <= 60 wait 344 is wtime else if 61 <= wtime <= 254 wait is 345 (wtime-60) * 10 + 60 else wtime == 255 wait is 346 infinite */ 347 uint8_t atime; /**< auto pause wait time calculated same as wtime, 348 used for each item in list if the auto pause flag 349 in a sector is true */ 350 uint16_t itemid[EMPTY_ARRAY_SIZE]; /**< item number 351 0 <= n <= 1 - play nothing 352 2 <= n <= 99 - play track n 353 100 <= n <= 599 - play entry 354 (n - 99) from entries 355 table to end of track 356 600 <= n <= 999 - reserved 357 1000 <= n <= 2979 - play segment 358 play item (n - 999) 359 2980 <= n <= 0xffff - reserved */ 360 } GNUC_PACKED _PsdPlayListDescriptor_t; 361 362 /* For backwards compatibility. Don't use PsdListDescriptor. */ 363 #define _PsdPlayListDescriptor _PsdPlayListDescriptor_t 364 365 366 #define PsdPlayListDescriptor_t_SIZEOF 14 367 368 /* TRACKS.SVD 369 SVCD\TRACKS.SVD is a mandatory file which describes the numbers and types 370 of MPEG tracks on the disc. */ 371 372 /* SVDTrackContent indicates the audio/video content of an MPEG Track */ 373 374 typedef struct { 375 #if defined(BITFIELD_LSBF) 376 bitfield_t audio : 2; /**< Audio Content 377 0x00 : No MPEG audio stream 378 0x01 : One MPEG{1|2} audio stream 379 0x02 : Two MPEG{1|2} streams 380 0x03 : One MPEG2 multi-channel 381 audio stream with 382 extension */ 383 bitfield_t video : 3; /**< Video Content 384 0x00 : No MPEG video 385 0x03 : NTSC video 386 0x07 : PAL video */ 387 bool reserved1 : 1; /**< Reserved, must be zero */ 388 bitfield_t ogt : 2; /**< 0x0 - no OGT substream 389 0x1 - sub-stream 0 available 390 0x2 - sub-stream 0 & 1 available 391 0x3 - all OGT sub-substreams 392 available */ 393 #else 394 bitfield_t ogt : 2; 395 bool reserved1 : 1; 396 bitfield_t video : 3; 397 bitfield_t audio : 2; 398 #endif 399 } GNUC_PACKED SVDTrackContent_t; 400 401 #define SVDTrackContent_t_SIZEOF 1 402 403 /** The TRACKS.SVD file contains a series of structures, one for each 404 track, which indicates the track's playing time (in sectors, not 405 actually real time) and contents. */ 406 407 #define TRACKS_SVD_FILE_ID "TRACKSVD" 408 #define TRACKS_SVD_VERSION 0x01 409 410 typedef struct { 411 char file_id[sizeof(TRACKS_SVD_FILE_ID)-1]; /**< == "TRACKSVD" with out 412 final NULL byte */ 413 uint8_t version; /**< == 0x01 */ 414 uint8_t reserved; /**< Reserved, must be zero */ 415 uint8_t tracks; /**< number of MPEG tracks */ 416 msf_t playing_time[EMPTY_ARRAY_SIZE]; /**< per track, BCD coded 417 mm:ss:ff */ 418 } GNUC_PACKED TracksSVD_t; 419 420 #define TracksSVD_t_SIZEOF 11 421 422 typedef struct { 423 /* TracksSVD tracks_svd; */ 424 SVDTrackContent_t contents[1]; /**< should be [], but C99 doesn't allow it 425 indicates track contents */ 426 } GNUC_PACKED TracksSVD2_t; 427 428 #define TracksSVD2_t_SIZEOF SVDTrackContent_t_SIZEOF 429 430 /** VCD30 TRACKS.SVD file. */ 431 432 typedef struct { 433 char file_id[sizeof(TRACKS_SVD_FILE_ID)-1]; /**< == "TRACKSVD" */ 434 uint8_t version; /**< == 0x01 */ 435 uint8_t reserved; /**< Reserved, must be zero */ 436 uint8_t tracks; /**< number of MPEG tracks */ 437 struct { 438 msf_t cum_playing_time; /**< BCD coded mm:ss:ff */ 439 uint8_t ogt_info; 440 uint8_t audio_info; 441 } GNUC_PACKED track[EMPTY_ARRAY_SIZE]; 442 } GNUC_PACKED TracksSVD_v30_t; 443 444 #define TracksSVD_v30_t_SIZEOF 11 445 446 /** SVCD/SEARCH.DAT 447 This file defines where the scan points are. It covers all mpeg tracks 448 together. A scan point at time T is the nearest I-picture in the MPEG 449 stream to the given time T. Scan points are given at every half-second 450 for the entire duration of the disc. */ 451 452 #define SEARCH_FILE_ID "SEARCHSV" 453 #define SEARCH_VERSION 0x01 454 #define SEARCH_TIME_INTERVAL 0x01 455 456 typedef struct { 457 char file_id[sizeof(SEARCH_FILE_ID)-1]; /**< == "SEARCHSV" without final 458 NULL byte */ 459 uint8_t version; /**< = 0x01 */ 460 uint8_t reserved; /**< Reserved, must be zero */ 461 uint16_t scan_points; /**< the number of scan points */ 462 uint8_t time_interval; /**< The interval of time in 463 between scan points, in units 464 of 0.5 seconds, must be 0x01 */ 465 msf_t points[EMPTY_ARRAY_SIZE]; /**< The series of scan points */ 466 } GNUC_PACKED SearchDat_t; 467 468 #define SearchDat_t_SIZEOF 13 469 470 /* SPICONTX.SVD 471 */ 472 473 #define SPICONTX_FILE_ID "SPICONSV" 474 #define SPICONTX_VERSION 0x01 475 476 typedef struct { 477 char file_id[sizeof(SPICONTX_FILE_ID)-1]; /**< = "SPICONSV" without final 478 NULL byte */ 479 uint8_t version; /**< = 0x01 */ 480 uint8_t reserved; /**< Reserved, must be zero */ 481 struct { 482 uint8_t ogt_info; 483 uint8_t audio_info; 484 } GNUC_PACKED spi[MAX_SEGMENTS]; 485 uint8_t reserved2[126]; /**< 0x00 */ 486 } GNUC_PACKED SpicontxSvd_t; 487 488 #define SpicontxSvd_t_SIZEOF (2*ISO_BLOCKSIZE) 489 490 /** SCANDATA.DAT for VCD 2.0 */ 491 492 #define SCANDATA_FILE_ID "SCAN_VCD" 493 #define SCANDATA_VERSION_VCD2 0x02 494 #define SCANDATA_VERSION_SVCD 0x01 495 496 typedef struct { 497 char file_id[sizeof(SCANDATA_FILE_ID)-1]; /**< == "SCAN_VCD" without final 498 NULL byte */ 499 uint8_t version; /**< = 0x02 */ 500 uint8_t reserved; /**< Reserved, must be zero */ 501 uint16_t scan_points; /**< the number of scan points */ 502 msf_t points[EMPTY_ARRAY_SIZE]; /**< actual scan points 503 points[time(iframe)/0.5] */ 504 } GNUC_PACKED ScandataDat_v2_t; 505 506 #define ScandataDat_v2_t_SIZEOF 12 507 508 /** SCANDATA.DAT for SVCD 509 This file fulfills much the same purpose of the SEARCH.DAT file except 510 that this file is mandatory only if the System Profile Tag of the 511 INFO.SVD file is 0x01 (HQ-VCD) and also that it contains sector addresses 512 also for each video Segment Play Items in addition to the regular MPEG 513 tracks. */ 514 515 typedef struct { 516 char file_id[sizeof(SCANDATA_FILE_ID)-1]; /**< == "SCAN_VCD" without final 517 NULL byte */ 518 uint8_t version; /**< = 0x01 */ 519 uint8_t reserved; /**< Reserved, must be zero */ 520 uint16_t scandata_count; /**< number of 3-byte entries in 521 the table */ 522 uint16_t track_count; /**< number of MPEG tracks on 523 disc */ 524 uint16_t spi_count; /**< number of consecutively 525 recorded play item segments 526 (as opposed to the number of 527 segment play items). */ 528 msf_t cum_playtimes[EMPTY_ARRAY_SIZE]; /**< cumulative playing 529 time up to track 530 N. Track time just wraps 531 at 99:59:74 */ 532 } GNUC_PACKED ScandataDat1_t; 533 534 #define ScandataDat1_t_SIZEOF 16 535 536 typedef struct { 537 /* ScandataDat head; */ 538 uint16_t spi_indexes[1]; /* should be [], but C doesn't allow that; 539 Indexes into the following scandata 540 table */ 541 } GNUC_PACKED ScandataDat2_t; 542 543 #define ScandataDat2_t_SIZEOF sizeof(uint16_t) 544 545 typedef struct { 546 /* ScandataDat2 head; */ 547 uint16_t mpegtrack_start_index; /* Index into the 548 following scandata table 549 where the MPEG track 550 scan points start */ 551 552 /* The scandata table starts here */ 553 struct { 554 uint8_t track_num; /* Track number as in TOC */ 555 uint16_t table_offset; /* Index into scandata table */ 556 } GNUC_PACKED mpeg_track_offsets[EMPTY_ARRAY_SIZE]; 557 } GNUC_PACKED ScandataDat3_t; 558 559 #define ScandataDat3_t_SIZEOF 2 560 561 typedef struct { 562 /* ScandataDat3 head; */ 563 msf_t scandata_table[1]; /* should be [] but C99 doesn't allow that */ 564 } GNUC_PACKED ScandataDat4_t; 565 566 #define ScandataDat4_t_SIZEOF msf_t_SIZEOF 567 568 PRAGMA_END_PACKED 569 570 #endif /* __VCD_FILES_PRIVATE_H__ */ 571 572 573 /* 574 * Local variables: 575 * c-file-style: "gnu" 576 * tab-width: 8 577 * indent-tabs-mode: nil 578 * End: 579 */ 580