annotate libvo/vo_svga.c @ 288:abe56b2561b1

bpp fix
author arpi_esp
date Thu, 05 Apr 2001 19:44:54 +0000
parents b2f3f2ab3787
children f40a55208b76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
1 /*
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
2 Video driver for SVGAlib - alpha version
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
3 by Zoltan Mark Vician <se7en@sch.bme.hu>
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
4 Code started: Mon Apr 1 23:25:47 2000
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
5 */
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
6
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
7 #include <stdio.h>
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
8 #include <stdlib.h>
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
9
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
10 #include <vga.h>
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
11 #include <vgagl.h>
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
12
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
13 #include "config.h"
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
14 #include "video_out.h"
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
15 #include "video_out_internal.h"
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
16
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
17 #include "yuv2rgb.h"
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
18
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
19 LIBVO_EXTERN(svga)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
20
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
21 static vo_info_t vo_info = {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
22 "SVGAlib",
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
23 "svga",
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
24 "Zoltan Mark Vician <se7en@sch.bme.hu>",
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
25 ""
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
26 };
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
27
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
28 // SVGAlib definitions
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
29
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
30 GraphicsContext *screen;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
31 GraphicsContext *virt;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
32
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
33 static uint8_t *scalebuf = NULL, *yuvbuf = NULL;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
34
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
35 static uint32_t orig_w, orig_h, maxw, maxh; // Width, height
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
36 static float scaling = 0;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
37 static uint32_t x_pos, y_pos; // Position
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
38
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
39 // Order must not change!
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
40 #define _640x480x32K 0 // 17
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
41 #define _640x480x64K 1 // 18
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
42 #define _640x480x16M 2 // 19
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
43 #define _640x480x16M32 3 // 34
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
44 #define _800x600x32K 4 // 20
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
45 #define _800x600x64K 5 // 21
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
46 #define _800x600x16M 6 // 22
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
47 #define _800x600x16M32 7 // 35
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
48 #define _1024x768x32K 8 // 23
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
49 #define _1024x768x64K 9 // 24
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
50 #define _1024x768x16M 10 // 25
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
51 #define _1024x768x16M32 11 // 36
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
52 #define VID_MODE_NUM 12
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
53
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
54 static uint8_t vid_modes[VID_MODE_NUM];
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
55 static uint8_t vid_mode;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
56
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
57 static uint32_t pformat;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
58
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
59 static uint8_t checked = 0;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
60
286
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
61 static void checksupportedmodes() {
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
62 int i;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
63
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
64 checked = 1;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
65 vga_init();
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
66 vga_disabledriverreport();
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
67 for (i = 0; i < VID_MODE_NUM; i++) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
68 if (vga_hasmode(i) > 0)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
69 vid_modes[i] = 1;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
70 else vid_modes[i] = 0;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
71 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
72 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
73
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
74 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
75 uint32_t d_height, uint32_t fullscreen, char *title,
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
76 uint32_t format) {
288
abe56b2561b1 bpp fix
arpi_esp
parents: 286
diff changeset
77 static uint8_t bpp;
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
78 if (!checked) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
79 checksupportedmodes(); // Looking for available video modes
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
80 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
81 pformat = format;
288
abe56b2561b1 bpp fix
arpi_esp
parents: 286
diff changeset
82 if(format==IMGFMT_YV12) bpp=32; else bpp=format&255;
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
83 if (d_width > 800)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
84 switch (bpp) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
85 case 32: vid_mode = 36; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
86 case 24: vid_mode = 25; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
87 case 16: vid_mode = 24; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
88 case 15: vid_mode = 23; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
89 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
90 else
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
91 if (d_width > 640)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
92 switch (bpp) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
93 case 32: vid_mode = 35; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
94 case 24: vid_mode = 22; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
95 case 16: vid_mode = 21; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
96 case 15: vid_mode = 20; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
97 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
98 else
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
99 switch (bpp) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
100 case 32: vid_mode = 34; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
101 case 24: vid_mode = 19; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
102 case 16: vid_mode = 18; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
103 case 15: vid_mode = 17; break;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
104 }
286
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
105 if (vga_setmode(vid_mode) == -1){
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
106 printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode);
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
107 return(1); // error
286
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
108 }
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
109 if (gl_setcontextvga(vid_mode)){
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
110 printf("vo_svga: gl_setcontextvga(%d) failed.\n",vid_mode);
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
111 return(1); // error
286
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
112 }
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
113 screen = gl_allocatecontext();
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
114 gl_getcontext(screen);
286
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
115 if (gl_setcontextvgavirtual(vid_mode)){
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
116 printf("vo_svga: gl_setcontextvgavirtual(%d) failed.\n",vid_mode);
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
117 return(1); // error
286
b2f3f2ab3787 integrated vo_svga by se7en
arpi_esp
parents: 285
diff changeset
118 }
285
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
119 virt = gl_allocatecontext();
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
120 gl_getcontext(virt);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
121 gl_setcontext(virt);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
122 gl_clearscreen(0);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
123
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
124 orig_w = width;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
125 orig_h = height;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
126 if (fullscreen && (WIDTH != orig_w)) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
127 maxw = WIDTH;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
128 scaling = maxw / (orig_w*1.0);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
129 maxh = (uint32_t) (orig_h * scaling);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
130 scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
131 } else {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
132 maxw = orig_w;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
133 maxh = orig_h;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
134 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
135
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
136 x_pos = (WIDTH - maxw) / 2;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
137 y_pos = (HEIGHT - maxh) / 2;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
138
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
139 if (pformat == IMGFMT_YV12) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
140 yuv2rgb_init(bpp, MODE_RGB);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
141 yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
142 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
143
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
144 printf("SVGAlib resolution: %dx%d %dbpp - ",WIDTH,HEIGHT,bpp);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
145 if (maxw != orig_w || maxh != orig_h) printf("Video scaled to: %dx%d\n",maxw,maxh);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
146 else printf("No video scaling\n");
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
147
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
148 return (0);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
149 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
150
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
151 static uint32_t query_format(uint32_t format) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
152 if (!checked)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
153 checksupportedmodes(); // Looking for available video modes
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
154 switch (format) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
155 case IMGFMT_RGB32:
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
156 case IMGFMT_BGR|32: {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
157 return (vid_modes[_640x480x16M32] | vid_modes[_800x600x16M32] | vid_modes[_1024x768x16M32]);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
158 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
159 case IMGFMT_RGB24:
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
160 case IMGFMT_BGR|24: {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
161 return (vid_modes[_640x480x16M] | vid_modes[_800x600x16M] | vid_modes[_1024x768x16M]);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
162 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
163 case IMGFMT_RGB16:
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
164 case IMGFMT_BGR|16: {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
165 return (vid_modes[_640x480x64K] | vid_modes[_800x600x64K] | vid_modes[_1024x768x64K]);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
166 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
167 case IMGFMT_RGB15:
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
168 case IMGFMT_BGR|15: {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
169 return (vid_modes[_640x480x32K] | vid_modes[_800x600x32K] | vid_modes[_1024x768x32K]);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
170 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
171 case IMGFMT_YV12: return (1);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
172 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
173 return (0);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
174 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
175
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
176 static const vo_info_t* get_info(void) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
177 return (&vo_info);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
178 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
179
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
180 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
181 unsigned char *srca, int stride) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
182 int x, y, i;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
183 uint8_t *dest, buf;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
184
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
185 // if (pformat == IMGFMT_YV12) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
186 for (y = 0; y < h; y++) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
187 dest = virt->vbuf + ((WIDTH * (y0 + y) + x0) * BYTESPERPIXEL);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
188 for (x = 0; x < w; x++) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
189 if (srca[x]) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
190 for (i = 0; i < BYTESPERPIXEL; i++)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
191 dest[i] = /*((dest[i] * srca[x]) >> 8) +*/ src[x] >> 6;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
192 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
193 dest += BYTESPERPIXEL;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
194 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
195 src += stride;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
196 srca += stride;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
197 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
198 // }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
199 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
200
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
201 static uint32_t draw_frame(uint8_t *src[]) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
202 if (pformat == IMGFMT_YV12) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
203 yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, orig_w * BYTESPERPIXEL, orig_w, orig_w / 2);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
204 src[0] = yuvbuf;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
205 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
206 if (scalebuf) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
207 gl_scalebox(orig_w, orig_h, src[0], maxw, maxh, scalebuf);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
208 src[0] = scalebuf;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
209 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
210 gl_putbox(x_pos, y_pos, maxw, maxh, src[0]);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
211 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
212
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
213 static uint32_t draw_slice(uint8_t *image[], int stride[],
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
214 int w, int h, int x, int y) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
215 uint8_t *src = yuvbuf;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
216
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
217 yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, orig_w * BYTESPERPIXEL, stride[0], stride[1]);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
218 if (scalebuf) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
219 gl_scalebox(w, h, yuvbuf,(int) (w * scaling), (int) (h * scaling), scalebuf);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
220 src = scalebuf;
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
221 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
222 gl_putbox(x + x_pos, y + y_pos, (int) (w * scaling), (int) (h * scaling), src);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
223 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
224
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
225
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
226 static void flip_page(void) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
227 gl_fillbox(0, 0, WIDTH, y_pos, 0);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
228 gl_fillbox(0, HEIGHT - y_pos, WIDTH, y_pos, 0);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
229 vo_draw_text(WIDTH, HEIGHT, draw_alpha);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
230 gl_copyscreen(screen);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
231 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
232
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
233 static void check_events(void) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
234 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
235
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
236 static void uninit(void) {
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
237 gl_freecontext(screen);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
238 gl_freecontext(virt);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
239 vga_setmode(TEXT);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
240 if (scalebuf)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
241 free(scalebuf);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
242 if (yuvbuf)
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
243 free(yuvbuf);
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
244 }
5cb4fdc94146 SVGAlib support - vo_svga.c added.
se7encode
parents:
diff changeset
245