comparison libvo/vo_vesa.c @ 2308:ce35271bdb10

Best fix of slice drawing with libmpeg2
author nick
date Sat, 20 Oct 2001 16:56:24 +0000
parents 1dcf06bfad9b
children 00f64d5858b8
comparison
equal deleted inserted replaced
2307:1dcf06bfad9b 2308:ce35271bdb10
76 static uint32_t image_width, image_height; /* source image dimension */ 76 static uint32_t image_width, image_height; /* source image dimension */
77 static uint32_t x_offset,y_offset; /* to center image on screen */ 77 static uint32_t x_offset,y_offset; /* to center image on screen */
78 static unsigned init_mode; /* mode before run of mplayer */ 78 static unsigned init_mode; /* mode before run of mplayer */
79 static void *init_state = NULL; /* state before run of mplayer */ 79 static void *init_state = NULL; /* state before run of mplayer */
80 static struct win_frame win; /* real-mode window to video memory */ 80 static struct win_frame win; /* real-mode window to video memory */
81 static void *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */ 81 static uint8_t *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */
82 static unsigned video_mode; /* selected video mode for playback */ 82 static unsigned video_mode; /* selected video mode for playback */
83 static struct VesaModeInfoBlock video_mode_info; 83 static struct VesaModeInfoBlock video_mode_info;
84 84
85 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) 85 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS)
86 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_READABLE | MODE_WIN_WRITEABLE) 86 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_READABLE | MODE_WIN_WRITEABLE)
210 Copies frame to video memory. Data should be in the same format as video 210 Copies frame to video memory. Data should be in the same format as video
211 memory. 211 memory.
212 */ 212 */
213 static void __vbeCopyData(uint8_t *image) 213 static void __vbeCopyData(uint8_t *image)
214 { 214 {
215 unsigned long i,j,image_offset,offset,limit; 215 unsigned long i,j,image_offset,offset;
216 unsigned pixel_size,image_line_size,screen_line_size,x_shift; 216 unsigned pixel_size,image_line_size,screen_line_size,x_shift;
217 pixel_size = (video_mode_info.BitsPerPixel+7)/8; 217 pixel_size = (video_mode_info.BitsPerPixel+7)/8;
218 screen_line_size = video_mode_info.XResolution*pixel_size; 218 screen_line_size = video_mode_info.XResolution*pixel_size;
219 image_line_size = image_width*pixel_size; 219 image_line_size = image_width*pixel_size;
220 if(image_width == video_mode_info.XResolution) 220 if(image_width == video_mode_info.XResolution)
223 __vbeCopyBlock(y_offset*screen_line_size,image,image_line_size*image_height); 223 __vbeCopyBlock(y_offset*screen_line_size,image,image_line_size*image_height);
224 } 224 }
225 else 225 else
226 { 226 {
227 x_shift = x_offset*pixel_size; 227 x_shift = x_offset*pixel_size;
228 limit = image_height+y_offset; 228 for(j=0,i=y_offset;j<image_height;i++,j++)
229 for(j=0,i=y_offset;i<limit;i++,j++)
230 { 229 {
231 offset = i*screen_line_size+x_shift; 230 offset = i*screen_line_size+x_shift;
232 image_offset = j*image_line_size; 231 image_offset = j*image_line_size;
233 __vbeCopyBlock(offset,&image[image_offset],image_line_size); 232 __vbeCopyBlock(offset,&image[image_offset],image_line_size);
234 } 233 }
235 } 234 }
236 } 235 }
237 /* is called for yuv only */ 236 /* is called for yuv only */
238 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) 237 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
239 { 238 {
239 uint8_t *yuv_slice;
240 if(vesa_zoom) 240 if(vesa_zoom)
241 { 241 {
242 SwScale_YV12slice_brg24(image,stride,y,h, 242 SwScale_YV12slice_brg24(image,stride,y,h,
243 yuv_buffer, 243 yuv_buffer,
244 image_width*((video_mode_info.BitsPerPixel+7)/8), 244 image_width*((video_mode_info.BitsPerPixel+7)/8),
245 image_width, video_mode_info.BitsPerPixel, 245 image_width, video_mode_info.BitsPerPixel,
246 scale_xinc, scale_yinc); 246 scale_xinc, scale_yinc);
247 } 247 }
248 else 248 else
249 { 249 {
250 uint8_t *yuv_slice;
251 yuv_slice=yuv_buffer+(image_width*y+x)*(video_mode_info.BitsPerPixel+7)/8; 250 yuv_slice=yuv_buffer+(image_width*y+x)*(video_mode_info.BitsPerPixel+7)/8;
252 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h, 251 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h,
253 image_width * ((video_mode_info.BitsPerPixel+7)/8), 252 image_width * ((video_mode_info.BitsPerPixel+7)/8),
254 stride[0], stride[1]); 253 stride[0], stride[1]);
255 } 254 }
256 __vbeCopyData((uint8_t *)yuv_buffer); 255 if(y || x || w != image_width || h != image_height)
256 {
257 unsigned long i,j,image_offset,offset;
258 unsigned pixel_size,image_line_size,screen_line_size,x_shift;
259 pixel_size = (video_mode_info.BitsPerPixel+7)/8;
260 screen_line_size = video_mode_info.XResolution*pixel_size;
261 image_line_size = w*pixel_size;
262 x_shift = (x_offset+x)*pixel_size;
263 for(j=0,i=(y_offset+y);j<h;i++,j++)
264 {
265 offset = i*screen_line_size+x_shift;
266 image_offset = j*image_line_size;
267 __vbeCopyBlock(offset,&yuv_slice[image_offset],image_line_size);
268 }
269 }
270 else __vbeCopyData((uint8_t *)yuv_buffer);
257 return 0; 271 return 0;
258 } 272 }
259 273
260 static void draw_osd(void) 274 static void draw_osd(void)
261 { 275 {
353 unsigned short *mode_ptr,win_seg; 367 unsigned short *mode_ptr,win_seg;
354 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; 368 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX;
355 int err; 369 int err;
356 image_width = width; 370 image_width = width;
357 image_height = height; 371 image_height = height;
358 printf("subdevice: %s\n",vo_subdevice);
359 if(fullscreen & (0x1|0x8)) 372 if(fullscreen & (0x1|0x8))
360 { 373 {
361 printf("vo_vesa: switches: -fs, -flip are not supported\n"); 374 printf("vo_vesa: switches: -fs, -flip are not supported\n");
362 } 375 }
363 if(fullscreen & 0x04) vesa_zoom = 1; 376 if(fullscreen & 0x04) vesa_zoom = 1;