Mercurial > mplayer.hg
annotate libvo/vo_dxr3.c @ 4019:079177a400cb
fbdev autodetection enabled (requires linux && /dev/fb0)
test changed for directfb (requires linux && /dev/fb0)
author | pl |
---|---|
date | Sun, 06 Jan 2002 22:57:58 +0000 |
parents | f473505a2744 |
children | 5a1558a521fb |
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" | |
3432 | 24 #ifdef USE_MP1E |
3333
5c6cdf5490f0
Minor typo fix (which I thought I commited yesterday)
mswitch
parents:
3329
diff
changeset
|
25 #include "../libmp1e/libmp1e.h" |
3432 | 26 #endif |
2645 | 27 |
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
|
28 #include "../postproc/rgb2rgb.h" |
2645 | 29 #ifdef HAVE_MMX |
30 #include "mmx.h" | |
31 #endif | |
32 | |
3639
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
33 #include "aspect.h" |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
34 |
2645 | 35 LIBVO_EXTERN (dxr3) |
36 | |
3432 | 37 #ifdef USE_MP1E |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
38 rte_context *mp1e_context = NULL; |
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
39 rte_codec *mp1e_codec = NULL; |
3201 | 40 rte_buffer mp1e_buffer; |
3432 | 41 #endif |
2645 | 42 |
3201 | 43 static unsigned char *picture_data[3]; |
44 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
|
45 |
2770 | 46 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
|
47 static int s_width,s_height; |
2645 | 48 static int s_pos_x,s_pos_y; |
49 static int d_pos_x,d_pos_y; | |
50 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
|
51 |
2770 | 52 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
|
53 |
2921 | 54 static int fd_control = -1; |
55 static int fd_video = -1; | |
56 static int fd_spu = -1; | |
57 static int ioval = 0; | |
2645 | 58 |
4006 | 59 struct { |
60 int se_version; | |
61 } conf_s; | |
62 | |
2645 | 63 static vo_info_t vo_info = |
64 { | |
65 "DXR3/H+ video out", | |
66 "dxr3", | |
67 "David Holm <dholm@iname.com>", | |
68 "" | |
69 }; | |
70 | |
3432 | 71 #ifdef USE_MP1E |
3201 | 72 void write_dxr3( rte_context* context, void* data, size_t size, void* user_data ) |
73 { | |
4005 | 74 size_t data_left = size; |
4006 | 75 if(!conf_s.se_version) if(ioctl(fd_video,EM8300_IOCTL_VIDEO_SETPTS,&vo_pts) < 0) |
3828 | 76 printf( "VO: [dxr3] Unable to set pts\n" ); |
4005 | 77 while( data_left ) |
78 data_left -= write( fd_video, (void*) data+(size-data_left), data_left ); | |
3201 | 79 } |
3432 | 80 #endif |
3201 | 81 |
4006 | 82 void parseconfig( ) |
83 { | |
84 conf_s.se_version = 0; | |
85 if(vo_subdevice == NULL) return; | |
86 conf_s.se_version = 1; | |
87 } | |
88 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
89 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 | 90 { |
3639
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
91 int tmp1,tmp2; |
4006 | 92 |
93 parseconfig(); | |
2921 | 94 fd_control = open( "/dev/em8300", O_WRONLY ); |
95 if( fd_control < 1 ) | |
2645 | 96 { |
2921 | 97 printf( "VO: [dxr3] Error opening /dev/em8300 for writing!\n" ); |
98 return -1; | |
99 } | |
100 fd_video = open( "/dev/em8300_mv", O_WRONLY ); | |
101 if( fd_video < 0 ) | |
102 { | |
103 printf( "VO: [dxr3] Error opening /dev/em8300_mv for writing!\n" ); | |
104 return -1; | |
105 } | |
106 else printf( "VO: [dxr3] Opened /dev/em8300_mv\n" ); | |
107 fd_spu = open( "/dev/em8300_sp", O_WRONLY ); | |
108 if( fd_spu < 0 ) | |
109 { | |
110 printf( "VO: [dxr3] Error opening /dev/em8300_sp for writing!\n" ); | |
111 return -1; | |
2645 | 112 } |
4006 | 113 |
114 if(!conf_s.se_version) | |
115 printf( "VO: [dxr3] Using hardware sync\n" ); | |
116 else | |
117 printf( "VO: [dxr3] Using software sync\n" ); | |
2645 | 118 |
2770 | 119 /* Subpic code isn't working yet, don't set to ON |
120 unless you are really sure what you are doing */ | |
2921 | 121 ioval = EM8300_SPUMODE_OFF; |
122 if( ioctl( fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval ) < 0 ) | |
123 { | |
124 printf( "VO: [dxr3] Unable to set subpicture mode!\n" ); | |
125 return -1; | |
126 } | |
127 | |
128 ioval = EM8300_PLAYMODE_PLAY; | |
2968 | 129 if( ioctl( fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval ) < 0 ) |
2921 | 130 printf( "VO: [dxr3] Unable to set playmode!\n" ); |
131 | |
2645 | 132 img_format = format; |
3861
f832811cf89a
Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents:
3828
diff
changeset
|
133 v_width = scr_width; |
f832811cf89a
Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents:
3828
diff
changeset
|
134 v_height = scr_height; |
2921 | 135 |
3861
f832811cf89a
Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents:
3828
diff
changeset
|
136 s_width = (v_width+15)/16; s_width*=16; |
f832811cf89a
Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents:
3828
diff
changeset
|
137 s_height = (v_height+15)/16; s_height*=16; |
3639
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
138 |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
139 /* Try to figure out whether to use ws output or not */ |
3861
f832811cf89a
Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents:
3828
diff
changeset
|
140 tmp1 = abs(height - ((width/4)*3)); |
f832811cf89a
Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents:
3828
diff
changeset
|
141 tmp2 = abs(height - (int)(width/2.35)); |
3639
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
142 if(tmp1 < tmp2) |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
143 { |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
144 tmp1 = EM8300_ASPECTRATIO_4_3; |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
145 printf( "VO: [dxr3] Setting aspect ratio to 4:3\n" ); |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
146 } |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
147 else |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
148 { |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
149 tmp1 = EM8300_ASPECTRATIO_16_9; |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
150 printf( "VO: [dxr3] Setting aspect ratio to 16:9\n" ); |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
151 } |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
152 ioctl(fd_control,EM8300_IOCTL_SET_ASPECTRATIO,&tmp1); |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
153 close(fd_control); |
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
154 |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
155 if( format == IMGFMT_YV12 || format == IMGFMT_YUY2 || format == IMGFMT_BGR24 ) |
2645 | 156 { |
3432 | 157 #ifdef USE_MP1E |
2645 | 158 int size; |
3201 | 159 enum rte_frame_rate frame_rate; |
3630
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
160 enum rte_pixformat pixel_format; |
2645 | 161 |
3201 | 162 if( !rte_init() ) |
2968 | 163 { |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
164 printf( "VO: [dxr3] Unable to initialize MP1E!\n" ); |
3201 | 165 return -1; |
166 } | |
167 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
168 mp1e_context = rte_context_new( s_width, s_height, NULL ); |
3201 | 169 rte_set_verbosity( mp1e_context, 0 ); |
170 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
171 printf( "VO: [dxr3] %dx%d => %dx%d\n", v_width, v_height, s_width, s_height ); |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
172 |
3201 | 173 if( !mp1e_context ) |
174 { | |
175 printf( "VO: [dxr3] Unable to create context!\n" ); | |
176 return -1; | |
177 } | |
178 | |
179 if( !rte_set_format( mp1e_context, "mpeg1" ) ) | |
180 { | |
181 printf( "VO: [dxr3] Unable to set format\n" ); | |
182 return -1; | |
183 } | |
184 | |
185 rte_set_mode( mp1e_context, RTE_VIDEO ); | |
186 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
|
187 |
3201 | 188 if( vo_fps < 24.0 ) frame_rate = RTE_RATE_1; |
189 else if( vo_fps < 25.0 ) frame_rate = RTE_RATE_2; | |
190 else if( vo_fps < 29.97 ) frame_rate = RTE_RATE_3; | |
191 else if( vo_fps < 30.0 ) frame_rate = RTE_RATE_4; | |
192 else if( vo_fps < 50.0 ) frame_rate = RTE_RATE_5; | |
193 else if( vo_fps < 59.97 ) frame_rate = RTE_RATE_6; | |
194 else if( vo_fps < 60.0 ) frame_rate = RTE_RATE_7; | |
195 else if( vo_fps > 60.0 ) frame_rate = RTE_RATE_8; | |
196 else frame_rate = RTE_RATE_NORATE; | |
197 | |
3630
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
198 if( format == IMGFMT_YUY2 ) |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
199 pixel_format = RTE_YUYV; |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
200 else |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
201 pixel_format = RTE_YUV420; |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
202 if( !rte_set_video_parameters( mp1e_context, pixel_format, mp1e_context->width, |
3201 | 203 mp1e_context->height, frame_rate, |
3828 | 204 3e6, "I" ) ) |
3201 | 205 { |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
206 printf( "VO: [dxr3] Unable to set mp1e context!\n" ); |
3201 | 207 rte_context_destroy( mp1e_context ); |
208 return -1; | |
209 } | |
210 | |
211 rte_set_input( mp1e_context, RTE_VIDEO, RTE_PUSH, TRUE, NULL, NULL, NULL ); | |
3208 | 212 rte_set_output( mp1e_context, (void*)write_dxr3, NULL, NULL ); |
3201 | 213 |
214 if( !rte_init_context( mp1e_context ) ) | |
215 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
216 printf( "VO: [dxr3] Unable to init mp1e context!\n" ); |
3201 | 217 rte_context_delete( mp1e_context ); |
218 return -1; | |
219 } | |
220 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
221 osd_w=s_width; |
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
222 d_pos_x=(s_width-v_width)/2; |
3208 | 223 if(d_pos_x<0) |
224 { | |
225 s_pos_x=-d_pos_x;d_pos_x=0; | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
226 osd_w=s_width; |
2645 | 227 } else s_pos_x=0; |
228 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
229 osd_h=s_height; |
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
230 d_pos_y=(s_height-v_height)/2; |
3208 | 231 if(d_pos_y<0) |
232 { | |
233 s_pos_y=-d_pos_y;d_pos_y=0; | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
234 osd_h=s_height; |
2645 | 235 } else s_pos_y=0; |
236 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
237 printf("VO: [dxr3] Position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
3201 | 238 |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
239 size = s_width*s_height; |
3201 | 240 |
3759 | 241 if( format == IMGFMT_YUY2 ) |
242 { | |
243 picture_data[0] = NULL; | |
244 picture_linesize[0] = s_width * 2; | |
245 } | |
246 else | |
247 { | |
248 picture_data[0] = malloc((size * 3)/2); | |
249 picture_data[1] = picture_data[0] + size; | |
250 picture_data[2] = picture_data[1] + size / 4; | |
251 picture_linesize[0] = s_width; | |
252 picture_linesize[1] = s_width / 2; | |
253 picture_linesize[2] = s_width / 2; | |
254 } | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
255 |
3201 | 256 |
257 if( !rte_start_encoding( mp1e_context ) ) | |
2968 | 258 { |
3201 | 259 printf( "VO: [dxr3] Unable to start mp1e encoding!\n" ); |
260 uninit(); | |
261 return -1; | |
262 } | |
2770 | 263 |
3639
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
264 if(format == IMGFMT_BGR24) yuv2rgb_init(24, MODE_BGR); |
2770 | 265 return 0; |
3432 | 266 #endif |
267 return -1; | |
2770 | 268 } |
2645 | 269 else if(format==IMGFMT_MPEGPES) |
270 { | |
2921 | 271 printf( "VO: [dxr3] Format: MPEG-PES (no conversion needed)\n" ); |
2645 | 272 return 0; |
273 } | |
274 | |
3614 | 275 printf( "VO: [dxr3] Format: Unsupported\n" ); |
2645 | 276 return -1; |
277 } | |
278 | |
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
|
279 static const vo_info_t* get_info(void) |
2645 | 280 { |
281 return &vo_info; | |
282 } | |
283 | |
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
|
284 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
2645 | 285 { |
3759 | 286 switch(img_format) |
287 { | |
288 case IMGFMT_BGR24: | |
289 case IMGFMT_YV12: | |
290 vo_draw_alpha_yv12(w,h,src,srca,srcstride,picture_data[0]+(x0+d_pos_x)+(y0+d_pos_y)*picture_linesize[0],picture_linesize[0]); | |
291 break; | |
292 case IMGFMT_YUY2: | |
293 vo_draw_alpha_yuy2(w,h,src,srca,srcstride,picture_data[0]+(x0+d_pos_x)*2+(y0+d_pos_y)*picture_linesize[0],picture_linesize[0]); | |
294 break; | |
295 } | |
2645 | 296 } |
297 | |
298 static void draw_osd(void) | |
299 { | |
3759 | 300 vo_draw_text(osd_w,osd_h,draw_alpha); |
2645 | 301 } |
302 | |
303 static uint32_t draw_frame(uint8_t * src[]) | |
304 { | |
305 if( img_format == IMGFMT_MPEGPES ) | |
306 { | |
307 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; | |
4005 | 308 size_t data_left = p->size; |
3201 | 309 |
4006 | 310 if(!conf_s.se_version) if(ioctl(fd_video,EM8300_IOCTL_VIDEO_SETPTS,&vo_pts) < 0) |
3828 | 311 printf( "VO: [dxr3] Unable to set pts\n" ); |
4005 | 312 |
2645 | 313 while( data_left ) |
4005 | 314 data_left -= write( fd_video, (void*) p->data+(p->size-data_left), data_left ); |
2921 | 315 |
2645 | 316 return 0; |
317 } | |
3432 | 318 #ifdef USE_MP1E |
3208 | 319 else if( img_format == IMGFMT_YUY2 ) |
320 { | |
3759 | 321 picture_data[0] = src[0]; |
3208 | 322 return 0; |
323 } | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
324 else if( img_format == IMGFMT_BGR24 ) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
325 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
326 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
|
327 unsigned char *s,*dY,*dU,*dV; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
328 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
329 if(d_pos_x+w>picture_linesize[0]) w=picture_linesize[0]-d_pos_x; |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
330 if(d_pos_y+h>s_height) h=s_height-d_pos_y; |
3232
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 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
|
333 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 |
3639
64ee21b3bd09
Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents:
3630
diff
changeset
|
338 rgb24toyv12(s,dY,dU,dV,w,h,picture_linesize[0],picture_linesize[1],v_width*3); |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
339 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
340 mp1e_buffer.data = picture_data[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
341 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
|
342 mp1e_buffer.user_data = NULL; |
3759 | 343 vo_draw_text(osd_w,osd_h,draw_alpha); |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
344 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
|
345 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
346 return 0; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
347 } |
3432 | 348 #endif |
2645 | 349 return -1; |
350 } | |
351 | |
352 static void flip_page (void) | |
353 { | |
3432 | 354 #ifdef USE_MP1E |
3201 | 355 if( img_format == IMGFMT_YV12 ) |
356 { | |
357 mp1e_buffer.data = picture_data[0]; | |
358 mp1e_buffer.time = vo_pts/90000.0; | |
359 mp1e_buffer.user_data = NULL; | |
360 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
361 } | |
3759 | 362 else if( img_format == IMGFMT_YUY2 ) |
363 { | |
364 mp1e_buffer.data = picture_data[0]; | |
365 mp1e_buffer.time = vo_pts/90000.0; | |
366 mp1e_buffer.user_data = NULL; | |
367 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
368 } | |
3432 | 369 #endif |
2645 | 370 } |
371 | |
372 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) | |
373 { | |
374 if( img_format == IMGFMT_YV12 ) | |
3201 | 375 { |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
376 int y; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
377 unsigned char *s,*s1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
378 unsigned char *d,*d1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
379 |
2645 | 380 x0+=d_pos_x; |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
381 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
|
382 |
3201 | 383 if(x0+w>picture_linesize[0]) w=picture_linesize[0]-x0; |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
384 if(y0+h>s_height) h=s_height-y0; |
2645 | 385 |
386 s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; | |
3201 | 387 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
|
388 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
389 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
390 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
391 s+=stride[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
392 d+=picture_linesize[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
393 } |
2645 | 394 |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
395 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
|
396 |
3208 | 397 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
|
398 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
|
399 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
|
400 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
|
401 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
402 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
403 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
404 memcpy(d1,s1,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
405 s+=stride[1];s1+=stride[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
406 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
|
407 } |
2645 | 408 |
409 return 0; | |
410 } | |
411 | |
412 return -1; | |
413 } | |
414 | |
415 | |
416 static uint32_t | |
417 query_format(uint32_t format) | |
418 { | |
4006 | 419 uint32_t flag = 0; |
420 if(format==IMGFMT_MPEGPES) flag = 0x2|0x4; | |
3432 | 421 #ifdef USE_MP1E |
4006 | 422 if(format==IMGFMT_YV12) flag = 0x1|0x4; |
423 if(format==IMGFMT_YUY2) flag = 0x1|0x4; | |
424 if(format==IMGFMT_BGR24) flag = 0x1|0x4; | |
3374 | 425 else printf( "VO: [dxr3] Format unsupported, mail dholm@iname.com\n" ); |
3432 | 426 #else |
427 else printf( "VO: [dxr3] You have disabled libmp1e support, you won't be able to play this format!\n" ); | |
428 #endif | |
4006 | 429 if(!conf_s.se_version && flag) flag |= 256; |
430 return flag; | |
2645 | 431 } |
432 | |
3208 | 433 static void uninit(void) |
2645 | 434 { |
2968 | 435 printf( "VO: [dxr3] Uninitializing\n" ); |
3201 | 436 if( picture_data[0] ) free(picture_data[0]); |
437 if( fd_video ) close(fd_video); | |
438 if( fd_spu ) close(fd_spu); | |
2645 | 439 } |
440 | |
441 | |
442 static void check_events(void) | |
443 { | |
444 } | |
445 |