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