Hoist common track mode, disk format and disk flags into sector.h

Hoist track information into image.h
This commit is contained in:
rocky
2004-07-10 02:17:57 +00:00
parent b525effb95
commit 13af656fea
7 changed files with 123 additions and 122 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: sector.h,v 1.15 2004/07/10 01:21:19 rocky Exp $ $Id: sector.h,v 1.16 2004/07/10 02:17:57 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -67,6 +67,39 @@
#include <cdio/types.h> #include <cdio/types.h>
/*! track modes (Table 350)
reference: MMC-3 draft revsion - 10g
*/
typedef enum {
AUDIO, /**< 2352 byte block length */
MODE1, /**< 2048 byte block length */
MODE1_RAW, /**< 2352 byte block length */
MODE2, /**< 2336 byte block length */
MODE2_FORM1, /**< 2048 byte block length */
MODE2_FORM2, /**< 2324 byte block length */
MODE2_FORM_MIX, /**< 2336 byte block length */
MODE2_RAW /**< 2352 byte block length */
} trackmode_t;
/*! disc modes (5.29.2.8) */
typedef enum {
CD_DA, /* CD-DA */
CD_ROM, /* CD-ROM mode 1 */
CD_ROM_XA /* CD-ROM XA and CD-I */
} discmode_t;
/*! track flags
* Q Sub-channel Control Field (4.2.3.3)
*/
typedef enum {
NONE = 0x00, /* no flags set */
PRE_EMPHASIS = 0x01, /* audio track recorded with pre-emphasis */
COPY_PERMITTED = 0x02, /* digital copy permitted */
DATA = 0x04, /* data track */
FOUR_CHANNEL_AUDIO = 0x08, /* 4 audio channels */
SCMS = 0x10 /* SCMS (5.29.2.7) */
} flag_t;
#define CDIO_PREGAP_SECTORS 150 #define CDIO_PREGAP_SECTORS 150
#define CDIO_POSTGAP_SECTORS 150 #define CDIO_POSTGAP_SECTORS 150

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.41 2004/07/09 01:05:31 rocky Exp $ # $Id: Makefile.am,v 1.42 2004/07/10 02:17:58 rocky Exp $
# #
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
# #
@@ -75,6 +75,7 @@ libcdio_sources = \
FreeBSD/freebsd.h \ FreeBSD/freebsd.h \
FreeBSD/freebsd_cam.c \ FreeBSD/freebsd_cam.c \
FreeBSD/freebsd_ioctl.c \ FreeBSD/freebsd_ioctl.c \
image.h \
image/bincue.c \ image/bincue.c \
image/cdrdao.c \ image/cdrdao.c \
image_common.h \ image_common.h \

71
lib/image.h Normal file
View File

@@ -0,0 +1,71 @@
/*
$Id: image.h,v 1.1 2004/07/10 02:17:59 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Common image routines. */
#ifndef __CDIO_IMAGE_H__
#define __CDIO_IMAGE_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/types.h>
#include <cdio/cdtext.h>
#include "cdio_private.h"
#include <cdio/sector.h>
/*!
The universal format for information about a track for CD image readers
It may be that some fields can be derived from other fields.
Over time this structure may get cleaned up. Possibly this can be
expanded/reused for real CD formats.
*/
typedef struct {
track_t track_num; /**< Probably is index+1 */
msf_t start_msf;
lba_t start_lba;
int start_index;
lba_t length;
lba_t pregap; /**< pre-gap with zero audio data */
int sec_count; /**< Number of sectors in this track. Does not
include pregap */
int num_indices;
flag_t flags; /**< "[NO] COPY", "4CH", "[NO] PREMPAHSIS" */
char *isrc; /**< IRSC Code (5.22.4) exactly 12 bytes */
char *filename;
CdioDataSource *data_source;
track_format_t track_format;
bool track_green;
cdtext_t *cdtext; /**< CD-TEXT */
trackmode_t mode;
uint16_t datasize; /**< How much is in the portion we return
back? */
uint16_t datastart; /**< Offset from begining that data starts */
uint16_t endsize; /**< How much stuff at the end to skip over.
This stuff may have error correction
(EDC, or ECC).*/
uint16_t blocksize; /**< total block size = start + size + end */
} track_info_t;
#endif /* __CDIO_IMAGE_H__ */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: bincue.c,v 1.29 2004/07/10 01:21:20 rocky Exp $ $Id: bincue.c,v 1.30 2004/07/10 02:17:59 rocky Exp $
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -26,16 +26,15 @@
(*.cue). (*.cue).
*/ */
static const char _rcsid[] = "$Id: bincue.c,v 1.29 2004/07/10 01:21:20 rocky Exp $"; static const char _rcsid[] = "$Id: bincue.c,v 1.30 2004/07/10 02:17:59 rocky Exp $";
#include "image.h"
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
#include "_cdio_stdio.h" #include "_cdio_stdio.h"
#include <cdio/logging.h> #include <cdio/logging.h>
#include <cdio/sector.h>
#include <cdio/util.h> #include <cdio/util.h>
#include <cdio/cdtext.h>
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
#include <stdio.h> #include <stdio.h>
@@ -71,63 +70,6 @@ static const char _rcsid[] = "$Id: bincue.c,v 1.29 2004/07/10 01:21:20 rocky Exp
#define DEFAULT_CDIO_DEVICE "videocd.bin" #define DEFAULT_CDIO_DEVICE "videocd.bin"
#define DEFAULT_CDIO_CUE "videocd.cue" #define DEFAULT_CDIO_CUE "videocd.cue"
/* track modes (Table 350) */
typedef enum {
AUDIO, /* 2352 byte block length */
MODE1, /* 2048 byte block length */
MODE1_RAW, /* 2352 byte block length */
MODE2, /* 2336 byte block length */
MODE2_FORM1, /* 2048 byte block length */
MODE2_FORM2, /* 2324 byte block length */
MODE2_FORM_MIX, /* 2336 byte block length */
MODE2_RAW /* 2352 byte block length */
} trackmode_t;
/* disc modes (5.29.2.8) */
typedef enum {
CD_DA, /* CD-DA */
CD_ROM, /* CD-ROM mode 1 */
CD_ROM_XA /* CD-ROM XA and CD-I */
} discmode_t;
/* track flags
* Q Sub-channel Control Field (4.2.3.3)
*/
typedef enum {
NONE = 0x00, /* no flags set */
PRE_EMPHASIS = 0x01, /* audio track recorded with pre-emphasis */
COPY_PERMITTED = 0x02, /* digital copy permitted */
DATA = 0x04, /* data track */
FOUR_CHANNEL_AUDIO = 0x08, /* 4 audio channels */
SCMS = 0x10 /* SCMS (5.29.2.7) */
} flag_t;
typedef struct {
track_t track_num; /* Probably is index+1 */
msf_t start_msf;
lba_t start_lba;
int start_index;
int sec_count; /* Number of sectors in this track. Does not
include pregap */
int num_indices;
flag_t flags; /* "DCP", "4CH", "PRE" */
track_format_t track_format;
char *filename;
bool track_green;
long int pregap; /* pre-gap with zero audio data */
char *isrc; /* IRSC Code (5.22.4) exactly 12 bytes */
cdtext_t *cdtext; /* CD-TEXT */
trackmode_t mode;
uint16_t datasize; /* How much is in the portion we return back? */
uint16_t datastart; /* Offset from begining that data starts */
uint16_t endsize; /* How much stuff at the end to skip over. This
stuff may have error correction (EDC, or ECC).*/
uint16_t blocksize; /* total block size = start + size + end */
} track_info_t;
typedef struct { typedef struct {
/* Things common to all drivers like this. /* Things common to all drivers like this.
This must be first. */ This must be first. */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdrdao.c,v 1.15 2004/07/10 01:21:20 rocky Exp $ $Id: cdrdao.c,v 1.16 2004/07/10 02:17:59 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
toc reading routine adapted from cuetools toc reading routine adapted from cuetools
@@ -25,20 +25,15 @@
(*.cue). (*.cue).
*/ */
#ifdef HAVE_CONFIG_H static const char _rcsid[] = "$Id: cdrdao.c,v 1.16 2004/07/10 02:17:59 rocky Exp $";
# include "config.h"
#endif
static const char _rcsid[] = "$Id: cdrdao.c,v 1.15 2004/07/10 01:21:20 rocky Exp $";
#include "image.h"
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h"
#include "_cdio_stdio.h" #include "_cdio_stdio.h"
#include <cdio/logging.h> #include <cdio/logging.h>
#include <cdio/sector.h> #include <cdio/sector.h>
#include <cdio/util.h> #include <cdio/util.h>
#include <cdio/cdtext.h>
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
#include <stdio.h> #include <stdio.h>
@@ -73,32 +68,7 @@ static const char _rcsid[] = "$Id: cdrdao.c,v 1.15 2004/07/10 01:21:20 rocky Exp
/* reader */ /* reader */
#define DEFAULT_CDIO_DEVICE "videocd.bin" #define DEFAULT_CDIO_DEVICE "videocd.bin"
#define DEFAULT_CDIO_CDRDAO "videocd.toc" #define DEFAULT_CDIO_CDRDAO "videocd.toc"
typedef struct {
track_t track_num; /* Probably is index+1 */
msf_t start_msf;
lba_t start_lba;
lba_t length;
lba_t pregap;
int start_index;
int sec_count; /* Number of sectors in this track. Does not
include pregap */
int num_indices;
int flags; /* "DCP", "4CH", "PRE" */
char *isrc; /* IRSC Code (5.22.4) exactly 12 bytes. */
char *filename; /* name given inside TOC file. */
CdioDataSource *data_source;
track_format_t track_format;
bool track_green;
uint16_t datasize; /* How much is in the portion we return back? */
uint16_t datastart; /* Offset from begining that data starts */
uint16_t endsize; /* How much stuff at the end to skip over. This
stuff may have error correction (EDC, or ECC).*/
uint16_t blocksize; /* total block size = start + size + end */
} track_info_t;
typedef struct { typedef struct {
/* Things common to all drivers like this. /* Things common to all drivers like this.

View File

@@ -1,5 +1,5 @@
/* /*
$Id: nrg.c,v 1.26 2004/07/09 02:46:42 rocky Exp $ $Id: nrg.c,v 1.27 2004/07/10 02:17:59 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -22,9 +22,7 @@
CD-image format residing inside a disk file (*.nrg). CD-image format residing inside a disk file (*.nrg).
*/ */
#ifdef HAVE_CONFIG_H #include "image.h"
#include "config.h"
#endif
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
#include <stdio.h> #include <stdio.h>
@@ -40,39 +38,20 @@
#endif #endif
#include <cdio/logging.h> #include <cdio/logging.h>
#include <cdio/sector.h>
#include <cdio/util.h> #include <cdio/util.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include "bytesex.h" #include "bytesex.h"
#include "ds.h" #include "ds.h"
#include "cdio_private.h"
#include "_cdio_stdio.h" #include "_cdio_stdio.h"
#include "nrg.h" #include "nrg.h"
static const char _rcsid[] = "$Id: nrg.c,v 1.26 2004/07/09 02:46:42 rocky Exp $"; static const char _rcsid[] = "$Id: nrg.c,v 1.27 2004/07/10 02:17:59 rocky Exp $";
/* reader */ /* reader */
#define DEFAULT_CDIO_DEVICE "image.nrg" #define DEFAULT_CDIO_DEVICE "image.nrg"
typedef struct {
int track_num; /* Probably is index+1 */
msf_t start_msf;
lba_t start_lba;
int start_index;
int sec_count; /* Number of sectors in track. Does not
include pregap before next entry. */
int flags; /* don't copy, 4 channel audio, pre emphasis */
track_format_t track_format;
bool track_green;
uint16_t datasize; /* How much is in the portion we return back? */
long int datastart; /* Offset from begining that data starts */
uint16_t endsize; /* How much stuff at the end to skip over. This
stuff may have error correction (EDC, or ECC).*/
uint16_t blocksize; /* total block size = start + size + end */
} track_info_t;
/* /*
Link element of track structure as a linked list. Link element of track structure as a linked list.
Possibly redundant with above track_info_t */ Possibly redundant with above track_info_t */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: image_common.h,v 1.6 2004/07/09 02:46:42 rocky Exp $ $Id: image_common.h,v 1.7 2004/07/10 02:17:59 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -20,6 +20,9 @@
/* Common image routines. */ /* Common image routines. */
#ifndef __CDIO_IMAGE_COMMON_H__
#define __CDIO_IMAGE_COMMON_H__
/*! /*!
Return the media catalog number (MCN) from the CD or NULL if there Return the media catalog number (MCN) from the CD or NULL if there
is none or we don't have the ability to get it. is none or we don't have the ability to get it.
@@ -82,3 +85,5 @@ _get_num_tracks_image(void *user_data)
return env->i_tracks; return env->i_tracks;
} }
#endif /* __CDIO_IMAGE_COMMON_H__ */