Mercurial > mplayer.hg
annotate libvo/vo_dxr3.c @ 3343:58ab1490a0be
dunnowhat Q/A de biztos jo
author | gabucino |
---|---|
date | Wed, 05 Dec 2001 23:07:05 +0000 |
parents | 5c6cdf5490f0 |
children | c49a9b272c44 |
rev | line source |
---|---|
2645 | 1 /* |
2 * vo_dxr3.c - DXR3/H+ video out | |
3 * | |
4 * Copyright (C) 2001 David Holm <dholm@iname.com> | |
5 * | |
6 */ | |
7 | |
8 #include "fastmemcpy.h" | |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 #include <string.h> | |
2921 | 12 #include <unistd.h> |
13 #include <linux/em8300.h> | |
14 #include <sys/ioctl.h> | |
15 #include <sys/stat.h> | |
16 #include <sys/types.h> | |
17 #include <fcntl.h> | |
2645 | 18 #include <stdio.h> |
19 #include <time.h> | |
20 | |
21 #include "config.h" | |
22 #include "video_out.h" | |
23 #include "video_out_internal.h" | |
3333
5c6cdf5490f0
Minor typo fix (which I thought I commited yesterday)
mswitch
parents:
3329
diff
changeset
|
24 #include "../libmp1e/libmp1e.h" |
2645 | 25 |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
26 #include "../postproc/rgb2rgb.h" |
2645 | 27 #ifdef HAVE_MMX |
28 #include "mmx.h" | |
29 #endif | |
30 | |
31 LIBVO_EXTERN (dxr3) | |
32 | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
33 rte_context *mp1e_context = NULL; |
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
34 rte_codec *mp1e_codec = NULL; |
3201 | 35 rte_buffer mp1e_buffer; |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
36 struct { uint16_t Y,U,V; } YUV_s; |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
37 #define RGBTOY(R,G,B) (uint16_t)( (0.257 * R) + (0.504 * G) + (0.098 * B) + 16 ) |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
38 #define RGBTOU(R,G,B) (uint16_t)( -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128 ) |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
39 #define RGBTOV(R,G,B) (uint16_t)( (0.439 * R) - (0.368 * G) - (0.071 * B) + 128 ) |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
40 #define RGBTOYUV(R,G,B) YUV_s.Y = RGBTOY(R,G,B); \ |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
41 YUV_s.U = RGBTOU(R,G,B); \ |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
42 YUV_s.V = RGBTOV(R,G,B); |
2645 | 43 |
3201 | 44 static unsigned char *picture_data[3]; |
45 static unsigned int picture_linesize[3]; | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
46 |
2770 | 47 static int v_width,v_height; |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
48 static int s_width,s_height; |
3201 | 49 static int c_width,c_height; |
2645 | 50 static int s_pos_x,s_pos_y; |
51 static int d_pos_x,d_pos_y; | |
52 static int osd_w,osd_h; | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
53 |
2770 | 54 static int img_format = 0; |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
55 |
2921 | 56 static int fd_control = -1; |
57 static int fd_video = -1; | |
58 static int fd_spu = -1; | |
59 static int ioval = 0; | |
2645 | 60 |
61 static vo_info_t vo_info = | |
62 { | |
63 "DXR3/H+ video out", | |
64 "dxr3", | |
65 "David Holm <dholm@iname.com>", | |
66 "" | |
67 }; | |
68 | |
3201 | 69 void write_dxr3( rte_context* context, void* data, size_t size, void* user_data ) |
70 { | |
71 if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ) < 0 ) | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
72 printf( "VO: [dxr3] Unable to set video PTS\n" ); |
3201 | 73 write( fd_video, data, size ); |
74 } | |
75 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
76 static uint32_t init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format) |
2645 | 77 { |
2921 | 78 fd_control = open( "/dev/em8300", O_WRONLY ); |
79 if( fd_control < 1 ) | |
2645 | 80 { |
2921 | 81 printf( "VO: [dxr3] Error opening /dev/em8300 for writing!\n" ); |
82 return -1; | |
83 } | |
84 fd_video = open( "/dev/em8300_mv", O_WRONLY ); | |
85 if( fd_video < 0 ) | |
86 { | |
87 printf( "VO: [dxr3] Error opening /dev/em8300_mv for writing!\n" ); | |
88 return -1; | |
89 } | |
90 else printf( "VO: [dxr3] Opened /dev/em8300_mv\n" ); | |
91 fd_spu = open( "/dev/em8300_sp", O_WRONLY ); | |
92 if( fd_spu < 0 ) | |
93 { | |
94 printf( "VO: [dxr3] Error opening /dev/em8300_sp for writing!\n" ); | |
95 return -1; | |
2645 | 96 } |
97 | |
2770 | 98 /* Subpic code isn't working yet, don't set to ON |
99 unless you are really sure what you are doing */ | |
2921 | 100 ioval = EM8300_SPUMODE_OFF; |
101 if( ioctl( fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval ) < 0 ) | |
102 { | |
103 printf( "VO: [dxr3] Unable to set subpicture mode!\n" ); | |
104 return -1; | |
105 } | |
106 | |
107 ioval = EM8300_PLAYMODE_PLAY; | |
2968 | 108 if( ioctl( fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval ) < 0 ) |
2921 | 109 printf( "VO: [dxr3] Unable to set playmode!\n" ); |
110 | |
111 close( fd_control ); | |
2645 | 112 |
113 img_format = format; | |
2770 | 114 v_width = width; |
115 v_height = height; | |
3201 | 116 s_width = scr_width; |
117 s_height = scr_height; | |
2921 | 118 |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
119 if( format == IMGFMT_YV12 || format == IMGFMT_YUY2 || format == IMGFMT_BGR24 ) |
2645 | 120 { |
121 int size; | |
3201 | 122 enum rte_frame_rate frame_rate; |
2645 | 123 |
3201 | 124 if( !rte_init() ) |
2968 | 125 { |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
126 printf( "VO: [dxr3] Unable to initialize MP1E!\n" ); |
3201 | 127 return -1; |
128 } | |
129 | |
2645 | 130 if(width<=352 && height<=288){ |
3201 | 131 c_width=352; |
132 c_height=288; | |
2645 | 133 } else |
134 if(width<=352 && height<=576){ | |
3201 | 135 c_width=352; |
136 c_height=576; | |
2645 | 137 } else |
138 if(width<=480 && height<=576){ | |
3201 | 139 c_width=480; |
140 c_height=576; | |
2645 | 141 } else |
142 if(width<=544 && height<=576){ | |
3201 | 143 c_width=544; |
144 c_height=576; | |
2645 | 145 } else { |
3201 | 146 c_width=704; |
147 c_height=576; | |
2645 | 148 } |
3201 | 149 |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
150 mp1e_context = rte_context_new( c_width, c_height, NULL ); |
3201 | 151 rte_set_verbosity( mp1e_context, 0 ); |
152 | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
153 printf( "VO: [dxr3] %dx%d => %dx%d\n", v_width, v_height, c_width, c_height ); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
154 |
3201 | 155 if( !mp1e_context ) |
156 { | |
157 printf( "VO: [dxr3] Unable to create context!\n" ); | |
158 return -1; | |
159 } | |
160 | |
161 if( !rte_set_format( mp1e_context, "mpeg1" ) ) | |
162 { | |
163 printf( "VO: [dxr3] Unable to set format\n" ); | |
164 return -1; | |
165 } | |
166 | |
167 rte_set_mode( mp1e_context, RTE_VIDEO ); | |
168 mp1e_codec = rte_codec_set( mp1e_context, RTE_STREAM_VIDEO, 0, "mpeg1-video" ); | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
169 |
3201 | 170 if( vo_fps < 24.0 ) frame_rate = RTE_RATE_1; |
171 else if( vo_fps < 25.0 ) frame_rate = RTE_RATE_2; | |
172 else if( vo_fps < 29.97 ) frame_rate = RTE_RATE_3; | |
173 else if( vo_fps < 30.0 ) frame_rate = RTE_RATE_4; | |
174 else if( vo_fps < 50.0 ) frame_rate = RTE_RATE_5; | |
175 else if( vo_fps < 59.97 ) frame_rate = RTE_RATE_6; | |
176 else if( vo_fps < 60.0 ) frame_rate = RTE_RATE_7; | |
177 else if( vo_fps > 60.0 ) frame_rate = RTE_RATE_8; | |
178 else frame_rate = RTE_RATE_NORATE; | |
179 | |
180 if( !rte_set_video_parameters( mp1e_context, RTE_YUV420, mp1e_context->width, | |
181 mp1e_context->height, frame_rate, | |
182 3e6, "I" ) ) | |
183 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
184 printf( "VO: [dxr3] Unable to set mp1e context!\n" ); |
3201 | 185 rte_context_destroy( mp1e_context ); |
186 return -1; | |
187 } | |
188 | |
189 rte_set_input( mp1e_context, RTE_VIDEO, RTE_PUSH, TRUE, NULL, NULL, NULL ); | |
3208 | 190 rte_set_output( mp1e_context, (void*)write_dxr3, NULL, NULL ); |
3201 | 191 |
192 if( !rte_init_context( mp1e_context ) ) | |
193 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
194 printf( "VO: [dxr3] Unable to init mp1e context!\n" ); |
3201 | 195 rte_context_delete( mp1e_context ); |
196 return -1; | |
197 } | |
198 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
199 osd_w=scr_width; |
3201 | 200 d_pos_x=(c_width-(int)scr_width)/2; |
3208 | 201 if(d_pos_x<0) |
202 { | |
203 s_pos_x=-d_pos_x;d_pos_x=0; | |
204 osd_w=c_width; | |
2645 | 205 } else s_pos_x=0; |
206 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
207 osd_h=scr_height; |
3201 | 208 d_pos_y=(c_height-(int)scr_height)/2; |
3208 | 209 if(d_pos_y<0) |
210 { | |
211 s_pos_y=-d_pos_y;d_pos_y=0; | |
212 osd_h=c_height; | |
2645 | 213 } else s_pos_y=0; |
214 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
215 printf("VO: [dxr3] Position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
3201 | 216 |
217 size = c_width*c_height; | |
218 | |
219 picture_data[0] = malloc((size * 3)/2); | |
220 picture_data[1] = picture_data[0] + size; | |
221 picture_data[2] = picture_data[1] + size / 4; | |
222 picture_linesize[0] = c_width; | |
223 picture_linesize[1] = c_width / 2; | |
224 picture_linesize[2] = c_width / 2; | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
225 |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
226 // Set the border colorwou |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
227 RGBTOYUV(0,0,0) |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
228 memset( picture_data[0], YUV_s.Y, picture_linesize[0]*c_height ); |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
229 memset( picture_data[1], YUV_s.U, picture_linesize[1]*(c_height/2) ); |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
230 memset( picture_data[2], YUV_s.V, picture_linesize[2]*(c_height/2) ); |
3201 | 231 |
232 if( !rte_start_encoding( mp1e_context ) ) | |
2968 | 233 { |
3201 | 234 printf( "VO: [dxr3] Unable to start mp1e encoding!\n" ); |
235 uninit(); | |
236 return -1; | |
237 } | |
2770 | 238 |
239 return 0; | |
240 } | |
2645 | 241 else if(format==IMGFMT_MPEGPES) |
242 { | |
2921 | 243 printf( "VO: [dxr3] Format: MPEG-PES (no conversion needed)\n" ); |
2645 | 244 return 0; |
245 } | |
246 | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
247 printf( "VO: [dxr3] Format: Unsuppomp1ed\n" ); |
2645 | 248 return -1; |
249 } | |
250 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
251 static const vo_info_t* get_info(void) |
2645 | 252 { |
253 return &vo_info; | |
254 } | |
255 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
256 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
2645 | 257 { |
258 } | |
259 | |
260 static void draw_osd(void) | |
261 { | |
262 } | |
263 | |
264 static uint32_t draw_frame(uint8_t * src[]) | |
265 { | |
266 if( img_format == IMGFMT_MPEGPES ) | |
267 { | |
2770 | 268 int data_left; |
2645 | 269 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
3201 | 270 |
271 if( ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ) < 0 ) | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
272 printf( "VO: [dxr3] Unable to set video PTS\n" ); |
2968 | 273 |
2645 | 274 data_left = p->size; |
275 while( data_left ) | |
2921 | 276 data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left ); |
277 | |
2645 | 278 return 0; |
279 } | |
3208 | 280 else if( img_format == IMGFMT_YUY2 ) |
281 { | |
282 int w=v_width,h=v_height; | |
283 unsigned char *s,*dY,*dU,*dV; | |
284 | |
285 if(d_pos_x+w>picture_linesize[0]) w=picture_linesize[0]-d_pos_x; | |
286 if(d_pos_y+h>c_height) h=c_height-d_pos_y; | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
287 |
3208 | 288 s = src[0]+s_pos_x+s_pos_y*(w*2); |
289 dY = picture_data[0]+d_pos_x+d_pos_y*picture_linesize[0]; | |
290 dU = picture_data[1]+(d_pos_x/2)+(d_pos_y/2)*picture_linesize[1]; | |
291 dV = picture_data[2]+(d_pos_x/2)+(d_pos_y/2)*picture_linesize[2]; | |
292 | |
293 yuy2toyv12( s, dY, dU, dV, w, h, picture_linesize[0], picture_linesize[1], w*2 ); | |
294 | |
295 mp1e_buffer.data = picture_data[0]; | |
296 mp1e_buffer.time = vo_pts/90000.0; | |
297 mp1e_buffer.user_data = NULL; | |
298 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
299 return 0; | |
300 } | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
301 else if( img_format == IMGFMT_BGR24 ) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
302 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
303 int x,y,w=v_width,h=v_height; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
304 unsigned char *s,*dY,*dU,*dV; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
305 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
306 if(d_pos_x+w>picture_linesize[0]) w=picture_linesize[0]-d_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
307 if(d_pos_y+h>c_height) h=c_height-d_pos_y; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
308 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
309 s = src[0]+s_pos_y*(w*3); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
310 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
311 dY = picture_data[0]+d_pos_y*picture_linesize[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
312 dU = picture_data[1]+(d_pos_y/2)*picture_linesize[1]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
313 dV = picture_data[2]+(d_pos_y/2)*picture_linesize[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
314 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
315 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
316 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
317 dY+=d_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
318 dU+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
319 dV+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
320 s+=s_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
321 for(x=0;x<w;x+=4) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
322 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
323 RGBTOYUV(s[2],s[1],s[0]); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
324 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
325 *dY = YUV_s.Y;dY++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
326 // The chrominance is shifted, ppl will have to settle with b&w for now ;) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
327 // *dU = YUV_s.U;dU++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
328 // *dV = YUV_s.V;dV++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
329 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
330 *dY = RGBTOY(s[2],s[1],s[0]);dY++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
331 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
332 *dY = RGBTOY(s[2],s[1],s[0]);dY++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
333 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
334 *dY = RGBTOY(s[2],s[1],s[0]);dY++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
335 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
336 } |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
337 dY+=d_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
338 dU+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
339 dV+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
340 s+=s_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
341 } |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
342 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
343 mp1e_buffer.data = picture_data[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
344 mp1e_buffer.time = vo_pts/90000.0; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
345 mp1e_buffer.user_data = NULL; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
346 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
347 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
348 return 0; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
349 } |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
350 |
2645 | 351 return -1; |
352 } | |
353 | |
354 static void flip_page (void) | |
355 { | |
3201 | 356 if( img_format == IMGFMT_YV12 ) |
357 { | |
358 mp1e_buffer.data = picture_data[0]; | |
359 mp1e_buffer.time = vo_pts/90000.0; | |
360 mp1e_buffer.user_data = NULL; | |
361 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
362 } | |
2645 | 363 } |
364 | |
365 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) | |
366 { | |
367 if( img_format == IMGFMT_YV12 ) | |
3201 | 368 { |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
369 int y; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
370 unsigned char *s,*s1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
371 unsigned char *d,*d1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
372 |
2645 | 373 x0+=d_pos_x; |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
374 y0+=d_pos_y; |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
375 |
3201 | 376 if(x0+w>picture_linesize[0]) w=picture_linesize[0]-x0; |
377 if(y0+h>c_height) h=c_height-y0; | |
2645 | 378 |
379 s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; | |
3201 | 380 d=picture_data[0]+x0+y0*picture_linesize[0]; |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
381 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
382 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
383 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
384 s+=stride[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
385 d+=picture_linesize[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
386 } |
2645 | 387 |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
388 w/=2;h/=2;x0/=2;y0/=2; |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
389 |
3208 | 390 s=srcimg[1]+s_pos_x+s_pos_y*stride[1]; |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
391 d=picture_data[1]+x0+y0*picture_linesize[1]; |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
392 s1=srcimg[2]+s_pos_x+s_pos_y*stride[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
393 d1=picture_data[2]+x0+y0*picture_linesize[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
394 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
395 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
396 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
397 memcpy(d1,s1,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
398 s+=stride[1];s1+=stride[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
399 d+=picture_linesize[1];d1+=picture_linesize[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
400 } |
2645 | 401 |
402 return 0; | |
403 } | |
404 | |
405 return -1; | |
406 } | |
407 | |
408 | |
409 static uint32_t | |
410 query_format(uint32_t format) | |
411 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
412 if(format==IMGFMT_MPEGPES) return 0x2;0x4; |
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
413 if(format==IMGFMT_YV12) return 0x1|0x4; |
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
414 if(format==IMGFMT_YUY2) return 0x1|0x4; |
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
415 if(format==IMGFMT_BGR24) { printf( "VO: [dxr3] WARNING\tExperimental output, black&white only and very slow\n\t(will be inproved later, this format is rarely used)\n" ); return 0x1|0x4; } |
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
416 else printf( "VO: [dxr3] Format unsuppomp1ed, mail dholm@iname.com\n" ); |
2645 | 417 return 0; |
418 } | |
419 | |
3208 | 420 static void uninit(void) |
2645 | 421 { |
2968 | 422 printf( "VO: [dxr3] Uninitializing\n" ); |
3201 | 423 if( picture_data[0] ) free(picture_data[0]); |
424 if( fd_video ) close(fd_video); | |
425 if( fd_spu ) close(fd_spu); | |
2645 | 426 } |
427 | |
428 | |
429 static void check_events(void) | |
430 { | |
431 } | |
432 |