Mercurial > mplayer.hg
annotate stream/vcd_read_fbsd.h @ 22237:21e4a2835569
Avoid parts of xvmc reinit when source format does not change
author | reimar |
---|---|
date | Sun, 18 Feb 2007 09:33:45 +0000 |
parents | 64d82a45a05d |
children | 773e6c50d1b8 |
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; |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
63 int i, min = 0, sec = 0, frame = 0; |
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 } | |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
68 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", tochdr.starting_track); |
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
69 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", tochdr.ending_track); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
70 for (i=tochdr.starting_track ; i<=tochdr.ending_track + 1; i++){ |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
71 struct ioc_read_toc_single_entry tocentry; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
72 |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
73 tocentry.track = i<=tochdr.ending_track ? i : CDROM_LEADOUT; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
74 tocentry.address_format = CD_MSF_FORMAT; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
75 |
9887 | 76 if (ioctl(fd,CDIOREADTOCENTRY,&tocentry)==-1) { |
77 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno)); | |
78 return NULL; | |
79 } | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
80 |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
81 if (i<=tochdr.ending_track) |
9887 | 82 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
|
83 (int)tocentry.track, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
84 (int)tocentry.entry.addr_type, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
85 (int)tocentry.entry.control, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
86 (int)tocentry.address_format, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
87 (int)tocentry.entry.addr.msf.minute, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
88 (int)tocentry.entry.addr.msf.second, |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
89 (int)tocentry.entry.addr.msf.frame |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
90 ); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
91 |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
92 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
93 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
94 if (i > tochdr.starting_track) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
95 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
96 min = tocentry.entry.addr.msf.minute - min; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
97 sec = tocentry.entry.addr.msf.second - sec; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
98 frame = tocentry.entry.addr.msf.frame - frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
99 if ( frame < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
100 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
101 frame += 75; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
102 sec --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
103 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
104 if ( sec < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
105 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
106 sec += 60; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
107 min --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
108 } |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
109 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
110 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
111 min = tocentry.entry.addr.msf.minute; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
112 sec = tocentry.entry.addr.msf.second; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
113 frame = tocentry.entry.addr.msf.frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
114 } |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
115 } |
9887 | 116 vcd = malloc(sizeof(mp_vcd_priv_t)); |
117 vcd->fd = fd; | |
118 return vcd; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
119 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
120 |
9887 | 121 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
|
122 |
9899 | 123 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
|
124 != VCD_SECTOR_SIZE) return 0; // EOF? |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
125 |
9887 | 126 vcd->entry.entry.addr.msf.frame++; |
127 if (vcd->entry.entry.addr.msf.frame==75){ | |
128 vcd->entry.entry.addr.msf.frame=0; | |
129 vcd->entry.entry.addr.msf.second++; | |
130 if (vcd->entry.entry.addr.msf.second==60){ | |
131 vcd->entry.entry.addr.msf.second=0; | |
132 vcd->entry.entry.addr.msf.minute++; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
133 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
134 } |
9899 | 135 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
136 return VCD_SECTOR_DATA; |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
137 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
138 |