annotate libvo/vo_vesa.c @ 5161:b9ba9cefcd7d

Mp4S fixed
author arpi
date Sun, 17 Mar 2002 14:21:07 +0000
parents cbce019d2d94
children e01c664def74
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2506
diff changeset
1 /*
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
2 * video_out_vesa.c
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
3 *
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
5 *
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
6 * You can redistribute this file under terms and conditions
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
7 * of GNU General Public licence v2.
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
8 * This file is partly based on vbetest.c from lrmi distributive.
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
9 */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
10
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
11 /*
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
12 TODO:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
13 - hw YUV support (need volunteers who have corresponding hardware)
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
14 - triple buffering (if it will really speedup playback).
2692
b8e628b7a029 Minor notes
nick
parents: 2689
diff changeset
15 note: triple buffering requires VBE 3.0 - need volunteers.
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
16 - refresh rate support (need additional info from mplayer)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
17 */
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2774
diff changeset
18 #include "config.h"
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2774
diff changeset
19
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
20 #include <stdio.h>
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2774
diff changeset
21 #ifdef HAVE_MALLOC_H
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2774
diff changeset
22 #include <malloc.h>
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2774
diff changeset
23 #endif
2446
6fb598bd7ede Suppressing warnings
nick
parents: 2410
diff changeset
24 #include <stdlib.h>
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
25 #include <string.h>
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
26 #include <stddef.h>
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
27 #include <limits.h>
4739
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
28 #include <unistd.h>
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
29 #include <pwd.h>
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
30 #include <sys/types.h>
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
31 #include <sys/stat.h>
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
32
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
33
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
34 #include "video_out.h"
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
35 #include "video_out_internal.h"
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
36
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
37 #include "fastmemcpy.h"
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
38 #include "sub.h"
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
39 #include "linux/vbelib.h"
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
40 #include "bswap.h"
2689
6a5b6b16d85c Use standard aspect code
nick
parents: 2688
diff changeset
41 #include "aspect.h"
3202
e9b18714e3dc Minor optimization
nick
parents: 2971
diff changeset
42 #include "vesa_lvo.h"
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
43 #ifdef CONFIG_VIDIX
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
44 #include "vosub_vidix.h"
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
45 #endif
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
46
2298
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
47 #include "../postproc/swscale.h"
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
48
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
49 LIBVO_EXTERN(vesa)
4739
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
50
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
51 #ifdef HAVE_PNG
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
52 extern vo_functions_t video_out_png;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
53 #endif
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
54
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
55 extern int verbose;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
56
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
57 #define MAX_BUFFERS 3
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
58
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
59 #ifndef max
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
60 #define max(a,b) ((a)>(b)?(a):(b))
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
61 #endif
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
62 #ifndef min
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
63 #define min(a,b) ((a)<(b)?(a):(b))
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
64 #endif
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
65
2688
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
66 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
67
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
68 static vo_info_t vo_info =
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
69 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
70 "VESA VBE 2.0 video output",
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
71 "vesa",
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
72 "Nick Kurshev <nickols_k@mail.ru>",
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
73 "Requires ROOT privileges"
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
74 };
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
75
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
76 /* driver data */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
77
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
78 struct win_frame
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
79 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
80 uint8_t *ptr; /* pointer to window's frame memory */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
81 uint32_t low; /* lowest boundary of frame */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
82 uint32_t high; /* highest boundary of frame */
2610
65cb69a90a9f vo_vesa: DGA support
nick
parents: 2554
diff changeset
83 char idx; /* indicates index of relocatable frame (A=0 or B=1)
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
84 special case for DGA: idx=-1
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
85 idx=-2 indicates invalid frame, exists only in init() */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
86 };
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
87
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
88 static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
89
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
90 static uint32_t srcW=0,srcH=0,srcBpp,srcFourcc; /* source image description */
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
91 static uint32_t dstBpp,dstW, dstH,dstFourcc; /* destinition image description */
2298
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
92
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
93 static SwsContext * sws = NULL;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
94
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
95 static int32_t x_offset,y_offset; /* to center image on screen */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
96 static unsigned init_mode; /* mode before run of mplayer */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
97 static void *init_state = NULL; /* state before run of mplayer */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
98 static struct win_frame win; /* real-mode window to video memory */
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
99 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
100 static unsigned video_mode; /* selected video mode for playback */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
101 static struct VesaModeInfoBlock video_mode_info;
2331
9e8585a7182e Final fix of libmpeg2 zooming: flipping page support
nick
parents: 2329
diff changeset
102 static int flip_trigger = 0;
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
103 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
104
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
105 /* multibuffering */
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
106 uint8_t* video_base; /* should be never changed */
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
107 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
108 uint8_t multi_size=0; /* total number of buffers */
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
109 uint8_t multi_idx=0; /* active buffer */
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
110
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
111 /* Linux Video Overlay */
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
112 static const char *lvo_name = NULL;
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
113 #ifdef CONFIG_VIDIX
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
114 static const char *vidix_name = NULL;
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
115 #endif
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
116
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
117 #define HAS_DGA() (win.idx == -1)
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
118 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS)
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
119 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_WRITEABLE)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
120
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
121 static char * vbeErrToStr(int err)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
122 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
123 char *retval;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
124 static char sbuff[80];
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
125 if((err & VBE_VESA_ERROR_MASK) == VBE_VESA_ERROR_MASK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
126 {
4667
95fa3901cafc add vsync support for doublebuffering to vo_vesa
atmos4
parents: 4601
diff changeset
127 sprintf(sbuff,"VESA failed = 0x4f%02x",(err & VBE_VESA_ERRCODE_MASK)>>8);
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
128 retval = sbuff;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
129 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
130 else
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
131 switch(err)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
132 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
133 case VBE_OK: retval = "No error"; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
134 case VBE_VM86_FAIL: retval = "vm86() syscall failed"; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
135 case VBE_OUT_OF_DOS_MEM: retval = "Out of DOS memory"; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
136 case VBE_OUT_OF_MEM: retval = "Out of memory"; break;
2360
aa4d96380b7f Broken BIOS test
nick
parents: 2337
diff changeset
137 case VBE_BROKEN_BIOS: retval = "Broken BIOS or DOS TSR"; break;
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
138 default: sprintf(sbuff,"Unknown or internal error: %i",err); retval=sbuff; break;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
139 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
140 return retval;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
141 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
142
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
143 #define PRINT_VBE_ERR(name,err) { printf("vo_vesa: %s returns: %s\n",name,vbeErrToStr(err)); fflush(stdout); }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
144
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
145 static void vesa_term( void )
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
146 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
147 int err;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
148 if(lvo_name) vlvo_term();
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
149 #ifdef CONFIG_VIDIX
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
150 else if(vidix_name) vidix_term();
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
151 #endif
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
152 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
153 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err);
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
154 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high);
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
155 if(dga_buffer && !HAS_DGA()) free(dga_buffer);
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
156 vbeDestroy();
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
157 if(sws) freeSwsContext(sws);
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
158 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
159
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
160 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
161 #define VIDEO_PTR(offset) (win.ptr + offset - win.low)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
162
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
163 static inline void __vbeSwitchBank(unsigned long offset)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
164 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
165 unsigned long gran;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
166 unsigned new_offset;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
167 int err;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
168 gran = video_mode_info.WinGranularity*1024;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
169 new_offset = offset / gran;
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
170 if(HAS_DGA()) { err = -1; goto show_err; }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
171 if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
172 {
2610
65cb69a90a9f vo_vesa: DGA support
nick
parents: 2554
diff changeset
173 show_err:
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
174 vesa_term();
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
175 PRINT_VBE_ERR("vbeSetWindow",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
176 printf("vo_vesa: Fatal error occured! Can't continue\n");
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
177 exit(-1);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
178 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
179 win.low = new_offset * gran;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
180 win.high = win.low + video_mode_info.WinSize*1024;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
181 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
182
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
183 static void __vbeSetPixel(int x, int y, int r, int g, int b)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
184 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
185 int x_res = video_mode_info.XResolution;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
186 int y_res = video_mode_info.YResolution;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
187 int shift_r = video_mode_info.RedFieldPosition;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
188 int shift_g = video_mode_info.GreenFieldPosition;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
189 int shift_b = video_mode_info.BlueFieldPosition;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
190 int pixel_size = (dstBpp+7)/8;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
191 int bpl = video_mode_info.BytesPerScanLine;
2676
d3393d940aa5 Fixed rgb2rgb in DGA mode
nick
parents: 2649
diff changeset
192 int color;
d3393d940aa5 Fixed rgb2rgb in DGA mode
nick
parents: 2649
diff changeset
193 unsigned offset;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
194
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
195 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
196 r >>= 8 - video_mode_info.RedMaskSize;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
197 g >>= 8 - video_mode_info.GreenMaskSize;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
198 b >>= 8 - video_mode_info.BlueMaskSize;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
199 color = (r << shift_r) | (g << shift_g) | (b << shift_b);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
200 offset = y * bpl + (x * pixel_size);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
201 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
202 memcpy(VIDEO_PTR(offset), &color, pixel_size);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
203 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
204
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
205 /*
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
206 Copies part of frame to video memory. Data should be in the same format
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
207 as video memory.
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
208 */
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
209 static void __vbeCopyBlockFast(unsigned long offset,uint8_t *image,unsigned long size)
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
210 {
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
211 memcpy(&win.ptr[offset],image,size);
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
212 }
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
213
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
214 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
215 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
216 unsigned long delta,src_idx = 0;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
217 while(size)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
218 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
219 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset);
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
220 delta = min(size,win.high - offset);
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
221 memcpy(VIDEO_PTR(offset),&image[src_idx],delta);
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
222 src_idx += delta;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
223 offset += delta;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
224 size -= delta;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
225 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
226 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
227
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
228 /*
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
229 Copies frame to video memory. Data should be in the same format as video
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
230 memory.
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
231 */
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
232
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
233 #define PIXEL_SIZE() ((dstBpp+7)/8)
2676
d3393d940aa5 Fixed rgb2rgb in DGA mode
nick
parents: 2649
diff changeset
234 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
235 #define IMAGE_LINE_SIZE(pixel_size) (dstW*(pixel_size))
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
236
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
237 static void __vbeCopyData(uint8_t *image)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
238 {
2308
ce35271bdb10 Best fix of slice drawing with libmpeg2
nick
parents: 2307
diff changeset
239 unsigned long i,j,image_offset,offset;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
240 unsigned pixel_size,image_line_size,screen_line_size,x_shift;
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
241 pixel_size = PIXEL_SIZE();
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
242 screen_line_size = SCREEN_LINE_SIZE(pixel_size);
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
243 image_line_size = IMAGE_LINE_SIZE(pixel_size);
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
244 if(dstW == video_mode_info.XResolution)
2306
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
245 {
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
246 /* Special case for zooming */
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
247 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*dstH);
2306
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
248 }
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
249 else
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
250 {
2306
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
251 x_shift = x_offset*pixel_size;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
252 for(j=0,i=y_offset;j<dstH;i++,j++)
2306
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
253 {
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
254 offset = i*screen_line_size+x_shift;
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
255 image_offset = j*image_line_size;
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
256 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size);
2306
42cf51474f45 Qualitative speedup for P3 & K7 cpus
nick
parents: 2305
diff changeset
257 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
258 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
259 }
2328
00f64d5858b8 Bad fix of libmpeg2 zooming
nick
parents: 2308
diff changeset
260
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
261 /* is called for yuv only */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
262 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
263 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
264 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
265 uint8_t *dst[3]= {dga_buffer, NULL, NULL};
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
266 int dstStride[3];
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
267 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
268 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y);
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
269 dstStride[0]=dstride*((dstBpp+7)/8);
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
270 dstStride[1]=
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
271 dstStride[2]=dstStride[0]>>1;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
272 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE();
4554
16fdb694cf13 swScale internally uses yuv2rgb now if possible
michael
parents: 4548
diff changeset
273 sws->swScale(sws,image,stride,y,h,dst,dstStride);
2331
9e8585a7182e Final fix of libmpeg2 zooming: flipping page support
nick
parents: 2329
diff changeset
274 flip_trigger = 1;
2298
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
275 return 0;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
276 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
277
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
278 /* Please comment it out if you want have OSD within movie */
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
279 #define OSD_OUTSIDE_MOVIE 1
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
280
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
281 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
282 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
283 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
284 #ifndef OSD_OUTSIDE_MOVIE
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
285 if(HAS_DGA())
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
286 {
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
287 x0 += x_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
288 y0 += y_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
289 }
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
290 #endif
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
291 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride);
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
292 }
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
293
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
294 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
295 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
296 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
297 #ifndef OSD_OUTSIDE_MOVIE
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
298 if(HAS_DGA())
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
299 {
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
300 x0 += x_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
301 y0 += y_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
302 }
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
303 #endif
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
304 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride);
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
305 }
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
306
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
307 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
308 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
309 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
310 #ifndef OSD_OUTSIDE_MOVIE
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
311 if(HAS_DGA())
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
312 {
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
313 x0 += x_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
314 y0 += y_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
315 }
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
316 #endif
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
317 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride);
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
318 }
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
319
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
320 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
321 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
322 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
323 #ifndef OSD_OUTSIDE_MOVIE
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
324 if(HAS_DGA())
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
325 {
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
326 x0 += x_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
327 y0 += y_offset;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
328 }
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
329 #endif
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
330 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride);
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
331 }
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
332
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
333 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
334 {
2688
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
335 UNUSED(x0);
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
336 UNUSED(y0);
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
337 UNUSED(w);
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
338 UNUSED(h);
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
339 UNUSED(src);
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
340 UNUSED(srca);
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
341 UNUSED(stride);
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
342 }
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
343
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
344
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
345 static void draw_osd(void)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
346 {
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
347 uint32_t w,h;
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
348 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
349 printf("vo_vesa: draw_osd was called\n");
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
350 {
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
351 #ifdef OSD_OUTSIDE_MOVIE
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
352 w = HAS_DGA()?video_mode_info.XResolution:dstW;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
353 h = HAS_DGA()?video_mode_info.YResolution:dstH;
4572
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
354 #else
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
355 w = dstW;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
356 h = dstH;
67d10f13a930 Configurable OSD zones
nick
parents: 4554
diff changeset
357 #endif
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
358 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
359 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
360 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
361
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
362 static void flip_page(void)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
363 {
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
364 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
365 printf("vo_vesa: flip_page was called\n");
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
366 if(flip_trigger)
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
367 {
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
368 if(!HAS_DGA()) __vbeCopyData(dga_buffer);
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
369 flip_trigger = 0;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
370 }
4493
be41ab8c8918 code cleanup
nick
parents: 4434
diff changeset
371 if(vo_doublebuffering && multi_size > 1)
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
372 {
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
373 int err;
4667
95fa3901cafc add vsync support for doublebuffering to vo_vesa
atmos4
parents: 4601
diff changeset
374 if((err=vbeSetDisplayStart(multi_buff[multi_idx],vo_vsync)) != VBE_OK)
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
375 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
376 vesa_term();
2692
b8e628b7a029 Minor notes
nick
parents: 2689
diff changeset
377 PRINT_VBE_ERR("vbeSetDisplayStart",err);
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
378 printf("vo_vesa: Fatal error occured! Can't continue\n");
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
379 exit(EXIT_FAILURE);
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
380 }
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
381 multi_idx = multi_idx ? 0 : 1;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
382 win.ptr = dga_buffer = video_base + multi_buff[multi_idx];
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
383 }
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
384 /*
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
385 else
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
386 if(tripple_buffering)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
387 {
4667
95fa3901cafc add vsync support for doublebuffering to vo_vesa
atmos4
parents: 4601
diff changeset
388 vbeSetScheduledDisplayStart(multi_buff[multi_idx],vo_vsync);
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
389 multi_idx++;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
390 if(multi_idx > 2) multi_idx = 0;
4667
95fa3901cafc add vsync support for doublebuffering to vo_vesa
atmos4
parents: 4601
diff changeset
391 win.ptr = dga_buffer = video_base + multi_buff[multi_idx];
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
392 }
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
393 */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
394 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
395
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
396 /* is called for rgb only */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
397 static uint32_t draw_frame(uint8_t *src[])
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
398 {
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
399 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
400 printf("vo_vesa: draw_frame was called\n");
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
401 if(sws)
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
402 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
403 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
404 int srcStride[1];
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
405 uint8_t *dst[3]= {dga_buffer, NULL, NULL};
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
406 int dstStride[3];
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
407 dstStride[0]=dstride*((dstBpp+7)/8);
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
408 dstStride[1]=
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
409 dstStride[2]=dstStride[0]>>1;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
410 if(srcFourcc == IMGFMT_RGB32 || srcFourcc == IMGFMT_BGR32)
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
411 srcStride[0] = srcW*4;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
412 else
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
413 if(srcFourcc == IMGFMT_RGB24 || srcFourcc == IMGFMT_BGR24)
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
414 srcStride[0] = srcW*3;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
415 else
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
416 srcStride[0] = srcW*2;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
417 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE();
4554
16fdb694cf13 swScale internally uses yuv2rgb now if possible
michael
parents: 4548
diff changeset
418 sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride);
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
419 flip_trigger=1;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
420 }
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
421 return 0;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
422 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
423
2953
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
424 #define SUBDEV_NODGA 0x00000001UL
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
425 #define SUBDEV_FORCEDGA 0x00000002UL
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
426 static uint32_t subdev_flags = 0xFFFFFFFEUL;
2953
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
427 static uint32_t parseSubDevice(const char *sd)
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
428 {
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
429 uint32_t flags;
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
430 flags = 0;
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
431 if(strcmp(sd,"nodga") == 0) { flags |= SUBDEV_NODGA; flags &= ~(SUBDEV_FORCEDGA); }
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
432 else
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
433 if(strcmp(sd,"dga") == 0) { flags &= ~(SUBDEV_NODGA); flags |= SUBDEV_FORCEDGA; }
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
434 else
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
435 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
436 #ifdef CONFIG_VIDIX
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
437 else
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
438 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
439 #endif
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
440 else { printf("vo_vesa: Unknown subdevice: '%s'\n", sd); return 0xFFFFFFFFUL; }
2953
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
441 return flags;
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
442 }
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
443
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
444 static uint32_t query_format(uint32_t format)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
445 {
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
446 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
447 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format));
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
448 return 1; /* due new SwScale code */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
449 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
450
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
451 static void paintBkGnd( void )
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
452 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
453 int x_res = video_mode_info.XResolution;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
454 int y_res = video_mode_info.YResolution;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
455 int x, y;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
456
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
457 for (y = 0; y < y_res; ++y)
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
458 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
459 for (x = 0; x < x_res; ++x)
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
460 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
461 int r, g, b;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
462 if ((x & 16) ^ (y & 16))
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
463 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
464 r = x * 255 / x_res;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
465 g = y * 255 / y_res;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
466 b = 255 - x * 255 / x_res;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
467 }
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
468 else
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
469 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
470 r = 255 - x * 255 / x_res;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
471 g = y * 255 / y_res;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
472 b = 255 - y * 255 / y_res;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
473 }
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
474 __vbeSetPixel(x, y, r, g, b);
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
475 }
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
476 }
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
477 }
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
478
2914
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
479 static void clear_screen( void )
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
480 {
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
481 int x_res = video_mode_info.XResolution;
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
482 int y_res = video_mode_info.YResolution;
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
483 int x, y;
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
484
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
485 for (y = 0; y < y_res; ++y)
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
486 for (x = 0; x < x_res; ++x)
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
487 __vbeSetPixel(x, y, 0, 0, 0);
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
488 }
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
489
2293
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
490 static char *model2str(unsigned char type)
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
491 {
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
492 char *retval;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
493 switch(type)
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
494 {
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
495 case memText: retval = "Text"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
496 case memCGA: retval="CGA"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
497 case memHercules: retval="Hercules"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
498 case memPL: retval="Planar"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
499 case memPK: retval="Packed pixel"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
500 case mem256: retval="256"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
501 case memRGB: retval="Direct color RGB"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
502 case memYUV: retval="Direct color YUV"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
503 default: retval="Unknown"; break;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
504 }
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
505 return retval;
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
506 }
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
507
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
508 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs )
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
509 {
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
510 unsigned long screen_size, offset;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
511 unsigned total,i;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
512 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((dstBpp+7)/8);
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
513 if(screen_size%64) screen_size=((screen_size/64)*64)+64;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
514 total = vsize / screen_size;
2918
a4646faefabd No comments
nick
parents: 2914
diff changeset
515 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total);
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
516 i = 0;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
517 offset = 0;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
518 total = min(total,nbuffs);
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
519 while(i < total) { multi_buff[i++] = offset; offset += screen_size; }
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
520 if(!i)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
521 printf("vo_vesa: Your have too small size of video memory for this mode:\n"
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
522 "vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize);
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
523 return i;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
524 }
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
525
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
526
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
527 /* fullscreen:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
528 * bit 0 (0x01) means fullscreen (-fs)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
529 * bit 1 (0x02) means mode switching (-vm)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
530 * bit 2 (0x04) enables software scaling (-zoom)
2335
26fdd1a317ad Again changed logic:
nick
parents: 2333
diff changeset
531 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?)
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
532 */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
533 static uint32_t
4433
df8e0f71cc3c new info for tuning
nick
parents: 4362
diff changeset
534 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format,const vo_tune_info_t *info)
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
535 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
536 struct VbeInfoBlock vib;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
537 struct VesaModeInfoBlock vmib;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
538 size_t i,num_modes;
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
539 uint32_t w,h;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
540 unsigned short *mode_ptr,win_seg;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
541 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX;
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
542 int err,fs_mode,use_scaler=0;
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
543 srcW = dstW = width;
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
544 srcH = dstH = height;
2336
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
545 fs_mode = 0;
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
546 if(subdev_flags == 0xFFFFFFFEUL)
2971
56faed773768 Added preinit of lvo stuff
nick
parents: 2966
diff changeset
547 {
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
548 printf("vo_vesa: detected internal fatal error: init is called before preinit\n");
2971
56faed773768 Added preinit of lvo stuff
nick
parents: 2966
diff changeset
549 return -1;
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
550 }
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
551 if(subdev_flags == 0xFFFFFFFFUL) return -1;
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
552 if(flags & 0x8)
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
553 {
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
554 printf("vo_vesa: switch -flip is not supported\n");
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
555 }
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
556 if(flags & 0x04) use_scaler = 1;
2336
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
557 if(flags & 0x01)
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
558 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
559 if(use_scaler) use_scaler = 2;
2336
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
560 else fs_mode = 1;
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
561 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
562 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
563 memcpy(vib.VESASignature,"VBE2",4);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
564 if((err=vbeGetControllerInfo(&vib)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
565 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
566 PRINT_VBE_ERR("vbeGetControllerInfo",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
567 printf("vo_vesa: possible reason: No VBE2 BIOS found\n");
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
568 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
569 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
570 /* Print general info here */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
571 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n",
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
572 (int)(vib.VESAVersion >> 8) & 0xff,
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
573 (int)(vib.VESAVersion & 0xff),
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
574 (int)(vib.OemSoftwareRev & 0xffff));
2255
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
575 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64);
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
576 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n"
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
577 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC,"
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
578 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC,"
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
579 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC,"
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
580 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic,"
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
581 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo");
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
582 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n");
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
583 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n");
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
584 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr);
2255
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
585 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev);
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
586 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr);
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
587 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr);
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
588 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr);
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
589 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n"
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
590 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n");
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
591 /* Find best mode here */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
592 num_modes = 0;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
593 mode_ptr = vib.VideoModePtr;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
594 while(*mode_ptr++ != 0xffff) num_modes++;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
595 switch(format)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
596 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
597 case IMGFMT_BGR8:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
598 case IMGFMT_RGB8: bpp = 8; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
599 case IMGFMT_BGR15:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
600 case IMGFMT_RGB15: bpp = 15; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
601 case IMGFMT_BGR16:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
602 case IMGFMT_RGB16: bpp = 16; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
603 case IMGFMT_BGR24:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
604 case IMGFMT_RGB24: bpp = 24; break;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
605 case IMGFMT_BGR32:
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
606 case IMGFMT_RGB32: bpp = 32; break;
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
607 default: bpp = 16; break;
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
608 }
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
609 srcBpp = bpp;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
610 srcFourcc = format;
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
611 if(vo_dbpp) bpp = vo_dbpp;
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
612 switch(bpp)
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
613 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
614 case 15: draw_alpha_fnc = draw_alpha_15;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
615 dstFourcc = IMGFMT_BGR15;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
616 break;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
617 case 16: draw_alpha_fnc = draw_alpha_16;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
618 dstFourcc = IMGFMT_BGR16;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
619 break;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
620 case 24: draw_alpha_fnc = draw_alpha_24;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
621 dstFourcc = IMGFMT_BGR24;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
622 break;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
623 case 32: draw_alpha_fnc = draw_alpha_32;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
624 dstFourcc = IMGFMT_BGR32;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
625 break;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
626 default: draw_alpha_fnc = draw_alpha_null;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
627 dstFourcc = IMGFMT_BGR16;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
628 break;
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
629 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
630 if(verbose)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
631 {
2304
0769b2fb3ce2 Fixed zooming bug
nick
parents: 2298
diff changeset
632 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format));
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
633 printf("vo_vesa: Total modes found: %u\n",num_modes);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
634 mode_ptr = vib.VideoModePtr;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
635 printf("vo_vesa: Mode list:");
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
636 for(i = 0;i < num_modes;i++)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
637 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
638 printf(" %04X",mode_ptr[i]);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
639 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
640 printf("\nvo_vesa: Modes in detail:\n");
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
641 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
642 mode_ptr = vib.VideoModePtr;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
643 if(use_scaler)
2335
26fdd1a317ad Again changed logic:
nick
parents: 2333
diff changeset
644 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
645 dstW = d_width;
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
646 dstH = d_height;
2335
26fdd1a317ad Again changed logic:
nick
parents: 2333
diff changeset
647 }
26fdd1a317ad Again changed logic:
nick
parents: 2333
diff changeset
648 if(vo_screenwidth) w = vo_screenwidth;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
649 else w = max(dstW,width);
2335
26fdd1a317ad Again changed logic:
nick
parents: 2333
diff changeset
650 if(vo_screenheight) h = vo_screenheight;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
651 else h = max(dstH,height);
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
652 for(i=0;i < num_modes;i++)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
653 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
654 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
655 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
656 PRINT_VBE_ERR("vbeGetModeInfo",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
657 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
658 }
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
659 if(vmib.XResolution >= w &&
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
660 vmib.YResolution >= h &&
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
661 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE &&
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
662 vmib.BitsPerPixel == bpp &&
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
663 vmib.MemoryModel == memRGB)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
664 {
2293
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
665 if(vmib.XResolution <= best_x &&
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
666 vmib.YResolution <= best_y)
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
667 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
668 best_x = vmib.XResolution;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
669 best_y = vmib.YResolution;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
670 best_mode_idx = i;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
671 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
672 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
673 if(verbose)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
674 {
2298
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
675 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n"
2293
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
676 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n"
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
677 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n"
2446
6fb598bd7ede Suppressing warnings
nick
parents: 2410
diff changeset
678 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n"
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
679 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes
2293
638cd37032da Better resolution detection
nick
parents: 2255
diff changeset
680 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
681 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
682 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
683 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
684 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n"
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
685 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
686 fflush(stdout);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
687 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
688 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
689 if(best_mode_idx != UINT_MAX)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
690 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
691 video_mode = vib.VideoModePtr[best_mode_idx];
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
692 fflush(stdout);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
693 if((err=vbeGetMode(&init_mode)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
694 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
695 PRINT_VBE_ERR("vbeGetMode",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
696 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
697 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
698 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
699 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
700 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
701 PRINT_VBE_ERR("vbeGetModeInfo",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
702 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
703 }
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
704 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n"
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
705 ,best_mode_idx,video_mode,video_mode_info.XResolution
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
706 ,video_mode_info.YResolution,dstBpp);
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
707 dstBpp = video_mode_info.BitsPerPixel;
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
708 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0;
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
709 if(use_scaler || fs_mode)
2298
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
710 {
2304
0769b2fb3ce2 Fixed zooming bug
nick
parents: 2298
diff changeset
711 /* software scale */
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
712 if(use_scaler > 1)
2689
6a5b6b16d85c Use standard aspect code
nick
parents: 2688
diff changeset
713 {
6a5b6b16d85c Use standard aspect code
nick
parents: 2688
diff changeset
714 aspect_save_orig(width,height);
6a5b6b16d85c Use standard aspect code
nick
parents: 2688
diff changeset
715 aspect_save_prescale(d_width,d_height);
6a5b6b16d85c Use standard aspect code
nick
parents: 2688
diff changeset
716 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution);
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
717 aspect(&dstW,&dstH,A_ZOOM);
2689
6a5b6b16d85c Use standard aspect code
nick
parents: 2688
diff changeset
718 }
2336
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
719 else
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
720 if(fs_mode)
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
721 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
722 dstW = video_mode_info.XResolution;
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
723 dstH = video_mode_info.YResolution;
2336
b2e0b131c1a7 Again changed logic:
nick
parents: 2335
diff changeset
724 }
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
725 use_scaler = 1;
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
726 }
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
727 if(!lvo_name
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
728 #ifdef CONFIG_VIDIX
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
729 && !vidix_name
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
730 #endif
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
731 )
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
732 {
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
733 sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc);
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
734 if(!sws)
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
735 {
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
736 printf("vo_vesa: Can't initialize SwScaler\n");
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
737 return -1;
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
738 }
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
739 else if(verbose) printf("vo_vesa: Using SW BES emulator\n");
2298
674acdf0aa43 SwScaling support
nick
parents: 2296
diff changeset
740 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
741 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
742 win.idx = 0; /* frame A */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
743 else
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
744 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
745 win.idx = 1; /* frame B */
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
746 else win.idx = -2;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
747 /* Try use DGA instead */
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
748 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR))
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
749 {
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
750 void *lfb;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
751 unsigned long vsize;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
752 vsize = vib.TotalMemory*64*1024;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
753 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize);
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
754 if(lfb == NULL)
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
755 printf("vo_vesa: Can't use DGA. Force bank switching mode. :(\n");
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
756 else
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
757 {
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
758 video_base = win.ptr = lfb;
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
759 win.low = 0UL;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
760 win.high = vsize;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
761 win.idx = -1; /* HAS_DGA() is on */
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
762 video_mode |= VESA_MODE_USE_LINEAR;
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
763 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)"
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
764 ,video_mode_info.PhysBasePtr
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
765 ,vsize);
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
766 if(verbose) printf(" at %08lXh",(unsigned long)lfb);
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
767 printf("\n");
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
768 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
769 if(vo_doublebuffering && multi_size < 2)
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
770 printf("vo_vesa: Can't use double buffering: not enough video memory\n");
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
771 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
772 }
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
773 if(win.idx == -2)
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
774 {
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
775 printf("vo_vesa: Can't find neither DGA nor relocatable window's frame.\n");
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
776 return -1;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
777 }
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
778 if(!HAS_DGA())
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
779 {
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
780 if(subdev_flags & SUBDEV_FORCEDGA)
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
781 {
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
782 printf("vo_vesa: you've forced DGA. Exiting\n");
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
783 return -1;
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
784 }
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
785 if(!(win_seg = win.idx == 0 ? video_mode_info.WinASegment:video_mode_info.WinBSegment))
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
786 {
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
787 printf("vo_vesa: Can't find valid window address\n");
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
788 return -1;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
789 }
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
790 win.ptr = PhysToVirtSO(win_seg,0);
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
791 win.low = 0L;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
792 win.high= video_mode_info.WinSize*1024;
2649
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
793 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n"
d05fc32b7984 What's new:
nick
parents: 2637
diff changeset
794 ,(unsigned long)win.ptr,(unsigned long)win.high);
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
795 }
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
796 if(video_mode_info.XResolution > dstW)
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
797 x_offset = (video_mode_info.XResolution - dstW) / 2;
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
798 else x_offset = 0;
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
799 if(video_mode_info.YResolution > dstH)
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
800 y_offset = (video_mode_info.YResolution - dstH) / 2;
2329
fc52a0a1626f Support of: -x -y -bpp
nick
parents: 2328
diff changeset
801 else y_offset = 0;
2305
82c17b134946 Fixed half-image bug and added computing of correct aspect during zooming
nick
parents: 2304
diff changeset
802 if(verbose)
82c17b134946 Fixed half-image bug and added computing of correct aspect during zooming
nick
parents: 2304
diff changeset
803 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n"
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
804 ,dstW,dstH
2305
82c17b134946 Fixed half-image bug and added computing of correct aspect during zooming
nick
parents: 2304
diff changeset
805 ,video_mode_info.XResolution,video_mode_info.YResolution
82c17b134946 Fixed half-image bug and added computing of correct aspect during zooming
nick
parents: 2304
diff changeset
806 ,x_offset,y_offset);
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
807 if(HAS_DGA())
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
808 {
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
809 dga_buffer = win.ptr; /* Trickly ;) */
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
810 cpy_blk_fnc = __vbeCopyBlockFast;
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
811 }
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
812 else
2610
65cb69a90a9f vo_vesa: DGA support
nick
parents: 2554
diff changeset
813 {
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
814 cpy_blk_fnc = __vbeCopyBlock;
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
815 if(!lvo_name
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
816 #ifdef CONFIG_VIDIX
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
817 && !vidix_name
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
818 #endif
4601
8cda24d7f074 Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents: 4596
diff changeset
819 )
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
820 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
821 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp)))
2610
65cb69a90a9f vo_vesa: DGA support
nick
parents: 2554
diff changeset
822 {
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
823 printf("vo_vesa: Can't allocate temporary buffer\n");
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
824 return -1;
2610
65cb69a90a9f vo_vesa: DGA support
nick
parents: 2554
diff changeset
825 }
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
826 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer);
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
827 }
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
828 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
829 if((err=vbeSaveState(&init_state)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
830 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
831 PRINT_VBE_ERR("vbeSaveState",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
832 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
833 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
834 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
835 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
836 PRINT_VBE_ERR("vbeSetMode",err);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
837 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
838 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
839 /* Now we are in video mode!!!*/
2337
e6d8e9a54afa OSD support
nick
parents: 2336
diff changeset
840 /* Below 'return -1' is impossible */
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
841 if(verbose)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
842 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
843 printf("vo_vesa: Graphics mode was activated\n");
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
844 fflush(stdout);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
845 }
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
846 if(lvo_name)
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
847 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
848 if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0)
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
849 {
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
850 printf("vo_vesa: Can't initialize Linux Video Overlay\n");
2953
b0cf2b649d3c Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents: 2918
diff changeset
851 lvo_name = NULL;
2869
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
852 vesa_term();
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
853 return -1;
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
854 }
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
855 else printf("vo_vesa: Using video overlay: %s\n",lvo_name);
107d9e9e5bd1 New video output technique Linux Video Overlay:
nick
parents: 2775
diff changeset
856 }
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
857 #ifdef CONFIG_VIDIX
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
858 else
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
859 if(vidix_name)
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
860 {
4537
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
861 if(vidix_init(width,height,x_offset,y_offset,dstW,
bc5b78f1df77 Support of scaling with every fourcc
nick
parents: 4493
diff changeset
862 dstH,format,dstBpp,
4434
e956fa7f79c7 Use new tune info
nick
parents: 4433
diff changeset
863 video_mode_info.XResolution,video_mode_info.YResolution,info) != 0)
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
864 {
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
865 printf("vo_vesa: Can't initialize VIDIX driver\n");
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
866 vidix_name = NULL;
4548
59a90d0d662d Correct vesa shutdown on 'config playback' errors
nick
parents: 4537
diff changeset
867 vesa_term();
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
868 return -1;
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
869 }
4083
00c1bba6ca14 Minor bugs and new vidix stuff support
nick
parents: 4030
diff changeset
870 else printf("vo_vesa: Using VIDIX\n");
4198
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4089
diff changeset
871 vidix_start();
4030
922241968c63 Embedding vidix
nick
parents: 4002
diff changeset
872 }
4089
e1c6178de089 Configurable VIDIX usage
nick
parents: 4083
diff changeset
873 #endif
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
874 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
875 else
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
876 {
2255
98c2bfc87825 More hints. Use save-restore mechanism
nick
parents: 2244
diff changeset
877 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp);
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
878 return -1;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
879 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
880 if(verbose)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
881 {
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
882 printf("vo_vesa: VESA initialization complete\n");
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
883 fflush(stdout);
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
884 }
2914
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
885 /* Clear screen for stupid BIOSes */
1ccec8cd9310 Screen clearing instead of stupid BIOSes
nick
parents: 2872
diff changeset
886 clear_screen();
2688
e9f6634c6374 Code cleanup
nick
parents: 2686
diff changeset
887 if(HAS_DGA() && vo_doublebuffering)
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
888 {
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
889 for(i=0;i<MAX_BUFFERS;i++)
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
890 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
891 win.ptr = dga_buffer = video_base + multi_buff[i];
4002
6ce744b637ad paint background on -v -v
nick
parents: 3209
diff changeset
892 if(verbose>1) paintBkGnd();
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
893 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
894 }
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
895 else
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
896 {
4002
6ce744b637ad paint background on -v -v
nick
parents: 3209
diff changeset
897 if(verbose>1) paintBkGnd();
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
898 {
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
899 int x;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
900 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
901 if(x < 0) x = 0;
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
902 vbeWriteString(x,0,7,title);
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
903 }
2633
fe5ab8c660de Qualitative speedup decoding when video card supports DGA!
nick
parents: 2610
diff changeset
904 }
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
905 return 0;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
906 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
907
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
908 static const vo_info_t*
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
909 get_info(void)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
910 {
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
911 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
912 printf("vo_vesa: get_info was called\n");
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
913 return &vo_info;
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
914 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
915
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
916 static void
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
917 uninit(void)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
918 {
2686
44ff6b5c7cea Double buffering support
nick
parents: 2676
diff changeset
919 vesa_term();
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
920 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
921 printf("vo_vesa: uninit was called\n");
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
922 }
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
923
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
924
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
925 static void check_events(void)
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
926 {
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
927 if(verbose > 2)
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents: 2446
diff changeset
928 printf("vo_vesa: check_events was called\n");
2244
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
929 /* Nothing to do */
4e464b527f5a vo_vesa support
nick
parents:
diff changeset
930 }
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
931
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
932 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
933 {
4362
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
934 int pre_init_err = 0;
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
935 if(verbose>1) printf("vo_vesa: preinit(%s) was called\n",arg);
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
936 if(verbose > 2)
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
937 printf("vo_vesa: subdevice %s is being initialized\n",arg);
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
938 subdev_flags = 0;
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
939 if(arg) subdev_flags = parseSubDevice(arg);
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
940 if(lvo_name) pre_init_err = vlvo_preinit(lvo_name);
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
941 #ifdef CONFIG_VIDIX
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
942 else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa);
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
943 #endif
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
944 if(verbose > 2)
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
945 printf("vo_subdevice: initialization returns: %i\n",pre_init_err);
7ef67ffa9274 preinit usage
nick
parents: 4352
diff changeset
946 return pre_init_err;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
947 }
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
948
4739
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
949 #ifdef HAVE_PNG
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
950 static int vesa_screenshot(const char *fname)
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
951 {
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
952 uint32_t i,n;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
953 uint8_t *ptrs[video_mode_info.YResolution];
4746
cbce019d2d94 Change order of vo_function calls (Although it doesn't matter for now).
nick
parents: 4739
diff changeset
954 if(video_out_png.preinit(NULL))
cbce019d2d94 Change order of vo_function calls (Although it doesn't matter for now).
nick
parents: 4739
diff changeset
955 {
cbce019d2d94 Change order of vo_function calls (Although it doesn't matter for now).
nick
parents: 4739
diff changeset
956 printf("\nvo_vesa: can't preinit vo_png\n");
cbce019d2d94 Change order of vo_function calls (Although it doesn't matter for now).
nick
parents: 4739
diff changeset
957 return 1;
cbce019d2d94 Change order of vo_function calls (Although it doesn't matter for now).
nick
parents: 4739
diff changeset
958 }
4739
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
959 if(!video_out_png.control(VOCTRL_QUERY_FORMAT, &dstFourcc))
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
960 {
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
961 printf("\nvo_vesa: vo_png doesn't support: %s fourcc\n",vo_format_name(dstFourcc));
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
962 return 1;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
963 }
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
964 if(video_out_png.config(HAS_DGA()?video_mode_info.XResolution:dstW,
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
965 HAS_DGA()?video_mode_info.YResolution:dstH,
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
966 HAS_DGA()?video_mode_info.XResolution:dstW,
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
967 HAS_DGA()?video_mode_info.YResolution:dstH,
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
968 0,NULL,dstFourcc,NULL))
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
969 {
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
970 printf("\nvo_vesa: can't configure vo_png\n");
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
971 return 1;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
972 }
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
973 n = HAS_DGA()?video_mode_info.YResolution:dstH;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
974 for(i=0;i<n;i++)
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
975 ptrs[i] = &dga_buffer[(HAS_DGA()?video_mode_info.XResolution:dstW)*i*PIXEL_SIZE()];
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
976 if(video_out_png.draw_frame(ptrs))
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
977 {
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
978 printf("\nvo_vesa: vo_png: error during dumping\n");
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
979 return 1;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
980 }
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
981
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
982 video_out_png.uninit();
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
983 if(verbose) printf("\nvo_vesa: png output has been created\n");
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
984 return 0;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
985 }
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
986
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
987
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
988 static char _home_name[FILENAME_MAX + 1];
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
989 static char * __get_home_filename(const char *progname)
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
990 {
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
991 char *p = getenv("HOME");
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
992
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
993 if (p == NULL || strlen(p) < 2) {
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
994 struct passwd *psw = getpwuid(getuid());
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
995 if (psw != NULL) p = psw->pw_dir;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
996 }
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
997
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
998 if (p == NULL || strlen(p) > FILENAME_MAX - (strlen(progname) + 4))
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
999 p = "/tmp";
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1000
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1001 strcpy(_home_name, p);
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1002 strcat(_home_name, "/.");
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1003 return strcat(_home_name, progname);
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1004 }
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1005 #endif
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1006
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
1007 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
1008 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4572
diff changeset
1009 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4572
diff changeset
1010 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4572
diff changeset
1011 return query_format(*((uint32_t*)data));
4739
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1012 #ifdef HAVE_PNG
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1013 case VOCTRL_SCREENSHOT:
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1014 return vesa_screenshot(__get_home_filename("mplayer_vesa_dump.png"));
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1015 break;
a2df307ed979 Screenshot on the fly
nick
parents: 4667
diff changeset
1016 #endif
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4572
diff changeset
1017 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4572
diff changeset
1018 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4198
diff changeset
1019 }