Mercurial > mplayer.hg
annotate libmpdemux/vcd_read_fbsd.h @ 13690:91faa5745914
consistent I/P/B-frame spelling
author | diego |
---|---|
date | Tue, 19 Oct 2004 02:09:00 +0000 |
parents | 248c478a0699 |
children | aa15d627a00b |
rev | line source |
---|---|
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
958
diff
changeset
|
1 #include <sys/cdio.h> |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
958
diff
changeset
|
2 #include <sys/cdrio.h> |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
958
diff
changeset
|
3 |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
4 //=================== VideoCD ========================== |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
5 #define CDROM_LEADOUT 0xAA |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
6 |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
7 typedef struct { |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
8 uint8_t sync [12]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
9 uint8_t header [4]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
10 uint8_t subheader [8]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
11 uint8_t data [2324]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
12 uint8_t spare [4]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
13 } cdsector_t; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
14 |
9887 | 15 typedef struct mp_vcd_priv_st { |
16 int fd; | |
17 struct ioc_read_toc_single_entry entry; | |
18 cdsector_t buf; | |
19 } mp_vcd_priv_t; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
20 |
9887 | 21 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){ |
22 vcd->entry.entry.addr.msf.frame=sect%75; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
23 sect=sect/75; |
9887 | 24 vcd->entry.entry.addr.msf.second=sect%60; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
25 sect=sect/60; |
9887 | 26 vcd->entry.entry.addr.msf.minute=sect; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
27 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
28 |
9887 | 29 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){ |
30 return vcd->entry.entry.addr.msf.frame + | |
31 (vcd->entry.entry.addr.msf.second+ | |
32 vcd->entry.entry.addr.msf.minute*60)*75; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
33 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
34 |
9887 | 35 int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track){ |
36 vcd->entry.address_format = CD_MSF_FORMAT; | |
37 vcd->entry.track = track; | |
9899 | 38 if (ioctl(vcd->fd, CDIOREADTOCENTRY, &vcd->entry)) { |
9887 | 39 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno)); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
40 return -1; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
41 } |
9887 | 42 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
43 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
44 |
9887 | 45 int vcd_get_track_end(mp_vcd_priv_t* vcd, int track){ |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
46 struct ioc_toc_header tochdr; |
9887 | 47 if (ioctl(vcd->fd,CDIOREADTOCHEADER,&tochdr)==-1) { |
48 mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); | |
49 return -1; | |
50 } | |
51 vcd->entry.address_format = CD_MSF_FORMAT; | |
52 vcd->entry.track = track<tochdr.ending_track?(track+1):CDROM_LEADOUT; | |
9899 | 53 if (ioctl(vcd->fd, CDIOREADTOCENTRY, &vcd->entry)) { |
9887 | 54 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno)); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
55 return -1; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
56 } |
9887 | 57 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
58 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
59 |
9887 | 60 mp_vcd_priv_t* vcd_read_toc(int fd){ |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
61 struct ioc_toc_header tochdr; |
9887 | 62 mp_vcd_priv_t* vcd; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
63 int i; |
9887 | 64 if (ioctl(fd,CDIOREADTOCHEADER,&tochdr)==-1) { |
65 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); | |
66 return NULL; | |
67 } | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
68 for (i=tochdr.starting_track ; i<=tochdr.ending_track ; i++){ |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
69 struct ioc_read_toc_single_entry tocentry; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
70 |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
71 tocentry.track = i; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
72 tocentry.address_format = CD_MSF_FORMAT; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
73 |
9887 | 74 if (ioctl(fd,CDIOREADTOCENTRY,&tocentry)==-1) { |
75 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno)); | |
76 return NULL; | |
77 } | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
78 |
9887 | 79 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
80 (int)tocentry.track, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
81 (int)tocentry.entry.addr_type, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
82 (int)tocentry.entry.control, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
83 (int)tocentry.address_format, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
84 (int)tocentry.entry.addr.msf.minute, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
85 (int)tocentry.entry.addr.msf.second, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
86 (int)tocentry.entry.addr.msf.frame |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
87 ); |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
88 } |
9887 | 89 vcd = malloc(sizeof(mp_vcd_priv_t)); |
90 vcd->fd = fd; | |
91 return vcd; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
92 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
93 |
9887 | 94 static int vcd_read(mp_vcd_priv_t* vcd,char *mem){ |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
95 |
9899 | 96 if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
97 != VCD_SECTOR_SIZE) return 0; // EOF? |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
98 |
9887 | 99 vcd->entry.entry.addr.msf.frame++; |
100 if (vcd->entry.entry.addr.msf.frame==75){ | |
101 vcd->entry.entry.addr.msf.frame=0; | |
102 vcd->entry.entry.addr.msf.second++; | |
103 if (vcd->entry.entry.addr.msf.second==60){ | |
104 vcd->entry.entry.addr.msf.second=0; | |
105 vcd->entry.entry.addr.msf.minute++; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
106 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
107 } |
9899 | 108 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
109 return VCD_SECTOR_DATA; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
110 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
111 |