Mercurial > mplayer.hg
annotate libvo/vo_mpegpes.c @ 23435:ccf4719617b6
Remove non-existing make_decode_tables_MMX()
author | zuxy |
---|---|
date | Sat, 02 Jun 2007 16:47:10 +0000 |
parents | 3f2de7ba8aa0 |
children | 3aee342be929 |
rev | line source |
---|---|
1876 | 1 /* |
2 * Based on: | |
3 * | |
4 * test_av.c - Test program for new API | |
5 * | |
6 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de> | |
7 * & Marcus Metzler <marcus@convergence.de> | |
8 * for convergence integrated media GmbH | |
9 * | |
10 * libav - MPEG-PS multiplexer, part of ffmpeg | |
11 * Copyright Gerard Lantau (see http://ffmpeg.sf.net) | |
12 * | |
13 */ | |
1871 | 14 |
6239 | 15 #include "config.h" |
1871 | 16 #include <stdio.h> |
17 #include <stdlib.h> | |
18 #include <string.h> | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
19 #include <errno.h> |
1876 | 20 #include <sys/types.h> |
21 #include <sys/stat.h> | |
22 #include <fcntl.h> | |
6239 | 23 #include <unistd.h> |
1876 | 24 |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
25 #include "mp_msg.h" |
8594 | 26 #ifdef HAVE_DVB_HEAD |
27 #define HAVE_DVB 1 | |
28 #endif | |
1876 | 29 #ifdef HAVE_DVB |
8594 | 30 #ifndef HAVE_DVB_HEAD |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
31 #include <sys/poll.h> |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
32 |
1876 | 33 #include <sys/ioctl.h> |
34 #include <stdio.h> | |
35 #include <time.h> | |
36 | |
37 #include <ost/dmx.h> | |
38 #include <ost/frontend.h> | |
39 #include <ost/sec.h> | |
40 #include <ost/video.h> | |
41 #include <ost/audio.h> | |
42 | |
8594 | 43 #else |
44 #define true 1 | |
45 #define false 0 | |
46 #include <sys/poll.h> | |
47 | |
48 #include <sys/ioctl.h> | |
49 #include <stdio.h> | |
50 #include <time.h> | |
51 | |
52 #include <linux/dvb/dmx.h> | |
53 #include <linux/dvb/frontend.h> | |
54 #include <linux/dvb/video.h> | |
55 #include <linux/dvb/audio.h> | |
56 #endif | |
1876 | 57 #endif |
58 | |
1871 | 59 #include "config.h" |
60 #include "video_out.h" | |
61 #include "video_out_internal.h" | |
19148
3b839a8d297a
simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents:
16171
diff
changeset
|
62 #include "libmpdemux/mpeg_packetizer.h" |
1871 | 63 |
1872 | 64 int vo_mpegpes_fd=-1; |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
19163
diff
changeset
|
65 extern int vo_mpegpes_fd2; |
1872 | 66 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
67 static vo_info_t info = |
1871 | 68 { |
1876 | 69 #ifdef HAVE_DVB |
70 "Mpeg-PES to DVB card", | |
71 #else | |
1871 | 72 "Mpeg-PES file", |
1876 | 73 #endif |
74 "mpegpes", | |
1871 | 75 "A'rpi", |
76 "" | |
77 }; | |
78 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
79 LIBVO_EXTERN (mpegpes) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
80 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
81 static int |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13048
diff
changeset
|
82 config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t flags, char *title, uint32_t format) |
1871 | 83 { |
1876 | 84 #ifdef HAVE_DVB |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
85 switch(s_height){ |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
86 case 288: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
87 case 576: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
88 case 240: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
89 case 480: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
90 break; |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
91 default: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
92 mp_msg(MSGT_VO,MSGL_ERR,"DVB: height=%d not supported (try 240/480 (ntsc) or 288/576 (pal)\n",s_height); |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
93 return -1; |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
94 } |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
95 #endif |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
96 return 0; |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
97 } |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
98 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
99 static int preinit(const char *arg){ |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
100 #ifdef HAVE_DVB |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
101 int card = 0; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
102 char vo_file[30], ao_file[30], *tmp; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
103 |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
104 if(arg != NULL){ |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
105 if((tmp = strstr(arg, "card=")) != NULL) { |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
106 card = atoi(&tmp[5]); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
107 if((card < 1) || (card > 4)) { |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
108 mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
109 return -1; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
110 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
111 card--; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
112 arg = NULL; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
113 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
114 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
115 |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
116 if(!arg){ |
1876 | 117 //|O_NONBLOCK |
8594 | 118 #ifndef HAVE_DVB_HEAD |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
119 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/ost/video+audio\n"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
120 sprintf(vo_file, "/dev/ost/video"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
121 sprintf(ao_file, "/dev/ost/audio"); |
8594 | 122 #else |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
123 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/dvb/adapter%d/video0+audio0\n", card); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
124 sprintf(vo_file, "/dev/dvb/adapter%d/video0", card); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
125 sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
126 #endif |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
127 if((vo_mpegpes_fd = open(vo_file,O_RDWR)) < 0){ |
8594 | 128 perror("DVB VIDEO DEVICE: "); |
129 return -1; | |
130 } | |
1876 | 131 if ( (ioctl(vo_mpegpes_fd,VIDEO_SET_BLANK, false) < 0)){ |
132 perror("DVB VIDEO SET BLANK: "); | |
133 return -1; | |
134 } | |
135 if ( (ioctl(vo_mpegpes_fd,VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)){ | |
136 perror("DVB VIDEO SELECT SOURCE: "); | |
137 return -1; | |
138 } | |
139 if ( (ioctl(vo_mpegpes_fd,VIDEO_PLAY) < 0)){ | |
140 perror("DVB VIDEO PLAY: "); | |
141 return -1; | |
142 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
143 return 0; |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
144 } |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
145 #endif |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
146 arg = (arg ? arg : "grab.mpg"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
147 mp_msg(MSGT_VO,MSGL_INFO, "Saving PES stream to %s\n", arg); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
148 vo_mpegpes_fd=open(arg,O_WRONLY|O_CREAT,0666); |
1872 | 149 if(vo_mpegpes_fd<0){ |
150 perror("vo_mpegpes"); | |
151 return -1; | |
152 } | |
1871 | 153 return 0; |
154 } | |
155 | |
156 | |
157 static void draw_osd(void) | |
158 { | |
159 } | |
160 | |
1876 | 161 |
19150 | 162 static int my_write(unsigned char* data,int len){ |
19153 | 163 int orig_len = len; |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
164 #ifdef HAVE_DVB |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
165 #define NFD 2 |
1876 | 166 struct pollfd pfd[NFD]; |
167 | |
168 // printf("write %d bytes \n",len); | |
169 | |
170 pfd[0].fd = vo_mpegpes_fd; | |
171 pfd[0].events = POLLOUT; | |
172 | |
173 pfd[1].fd = vo_mpegpes_fd2; | |
174 pfd[1].events = POLLOUT; | |
175 | |
1872 | 176 while(len>0){ |
1876 | 177 if (poll(pfd,NFD,1)){ |
178 if (pfd[0].revents & POLLOUT){ | |
179 int ret=write(vo_mpegpes_fd,data,len); | |
180 // printf("ret=%d \n",ret); | |
181 if(ret<=0){ | |
182 perror("write"); | |
183 usleep(0); | |
184 } else { | |
185 len-=ret; data+=ret; | |
186 } | |
187 } else usleep(1000); | |
188 } | |
1872 | 189 } |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
190 |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
191 #else |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
192 write(vo_mpegpes_fd,data,len); // write to file |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
193 #endif |
19150 | 194 return orig_len; |
1872 | 195 } |
1871 | 196 |
2706 | 197 void send_pes_packet(unsigned char* data,int len,int id,int timestamp){ |
19148
3b839a8d297a
simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents:
16171
diff
changeset
|
198 send_mpeg_pes_packet (data, len, id, timestamp, 1, my_write); |
1876 | 199 } |
200 | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
201 void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){ |
19161
049c74156629
reuse send_mpeg_lpcm_packet() instead of the old packetizer
nicodvb
parents:
19153
diff
changeset
|
202 send_mpeg_lpcm_packet(data, len, id, timestamp, freq_id, my_write); |
2706 | 203 } |
204 | |
205 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
206 static int draw_frame(uint8_t * src[]) |
1871 | 207 { |
1872 | 208 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
209 send_pes_packet(p->data,p->size,p->id,(p->timestamp>0)?p->timestamp:vo_pts); // video data |
1871 | 210 return 0; |
211 } | |
212 | |
1935 | 213 static void flip_page (void) |
214 { | |
215 } | |
216 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
217 static int draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x0,int y0) |
1935 | 218 { |
219 return 0; | |
220 } | |
221 | |
222 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
223 static int |
1871 | 224 query_format(uint32_t format) |
225 { | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13048
diff
changeset
|
226 if(format==IMGFMT_MPEGPES) return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER; |
1871 | 227 return 0; |
228 } | |
229 | |
230 static void | |
231 uninit(void) | |
232 { | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
233 if(vo_mpegpes_fd2>=0 && vo_mpegpes_fd2!=vo_mpegpes_fd) close(vo_mpegpes_fd2); |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
234 vo_mpegpes_fd2=-1; |
1876 | 235 if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;} |
1871 | 236 } |
237 | |
238 | |
239 static void check_events(void) | |
240 { | |
241 } | |
242 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
243 static int control(uint32_t request, void *data, ...) |
4352 | 244 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
245 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
246 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
247 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
248 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
249 return VO_NOTIMPL; |
4352 | 250 } |