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