Mercurial > mplayer.hg
changeset 23847:773e6c50d1b8
TOCADDR macro as first step to common *BSD vcd reading code
author | reimar |
---|---|
date | Thu, 26 Jul 2007 22:51:23 +0000 |
parents | 21aab907150e |
children | 2ab8edad035d |
files | stream/vcd_read_fbsd.h stream/vcd_read_nbsd.h |
diffstat | 2 files changed, 50 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/vcd_read_fbsd.h Thu Jul 26 09:54:57 2007 +0000 +++ b/stream/vcd_read_fbsd.h Thu Jul 26 22:51:23 2007 +0000 @@ -3,6 +3,7 @@ //=================== VideoCD ========================== #define CDROM_LEADOUT 0xAA +#define TOCADDR(te) ((te).entry.addr) typedef struct { uint8_t sync [12]; @@ -19,17 +20,17 @@ } mp_vcd_priv_t; 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; - vcd->entry.entry.addr.msf.second=sect%60; + TOCADDR(vcd->entry).msf.second=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){ - return vcd->entry.entry.addr.msf.frame + - (vcd->entry.entry.addr.msf.second+ - vcd->entry.entry.addr.msf.minute*60)*75; + return TOCADDR(vcd->entry).msf.frame + + (TOCADDR(vcd->entry).msf.second+ + TOCADDR(vcd->entry).msf.minute*60)*75; } int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track){ @@ -84,18 +85,18 @@ (int)tocentry.entry.addr_type, (int)tocentry.entry.control, (int)tocentry.address_format, - (int)tocentry.entry.addr.msf.minute, - (int)tocentry.entry.addr.msf.second, - (int)tocentry.entry.addr.msf.frame + (int)TOCADDR(tocentry).msf.minute, + (int)TOCADDR(tocentry).msf.second, + (int)TOCADDR(tocentry).msf.frame ); if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) { if (i > tochdr.starting_track) { - min = tocentry.entry.addr.msf.minute - min; - sec = tocentry.entry.addr.msf.second - sec; - frame = tocentry.entry.addr.msf.frame - frame; + min = TOCADDR(tocentry).msf.minute - min; + sec = TOCADDR(tocentry).msf.second - sec; + frame = TOCADDR(tocentry).msf.frame - frame; if ( frame < 0 ) { frame += 75; @@ -108,9 +109,9 @@ } 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; - sec = tocentry.entry.addr.msf.second; - frame = tocentry.entry.addr.msf.frame; + min = TOCADDR(tocentry).msf.minute; + sec = TOCADDR(tocentry).msf.second; + frame = TOCADDR(tocentry).msf.frame; } } vcd = malloc(sizeof(mp_vcd_priv_t)); @@ -123,13 +124,13 @@ if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) != VCD_SECTOR_SIZE) return 0; // EOF? - vcd->entry.entry.addr.msf.frame++; - if (vcd->entry.entry.addr.msf.frame==75){ - vcd->entry.entry.addr.msf.frame=0; - vcd->entry.entry.addr.msf.second++; - if (vcd->entry.entry.addr.msf.second==60){ - vcd->entry.entry.addr.msf.second=0; - vcd->entry.entry.addr.msf.minute++; + TOCADDR(vcd->entry).msf.frame++; + if (TOCADDR(vcd->entry).msf.frame==75){ + TOCADDR(vcd->entry).msf.frame=0; + TOCADDR(vcd->entry).msf.second++; + if (TOCADDR(vcd->entry).msf.second==60){ + TOCADDR(vcd->entry).msf.second=0; + TOCADDR(vcd->entry).msf.minute++; } } memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA);
--- a/stream/vcd_read_nbsd.h Thu Jul 26 09:54:57 2007 +0000 +++ b/stream/vcd_read_nbsd.h Thu Jul 26 22:51:23 2007 +0000 @@ -7,6 +7,7 @@ #include <sys/scsiio.h> #define CDROM_LEADOUT 0xAA +#define TOCADDR(te) ((te).data->addr) typedef struct mp_vcd_priv_st { int fd; @@ -17,23 +18,25 @@ static inline void 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; - vcd->entry_data.addr.msf.second = sect % 60; + TOCADDR(vcd->entry).msf.second = sect % 60; sect = sect / 60; - vcd->entry_data.addr.msf.minute = sect; + TOCADDR(vcd->entry).msf.minute = sect; } static inline void vcd_inc_msf(mp_vcd_priv_t* vcd) { - vcd->entry_data.addr.msf.frame++; - if (vcd->entry_data.addr.msf.frame==75){ - vcd->entry_data.addr.msf.frame=0; - vcd->entry_data.addr.msf.second++; - if (vcd->entry_data.addr.msf.second==60){ - vcd->entry_data.addr.msf.second=0; - vcd->entry_data.addr.msf.minute++; + vcd->entry.data = &vcd->entry_data; + TOCADDR(vcd->entry).msf.frame++; + if (TOCADDR(vcd->entry).msf.frame==75){ + TOCADDR(vcd->entry).msf.frame=0; + TOCADDR(vcd->entry).msf.second++; + if (TOCADDR(vcd->entry).msf.second==60){ + TOCADDR(vcd->entry).msf.second=0; + TOCADDR(vcd->entry).msf.minute++; } } } @@ -41,9 +44,10 @@ static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd) { - return vcd->entry_data.addr.msf.frame + - (vcd->entry_data.addr.msf.second + - vcd->entry_data.addr.msf.minute * 60) * 75; + vcd->entry.data = &vcd->entry_data; + return TOCADDR(vcd->entry).msf.frame + + (TOCADDR(vcd->entry).msf.second + + TOCADDR(vcd->entry).msf.minute * 60) * 75; } int @@ -107,21 +111,21 @@ if (i <= tochdr.ending_track) mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", (int) tocentry.starting_track, - (int) tocentry.data->addr_type, + (int) TOCADDR(tocentry)_type, (int) tocentry.data->control, (int) tocentry.address_format, - (int) tocentry.data->addr.msf.minute, - (int) tocentry.data->addr.msf.second, - (int) tocentry.data->addr.msf.frame + (int) TOCADDR(tocentry).msf.minute, + (int) TOCADDR(tocentry).msf.second, + (int) TOCADDR(tocentry).msf.frame ); if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) { if (i > tochdr.starting_track) { - min = tocentry.data->addr.msf.minute - min; - sec = tocentry.data->addr.msf.second - sec; - frame = tocentry.data->addr.msf.frame - frame; + min = TOCADDR(tocentry).msf.minute - min; + sec = TOCADDR(tocentry).msf.second - sec; + frame = TOCADDR(tocentry).msf.frame - frame; if ( frame < 0 ) { frame += 75; @@ -134,9 +138,9 @@ } 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; - sec = tocentry.data->addr.msf.second; - frame = tocentry.data->addr.msf.frame; + min = TOCADDR(tocentry).msf.minute; + sec = TOCADDR(tocentry).msf.second; + frame = TOCADDR(tocentry).msf.frame; } } vcd = malloc(sizeof(mp_vcd_priv_t));