1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-15 19:35:49 +00:00

TOCADDR macro as first step to common *BSD vcd reading code

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23867 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2007-07-26 22:51:23 +00:00
parent c36203ad76
commit 2134bb4673
2 changed files with 50 additions and 45 deletions

View File

@ -3,6 +3,7 @@
//=================== VideoCD ========================== //=================== VideoCD ==========================
#define CDROM_LEADOUT 0xAA #define CDROM_LEADOUT 0xAA
#define TOCADDR(te) ((te).entry.addr)
typedef struct { typedef struct {
uint8_t sync [12]; uint8_t sync [12];
@ -19,17 +20,17 @@ typedef struct mp_vcd_priv_st {
} mp_vcd_priv_t; } mp_vcd_priv_t;
static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){ static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){
vcd->entry.entry.addr.msf.frame=sect%75; TOCADDR(vcd->entry).msf.frame=sect%75;
sect=sect/75; sect=sect/75;
vcd->entry.entry.addr.msf.second=sect%60; TOCADDR(vcd->entry).msf.second=sect%60;
sect=sect/60; sect=sect/60;
vcd->entry.entry.addr.msf.minute=sect; TOCADDR(vcd->entry).msf.minute=sect;
} }
static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){ static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){
return vcd->entry.entry.addr.msf.frame + return TOCADDR(vcd->entry).msf.frame +
(vcd->entry.entry.addr.msf.second+ (TOCADDR(vcd->entry).msf.second+
vcd->entry.entry.addr.msf.minute*60)*75; TOCADDR(vcd->entry).msf.minute*60)*75;
} }
int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track){ int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track){
@ -84,18 +85,18 @@ mp_vcd_priv_t* vcd_read_toc(int fd){
(int)tocentry.entry.addr_type, (int)tocentry.entry.addr_type,
(int)tocentry.entry.control, (int)tocentry.entry.control,
(int)tocentry.address_format, (int)tocentry.address_format,
(int)tocentry.entry.addr.msf.minute, (int)TOCADDR(tocentry).msf.minute,
(int)tocentry.entry.addr.msf.second, (int)TOCADDR(tocentry).msf.second,
(int)tocentry.entry.addr.msf.frame (int)TOCADDR(tocentry).msf.frame
); );
if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
{ {
if (i > tochdr.starting_track) if (i > tochdr.starting_track)
{ {
min = tocentry.entry.addr.msf.minute - min; min = TOCADDR(tocentry).msf.minute - min;
sec = tocentry.entry.addr.msf.second - sec; sec = TOCADDR(tocentry).msf.second - sec;
frame = tocentry.entry.addr.msf.frame - frame; frame = TOCADDR(tocentry).msf.frame - frame;
if ( frame < 0 ) if ( frame < 0 )
{ {
frame += 75; frame += 75;
@ -108,9 +109,9 @@ mp_vcd_priv_t* vcd_read_toc(int fd){
} }
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame);
} }
min = tocentry.entry.addr.msf.minute; min = TOCADDR(tocentry).msf.minute;
sec = tocentry.entry.addr.msf.second; sec = TOCADDR(tocentry).msf.second;
frame = tocentry.entry.addr.msf.frame; frame = TOCADDR(tocentry).msf.frame;
} }
} }
vcd = malloc(sizeof(mp_vcd_priv_t)); vcd = malloc(sizeof(mp_vcd_priv_t));
@ -123,13 +124,13 @@ static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE)
!= VCD_SECTOR_SIZE) return 0; // EOF? != VCD_SECTOR_SIZE) return 0; // EOF?
vcd->entry.entry.addr.msf.frame++; TOCADDR(vcd->entry).msf.frame++;
if (vcd->entry.entry.addr.msf.frame==75){ if (TOCADDR(vcd->entry).msf.frame==75){
vcd->entry.entry.addr.msf.frame=0; TOCADDR(vcd->entry).msf.frame=0;
vcd->entry.entry.addr.msf.second++; TOCADDR(vcd->entry).msf.second++;
if (vcd->entry.entry.addr.msf.second==60){ if (TOCADDR(vcd->entry).msf.second==60){
vcd->entry.entry.addr.msf.second=0; TOCADDR(vcd->entry).msf.second=0;
vcd->entry.entry.addr.msf.minute++; TOCADDR(vcd->entry).msf.minute++;
} }
} }
memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA); memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA);

View File

@ -7,6 +7,7 @@
#include <sys/scsiio.h> #include <sys/scsiio.h>
#define CDROM_LEADOUT 0xAA #define CDROM_LEADOUT 0xAA
#define TOCADDR(te) ((te).data->addr)
typedef struct mp_vcd_priv_st { typedef struct mp_vcd_priv_st {
int fd; int fd;
@ -17,23 +18,25 @@ typedef struct mp_vcd_priv_st {
static inline void static inline void
vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect) vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect)
{ {
vcd->entry_data.addr.msf.frame = sect % 75; vcd->entry.data = &vcd->entry_data;
TOCADDR(vcd->entry).msf.frame = sect % 75;
sect = sect / 75; sect = sect / 75;
vcd->entry_data.addr.msf.second = sect % 60; TOCADDR(vcd->entry).msf.second = sect % 60;
sect = sect / 60; sect = sect / 60;
vcd->entry_data.addr.msf.minute = sect; TOCADDR(vcd->entry).msf.minute = sect;
} }
static inline void static inline void
vcd_inc_msf(mp_vcd_priv_t* vcd) vcd_inc_msf(mp_vcd_priv_t* vcd)
{ {
vcd->entry_data.addr.msf.frame++; vcd->entry.data = &vcd->entry_data;
if (vcd->entry_data.addr.msf.frame==75){ TOCADDR(vcd->entry).msf.frame++;
vcd->entry_data.addr.msf.frame=0; if (TOCADDR(vcd->entry).msf.frame==75){
vcd->entry_data.addr.msf.second++; TOCADDR(vcd->entry).msf.frame=0;
if (vcd->entry_data.addr.msf.second==60){ TOCADDR(vcd->entry).msf.second++;
vcd->entry_data.addr.msf.second=0; if (TOCADDR(vcd->entry).msf.second==60){
vcd->entry_data.addr.msf.minute++; TOCADDR(vcd->entry).msf.second=0;
TOCADDR(vcd->entry).msf.minute++;
} }
} }
} }
@ -41,9 +44,10 @@ vcd_inc_msf(mp_vcd_priv_t* vcd)
static inline unsigned int static inline unsigned int
vcd_get_msf(mp_vcd_priv_t* vcd) vcd_get_msf(mp_vcd_priv_t* vcd)
{ {
return vcd->entry_data.addr.msf.frame + vcd->entry.data = &vcd->entry_data;
(vcd->entry_data.addr.msf.second + return TOCADDR(vcd->entry).msf.frame +
vcd->entry_data.addr.msf.minute * 60) * 75; (TOCADDR(vcd->entry).msf.second +
TOCADDR(vcd->entry).msf.minute * 60) * 75;
} }
int int
@ -107,21 +111,21 @@ vcd_read_toc(int fd)
if (i <= tochdr.ending_track) if (i <= tochdr.ending_track)
mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
(int) tocentry.starting_track, (int) tocentry.starting_track,
(int) tocentry.data->addr_type, (int) TOCADDR(tocentry)_type,
(int) tocentry.data->control, (int) tocentry.data->control,
(int) tocentry.address_format, (int) tocentry.address_format,
(int) tocentry.data->addr.msf.minute, (int) TOCADDR(tocentry).msf.minute,
(int) tocentry.data->addr.msf.second, (int) TOCADDR(tocentry).msf.second,
(int) tocentry.data->addr.msf.frame (int) TOCADDR(tocentry).msf.frame
); );
if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
{ {
if (i > tochdr.starting_track) if (i > tochdr.starting_track)
{ {
min = tocentry.data->addr.msf.minute - min; min = TOCADDR(tocentry).msf.minute - min;
sec = tocentry.data->addr.msf.second - sec; sec = TOCADDR(tocentry).msf.second - sec;
frame = tocentry.data->addr.msf.frame - frame; frame = TOCADDR(tocentry).msf.frame - frame;
if ( frame < 0 ) if ( frame < 0 )
{ {
frame += 75; frame += 75;
@ -134,9 +138,9 @@ vcd_read_toc(int fd)
} }
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame);
} }
min = tocentry.data->addr.msf.minute; min = TOCADDR(tocentry).msf.minute;
sec = tocentry.data->addr.msf.second; sec = TOCADDR(tocentry).msf.second;
frame = tocentry.data->addr.msf.frame; frame = TOCADDR(tocentry).msf.frame;
} }
} }
vcd = malloc(sizeof(mp_vcd_priv_t)); vcd = malloc(sizeof(mp_vcd_priv_t));