Mercurial > mplayer.hg
comparison libvo/vosub_vidix.c @ 4999:7f1fa1db24b4
Optimization and get_image fixes (still untested)
author | nick |
---|---|
date | Sat, 09 Mar 2002 08:08:43 +0000 |
parents | ad943b99610a |
children | 70751bbd6404 |
comparison
equal
deleted
inserted
replaced
4998:c32191b02a66 | 4999:7f1fa1db24b4 |
---|---|
35 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */ | 35 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */ |
36 | 36 |
37 static VDL_HANDLE vidix_handler = NULL; | 37 static VDL_HANDLE vidix_handler = NULL; |
38 static uint8_t *vidix_mem = NULL; | 38 static uint8_t *vidix_mem = NULL; |
39 static uint8_t next_frame; | 39 static uint8_t next_frame; |
40 static unsigned image_bpp,image_height,image_width,src_format; | 40 static unsigned image_Bpp,image_height,image_width,src_format; |
41 extern int verbose; | 41 extern int verbose; |
42 static int video_on=0; | 42 static int video_on=0; |
43 | 43 |
44 static vidix_capability_t vidix_cap; | 44 static vidix_capability_t vidix_cap; |
45 static vidix_playback_t vidix_play; | 45 static vidix_playback_t vidix_play; |
46 static vidix_fourcc_t vidix_fourcc; | 46 static vidix_fourcc_t vidix_fourcc; |
47 static vo_functions_t * vo_server; | 47 static vo_functions_t * vo_server; |
48 static vidix_yuv_t dstrides; | |
48 static uint32_t (*server_control)(uint32_t request, void *data, ...); | 49 static uint32_t (*server_control)(uint32_t request, void *data, ...); |
49 | 50 |
50 | 51 |
51 static int vidix_get_bes_da(bes_da_t *); | 52 static int vidix_get_bes_da(bes_da_t *); |
52 static int vidix_get_video_eq(vidix_video_eq_t *info); | 53 static int vidix_get_video_eq(vidix_video_eq_t *info); |
144 | 145 |
145 static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) | 146 static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) |
146 { | 147 { |
147 uint8_t *src; | 148 uint8_t *src; |
148 uint8_t *dest; | 149 uint8_t *dest; |
149 unsigned bespitch,apitch; | |
150 int i; | 150 int i; |
151 | 151 |
152 /* Plane Y */ | 152 /* Plane Y */ |
153 apitch = vidix_play.dest.pitch.y-1; | |
154 bespitch = (w + apitch) & ~apitch; | |
155 | |
156 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | 153 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
157 dest += bespitch*y + x; | 154 dest += dstrides.y*y + x; |
158 src = image[0]; | 155 src = image[0]; |
159 for(i=0;i<h;i++){ | 156 for(i=0;i<h;i++){ |
160 memcpy(dest,src,w); | 157 memcpy(dest,src,w); |
161 src+=stride[0]; | 158 src+=stride[0]; |
162 dest += bespitch; | 159 dest += dstrides.y; |
163 } | 160 } |
164 | 161 |
165 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV) | 162 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV) |
166 { | 163 { |
167 int hi,wi; | 164 int hi,wi; |
168 uint8_t *src2; | 165 uint8_t *src2; |
169 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; | 166 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
170 dest += bespitch*y/2 + x; // <- is this correct ? | 167 dest += dstrides.y*y/2 + x; // <- is this correct ? |
171 h/=2; | 168 h/=2; |
172 w/=2; | 169 w/=2; |
173 src = image[1]; | 170 src = image[1]; |
174 src2 = image[2]; | 171 src2 = image[2]; |
175 for(hi = 0; hi < h; hi++) | 172 for(hi = 0; hi < h; hi++) |
177 for(wi = 0; wi < w; wi++) | 174 for(wi = 0; wi < w; wi++) |
178 { | 175 { |
179 dest[2*wi+0] = src[wi]; | 176 dest[2*wi+0] = src[wi]; |
180 dest[2*wi+1] = src2[wi]; | 177 dest[2*wi+1] = src2[wi]; |
181 } | 178 } |
182 dest += bespitch; | 179 dest += dstrides.y; |
183 src += stride[1]; | 180 src += stride[1]; |
184 src2+= stride[2]; | 181 src2+= stride[2]; |
185 } | 182 } |
186 | 183 } |
187 } else { | 184 else |
188 | 185 { |
189 /* Plane V */ | 186 /* Plane V */ |
190 apitch = vidix_play.dest.pitch.v-1; | |
191 bespitch = (w + apitch) & ~apitch; | |
192 | |
193 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; | 187 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
194 dest += bespitch*y/4 + x; | 188 dest += dstrides.v*y/4 + x; |
195 src = image[1]; | 189 src = image[1]; |
196 for(i=0;i<h/2;i++){ | 190 for(i=0;i<h/2;i++){ |
197 memcpy(dest,src,w/2); | 191 memcpy(dest,src,w/2); |
198 src+=stride[1]; | 192 src+=stride[1]; |
199 dest+=bespitch/2; | 193 dest+=dstrides.v/2; |
200 } | 194 } |
201 | 195 |
202 /* Plane U */ | 196 /* Plane U */ |
203 apitch = vidix_play.dest.pitch.u-1; | |
204 bespitch = (w + apitch) & ~apitch; | |
205 | |
206 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u; | 197 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u; |
207 dest += bespitch*y/4 + x; | 198 dest += dstrides.u*y/4 + x; |
208 src = image[2]; | 199 src = image[2]; |
209 for(i=0;i<h/2;i++){ | 200 for(i=0;i<h/2;i++){ |
210 memcpy(dest,src,w/2); | 201 memcpy(dest,src,w/2); |
211 src+=stride[2]; | 202 src+=stride[2]; |
212 dest += bespitch/2; | 203 dest += dstrides.u/2; |
213 } | 204 } |
214 return 0; | 205 return 0; |
215 } | 206 } |
216 } | 207 } |
217 | 208 |
218 static uint32_t vidix_draw_slice_422(uint8_t *image[], int stride[], int w,int h,int x,int y) | 209 static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y) |
219 { | 210 { |
220 uint8_t *src; | 211 uint8_t *src; |
221 uint8_t *dest; | 212 uint8_t *dest; |
222 unsigned bespitch,apitch; | |
223 int i; | 213 int i; |
224 apitch = vidix_play.dest.pitch.y-1; | |
225 bespitch = (w*2 + apitch) & ~apitch; | |
226 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | 214 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
227 dest += bespitch*y + x; | 215 dest += dstrides.y*y + x; |
228 src = image[0]; | 216 src = image[0]; |
229 for(i=0;i<h;i++){ | 217 for(i=0;i<h;i++){ |
230 memcpy(dest,src,w*2); | 218 memcpy(dest,src,w*image_Bpp); |
231 src+=stride[0]; | 219 src+=stride[0]; |
232 dest += bespitch; | 220 dest += dstrides.y; |
233 } | 221 } |
234 return 0; | 222 return 0; |
235 } | 223 } |
236 | 224 |
237 static uint32_t vidix_draw_slice_422_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) | 225 static uint32_t vidix_draw_slice_packed_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) |
238 { | 226 { |
239 uint8_t *src; | 227 uint8_t *src; |
240 uint8_t *dest; | 228 uint8_t *dest; |
241 unsigned bespitch,apitch; | |
242 int i; | 229 int i; |
243 apitch = vidix_play.dest.pitch.y-1; | |
244 bespitch = (w*2 + apitch) & ~apitch; | |
245 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | 230 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
246 dest += bespitch*y + x; | 231 dest += dstrides.y*y + x; |
247 src = image[0]; | 232 src = image[0]; |
248 memcpy(dest,src,h*bespitch); | 233 memcpy(dest,src,h*dstrides.y); |
249 return 0; | |
250 } | |
251 | |
252 static uint32_t vidix_draw_slice_32(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
253 { | |
254 uint8_t *src; | |
255 uint8_t *dest; | |
256 unsigned bespitch,apitch; | |
257 int i; | |
258 apitch = vidix_play.dest.pitch.y-1; | |
259 bespitch = (w*4 + apitch) & ~apitch; | |
260 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
261 dest += bespitch*y + x; | |
262 src = image[0]; | |
263 for(i=0;i<h;i++){ | |
264 memcpy(dest,src,w*4); | |
265 src+=stride[0]; | |
266 dest += bespitch; | |
267 } | |
268 | |
269 return 0; | |
270 } | |
271 | |
272 static uint32_t vidix_draw_slice_32_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
273 { | |
274 uint8_t *src; | |
275 uint8_t *dest; | |
276 unsigned bespitch,apitch; | |
277 int i; | |
278 apitch = vidix_play.dest.pitch.y-1; | |
279 bespitch = (w*4 + apitch) & ~apitch; | |
280 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
281 dest += bespitch*y + x; | |
282 src = image[0]; | |
283 memcpy(dest,src,h*bespitch); | |
284 return 0; | |
285 } | |
286 | |
287 static uint32_t vidix_draw_slice_24(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
288 { | |
289 uint8_t *src; | |
290 uint8_t *dest; | |
291 unsigned bespitch,apitch; | |
292 int i; | |
293 apitch = vidix_play.dest.pitch.y-1; | |
294 bespitch = (w*3 + apitch) & ~apitch; | |
295 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
296 dest += bespitch*y + x; | |
297 src = image[0]; | |
298 for(i=0;i<h;i++){ | |
299 memcpy(dest,src,w*3); | |
300 src+=stride[0]; | |
301 dest += bespitch; | |
302 } | |
303 | |
304 return 0; | |
305 } | |
306 | |
307 static uint32_t vidix_draw_slice_24_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
308 { | |
309 uint8_t *src; | |
310 uint8_t *dest; | |
311 unsigned bespitch,apitch; | |
312 int i; | |
313 apitch = vidix_play.dest.pitch.y-1; | |
314 bespitch = (w*3 + apitch) & ~apitch; | |
315 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
316 dest += bespitch*y + x; | |
317 src = image[0]; | |
318 memcpy(dest,src,h*bespitch); | |
319 return 0; | 234 return 0; |
320 } | 235 } |
321 | 236 |
322 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | 237 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) |
323 { | 238 { |
504 unsigned dst_height,unsigned format,unsigned dest_bpp, | 419 unsigned dst_height,unsigned format,unsigned dest_bpp, |
505 unsigned vid_w,unsigned vid_h,const void *info) | 420 unsigned vid_w,unsigned vid_h,const void *info) |
506 { | 421 { |
507 size_t i,awidth; | 422 size_t i,awidth; |
508 int err,is_422_planes_eq; | 423 int err,is_422_planes_eq; |
509 uint32_t sstride,dstride; | 424 uint32_t sstride,apitch; |
510 if(verbose > 1) | 425 if(verbose > 1) |
511 printf("vosub_vidix: vidix_init() was called\n" | 426 printf("vosub_vidix: vidix_init() was called\n" |
512 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n" | 427 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n" |
513 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n" | 428 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n" |
514 ,src_width,src_height,x_org,y_org,dst_width,dst_height | 429 ,src_width,src_height,x_org,y_org,dst_width,dst_height |
632 | 547 |
633 /* clear every frame with correct address and frame_size */ | 548 /* clear every frame with correct address and frame_size */ |
634 for (i = 0; i < vidix_play.num_frames; i++) | 549 for (i = 0; i < vidix_play.num_frames; i++) |
635 memset(vidix_mem + vidix_play.offsets[i], 0x80, | 550 memset(vidix_mem + vidix_play.offsets[i], 0x80, |
636 vidix_play.frame_size); | 551 vidix_play.frame_size); |
552 switch(format) | |
553 { | |
554 /* | |
555 case IMGFMT_YV09: | |
556 case IMGFMT_IF09: | |
557 */ | |
558 case IMGFMT_I420: | |
559 case IMGFMT_IYUV: | |
560 case IMGFMT_YV12: | |
561 apitch = vidix_play.dest.pitch.y-1; | |
562 dstrides.y = (image_width + apitch) & ~apitch; | |
563 apitch = vidix_play.dest.pitch.v-1; | |
564 dstrides.v = (image_width + apitch) & ~apitch; | |
565 apitch = vidix_play.dest.pitch.u-1; | |
566 dstrides.u = (image_width + apitch) & ~apitch; | |
567 image_Bpp=1; | |
568 break; | |
569 case IMGFMT_RGB32: | |
570 case IMGFMT_BGR32: | |
571 apitch = vidix_play.dest.pitch.y-1; | |
572 dstrides.y = (image_width*4 + apitch) & ~apitch; | |
573 dstrides.u = dstrides.v = 0; | |
574 image_Bpp=4; | |
575 break; | |
576 case IMGFMT_RGB24: | |
577 case IMGFMT_BGR24: | |
578 apitch = vidix_play.dest.pitch.y-1; | |
579 dstrides.y = (image_width*3 + apitch) & ~apitch; | |
580 dstrides.u = dstrides.v = 0; | |
581 image_Bpp=3; | |
582 break; | |
583 default: | |
584 apitch = vidix_play.dest.pitch.y-1; | |
585 dstrides.y = (image_width*2 + apitch) & ~apitch; | |
586 dstrides.u = dstrides.v = 0; | |
587 image_Bpp=2; | |
588 break; | |
589 } | |
637 /* tune some info here */ | 590 /* tune some info here */ |
638 sstride = src_width*2; | 591 sstride = src_width*2; |
639 dstride = (src_width*2+(vidix_play.dest.pitch.y-1))&~(vidix_play.dest.pitch.y-1); | 592 is_422_planes_eq = sstride == dstrides.y; |
640 is_422_planes_eq = sstride == dstride; | |
641 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | 593 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) |
642 vo_server->draw_slice = vidix_draw_slice_420; | 594 vo_server->draw_slice = vidix_draw_slice_420; |
643 else | 595 else vo_server->draw_slice = |
644 if(src_format == IMGFMT_RGB32 || src_format == IMGFMT_BGR32) | |
645 vo_server->draw_slice = | |
646 is_422_planes_eq ? | 596 is_422_planes_eq ? |
647 vidix_draw_slice_32_fast: | 597 vidix_draw_slice_packed_fast: |
648 vidix_draw_slice_32; | 598 vidix_draw_slice_packed; |
649 else | |
650 if(src_format == IMGFMT_RGB24 || src_format == IMGFMT_BGR24) | |
651 vo_server->draw_slice = | |
652 is_422_planes_eq ? | |
653 vidix_draw_slice_24_fast: | |
654 vidix_draw_slice_24; | |
655 else | |
656 vo_server->draw_slice = | |
657 is_422_planes_eq ? | |
658 vidix_draw_slice_422_fast: | |
659 vidix_draw_slice_422; | |
660 return 0; | 599 return 0; |
661 } | 600 } |
662 | 601 |
663 static uint32_t vidix_get_image(mp_image_t *mpi) | 602 static uint32_t vidix_get_image(mp_image_t *mpi) |
664 { | 603 { |
665 if(mpi->type==MP_IMGTYPE_STATIC && vidix_play.num_frames>1) return VO_FALSE; | 604 if(mpi->type==MP_IMGTYPE_STATIC && vidix_play.num_frames>1) return VO_FALSE; |
666 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; /* slow video ram */ | 605 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; /* slow video ram */ |
667 mpi->planes[0]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.y; | 606 mpi->planes[0]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.y; |
668 mpi->stride[0]=vidix_play.dest.pitch.y; | 607 mpi->stride[0]=dstrides.y; |
669 if(mpi->flags&MP_IMGFLAG_PLANAR) | 608 if(mpi->flags&MP_IMGFLAG_PLANAR) |
670 { | 609 { |
671 mpi->planes[1]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.v; | 610 mpi->planes[1]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.v; |
672 mpi->stride[1]=vidix_play.dest.pitch.v; | 611 mpi->stride[1]=dstrides.v; |
673 mpi->planes[2]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.u; | 612 mpi->planes[2]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.u; |
674 mpi->stride[2]=vidix_play.dest.pitch.u; | 613 mpi->stride[2]=dstrides.u; |
675 } | 614 } |
676 mpi->flags|=MP_IMGFLAG_DIRECT; | 615 mpi->flags|=MP_IMGFLAG_DIRECT; |
677 return VO_TRUE; | 616 return VO_TRUE; |
678 } | 617 } |
679 | 618 |