Mercurial > mplayer.hg
annotate libvo/vo_dxr3.c @ 3810:007b3992c6b5
fixed RTjpeg and removed one memcpy
author | alex |
---|---|
date | Thu, 27 Dec 2001 23:05:01 +0000 |
parents | a5f9c19f734f |
children | 063e5b0065a4 |
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 |
59 static vo_info_t vo_info = | |
60 { | |
61 "DXR3/H+ video out", | |
62 "dxr3", | |
63 "David Holm <dholm@iname.com>", | |
64 "" | |
65 }; | |
66 | |
3432 | 67 #ifdef USE_MP1E |
3201 | 68 void write_dxr3( rte_context* context, void* data, size_t size, void* user_data ) |
69 { | |
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
|
70 /* if(ioctl(fd_video,EM8300_IOCTL_VIDEO_SETPTS,&vo_pts) < 0) |
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
|
71 printf( "VO: [dxr3] Unable to set pts\n" );*/ |
3201 | 72 write( fd_video, data, size ); |
73 } | |
3432 | 74 #endif |
3201 | 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 { |
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
|
78 int tmp1,tmp2; |
2921 | 79 fd_control = open( "/dev/em8300", O_WRONLY ); |
80 if( fd_control < 1 ) | |
2645 | 81 { |
2921 | 82 printf( "VO: [dxr3] Error opening /dev/em8300 for writing!\n" ); |
83 return -1; | |
84 } | |
85 fd_video = open( "/dev/em8300_mv", O_WRONLY ); | |
86 if( fd_video < 0 ) | |
87 { | |
88 printf( "VO: [dxr3] Error opening /dev/em8300_mv for writing!\n" ); | |
89 return -1; | |
90 } | |
91 else printf( "VO: [dxr3] Opened /dev/em8300_mv\n" ); | |
92 fd_spu = open( "/dev/em8300_sp", O_WRONLY ); | |
93 if( fd_spu < 0 ) | |
94 { | |
95 printf( "VO: [dxr3] Error opening /dev/em8300_sp for writing!\n" ); | |
96 return -1; | |
2645 | 97 } |
98 | |
2770 | 99 /* Subpic code isn't working yet, don't set to ON |
100 unless you are really sure what you are doing */ | |
2921 | 101 ioval = EM8300_SPUMODE_OFF; |
102 if( ioctl( fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval ) < 0 ) | |
103 { | |
104 printf( "VO: [dxr3] Unable to set subpicture mode!\n" ); | |
105 return -1; | |
106 } | |
107 | |
108 ioval = EM8300_PLAYMODE_PLAY; | |
2968 | 109 if( ioctl( fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval ) < 0 ) |
2921 | 110 printf( "VO: [dxr3] Unable to set playmode!\n" ); |
111 | |
2645 | 112 img_format = format; |
2770 | 113 v_width = width; |
114 v_height = height; | |
2921 | 115 |
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
|
116 /* Calculate screen res */ |
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
|
117 aspect_save_orig(v_width,v_height); |
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
|
118 aspect_save_prescale(scr_width,scr_height); |
3661
4ecbbf74e532
Modified aspect reference, uses default PAL values... Difference to NTSC should be minimal enough so that no checking of videomode is necessary.
mswitch
parents:
3639
diff
changeset
|
119 aspect_save_screenres(702,575); /* Reference values from DVD spec (711,483) (702,575) */ |
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
|
120 aspect(&s_width,&s_height,A_NOZOOM); |
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
|
121 s_width = (scr_width+15)/16; s_width*=16; |
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
|
122 s_height = (scr_height+15)/16; s_height*=16; |
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
|
123 |
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
|
124 /* Try to figure out whether to use ws output or not */ |
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
|
125 tmp1 = abs(height - ((s_width/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
|
126 tmp2 = abs(height - ((s_width/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
|
127 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
|
128 { |
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
|
129 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
|
130 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
|
131 } |
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
|
132 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
|
133 { |
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
|
134 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
|
135 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
|
136 } |
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
|
137 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
|
138 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
|
139 |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
140 if( format == IMGFMT_YV12 || format == IMGFMT_YUY2 || format == IMGFMT_BGR24 ) |
2645 | 141 { |
3432 | 142 #ifdef USE_MP1E |
2645 | 143 int size; |
3201 | 144 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
|
145 enum rte_pixformat pixel_format; |
2645 | 146 |
3201 | 147 if( !rte_init() ) |
2968 | 148 { |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
149 printf( "VO: [dxr3] Unable to initialize MP1E!\n" ); |
3201 | 150 return -1; |
151 } | |
152 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
153 mp1e_context = rte_context_new( s_width, s_height, NULL ); |
3201 | 154 rte_set_verbosity( mp1e_context, 0 ); |
155 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
156 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
|
157 |
3201 | 158 if( !mp1e_context ) |
159 { | |
160 printf( "VO: [dxr3] Unable to create context!\n" ); | |
161 return -1; | |
162 } | |
163 | |
164 if( !rte_set_format( mp1e_context, "mpeg1" ) ) | |
165 { | |
166 printf( "VO: [dxr3] Unable to set format\n" ); | |
167 return -1; | |
168 } | |
169 | |
170 rte_set_mode( mp1e_context, RTE_VIDEO ); | |
171 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
|
172 |
3201 | 173 if( vo_fps < 24.0 ) frame_rate = RTE_RATE_1; |
174 else if( vo_fps < 25.0 ) frame_rate = RTE_RATE_2; | |
175 else if( vo_fps < 29.97 ) frame_rate = RTE_RATE_3; | |
176 else if( vo_fps < 30.0 ) frame_rate = RTE_RATE_4; | |
177 else if( vo_fps < 50.0 ) frame_rate = RTE_RATE_5; | |
178 else if( vo_fps < 59.97 ) frame_rate = RTE_RATE_6; | |
179 else if( vo_fps < 60.0 ) frame_rate = RTE_RATE_7; | |
180 else if( vo_fps > 60.0 ) frame_rate = RTE_RATE_8; | |
181 else frame_rate = RTE_RATE_NORATE; | |
182 | |
3630
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
183 if( format == IMGFMT_YUY2 ) |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
184 pixel_format = RTE_YUYV; |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
185 else |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
186 pixel_format = RTE_YUV420; |
f24527fc1b79
Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents:
3629
diff
changeset
|
187 if( !rte_set_video_parameters( mp1e_context, pixel_format, mp1e_context->width, |
3201 | 188 mp1e_context->height, frame_rate, |
3759 | 189 3e6, "IPP" ) ) |
3201 | 190 { |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
191 printf( "VO: [dxr3] Unable to set mp1e context!\n" ); |
3201 | 192 rte_context_destroy( mp1e_context ); |
193 return -1; | |
194 } | |
195 | |
196 rte_set_input( mp1e_context, RTE_VIDEO, RTE_PUSH, TRUE, NULL, NULL, NULL ); | |
3208 | 197 rte_set_output( mp1e_context, (void*)write_dxr3, NULL, NULL ); |
3201 | 198 |
199 if( !rte_init_context( mp1e_context ) ) | |
200 { | |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
201 printf( "VO: [dxr3] Unable to init mp1e context!\n" ); |
3201 | 202 rte_context_delete( mp1e_context ); |
203 return -1; | |
204 } | |
205 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
206 osd_w=s_width; |
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
207 d_pos_x=(s_width-v_width)/2; |
3208 | 208 if(d_pos_x<0) |
209 { | |
210 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
|
211 osd_w=s_width; |
2645 | 212 } else s_pos_x=0; |
213 | |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
214 osd_h=s_height; |
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
215 d_pos_y=(s_height-v_height)/2; |
3208 | 216 if(d_pos_y<0) |
217 { | |
218 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
|
219 osd_h=s_height; |
2645 | 220 } else s_pos_y=0; |
221 | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
222 printf("VO: [dxr3] Position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
3201 | 223 |
3629
a9d1ee93d1c9
Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents:
3621
diff
changeset
|
224 size = s_width*s_height; |
3201 | 225 |
3759 | 226 if( format == IMGFMT_YUY2 ) |
227 { | |
228 picture_data[0] = NULL; | |
229 picture_linesize[0] = s_width * 2; | |
230 } | |
231 else | |
232 { | |
233 picture_data[0] = malloc((size * 3)/2); | |
234 picture_data[1] = picture_data[0] + size; | |
235 picture_data[2] = picture_data[1] + size / 4; | |
236 picture_linesize[0] = s_width; | |
237 picture_linesize[1] = s_width / 2; | |
238 picture_linesize[2] = s_width / 2; | |
239 } | |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
240 |
3201 | 241 |
242 if( !rte_start_encoding( mp1e_context ) ) | |
2968 | 243 { |
3201 | 244 printf( "VO: [dxr3] Unable to start mp1e encoding!\n" ); |
245 uninit(); | |
246 return -1; | |
247 } | |
2770 | 248 |
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
|
249 if(format == IMGFMT_BGR24) yuv2rgb_init(24, MODE_BGR); |
2770 | 250 return 0; |
3432 | 251 #endif |
252 return -1; | |
2770 | 253 } |
2645 | 254 else if(format==IMGFMT_MPEGPES) |
255 { | |
2921 | 256 printf( "VO: [dxr3] Format: MPEG-PES (no conversion needed)\n" ); |
2645 | 257 return 0; |
258 } | |
259 | |
3614 | 260 printf( "VO: [dxr3] Format: Unsupported\n" ); |
2645 | 261 return -1; |
262 } | |
263 | |
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
|
264 static const vo_info_t* get_info(void) |
2645 | 265 { |
266 return &vo_info; | |
267 } | |
268 | |
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
|
269 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
2645 | 270 { |
3759 | 271 switch(img_format) |
272 { | |
273 case IMGFMT_BGR24: | |
274 case IMGFMT_YV12: | |
275 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]); | |
276 break; | |
277 case IMGFMT_YUY2: | |
278 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]); | |
279 break; | |
280 } | |
2645 | 281 } |
282 | |
283 static void draw_osd(void) | |
284 { | |
3759 | 285 vo_draw_text(osd_w,osd_h,draw_alpha); |
2645 | 286 } |
287 | |
288 static uint32_t draw_frame(uint8_t * src[]) | |
289 { | |
290 if( img_format == IMGFMT_MPEGPES ) | |
291 { | |
2770 | 292 int data_left; |
2645 | 293 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
3201 | 294 |
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
|
295 /* if(ioctl(fd_video,EM8300_IOCTL_VIDEO_SETPTS,&p->timestamp) < 0) |
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
|
296 printf( "VO: [dxr3] Unable to set pts\n" );*/ |
2645 | 297 data_left = p->size; |
298 while( data_left ) | |
2921 | 299 data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left ); |
300 | |
2645 | 301 return 0; |
302 } | |
3432 | 303 #ifdef USE_MP1E |
3208 | 304 else if( img_format == IMGFMT_YUY2 ) |
305 { | |
3759 | 306 picture_data[0] = src[0]; |
3208 | 307 return 0; |
308 } | |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
309 else if( img_format == IMGFMT_BGR24 ) |
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 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
|
312 unsigned char *s,*dY,*dU,*dV; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
313 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
314 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
|
315 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
|
316 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
317 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
|
318 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 |
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
|
323 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
|
324 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
325 mp1e_buffer.data = picture_data[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
326 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
|
327 mp1e_buffer.user_data = NULL; |
3759 | 328 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
|
329 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
|
330 |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
331 return 0; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
332 } |
3432 | 333 #endif |
2645 | 334 return -1; |
335 } | |
336 | |
337 static void flip_page (void) | |
338 { | |
3432 | 339 #ifdef USE_MP1E |
3201 | 340 if( img_format == IMGFMT_YV12 ) |
341 { | |
342 mp1e_buffer.data = picture_data[0]; | |
343 mp1e_buffer.time = vo_pts/90000.0; | |
344 mp1e_buffer.user_data = NULL; | |
345 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
346 } | |
3759 | 347 else if( img_format == IMGFMT_YUY2 ) |
348 { | |
349 mp1e_buffer.data = picture_data[0]; | |
350 mp1e_buffer.time = vo_pts/90000.0; | |
351 mp1e_buffer.user_data = NULL; | |
352 rte_push_video_buffer( mp1e_context, &mp1e_buffer ); | |
353 } | |
3432 | 354 #endif |
2645 | 355 } |
356 | |
357 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) | |
358 { | |
359 if( img_format == IMGFMT_YV12 ) | |
3201 | 360 { |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
361 int y; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
362 unsigned char *s,*s1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
363 unsigned char *d,*d1; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
364 |
2645 | 365 x0+=d_pos_x; |
3232
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
366 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
|
367 |
3201 | 368 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
|
369 if(y0+h>s_height) h=s_height-y0; |
2645 | 370 |
371 s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; | |
3201 | 372 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
|
373 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
374 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
375 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
376 s+=stride[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
377 d+=picture_linesize[0]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
378 } |
2645 | 379 |
3218
8ba06b63f873
Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents:
3208
diff
changeset
|
380 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
|
381 |
3208 | 382 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
|
383 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
|
384 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
|
385 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
|
386 for(y=0;y<h;y++) |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
387 { |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
388 memcpy(d,s,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
389 memcpy(d1,s1,w); |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
390 s+=stride[1];s1+=stride[2]; |
d037e1201721
Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents:
3218
diff
changeset
|
391 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
|
392 } |
2645 | 393 |
394 return 0; | |
395 } | |
396 | |
397 return -1; | |
398 } | |
399 | |
400 | |
401 static uint32_t | |
402 query_format(uint32_t format) | |
403 { | |
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
|
404 if(format==IMGFMT_MPEGPES) return 0x2|0x4; |
3432 | 405 #ifdef USE_MP1E |
3329
529a001496c2
Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents:
3232
diff
changeset
|
406 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
|
407 if(format==IMGFMT_YUY2) return 0x1|0x4; |
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
|
408 if(format==IMGFMT_BGR24) return 0x1|0x4; |
3374 | 409 else printf( "VO: [dxr3] Format unsupported, mail dholm@iname.com\n" ); |
3432 | 410 #else |
411 else printf( "VO: [dxr3] You have disabled libmp1e support, you won't be able to play this format!\n" ); | |
412 #endif | |
2645 | 413 return 0; |
414 } | |
415 | |
3208 | 416 static void uninit(void) |
2645 | 417 { |
2968 | 418 printf( "VO: [dxr3] Uninitializing\n" ); |
3201 | 419 if( picture_data[0] ) free(picture_data[0]); |
420 if( fd_video ) close(fd_video); | |
421 if( fd_spu ) close(fd_spu); | |
2645 | 422 } |
423 | |
424 | |
425 static void check_events(void) | |
426 { | |
427 } | |
428 |