Mercurial > mplayer.hg
annotate libvo/vo_dxr3.c @ 3394:35b18ed357c2
imported from liba52 CVS
author | arpi |
---|---|
date | Sun, 09 Dec 2001 15:28:44 +0000 |
parents | f8bfaa1c9487 |
children | 5cb7caab5536 |
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 write( fd_video, data, size ); | |
72 } | |
73 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
74 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 | 75 { |
2921 | 76 fd_control = open( "/dev/em8300", O_WRONLY ); |
77 if( fd_control < 1 ) | |
2645 | 78 { |
2921 | 79 printf( "VO: [dxr3] Error opening /dev/em8300 for writing!\n" ); |
80 return -1; | |
81 } | |
82 fd_video = open( "/dev/em8300_mv", O_WRONLY ); | |
83 if( fd_video < 0 ) | |
84 { | |
85 printf( "VO: [dxr3] Error opening /dev/em8300_mv for writing!\n" ); | |
86 return -1; | |
87 } | |
88 else printf( "VO: [dxr3] Opened /dev/em8300_mv\n" ); | |
89 fd_spu = open( "/dev/em8300_sp", O_WRONLY ); | |
90 if( fd_spu < 0 ) | |
91 { | |
92 printf( "VO: [dxr3] Error opening /dev/em8300_sp for writing!\n" ); | |
93 return -1; | |
2645 | 94 } |
95 | |
2770 | 96 /* Subpic code isn't working yet, don't set to ON |
97 unless you are really sure what you are doing */ | |
2921 | 98 ioval = EM8300_SPUMODE_OFF; |
99 if( ioctl( fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval ) < 0 ) | |
100 { | |
101 printf( "VO: [dxr3] Unable to set subpicture mode!\n" ); | |
102 return -1; | |
103 } | |
104 | |
105 ioval = EM8300_PLAYMODE_PLAY; | |
2968 | 106 if( ioctl( fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval ) < 0 ) |
2921 | 107 printf( "VO: [dxr3] Unable to set playmode!\n" ); |
108 | |
109 close( fd_control ); | |
2645 | 110 |
111 img_format = format; | |
2770 | 112 v_width = width; |
113 v_height = height; | |
3201 | 114 s_width = scr_width; |
115 s_height = scr_height; | |
2921 | 116 |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
117 if( format == IMGFMT_YV12 || format == IMGFMT_YUY2 || format == IMGFMT_BGR24 ) |
2645 | 118 { |
119 int size; | |
3201 | 120 enum rte_frame_rate frame_rate; |
2645 | 121 |
3201 | 122 if( !rte_init() ) |
2968 | 123 { |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
124 printf( "VO: [dxr3] Unable to initialize MP1E!\n" ); |
3201 | 125 return -1; |
126 } | |
127 | |
2645 | 128 if(width<=352 && height<=288){ |
3201 | 129 c_width=352; |
130 c_height=288; | |
2645 | 131 } else |
132 if(width<=352 && height<=576){ | |
3201 | 133 c_width=352; |
134 c_height=576; | |
2645 | 135 } else |
136 if(width<=480 && height<=576){ | |
3201 | 137 c_width=480; |
138 c_height=576; | |
2645 | 139 } else |
140 if(width<=544 && height<=576){ | |
3201 | 141 c_width=544; |
142 c_height=576; | |
2645 | 143 } else { |
3201 | 144 c_width=704; |
145 c_height=576; | |
2645 | 146 } |
3201 | 147 |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
148 mp1e_context = rte_context_new( c_width, c_height, NULL ); |
3201 | 149 rte_set_verbosity( mp1e_context, 0 ); |
150 | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
151 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
|
152 |
3201 | 153 if( !mp1e_context ) |
154 { | |
155 printf( "VO: [dxr3] Unable to create context!\n" ); | |
156 return -1; | |
157 } | |
158 | |
159 if( !rte_set_format( mp1e_context, "mpeg1" ) ) | |
160 { | |
161 printf( "VO: [dxr3] Unable to set format\n" ); | |
162 return -1; | |
163 } | |
164 | |
165 rte_set_mode( mp1e_context, RTE_VIDEO ); | |
166 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
|
167 |
3201 | 168 if( vo_fps < 24.0 ) frame_rate = RTE_RATE_1; |
169 else if( vo_fps < 25.0 ) frame_rate = RTE_RATE_2; | |
170 else if( vo_fps < 29.97 ) frame_rate = RTE_RATE_3; | |
171 else if( vo_fps < 30.0 ) frame_rate = RTE_RATE_4; | |
172 else if( vo_fps < 50.0 ) frame_rate = RTE_RATE_5; | |
173 else if( vo_fps < 59.97 ) frame_rate = RTE_RATE_6; | |
174 else if( vo_fps < 60.0 ) frame_rate = RTE_RATE_7; | |
175 else if( vo_fps > 60.0 ) frame_rate = RTE_RATE_8; | |
176 else frame_rate = RTE_RATE_NORATE; | |
177 | |
178 if( !rte_set_video_parameters( mp1e_context, RTE_YUV420, mp1e_context->width, | |
179 mp1e_context->height, frame_rate, | |
180 3e6, "I" ) ) | |
181 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
182 printf( "VO: [dxr3] Unable to set mp1e context!\n" ); |
3201 | 183 rte_context_destroy( mp1e_context ); |
184 return -1; | |
185 } | |
186 | |
187 rte_set_input( mp1e_context, RTE_VIDEO, RTE_PUSH, TRUE, NULL, NULL, NULL ); | |
3208 | 188 rte_set_output( mp1e_context, (void*)write_dxr3, NULL, NULL ); |
3201 | 189 |
190 if( !rte_init_context( mp1e_context ) ) | |
191 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
192 printf( "VO: [dxr3] Unable to init mp1e context!\n" ); |
3201 | 193 rte_context_delete( mp1e_context ); |
194 return -1; | |
195 } | |
196 | |
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
|
197 osd_w=scr_width; |
3201 | 198 d_pos_x=(c_width-(int)scr_width)/2; |
3208 | 199 if(d_pos_x<0) |
200 { | |
201 s_pos_x=-d_pos_x;d_pos_x=0; | |
202 osd_w=c_width; | |
2645 | 203 } else s_pos_x=0; |
204 | |
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
|
205 osd_h=scr_height; |
3201 | 206 d_pos_y=(c_height-(int)scr_height)/2; |
3208 | 207 if(d_pos_y<0) |
208 { | |
209 s_pos_y=-d_pos_y;d_pos_y=0; | |
210 osd_h=c_height; | |
2645 | 211 } else s_pos_y=0; |
212 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
213 printf("VO: [dxr3] Position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
3201 | 214 |
215 size = c_width*c_height; | |
216 | |
217 picture_data[0] = malloc((size * 3)/2); | |
218 picture_data[1] = picture_data[0] + size; | |
219 picture_data[2] = picture_data[1] + size / 4; | |
220 picture_linesize[0] = c_width; | |
221 picture_linesize[1] = c_width / 2; | |
222 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
|
223 |
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
224 // 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
|
225 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
|
226 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
|
227 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
|
228 memset( picture_data[2], YUV_s.V, picture_linesize[2]*(c_height/2) ); |
3201 | 229 |
230 if( !rte_start_encoding( mp1e_context ) ) | |
2968 | 231 { |
3201 | 232 printf( "VO: [dxr3] Unable to start mp1e encoding!\n" ); |
233 uninit(); | |
234 return -1; | |
235 } | |
2770 | 236 |
237 return 0; | |
238 } | |
2645 | 239 else if(format==IMGFMT_MPEGPES) |
240 { | |
2921 | 241 printf( "VO: [dxr3] Format: MPEG-PES (no conversion needed)\n" ); |
2645 | 242 return 0; |
243 } | |
244 | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
245 printf( "VO: [dxr3] Format: Unsuppomp1ed\n" ); |
2645 | 246 return -1; |
247 } | |
248 | |
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
|
249 static const vo_info_t* get_info(void) |
2645 | 250 { |
251 return &vo_info; | |
252 } | |
253 | |
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
|
254 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
2645 | 255 { |
256 } | |
257 | |
258 static void draw_osd(void) | |
259 { | |
260 } | |
261 | |
262 static uint32_t draw_frame(uint8_t * src[]) | |
263 { | |
264 if( img_format == IMGFMT_MPEGPES ) | |
265 { | |
2770 | 266 int data_left; |
2645 | 267 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
3201 | 268 |
2645 | 269 data_left = p->size; |
270 while( data_left ) | |
2921 | 271 data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left ); |
272 | |
2645 | 273 return 0; |
274 } | |
3208 | 275 else if( img_format == IMGFMT_YUY2 ) |
276 { | |
277 int w=v_width,h=v_height; | |
278 unsigned char *s,*dY,*dU,*dV; | |
279 | |
280 if(d_pos_x+w>picture_linesize[0]) w=picture_linesize[0]-d_pos_x; | |
281 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
|
282 |
3208 | 283 s = src[0]+s_pos_x+s_pos_y*(w*2); |
284 dY = picture_data[0]+d_pos_x+d_pos_y*picture_linesize[0]; | |
285 dU = picture_data[1]+(d_pos_x/2)+(d_pos_y/2)*picture_linesize[1]; | |
286 dV = picture_data[2]+(d_pos_x/2)+(d_pos_y/2)*picture_linesize[2]; | |
287 | |
288 yuy2toyv12( s, dY, dU, dV, w, h, picture_linesize[0], picture_linesize[1], w*2 ); | |
289 | |
290 mp1e_buffer.data = picture_data[0]; | |
291 mp1e_buffer.time = vo_pts/90000.0; | |
292 mp1e_buffer.user_data = NULL; | |
293 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
294 return 0; | |
295 } | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
296 else if( img_format == IMGFMT_BGR24 ) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
297 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
298 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
|
299 unsigned char *s,*dY,*dU,*dV; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
300 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
301 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
|
302 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
|
303 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
304 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
|
305 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
306 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
|
307 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
|
308 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
|
309 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
310 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
311 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
312 dY+=d_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
313 dU+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
314 dV+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
315 s+=s_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
316 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
|
317 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
318 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
|
319 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
320 *dY = YUV_s.Y;dY++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
321 // 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
|
322 // *dU = YUV_s.U;dU++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
323 // *dV = YUV_s.V;dV++; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
324 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
325 *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
|
326 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
327 *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
|
328 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
329 *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
|
330 s+=3; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
331 } |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
332 dY+=d_pos_x; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
333 dU+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
334 dV+=d_pos_x/4; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
335 s+=s_pos_x; |
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 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
338 mp1e_buffer.data = picture_data[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
339 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
|
340 mp1e_buffer.user_data = NULL; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
341 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
|
342 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
343 return 0; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
344 } |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
345 |
2645 | 346 return -1; |
347 } | |
348 | |
349 static void flip_page (void) | |
350 { | |
3201 | 351 if( img_format == IMGFMT_YV12 ) |
352 { | |
353 mp1e_buffer.data = picture_data[0]; | |
354 mp1e_buffer.time = vo_pts/90000.0; | |
355 mp1e_buffer.user_data = NULL; | |
356 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
357 } | |
2645 | 358 } |
359 | |
360 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) | |
361 { | |
362 if( img_format == IMGFMT_YV12 ) | |
3201 | 363 { |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
364 int y; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
365 unsigned char *s,*s1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
366 unsigned char *d,*d1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
367 |
2645 | 368 x0+=d_pos_x; |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
369 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
|
370 |
3201 | 371 if(x0+w>picture_linesize[0]) w=picture_linesize[0]-x0; |
372 if(y0+h>c_height) h=c_height-y0; | |
2645 | 373 |
374 s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; | |
3201 | 375 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
|
376 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
377 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
378 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
379 s+=stride[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
380 d+=picture_linesize[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
381 } |
2645 | 382 |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
383 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
|
384 |
3208 | 385 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
|
386 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
|
387 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
|
388 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
|
389 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
390 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
391 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
392 memcpy(d1,s1,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
393 s+=stride[1];s1+=stride[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
394 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
|
395 } |
2645 | 396 |
397 return 0; | |
398 } | |
399 | |
400 return -1; | |
401 } | |
402 | |
403 | |
404 static uint32_t | |
405 query_format(uint32_t format) | |
406 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
407 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
|
408 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
|
409 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
|
410 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; } |
3374 | 411 else printf( "VO: [dxr3] Format unsupported, mail dholm@iname.com\n" ); |
2645 | 412 return 0; |
413 } | |
414 | |
3208 | 415 static void uninit(void) |
2645 | 416 { |
2968 | 417 printf( "VO: [dxr3] Uninitializing\n" ); |
3201 | 418 if( picture_data[0] ) free(picture_data[0]); |
419 if( fd_video ) close(fd_video); | |
420 if( fd_spu ) close(fd_spu); | |
2645 | 421 } |
422 | |
423 | |
424 static void check_events(void) | |
425 { | |
426 } | |
427 |