Mercurial > mplayer.hg
annotate libvo/vo_dxr3.c @ 2963:510b7e4b51a5
Move ignores in subdirs to their respective .cvsignore files.
author | atmos4 |
---|---|
date | Sat, 17 Nov 2001 23:55:40 +0000 |
parents | ee37c7fc3022 |
children | 9989497ab31e |
rev | line source |
---|---|
2645 | 1 #define PES_MAX_SIZE 2048 |
2 /* | |
3 * vo_dxr3.c - DXR3/H+ video out | |
4 * | |
5 * Copyright (C) 2001 David Holm <dholm@iname.com> | |
6 * | |
7 * libav - MPEG-PS multiplexer, part of ffmpeg | |
8 * Copyright Gerard Lantau (see http://ffmpeg.sf.net) | |
9 * | |
10 */ | |
11 | |
12 #include "fastmemcpy.h" | |
13 #include <stdio.h> | |
14 #include <stdlib.h> | |
15 #include <string.h> | |
2921 | 16 #include <unistd.h> |
17 #include <linux/em8300.h> | |
18 #include <sys/ioctl.h> | |
19 #include <sys/stat.h> | |
20 #include <sys/types.h> | |
21 #include <fcntl.h> | |
2645 | 22 #include <stdio.h> |
23 #include <time.h> | |
24 | |
25 #include "config.h" | |
26 #include "video_out.h" | |
27 #include "video_out_internal.h" | |
28 | |
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
|
29 #include "../postproc/rgb2rgb.h" |
2645 | 30 #ifdef HAVE_MMX |
31 #include "mmx.h" | |
32 #endif | |
33 | |
34 LIBVO_EXTERN (dxr3) | |
35 | |
36 #ifdef USE_LIBAVCODEC | |
37 | |
38 #ifdef USE_LIBAVCODEC_SO | |
39 #include <libffmpeg/avcodec.h> | |
40 #else | |
41 #include "../libavcodec/avcodec.h" | |
42 #endif | |
43 static AVPicture picture; | |
44 static AVCodec *codec=NULL; | |
45 static AVCodecContext codec_context; | |
46 extern int avcodec_inited; | |
47 #endif | |
48 | |
49 static unsigned char *picture_buf=NULL; | |
50 static unsigned char *outbuf=NULL; | |
2770 | 51 static unsigned char *spubuf=NULL; |
52 static int outbuf_size = 0; | |
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; | |
2770 | 58 static int img_format = 0; |
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
|
59 static int palette[] = { 0x000000, 0x494949, 0xb5b5b5, 0xffffff }; |
2921 | 60 static int fd_control = -1; |
61 static int fd_video = -1; | |
62 static int fd_spu = -1; | |
63 static int ioval = 0; | |
2645 | 64 |
65 static vo_info_t vo_info = | |
66 { | |
67 "DXR3/H+ video out", | |
68 "dxr3", | |
69 "David Holm <dholm@iname.com>", | |
70 "" | |
71 }; | |
72 | |
73 static uint32_t | |
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
|
74 init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format) |
2645 | 75 { |
2921 | 76 int i; |
77 char tmp; | |
78 | |
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 } | |
2770 | 107 |
2921 | 108 /*for( i = 0; i < 64; i+= 4 ) |
109 { | |
110 tmp = palette[i]; | |
111 palette[i] = palette[i+3]; | |
112 palette[i+3] = tmp; | |
113 tmp = palette[i+1]; | |
114 palette[i+1] = palette[i+2]; | |
115 palette[i+2] = tmp; | |
116 }*/ | |
117 if( ioctl( fd_spu, EM8300_IOCTL_SPU_SETPALETTE, palette ) < 0 ) | |
118 { | |
119 printf( "VO: [dxr3] Unable to set subpicture palette!\n" ); | |
120 return -1; | |
121 } | |
122 | |
123 ioval = EM8300_PLAYMODE_PLAY; | |
124 if( ioctl( fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval ) < 0) | |
125 printf( "VO: [dxr3] Unable to set playmode!\n" ); | |
126 | |
127 close( fd_control ); | |
2645 | 128 |
129 img_format = format; | |
2770 | 130 v_width = width; |
131 v_height = height; | |
2921 | 132 spubuf = malloc(53220); /* 53220 bytes is the standardized max size of a subpic */ |
2645 | 133 picture_buf=NULL; |
2921 | 134 |
2645 | 135 if( format == IMGFMT_YV12 ) |
136 { | |
137 #ifdef USE_LIBAVCODEC | |
138 | |
139 int size; | |
140 | |
141 printf("Format: YV12\n"); | |
142 | |
143 if(!avcodec_inited){ | |
144 avcodec_init(); | |
145 avcodec_register_all(); | |
146 avcodec_inited=1; | |
147 } | |
148 | |
149 /* find the mpeg1 video encoder */ | |
150 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); | |
151 if (!codec) { | |
2921 | 152 fprintf(stderr, "mpeg1 codec not found\nRead DOCS/DXR3!\n"); |
2645 | 153 return -1; |
154 } | |
155 | |
156 memset(&codec_context,0,sizeof(codec_context)); | |
157 codec_context.bit_rate=100000; // not used | |
2770 | 158 codec_context.frame_rate=25*FRAME_RATE_BASE; |
159 codec_context.gop_size=0; | |
2645 | 160 codec_context.flags=CODEC_FLAG_QSCALE; |
2770 | 161 codec_context.quality=1; |
162 codec_context.pix_fmt = PIX_FMT_YUV420P; | |
2645 | 163 if(width<=352 && height<=288){ |
164 codec_context.width=352; | |
165 codec_context.height=288; | |
166 } else | |
167 if(width<=352 && height<=576){ | |
168 codec_context.width=352; | |
169 codec_context.height=576; | |
170 } else | |
171 if(width<=480 && height<=576){ | |
172 codec_context.width=480; | |
173 codec_context.height=576; | |
174 } else | |
175 if(width<=544 && height<=576){ | |
176 codec_context.width=544; | |
177 codec_context.height=576; | |
178 } else { | |
179 codec_context.width=704; | |
180 codec_context.height=576; | |
181 } | |
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
|
182 s_width = codec_context.width; |
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
|
183 s_height = codec_context.height;; |
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
|
184 |
2645 | 185 |
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
|
186 osd_w=scr_width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
187 d_pos_x=(codec_context.width-(int)scr_width)/2; |
2645 | 188 if(d_pos_x<0){ |
189 s_pos_x=-d_pos_x;d_pos_x=0; | |
190 osd_w=codec_context.width; | |
191 } else s_pos_x=0; | |
192 | |
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
|
193 osd_h=scr_height; |
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
|
194 d_pos_y=(codec_context.height-(int)scr_height)/2; |
2645 | 195 if(d_pos_y<0){ |
196 s_pos_y=-d_pos_y;d_pos_y=0; | |
197 osd_h=codec_context.height; | |
198 } else s_pos_y=0; | |
199 | |
200 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); | |
201 | |
202 /* open it */ | |
203 if (avcodec_open(&codec_context, codec) < 0) { | |
204 fprintf(stderr, "could not open codec\n"); | |
205 return -1; | |
206 } | |
207 | |
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
|
208 outbuf_size=10000+width*height; |
2645 | 209 outbuf = malloc(outbuf_size); |
210 | |
211 size = codec_context.width*codec_context.height; | |
2770 | 212 picture_buf = malloc((size * 3)/2); /* size for YUV 420 */ |
213 | |
214 picture.data[0] = picture_buf; | |
215 picture.data[1] = picture.data[0] + size; | |
216 picture.data[2] = picture.data[1] + size / 4; | |
217 picture.linesize[0] = codec_context.width; | |
218 picture.linesize[1] = codec_context.width / 2; | |
219 picture.linesize[2] = codec_context.width / 2; | |
220 | |
221 return 0; | |
222 #endif | |
223 return -1; | |
224 } | |
225 else if(format==IMGFMT_BGR24) | |
226 { | |
227 #ifdef USE_LIBAVCODEC | |
228 int size = 0; | |
229 printf("Format: BGR24\n"); | |
230 | |
231 if(!avcodec_inited) | |
232 { | |
233 avcodec_init(); | |
234 avcodec_register_all(); | |
235 avcodec_inited=1; | |
236 } | |
237 | |
238 /* find the mpeg1 video encoder */ | |
239 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); | |
240 if (!codec) | |
241 { | |
2921 | 242 fprintf(stderr, "mpeg1 codec not found\nRead DOCS/DXR3!\n"); |
2770 | 243 return -1; |
244 } | |
245 | |
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
|
246 outbuf_size=10000+width*height; |
2770 | 247 outbuf = malloc(outbuf_size); |
248 | |
249 memset(&codec_context,0,sizeof(codec_context)); | |
250 codec_context.bit_rate=100000; | |
251 codec_context.frame_rate=25*FRAME_RATE_BASE; | |
252 codec_context.gop_size=0; | |
253 codec_context.flags=CODEC_FLAG_QSCALE; | |
254 codec_context.quality=1; | |
255 codec_context.pix_fmt = PIX_FMT_YUV420P; | |
256 | |
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
|
257 /*if(width<=352 && height<=288){ |
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
|
258 codec_context.width=352; |
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
|
259 codec_context.height=288; |
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
|
260 } else |
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
|
261 if(width<=352 && height<=576){ |
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
|
262 codec_context.width=352; |
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
|
263 codec_context.height=576; |
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 } else |
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
|
265 if(width<=480 && height<=576){ |
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
|
266 codec_context.width=480; |
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
|
267 codec_context.height=576; |
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 } else |
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 if(width<=544 && height<=576){ |
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
|
270 codec_context.width=544; |
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
|
271 codec_context.height=576; |
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
|
272 } else { |
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 codec_context.width=704; |
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
|
274 codec_context.height=576; |
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
|
275 }*/ |
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
|
276 s_width = codec_context.width = width; |
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
|
277 s_height = codec_context.height = height; |
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
|
278 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
279 osd_w=scr_width; |
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
|
280 d_pos_x=(codec_context.width-(int)scr_width)/2; |
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
|
281 if(d_pos_x<0){ |
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
|
282 s_pos_x=-d_pos_x;d_pos_x=0; |
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
|
283 osd_w=codec_context.width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
284 } else s_pos_x=0; |
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
|
285 |
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
|
286 osd_h=scr_height; |
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
|
287 d_pos_y=(codec_context.height-(int)scr_height)/2; |
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
|
288 if(d_pos_y<0){ |
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
|
289 s_pos_y=-d_pos_y;d_pos_y=0; |
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
|
290 osd_h=codec_context.height; |
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
|
291 } else s_pos_y=0; |
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
|
292 |
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
|
293 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
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
|
294 |
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
|
295 /* open it */ |
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
|
296 if (avcodec_open(&codec_context, codec) < 0) { |
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
|
297 fprintf(stderr, "could not open codec\n"); |
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
|
298 return -1; |
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
|
299 } |
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
|
300 |
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
|
301 size = 10000+codec_context.width*codec_context.height; |
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
|
302 picture_buf = malloc((size * 3)/2); |
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
|
303 |
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
|
304 picture.data[0] = picture_buf; |
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
|
305 picture.data[1] = picture.data[0] + size; |
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
|
306 picture.data[2] = picture.data[1] + size / 4; |
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
|
307 picture.linesize[0] = codec_context.width; |
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
|
308 picture.linesize[1] = codec_context.width / 2; |
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
|
309 picture.linesize[2] = codec_context.width / 2; |
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
|
310 return 0; |
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
|
311 #endif |
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
|
312 return -1; |
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
|
313 } |
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
|
314 else if(format==IMGFMT_YUY2) |
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
|
315 { |
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
|
316 #ifdef USE_LIBAVCODEC |
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
|
317 int size = 0; |
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
|
318 printf("Format: YUY2\n"); |
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
|
319 |
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
|
320 if(!avcodec_inited) |
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
|
321 { |
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
|
322 avcodec_init(); |
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
|
323 avcodec_register_all(); |
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
|
324 avcodec_inited=1; |
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
|
325 } |
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
|
326 |
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
|
327 /* find the mpeg1 video encoder */ |
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
|
328 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); |
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
|
329 if (!codec) |
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
|
330 { |
2921 | 331 fprintf(stderr, "mpeg1 codec not found\nRead DOCS/DXR3!\n"); |
332 return -1; | |
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
|
333 } |
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
|
334 |
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
|
335 outbuf_size=10000+width*height; |
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
|
336 outbuf = malloc(outbuf_size); |
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
|
337 |
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
|
338 memset(&codec_context,0,sizeof(codec_context)); |
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
|
339 codec_context.bit_rate=100000; |
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
|
340 codec_context.frame_rate=25*FRAME_RATE_BASE; |
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
|
341 codec_context.gop_size=0; |
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
|
342 codec_context.flags=CODEC_FLAG_QSCALE; |
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
|
343 codec_context.quality=1; |
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
|
344 codec_context.pix_fmt = PIX_FMT_YUV420P; |
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
|
345 |
2770 | 346 if(width<=352 && height<=288){ |
347 codec_context.width=352; | |
348 codec_context.height=288; | |
349 } else | |
350 if(width<=352 && height<=576){ | |
351 codec_context.width=352; | |
352 codec_context.height=576; | |
353 } else | |
354 if(width<=480 && height<=576){ | |
355 codec_context.width=480; | |
356 codec_context.height=576; | |
357 } else | |
358 if(width<=544 && height<=576){ | |
359 codec_context.width=544; | |
360 codec_context.height=576; | |
361 } else { | |
362 codec_context.width=704; | |
363 codec_context.height=576; | |
364 } | |
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
|
365 s_width = codec_context.width; |
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
|
366 s_height = codec_context.height;; |
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
|
367 /* FOR DEBUGGING ONLY!! */ |
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
|
368 codec_context.width = width; |
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
|
369 codec_context.height = height; |
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
|
370 |
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
|
371 osd_w=scr_width; |
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
|
372 d_pos_x=(codec_context.width-(int)scr_width)/2; |
2770 | 373 if(d_pos_x<0){ |
374 s_pos_x=-d_pos_x;d_pos_x=0; | |
375 osd_w=codec_context.width; | |
376 } else s_pos_x=0; | |
377 | |
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
|
378 osd_h=scr_height; |
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
|
379 d_pos_y=(codec_context.height-(int)scr_height)/2; |
2770 | 380 if(d_pos_y<0){ |
381 s_pos_y=-d_pos_y;d_pos_y=0; | |
382 osd_h=codec_context.height; | |
383 } else s_pos_y=0; | |
384 | |
2921 | 385 printf("VO: [dxr3] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
2770 | 386 |
387 /* open it */ | |
388 if (avcodec_open(&codec_context, codec) < 0) { | |
389 fprintf(stderr, "could not open codec\n"); | |
390 return -1; | |
391 } | |
392 | |
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
|
393 size = 10000+codec_context.width*codec_context.height; |
2770 | 394 picture_buf = malloc((size * 3)/2); |
2645 | 395 |
396 picture.data[0] = picture_buf; | |
397 picture.data[1] = picture.data[0] + size; | |
398 picture.data[2] = picture.data[1] + size / 4; | |
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
|
399 picture.linesize[0] = codec_context.width; |
2645 | 400 picture.linesize[1] = codec_context.width / 2; |
401 picture.linesize[2] = codec_context.width / 2; | |
402 return 0; | |
403 #endif | |
2770 | 404 return -1; |
2645 | 405 } |
406 else if(format==IMGFMT_MPEGPES) | |
407 { | |
2921 | 408 printf( "VO: [dxr3] Format: MPEG-PES (no conversion needed)\n" ); |
2645 | 409 return 0; |
410 } | |
411 | |
412 printf( "Format: Unsupported\n" ); | |
413 return -1; | |
414 } | |
415 | |
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
|
416 static const vo_info_t* get_info(void) |
2645 | 417 { |
418 return &vo_info; | |
419 } | |
420 | |
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
|
421 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
2645 | 422 { |
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
|
423 int x,y,index=0; |
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
|
424 int n_rles=0, prev_nibbled=0, nibbled=0; |
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
|
425 char prevcolor=0; |
2770 | 426 unsigned char *dst = spubuf; |
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
|
427 unsigned short *subpic_size, *cs_table; |
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
|
428 subpic_size = dst+=2; |
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
|
429 cs_table = dst+=2; |
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
|
430 prevcolor = src[0]; |
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
|
431 for( y = 0; y <= (h-1); y+=2 ) |
2770 | 432 { |
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
|
433 for( x = 0; x < w; x++ ) |
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
|
434 { |
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
|
435 if( prevcolor == src[x+(y*w)] ) index++; |
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
|
436 else |
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
|
437 { |
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
|
438 if( prevcolor < 64 ) |
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
|
439 prevcolor = 0x00; |
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
|
440 else if( prevcolor < 128 ) |
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
|
441 prevcolor = 0x01; |
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
|
442 else if( prevcolor < 192 ) |
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
|
443 prevcolor = 0x02; |
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
|
444 else |
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
|
445 prevcolor = 0x03; |
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
|
446 } |
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
|
447 } |
2770 | 448 } |
2921 | 449 |
450 ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ); | |
451 write( fd_spu, spubuf, (dst-spubuf) ); | |
2645 | 452 } |
453 | |
454 static void draw_osd(void) | |
455 { | |
456 vo_draw_text(osd_w,osd_h,draw_alpha); | |
457 } | |
458 | |
459 static uint32_t draw_frame(uint8_t * src[]) | |
460 { | |
461 if( img_format == IMGFMT_MPEGPES ) | |
462 { | |
2770 | 463 int data_left; |
2645 | 464 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
465 | |
466 data_left = p->size; | |
2921 | 467 ioctl( fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts ); |
2645 | 468 while( data_left ) |
2921 | 469 data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left ); |
470 | |
2645 | 471 return 0; |
472 } | |
473 #ifdef USE_LIBAVCODEC | |
474 else if( img_format == IMGFMT_YV12 ) | |
475 { | |
476 printf("ERROR: Uninplemented\n"); | |
477 } | |
2770 | 478 else if( img_format == IMGFMT_BGR24 ) |
479 { | |
480 int tmp_size, out_size; | |
481 int wrap, wrap3, x, y; | |
482 int r, g, b, R, G, B, h = v_height, w = v_width; | |
483 unsigned char *s, *Y, *U, *V; | |
484 | |
485 if(d_pos_x+w>picture.linesize[0]) w=picture.linesize[0]-d_pos_x; | |
486 if(d_pos_y+h>codec_context.height) h=codec_context.height-d_pos_y; | |
487 | |
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
|
488 Y = picture.data[0]+d_pos_x+(d_pos_y*picture.linesize[0]); |
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
|
489 U = picture.data[1]+(d_pos_x/2)+((d_pos_y/2)*picture.linesize[1]); |
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
|
490 V = picture.data[2]+(d_pos_x/2)+((d_pos_y/2)*picture.linesize[2]); |
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
|
491 |
2770 | 492 //BGR24->YUV420P from ffmpeg, see ffmpeg.sourceforge.net for terms of license |
493 #define SCALEBITS 8 | |
494 #define ONE_HALF (1 << (SCALEBITS - 1)) | |
495 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |
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
|
496 wrap = s_width; |
2770 | 497 wrap3 = w * 3; |
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
|
498 s = src[0]+s_pos_x+(s_pos_y*wrap3); |
2770 | 499 for( y = 0; y < h; y+=2 ) |
500 { | |
501 for( x = 0; x < w; x+=2 ) | |
502 { | |
503 b = s[0]; | |
504 g = s[1]; | |
505 r = s[2]; | |
506 R = r; | |
507 G = g; | |
508 B = b; | |
509 Y[0] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
510 b = s[3]; | |
511 g = s[4]; | |
512 r = s[5]; | |
513 R += r; | |
514 G += g; | |
515 B += b; | |
516 Y[1] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
517 s += wrap3; | |
518 Y += wrap; | |
519 | |
520 b = s[0]; | |
521 g = s[1]; | |
522 r = s[2]; | |
523 R += r; | |
524 G += g; | |
525 B += b; | |
526 Y[0] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
527 b = s[3]; | |
528 g = s[4]; | |
529 r = s[5]; | |
530 R += r; | |
531 G += g; | |
532 B += b; | |
533 Y[1] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
534 U[0] = ((- FIX(0.16874) * R - FIX(0.33126) * G - FIX(0.50000) * B + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
535 V[0] = ((FIX(0.50000) * R - FIX(0.41869) * G - FIX(0.08131) * B + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
536 | |
537 U++; | |
538 V++; | |
539 s -= (wrap3-6); | |
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
|
540 Y -= (wrap-(3/2)); |
2770 | 541 } |
542 s += wrap3; | |
543 Y += wrap; | |
544 } | |
545 #undef SCALEBITS | |
546 #undef ONE_HALF | |
547 #undef FIX(x) | |
548 //End of ffmpeg code, see ffmpeg.sourceforge.net for terms of license | |
549 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture); | |
550 while( out_size ) | |
2921 | 551 out_size -= write( fd_video, &outbuf[tmp_size-out_size], out_size ); |
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
|
552 return 0; |
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
|
553 } |
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
|
554 else if( img_format == IMGFMT_YUY2 ) |
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
|
555 { |
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
|
556 int tmp_size, out_size; |
2921 | 557 int x, y, w = v_width, h = v_height; |
558 | |
559 for( y = 0; y < h; y++ ) | |
560 { | |
561 for( x = 0; x < w; x++ ) | |
562 { | |
563 } | |
564 } | |
565 | |
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
|
566 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture); |
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
|
567 while( out_size ) |
2921 | 568 out_size -= write( fd_video, &outbuf[tmp_size-out_size], out_size ); |
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
|
569 |
2770 | 570 return 0; |
571 } | |
2645 | 572 #endif |
573 | |
2770 | 574 printf( "Error in draw_frame(...)\n" ); |
2645 | 575 return -1; |
576 } | |
577 | |
578 static void flip_page (void) | |
579 { | |
580 } | |
581 | |
582 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) | |
583 { | |
584 int y; | |
585 unsigned char* s; | |
586 unsigned char* d; | |
587 int data_left; | |
588 vo_mpegpes_t *p = (vo_mpegpes_t *)srcimg[0]; | |
589 | |
590 if( img_format == IMGFMT_YV12 ) | |
591 { | |
592 #ifdef USE_LIBAVCODEC | |
2770 | 593 int out_size, tmp_size; |
2645 | 594 x0+=d_pos_x; |
595 y0+=d_pos_y; | |
596 if(x0+w>picture.linesize[0]) w=picture.linesize[0]-x0; // !! | |
597 if(y0+h>codec_context.height) h=codec_context.height-y0; | |
598 | |
599 // Y | |
600 s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; | |
601 d=picture.data[0]+x0+y0*picture.linesize[0]; | |
602 for( y = 0; y < h; y++) | |
603 { | |
604 memcpy(d,s,w); | |
605 s+=stride[0]; | |
606 d+=picture.linesize[0]; | |
607 } | |
608 | |
609 w/=2;h/=2;x0/=2;y0/=2; | |
610 | |
611 // U | |
612 s=srcimg[1]+(s_pos_x/2)+(s_pos_y/2)*stride[1]; | |
613 d=picture.data[1]+x0+y0*picture.linesize[1]; | |
614 for( y = 0; y < h; y++) | |
615 { | |
616 memcpy(d,s,w); | |
617 s+=stride[1]; | |
618 d+=picture.linesize[1]; | |
619 } | |
620 | |
621 // V | |
622 s=srcimg[2]+(s_pos_x/2)+(s_pos_y/2)*stride[2]; | |
623 d=picture.data[2]+x0+y0*picture.linesize[2]; | |
624 for(y=0;y<h;y++) | |
625 { | |
626 memcpy(d,s,w); | |
627 s+=stride[2]; | |
628 d+=picture.linesize[2]; | |
629 } | |
2770 | 630 |
631 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture); | |
632 while( out_size ) | |
2921 | 633 out_size -= write( fd_video, &outbuf[tmp_size-out_size], out_size ); |
2645 | 634 |
635 return 0; | |
636 #endif | |
2770 | 637 return -1; |
638 } | |
639 else if( img_format == IMGFMT_BGR24 ) | |
640 { | |
2645 | 641 return -1; |
642 } | |
643 else if( img_format == IMGFMT_MPEGPES ) | |
644 { | |
645 data_left = p->size; | |
646 while( data_left ) | |
2921 | 647 data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left ); |
2645 | 648 return 0; |
649 } | |
650 | |
651 return -1; | |
652 } | |
653 | |
654 | |
655 static uint32_t | |
656 query_format(uint32_t format) | |
657 { | |
2770 | 658 if(format==IMGFMT_MPEGPES) return 0x2|0x4; |
2645 | 659 #ifdef USE_LIBAVCODEC |
2770 | 660 if(format==IMGFMT_YV12) return 0x1|0x4; |
2921 | 661 // if(format==IMGFMT_YUY2) return 0x1|0x4; |
2770 | 662 if(format==IMGFMT_BGR24) return 0x1|0x4; |
663 #else | |
664 if(format==IMGFMT_YV12) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;} | |
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
|
665 if(format==IMGFMT_YUY2) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;} |
2770 | 666 if(format==IMGFMT_BGR24) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;} |
667 #endif | |
2645 | 668 return 0; |
669 } | |
670 | |
671 static void | |
672 uninit(void) | |
673 { | |
2770 | 674 free(outbuf); |
675 free(picture_buf); | |
676 free(spubuf); | |
2921 | 677 close(fd_video); |
678 close(fd_spu); | |
2645 | 679 } |
680 | |
681 | |
682 static void check_events(void) | |
683 { | |
684 } | |
685 |