libcdio  0.90
sector.h
Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2003, 2004, 2005, 2006, 2008, 2012
00003      Rocky Bernstein <rocky@gnu.org>
00004     Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
00005 
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00058 
00059 #ifndef CDIO_SECTOR_H_
00060 #define CDIO_SECTOR_H_
00061 
00062 #ifdef __cplusplus
00063     extern "C" {
00064 #endif
00065 
00066 #include <cdio/types.h>
00067 
00071       typedef enum cdio_subchannel
00072         {
00073           CDIO_SUBCHANNEL_SUBQ_DATA             = 0,
00074           CDIO_SUBCHANNEL_CURRENT_POSITION      = 1,
00075           CDIO_SUBCHANNEL_MEDIA_CATALOG         = 2,
00076           CDIO_SUBCHANNEL_TRACK_ISRC            = 3
00077         } cdio_subchannel;
00078       
00082       typedef enum {
00083         NONE =                  0x00,   /* no flags set */
00084         PRE_EMPHASIS =          0x01,   /* audio track recorded with pre-emphasis */
00085         COPY_PERMITTED =        0x02,   /* digital copy permitted */
00086         DATA =                  0x04,   /* data track */
00087         FOUR_CHANNEL_AUDIO =    0x08,   /* 4 audio channels */
00088         SCMS =                  0x10    /* SCMS (5.29.2.7) */
00089       } flag_t;
00090       
00091 #define CDIO_PREGAP_SECTORS  150
00092 #define CDIO_POSTGAP_SECTORS 150
00093       
00099       extern enum cdio_cd_enums {
00100         CDIO_CD_MINS =              74,   
00102         CDIO_CD_SECS_PER_MIN =      60,   
00103         CDIO_CD_FRAMES_PER_SEC =    75,   
00104         CDIO_CD_SYNC_SIZE =         12,   
00106         CDIO_CD_CHUNK_SIZE =        24,   
00108         CDIO_CD_NUM_OF_CHUNKS =     98,   
00109         CDIO_CD_FRAMESIZE_SUB =     96,   
00110         CDIO_CD_HEADER_SIZE =        4,   
00112         CDIO_CD_SUBHEADER_SIZE =     8,   
00114         CDIO_CD_ECC_SIZE =         276,   
00116         CDIO_CD_FRAMESIZE =       2048,   
00118         CDIO_CD_FRAMESIZE_RAW =   2352,   
00119         CDIO_CD_FRAMESIZE_RAWER = 2646,   
00121         CDIO_CD_FRAMESIZE_RAW1  = 2340,
00122         CDIO_CD_FRAMESIZE_RAW0  = 2336,
00123         CDIO_CD_MAX_SESSIONS =      99, 
00124         CDIO_CD_MIN_SESSION_NO =     1,   
00125         CDIO_CD_MAX_LSN =       450150,   
00126         CDIO_CD_MIN_LSN      = -450150,   
00127       } cdio_cd_enums;
00128         
00134 #define CDIO_CD_MINS              74   
00136 #define CDIO_CD_SECS_PER_MIN      60   
00137 #define CDIO_CD_FRAMES_PER_SEC    75   
00138 #define CDIO_CD_SYNC_SIZE         12   
00139 #define CDIO_CD_CHUNK_SIZE        24   
00140 #define CDIO_CD_NUM_OF_CHUNKS     98   
00141 #define CDIO_CD_FRAMESIZE_SUB     96   
00142 #define CDIO_CD_HEADER_SIZE        4   
00144 #define CDIO_CD_SUBHEADER_SIZE     8   
00146 #define CDIO_CD_EDC_SIZE           4   
00148 #define CDIO_CD_M1F1_ZERO_SIZE     8   
00150 #define CDIO_CD_ECC_SIZE         276   
00152 #define CDIO_CD_FRAMESIZE       2048   
00153 #define CDIO_CD_FRAMESIZE_RAW   2352   
00154 #define CDIO_CD_FRAMESIZE_RAWER 2646   
00156 #define CDIO_CD_FRAMESIZE_RAW1 (CDIO_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE) /*2340*/
00157 #define CDIO_CD_FRAMESIZE_RAW0 (CDIO_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE-CDIO_CD_HEADER_SIZE) /*2336*/
00158       
00160 #define CDIO_CD_XA_HEADER (CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE) 
00161       
00163 #define CDIO_CD_XA_TAIL   (CDIO_CD_EDC_SIZE+CDIO_CD_ECC_SIZE) 
00164       
00166 #define CDIO_CD_XA_SYNC_HEADER   (CDIO_CD_SYNC_SIZE+CDIO_CD_XA_HEADER) 
00167       
00170       extern const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE];
00180       extern enum m2_sector_enums {
00181         M2F2_SECTOR_SIZE  = 2324,
00182         M2SUB_SECTOR_SIZE = 2332,
00183         M2RAW_SECTOR_SIZE = 2336
00184       } m2_sector_enums;
00185       
00186 #define M2F2_SECTOR_SIZE    2324
00187 #define M2SUB_SECTOR_SIZE   2332
00188 #define M2RAW_SECTOR_SIZE   2336
00189       
00191 #define CDIO_CD_MAX_SESSIONS    99 
00192 
00193 #define CDIO_CD_MIN_SESSION_NO   1
00194       
00196 #define CDIO_CD_MAX_LSN   450150
00197 
00198 #define CDIO_CD_MIN_LSN  -450150
00199       
00200       
00201 #define CDIO_CD_FRAMES_PER_MIN                          \
00202       (CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN)
00203       
00204 typedef enum cdio_cd_minutes_sectors
00205 {
00206         CDIO_CD_74MIN_SECTORS = UINT32_C(74) * CDIO_CD_FRAMES_PER_MIN,
00207         CDIO_CD_80MIN_SECTORS = UINT32_C(80) * CDIO_CD_FRAMES_PER_MIN,
00208         CDIO_CD_90MIN_SECTORS = UINT32_C(90) * CDIO_CD_FRAMES_PER_MIN,
00209       
00210         CDIO_CD_MAX_SECTORS   = UINT32_C(100) * CDIO_CD_FRAMES_PER_MIN - CDIO_PREGAP_SECTORS
00211 } cdio_cd_minutes_sectors;
00212       
00213 #define msf_t_SIZEOF 3
00214       
00218       char *cdio_lba_to_msf_str (lba_t i_lba);
00219       
00223       char *cdio_msf_to_str (const msf_t *p_msf);
00224       
00228       lba_t cdio_lba_to_lsn (lba_t i_lba);
00229       
00233       void  cdio_lba_to_msf(lba_t i_lba, msf_t *p_msf);
00234       
00239       lba_t cdio_lsn_to_lba (lsn_t i_lsn);
00240       
00244       void  cdio_lsn_to_msf (lsn_t i_lsn, msf_t *p_msf);
00245       
00250       lba_t cdio_msf_to_lba (const msf_t *p_msf);
00251       
00256       lsn_t cdio_msf_to_lsn (const msf_t *p_msf);
00257       
00263       lba_t cdio_msf3_to_lba (unsigned int minutes, unsigned int seconds, 
00264                               unsigned int frames);
00265       
00270       lba_t cdio_mmssff_to_lba (const char *psz_mmssff);
00271       
00272 #ifdef __cplusplus
00273     }
00274 #endif
00275 
00276 #ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
00277 
00278 #define CD_FRAMESIZE_RAW        CDIO_CD_FRAMESIZE_RAW
00279 #endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
00280 
00281 #endif /* CDIO_SECTOR_H_ */
00282 
00283 
00284 /* 
00285  * Local variables:
00286  *  c-file-style: "gnu"
00287  *  tab-width: 8
00288  *  indent-tabs-mode: nil
00289  * End:
00290  */