Mercurial > mplayer.hg
annotate drivers/mga_vid_test.c @ 31685:31b6397e3b28
Another try at fixing swscale on win64, as per r31153.
Don't change paramater passing, but instead use casts.
Shouldn't affect asm output on anything other than win64.
libswscale should work on win64 now.
The rest of ffmpeg still isn't win64 compatible due to the issue of xmm
clobbers, but swscale doesn't use any SSE.
Patch by Anton Mitrofanov <BugMaster AT narod DOT ru>.
author | darkshikari |
---|---|
date | Sun, 18 Jul 2010 21:39:57 +0000 |
parents | 0ad2da052b2e |
children |
rev | line source |
---|---|
1 | 1 /* |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
2 * Copyright (C) 1999 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
1 | 3 * |
27027 | 4 * This file is part of mga_vid. |
1 | 5 * |
27027 | 6 * mga_vid is free software; you can redistribute it and/or modify |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
9 * (at your option) any later version. |
1 | 10 * |
27027 | 11 * mga_vid is distributed in the hope that it will be useful, |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
14 * GNU General Public License for more details. |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
15 * |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
27027 | 17 * with mga_vid; if not, write to the Free Software Foundation, Inc., |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
24287
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
1 | 19 */ |
20 | |
21 //#include <stddef.h> | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <sys/ioctl.h> | |
25 #include <unistd.h> | |
26 #include <fcntl.h> | |
27 #include <sys/mman.h> | |
854
76ca00724e12
gcc warnings fixed - patch by Aelius aelius@wish.net
arpi_esp
parents:
76
diff
changeset
|
28 #include <inttypes.h> |
6245
aee789fa2d07
When compiling mga_vid_test.c, memcpy() is subject to an implicit
jaf
parents:
854
diff
changeset
|
29 #include <string.h> |
1 | 30 #include "mga_vid.h" |
31 | |
32 mga_vid_config_t config; | |
33 uint8_t *mga_vid_base; | |
34 uint32_t is_g400; | |
35 | |
36 #define SRC_IMAGE_WIDTH 256 | |
37 #define SRC_IMAGE_HEIGHT 256 | |
38 | |
39 uint8_t y_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
40 uint8_t cr_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
41 uint8_t cb_image[SRC_IMAGE_WIDTH * SRC_IMAGE_HEIGHT]; | |
42 | |
43 | |
44 void | |
45 write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
46 { | |
30990 | 47 uint8_t *dest; |
48 uint32_t bespitch,h,w; | |
1 | 49 |
30990 | 50 dest = mga_vid_base; |
51 bespitch = (config.src_width + 31) & ~31; | |
1 | 52 |
30990 | 53 for(h=0; h < config.src_height; h++) |
54 { | |
55 memcpy(dest, y, config.src_width); | |
56 y += config.src_width; | |
57 dest += bespitch; | |
58 } | |
1 | 59 |
30990 | 60 for(h=0; h < config.src_height/2; h++) |
61 { | |
62 for(w=0; w < config.src_width/2; w++) | |
63 { | |
64 *dest++ = *cb++; | |
65 *dest++ = *cr++; | |
66 } | |
67 dest += bespitch - config.src_width; | |
68 } | |
1 | 69 } |
70 | |
71 void | |
72 write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
73 { | |
30990 | 74 uint8_t *dest; |
75 uint32_t bespitch,h; | |
1 | 76 |
30990 | 77 dest = mga_vid_base; |
78 bespitch = (config.src_width + 31) & ~31; | |
1 | 79 |
30990 | 80 for(h=0; h < config.src_height; h++) |
81 { | |
82 memcpy(dest, y, config.src_width); | |
83 y += config.src_width; | |
84 dest += bespitch; | |
85 } | |
1 | 86 |
30990 | 87 for(h=0; h < config.src_height/2; h++) |
88 { | |
89 memcpy(dest, cb, config.src_width/2); | |
90 cb += config.src_width/2; | |
91 dest += bespitch/2; | |
92 } | |
1 | 93 |
30990 | 94 for(h=0; h < config.src_height/2; h++) |
95 { | |
96 memcpy(dest, cr, config.src_width/2); | |
97 cr += config.src_width/2; | |
98 dest += bespitch/2; | |
99 } | |
1 | 100 } |
101 | |
102 void write_frame(uint8_t *y,uint8_t *cr, uint8_t *cb) | |
103 { | |
30990 | 104 if(is_g400) |
105 write_frame_g400(y,cr,cb); | |
106 else | |
107 write_frame_g200(y,cr,cb); | |
1 | 108 } |
109 | |
110 void | |
111 draw_cool_pattern(void) | |
112 { | |
30990 | 113 int i,x,y; |
1 | 114 |
30990 | 115 i = 0; |
116 for (y=0; y<config.src_height; y++) { | |
117 for (x=0; x<config.src_width; x++) { | |
118 y_image[i++] = x*x/2 + y*y/2 - 128; | |
119 } | |
120 } | |
1 | 121 |
30990 | 122 i = 0; |
123 for (y=0; y<config.src_height/2; y++) | |
124 for (x=0; x<config.src_width/2; x++) | |
125 { | |
126 cr_image[i++] = x - 128; | |
127 } | |
1 | 128 |
30990 | 129 i = 0; |
130 for (y=0; y<config.src_height/2; y++) | |
131 for (x=0; x<config.src_width/2; x++) | |
132 { | |
133 cb_image[i++] = y - 128; | |
134 } | |
1 | 135 } |
136 | |
137 void | |
138 draw_color_blend(void) | |
139 { | |
30990 | 140 int i,x,y; |
1 | 141 |
30990 | 142 i = 0; |
143 for (y=0; y<config.src_height; y++) { | |
144 for (x=0; x<config.src_width; x++) { | |
145 y_image[i++] = 0; | |
146 } | |
147 } | |
1 | 148 |
30990 | 149 i = 0; |
150 for (y=0; y<config.src_height/2; y++) | |
151 for (x=0; x<config.src_width/2; x++) | |
152 { | |
153 cr_image[i++] = x - 128; | |
154 } | |
1 | 155 |
30990 | 156 i = 0; |
157 for (y=0; y<config.src_height/2; y++) | |
158 for (x=0; x<config.src_width/2; x++) | |
159 { | |
160 cb_image[i++] = y - 128; | |
161 } | |
1 | 162 } |
163 | |
164 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27027
diff
changeset
|
165 int |
24287 | 166 main(void) |
1 | 167 { |
30990 | 168 int f; |
1 | 169 |
30990 | 170 f = open("/dev/mga_vid",O_RDWR); |
1 | 171 |
30990 | 172 if(f == -1) |
173 { | |
174 fprintf(stderr,"Couldn't open driver\n"); | |
175 exit(1); | |
176 } | |
1 | 177 |
30990 | 178 config.version = MGA_VID_VERSION; |
179 config.src_width = SRC_IMAGE_WIDTH; | |
180 config.src_height= SRC_IMAGE_HEIGHT; | |
181 config.dest_width = SRC_IMAGE_WIDTH; | |
182 config.dest_height = SRC_IMAGE_HEIGHT; | |
183 config.x_org= 10; | |
184 config.y_org= 10; | |
185 config.colkey_on = 0; | |
186 config.format = MGA_VID_FORMAT_YV12; | |
187 config.frame_size=SRC_IMAGE_WIDTH*SRC_IMAGE_HEIGHT*2; | |
188 config.num_frames=1; | |
1 | 189 |
30990 | 190 if (ioctl(f,MGA_VID_CONFIG,&config)) |
191 { | |
192 perror("Error in config ioctl"); | |
193 } | |
1 | 194 |
30990 | 195 if (config.card_type == MGA_G200) |
196 { | |
197 printf("Testing MGA G200 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
198 is_g400 = 0; | |
199 } | |
200 else | |
201 { | |
202 printf("Testing MGA G400 Backend Scaler with %d MB of RAM\n", config.ram_size); | |
203 is_g400 = 1; | |
204 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27027
diff
changeset
|
205 |
30990 | 206 ioctl(f,MGA_VID_ON,0); |
207 mga_vid_base = (uint8_t*)mmap(0,256 * 4096,PROT_WRITE,MAP_SHARED,f,0); | |
208 printf("mga_vid_base = %8p\n",mga_vid_base); | |
1 | 209 |
210 | |
30990 | 211 //memset(y_image,80,256 * 128); |
212 //memset(cr_image,80,256/2 * 20); | |
213 //memset(cb_image,80,256/2 * 20); | |
214 write_frame(y_image,cr_image,cb_image); | |
215 printf("(1) There should be a green square, offset by 10 pixels from\n" | |
216 " the upper left corner displayed\n"); | |
217 sleep(3); | |
1 | 218 |
219 | |
30990 | 220 draw_cool_pattern(); |
221 write_frame(y_image,cr_image,cb_image); | |
222 printf("(2) There should be a cool mosaic like pattern now.\n"); | |
223 sleep(3); | |
1 | 224 |
30990 | 225 draw_color_blend(); |
226 write_frame(y_image,cr_image,cb_image); | |
227 printf("(3) There should be a color blend with black, red, purple, blue\n" | |
228 " corners (starting top left going CW)\n"); | |
229 sleep(3); | |
1 | 230 |
30990 | 231 ioctl(f,MGA_VID_OFF,0); |
1 | 232 |
30990 | 233 close(f); |
234 return 0; | |
1 | 235 } |