110 } else if (j == y2) { |
126 } else if (j == y2) { |
111 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
127 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
112 } else { |
128 } else { |
113 xacc = 0; |
129 xacc = 0; |
114 vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride, |
130 vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride, |
115 dest->width, &xacc, x_increment); |
131 src->width, dest->width, &xacc, x_increment); |
116 y1 = j; |
132 y1 = j; |
117 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
133 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
118 } |
134 } |
119 } else { |
135 } else { |
120 if (j == y1) { |
136 if (j == y1) { |
121 if (j + 1 != y2) { |
137 if (j + 1 != y2) { |
122 xacc = 0; |
138 xacc = 0; |
123 vs_scanline_resample_linear_RGBA (tmp2, |
139 vs_scanline_resample_linear_RGBA (tmp2, |
124 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
140 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
125 x_increment); |
141 &xacc, x_increment); |
126 y2 = j + 1; |
142 y2 = j + 1; |
127 } |
143 } |
128 vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, |
144 vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, |
129 tmp1, tmp2, dest->width, x); |
145 tmp1, tmp2, dest->width, x); |
130 } else if (j == y2) { |
146 } else if (j == y2) { |
131 if (j + 1 != y1) { |
147 if (j + 1 != y1) { |
132 xacc = 0; |
148 xacc = 0; |
133 vs_scanline_resample_linear_RGBA (tmp1, |
149 vs_scanline_resample_linear_RGBA (tmp1, |
134 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
150 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
135 x_increment); |
151 &xacc, x_increment); |
136 y1 = j + 1; |
152 y1 = j + 1; |
137 } |
153 } |
138 vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, |
154 vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, |
139 tmp2, tmp1, dest->width, x); |
155 tmp2, tmp1, dest->width, x); |
140 } else { |
156 } else { |
141 xacc = 0; |
157 xacc = 0; |
142 vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride, |
158 vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride, |
143 dest->width, &xacc, x_increment); |
159 src->width, dest->width, &xacc, x_increment); |
144 y1 = j; |
160 y1 = j; |
145 xacc = 0; |
161 xacc = 0; |
146 vs_scanline_resample_linear_RGBA (tmp2, |
162 vs_scanline_resample_linear_RGBA (tmp2, |
147 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
163 src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, |
148 x_increment); |
164 x_increment); |
149 y2 = (j + 1); |
165 y2 = (j + 1); |
150 vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, |
166 vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, |
151 tmp1, tmp2, dest->width, x); |
167 tmp1, tmp2, dest->width, x); |
152 } |
168 } |
234 } else if (j == y2) { |
265 } else if (j == y2) { |
235 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
266 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
236 } else { |
267 } else { |
237 xacc = 0; |
268 xacc = 0; |
238 vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride, |
269 vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride, |
239 dest->width, &xacc, x_increment); |
270 src->width, dest->width, &xacc, x_increment); |
240 y1 = j; |
271 y1 = j; |
241 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
272 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
242 } |
273 } |
243 } else { |
274 } else { |
244 if (j == y1) { |
275 if (j == y1) { |
245 if (j + 1 != y2) { |
276 if (j + 1 != y2) { |
246 xacc = 0; |
277 xacc = 0; |
247 vs_scanline_resample_linear_RGB (tmp2, |
278 vs_scanline_resample_linear_RGB (tmp2, |
248 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
279 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
249 x_increment); |
280 &xacc, x_increment); |
250 y2 = j + 1; |
281 y2 = j + 1; |
251 } |
282 } |
252 vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, |
283 vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, |
253 tmp1, tmp2, dest->width, x); |
284 tmp1, tmp2, dest->width, x); |
254 } else if (j == y2) { |
285 } else if (j == y2) { |
255 if (j + 1 != y1) { |
286 if (j + 1 != y1) { |
256 xacc = 0; |
287 xacc = 0; |
257 vs_scanline_resample_linear_RGB (tmp1, |
288 vs_scanline_resample_linear_RGB (tmp1, |
258 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
289 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
259 x_increment); |
290 &xacc, x_increment); |
260 y1 = j + 1; |
291 y1 = j + 1; |
261 } |
292 } |
262 vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, |
293 vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, |
263 tmp2, tmp1, dest->width, x); |
294 tmp2, tmp1, dest->width, x); |
264 } else { |
295 } else { |
265 xacc = 0; |
296 xacc = 0; |
266 vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride, |
297 vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride, |
267 dest->width, &xacc, x_increment); |
298 src->width, dest->width, &xacc, x_increment); |
268 y1 = j; |
299 y1 = j; |
269 xacc = 0; |
300 xacc = 0; |
270 vs_scanline_resample_linear_RGB (tmp2, |
301 vs_scanline_resample_linear_RGB (tmp2, |
271 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
302 src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, |
272 x_increment); |
303 x_increment); |
273 y2 = (j + 1); |
304 y2 = (j + 1); |
274 vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, |
305 vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, |
275 tmp1, tmp2, dest->width, x); |
306 tmp1, tmp2, dest->width, x); |
276 } |
307 } |
363 } else if (j == y2) { |
405 } else if (j == y2) { |
364 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
406 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
365 } else { |
407 } else { |
366 xacc = 0; |
408 xacc = 0; |
367 vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, |
409 vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, |
368 n_quads, &xacc, x_increment); |
410 src->width, dest->width, &xacc, x_increment); |
369 y1 = j; |
411 y1 = j; |
370 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
412 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
371 } |
413 } |
372 } else { |
414 } else { |
373 if (j == y1) { |
415 if (j == y1) { |
374 if (j + 1 != y2) { |
416 if (j + 1 != y2) { |
375 xacc = 0; |
417 xacc = 0; |
376 vs_scanline_resample_linear_YUYV (tmp2, |
418 vs_scanline_resample_linear_YUYV (tmp2, |
377 src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); |
419 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
420 &xacc, x_increment); |
378 y2 = j + 1; |
421 y2 = j + 1; |
379 } |
422 } |
380 vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, |
423 vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, |
381 tmp1, tmp2, n_quads, x); |
424 tmp1, tmp2, dest->width, x); |
382 } else if (j == y2) { |
425 } else if (j == y2) { |
383 if (j + 1 != y1) { |
426 if (j + 1 != y1) { |
384 xacc = 0; |
427 xacc = 0; |
385 vs_scanline_resample_linear_YUYV (tmp1, |
428 vs_scanline_resample_linear_YUYV (tmp1, |
386 src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); |
429 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
430 &xacc, x_increment); |
387 y1 = j + 1; |
431 y1 = j + 1; |
388 } |
432 } |
389 vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, |
433 vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, |
390 tmp2, tmp1, n_quads, x); |
434 tmp2, tmp1, dest->width, x); |
391 } else { |
435 } else { |
392 xacc = 0; |
436 xacc = 0; |
393 vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, |
437 vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, |
394 n_quads, &xacc, x_increment); |
438 src->width, dest->width, &xacc, x_increment); |
395 y1 = j; |
439 y1 = j; |
396 xacc = 0; |
440 xacc = 0; |
397 vs_scanline_resample_linear_YUYV (tmp2, |
441 vs_scanline_resample_linear_YUYV (tmp2, |
398 src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); |
442 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
443 &xacc, x_increment); |
399 y2 = (j + 1); |
444 y2 = (j + 1); |
400 vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, |
445 vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, |
401 tmp1, tmp2, n_quads, x); |
446 tmp1, tmp2, dest->width, x); |
402 } |
447 } |
403 } |
448 } |
404 |
449 |
405 acc += y_increment; |
450 acc += y_increment; |
406 } |
451 } |
489 } else if (j == y2) { |
545 } else if (j == y2) { |
490 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
546 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
491 } else { |
547 } else { |
492 xacc = 0; |
548 xacc = 0; |
493 vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, |
549 vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, |
494 n_quads, &xacc, x_increment); |
550 src->width, dest->width, &xacc, x_increment); |
495 y1 = j; |
551 y1 = j; |
496 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
552 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
497 } |
553 } |
498 } else { |
554 } else { |
499 if (j == y1) { |
555 if (j == y1) { |
500 if (j + 1 != y2) { |
556 if (j + 1 != y2) { |
501 xacc = 0; |
557 xacc = 0; |
502 vs_scanline_resample_linear_UYVY (tmp2, |
558 vs_scanline_resample_linear_UYVY (tmp2, |
503 src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); |
559 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
560 &xacc, x_increment); |
504 y2 = j + 1; |
561 y2 = j + 1; |
505 } |
562 } |
506 vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, |
563 vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, |
507 tmp1, tmp2, n_quads, x); |
564 tmp1, tmp2, dest->width, x); |
508 } else if (j == y2) { |
565 } else if (j == y2) { |
509 if (j + 1 != y1) { |
566 if (j + 1 != y1) { |
510 xacc = 0; |
567 xacc = 0; |
511 vs_scanline_resample_linear_UYVY (tmp1, |
568 vs_scanline_resample_linear_UYVY (tmp1, |
512 src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); |
569 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
570 &xacc, x_increment); |
513 y1 = j + 1; |
571 y1 = j + 1; |
514 } |
572 } |
515 vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, |
573 vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, |
516 tmp2, tmp1, n_quads, x); |
574 tmp2, tmp1, dest->width, x); |
517 } else { |
575 } else { |
518 xacc = 0; |
576 xacc = 0; |
519 vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, |
577 vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, |
520 n_quads, &xacc, x_increment); |
578 src->width, dest->width, &xacc, x_increment); |
521 y1 = j; |
579 y1 = j; |
522 xacc = 0; |
580 xacc = 0; |
523 vs_scanline_resample_linear_UYVY (tmp2, |
581 vs_scanline_resample_linear_UYVY (tmp2, |
524 src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); |
582 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
583 &xacc, x_increment); |
525 y2 = (j + 1); |
584 y2 = (j + 1); |
526 vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, |
585 vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, |
527 tmp1, tmp2, n_quads, x); |
586 tmp1, tmp2, dest->width, x); |
528 } |
587 } |
529 } |
588 } |
530 |
589 |
531 acc += y_increment; |
590 acc += y_increment; |
532 } |
591 } |
611 } else if (j == y2) { |
685 } else if (j == y2) { |
612 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
686 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
613 } else { |
687 } else { |
614 xacc = 0; |
688 xacc = 0; |
615 vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride, |
689 vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride, |
616 dest->width, &xacc, x_increment); |
690 src->width, dest->width, &xacc, x_increment); |
617 y1 = j; |
691 y1 = j; |
618 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
692 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
619 } |
693 } |
620 } else { |
694 } else { |
621 if (j == y1) { |
695 if (j == y1) { |
622 if (j + 1 != y2) { |
696 if (j + 1 != y2) { |
623 xacc = 0; |
697 xacc = 0; |
624 vs_scanline_resample_linear_Y (tmp2, |
698 vs_scanline_resample_linear_Y (tmp2, |
625 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
699 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
626 x_increment); |
700 &xacc, x_increment); |
627 y2 = j + 1; |
701 y2 = j + 1; |
628 } |
702 } |
629 vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, |
703 vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, |
630 tmp1, tmp2, dest->width, x); |
704 tmp1, tmp2, dest->width, x); |
631 } else if (j == y2) { |
705 } else if (j == y2) { |
632 if (j + 1 != y1) { |
706 if (j + 1 != y1) { |
633 xacc = 0; |
707 xacc = 0; |
634 vs_scanline_resample_linear_Y (tmp1, |
708 vs_scanline_resample_linear_Y (tmp1, |
635 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
709 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
636 x_increment); |
710 &xacc, x_increment); |
637 y1 = j + 1; |
711 y1 = j + 1; |
638 } |
712 } |
639 vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, |
713 vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, |
640 tmp2, tmp1, dest->width, x); |
714 tmp2, tmp1, dest->width, x); |
641 } else { |
715 } else { |
642 xacc = 0; |
716 xacc = 0; |
643 vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride, |
717 vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride, |
644 dest->width, &xacc, x_increment); |
718 src->width, dest->width, &xacc, x_increment); |
645 y1 = j; |
719 y1 = j; |
646 xacc = 0; |
720 xacc = 0; |
647 vs_scanline_resample_linear_Y (tmp2, |
721 vs_scanline_resample_linear_Y (tmp2, |
648 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
722 src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, |
649 x_increment); |
723 x_increment); |
650 y2 = (j + 1); |
724 y2 = (j + 1); |
651 vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, |
725 vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, |
652 tmp1, tmp2, dest->width, x); |
726 tmp1, tmp2, dest->width, x); |
653 } |
727 } |
654 } |
728 } |
655 |
729 |
656 acc += y_increment; |
730 acc += y_increment; |
657 } |
731 } |
658 } |
732 } |
659 |
733 #ifdef __SYMBIAN32__ |
660 /* RGB565 */ |
734 EXPORT_C |
661 #ifdef __SYMBIAN32__ |
735 #endif |
662 EXPORT_C |
736 |
663 #endif |
737 void |
664 |
738 vs_image_scale_nearest_Y16 (const VSImage * dest, const VSImage * src, |
665 |
739 uint8_t * tmpbuf) |
666 void |
740 { |
667 vs_image_scale_nearest_RGB565 (const VSImage * dest, const VSImage * src, |
741 int acc; |
668 uint8_t * tmpbuf) |
742 int y_increment; |
669 { |
743 int x_increment; |
670 int acc; |
744 int i; |
671 int y_increment; |
745 int j; |
672 int x_increment; |
746 int x; |
673 int i; |
747 int xacc; |
674 int j; |
748 |
675 int x; |
749 if (dest->height == 1) |
676 int xacc; |
750 y_increment = 0; |
677 |
751 else |
678 y_increment = ((src->height - 1) << 16) / (dest->height - 1); |
752 y_increment = ((src->height - 1) << 16) / (dest->height - 1); |
679 x_increment = ((src->width - 1) << 16) / (dest->width - 1); |
753 |
|
754 if (dest->width == 1) |
|
755 x_increment = 0; |
|
756 else |
|
757 x_increment = ((src->width - 1) << 16) / (dest->width - 1); |
680 |
758 |
681 acc = 0; |
759 acc = 0; |
682 for (i = 0; i < dest->height; i++) { |
760 for (i = 0; i < dest->height; i++) { |
683 j = acc >> 16; |
761 j = acc >> 16; |
684 x = acc & 0xffff; |
762 x = acc & 0xffff; |
685 |
763 |
686 xacc = 0; |
764 xacc = 0; |
687 vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride, |
765 vs_scanline_resample_nearest_Y16 (dest->pixels + i * dest->stride, |
688 src->pixels + j * src->stride, dest->width, &xacc, x_increment); |
766 src->pixels + j * src->stride, src->width, dest->width, &xacc, |
689 |
767 x_increment); |
690 acc += y_increment; |
768 |
691 } |
769 acc += y_increment; |
692 } |
770 } |
693 #ifdef __SYMBIAN32__ |
771 } |
694 EXPORT_C |
772 #ifdef __SYMBIAN32__ |
695 #endif |
773 EXPORT_C |
696 |
774 #endif |
697 |
775 |
698 void |
776 void |
699 vs_image_scale_linear_RGB565 (const VSImage * dest, const VSImage * src, |
777 vs_image_scale_linear_Y16 (const VSImage * dest, const VSImage * src, |
700 uint8_t * tmpbuf) |
778 uint8_t * tmpbuf) |
701 { |
779 { |
702 int acc; |
780 int acc; |
703 int y_increment; |
781 int y_increment; |
704 int x_increment; |
782 int x_increment; |
735 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
820 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
736 } else if (j == y2) { |
821 } else if (j == y2) { |
737 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
822 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
738 } else { |
823 } else { |
739 xacc = 0; |
824 xacc = 0; |
740 vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride, |
825 vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride, |
741 dest->width, &xacc, x_increment); |
826 src->width, dest->width, &xacc, x_increment); |
742 y1 = j; |
827 y1 = j; |
743 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
828 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
744 } |
829 } |
745 } else { |
830 } else { |
746 if (j == y1) { |
831 if (j == y1) { |
747 if (j + 1 != y2) { |
832 if (j + 1 != y2) { |
748 xacc = 0; |
833 xacc = 0; |
749 vs_scanline_resample_linear_RGB565 (tmp2, |
834 vs_scanline_resample_linear_Y16 (tmp2, |
750 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
835 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
751 x_increment); |
836 &xacc, x_increment); |
752 y2 = j + 1; |
837 y2 = j + 1; |
753 } |
838 } |
754 vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, |
839 vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride, |
755 tmp1, tmp2, dest->width, x); |
840 tmp1, tmp2, dest->width, x); |
756 } else if (j == y2) { |
841 } else if (j == y2) { |
757 if (j + 1 != y1) { |
842 if (j + 1 != y1) { |
758 xacc = 0; |
843 xacc = 0; |
759 vs_scanline_resample_linear_RGB565 (tmp1, |
844 vs_scanline_resample_linear_Y16 (tmp1, |
760 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
845 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
761 x_increment); |
846 &xacc, x_increment); |
762 y1 = j + 1; |
847 y1 = j + 1; |
763 } |
848 } |
764 vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, |
849 vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride, |
765 tmp2, tmp1, dest->width, x); |
850 tmp2, tmp1, dest->width, x); |
766 } else { |
851 } else { |
767 xacc = 0; |
852 xacc = 0; |
768 vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride, |
853 vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride, |
769 dest->width, &xacc, x_increment); |
854 src->width, dest->width, &xacc, x_increment); |
770 y1 = j; |
855 y1 = j; |
771 xacc = 0; |
856 xacc = 0; |
772 vs_scanline_resample_linear_RGB565 (tmp2, |
857 vs_scanline_resample_linear_Y16 (tmp2, |
773 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
858 src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, |
774 x_increment); |
859 x_increment); |
775 y2 = (j + 1); |
860 y2 = (j + 1); |
776 vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, |
861 vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride, |
777 tmp1, tmp2, dest->width, x); |
862 tmp1, tmp2, dest->width, x); |
778 } |
863 } |
779 } |
864 } |
780 |
865 |
781 acc += y_increment; |
866 acc += y_increment; |
782 } |
867 } |
783 } |
868 } |
784 |
869 |
785 /* RGB555 */ |
870 /* RGB565 */ |
786 #ifdef __SYMBIAN32__ |
871 #ifdef __SYMBIAN32__ |
787 EXPORT_C |
872 EXPORT_C |
788 #endif |
873 #endif |
789 |
874 |
790 |
875 |
791 void |
876 void |
792 vs_image_scale_nearest_RGB555 (const VSImage * dest, const VSImage * src, |
877 vs_image_scale_nearest_RGB565 (const VSImage * dest, const VSImage * src, |
793 uint8_t * tmpbuf) |
878 uint8_t * tmpbuf) |
794 { |
879 { |
795 int acc; |
880 int acc; |
796 int y_increment; |
881 int y_increment; |
797 int x_increment; |
882 int x_increment; |
798 int i; |
883 int i; |
799 int j; |
884 int j; |
800 int x; |
885 int x; |
801 int xacc; |
886 int xacc; |
802 |
887 |
803 y_increment = ((src->height - 1) << 16) / (dest->height - 1); |
888 if (dest->height == 1) |
804 x_increment = ((src->width - 1) << 16) / (dest->width - 1); |
889 y_increment = 0; |
|
890 else |
|
891 y_increment = ((src->height - 1) << 16) / (dest->height - 1); |
|
892 |
|
893 if (dest->width == 1) |
|
894 x_increment = 0; |
|
895 else |
|
896 x_increment = ((src->width - 1) << 16) / (dest->width - 1); |
805 |
897 |
806 acc = 0; |
898 acc = 0; |
807 for (i = 0; i < dest->height; i++) { |
899 for (i = 0; i < dest->height; i++) { |
808 j = acc >> 16; |
900 j = acc >> 16; |
809 x = acc & 0xffff; |
901 x = acc & 0xffff; |
810 |
902 |
811 xacc = 0; |
903 xacc = 0; |
812 vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride, |
904 vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride, |
813 src->pixels + j * src->stride, dest->width, &xacc, x_increment); |
905 src->pixels + j * src->stride, src->width, dest->width, &xacc, |
814 |
906 x_increment); |
815 acc += y_increment; |
907 |
816 } |
908 acc += y_increment; |
817 } |
909 } |
818 #ifdef __SYMBIAN32__ |
910 } |
819 EXPORT_C |
911 #ifdef __SYMBIAN32__ |
820 #endif |
912 EXPORT_C |
821 |
913 #endif |
822 |
914 |
823 void |
915 |
824 vs_image_scale_linear_RGB555 (const VSImage * dest, const VSImage * src, |
916 void |
|
917 vs_image_scale_linear_RGB565 (const VSImage * dest, const VSImage * src, |
825 uint8_t * tmpbuf) |
918 uint8_t * tmpbuf) |
826 { |
919 { |
827 int acc; |
920 int acc; |
828 int y_increment; |
921 int y_increment; |
829 int x_increment; |
922 int x_increment; |
860 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
960 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
861 } else if (j == y2) { |
961 } else if (j == y2) { |
862 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
962 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
863 } else { |
963 } else { |
864 xacc = 0; |
964 xacc = 0; |
|
965 vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride, |
|
966 src->width, dest->width, &xacc, x_increment); |
|
967 y1 = j; |
|
968 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
|
969 } |
|
970 } else { |
|
971 if (j == y1) { |
|
972 if (j + 1 != y2) { |
|
973 xacc = 0; |
|
974 vs_scanline_resample_linear_RGB565 (tmp2, |
|
975 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
976 &xacc, x_increment); |
|
977 y2 = j + 1; |
|
978 } |
|
979 vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, |
|
980 tmp1, tmp2, dest->width, x); |
|
981 } else if (j == y2) { |
|
982 if (j + 1 != y1) { |
|
983 xacc = 0; |
|
984 vs_scanline_resample_linear_RGB565 (tmp1, |
|
985 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
|
986 &xacc, x_increment); |
|
987 y1 = j + 1; |
|
988 } |
|
989 vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, |
|
990 tmp2, tmp1, dest->width, x); |
|
991 } else { |
|
992 xacc = 0; |
|
993 vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride, |
|
994 src->width, dest->width, &xacc, x_increment); |
|
995 y1 = j; |
|
996 xacc = 0; |
|
997 vs_scanline_resample_linear_RGB565 (tmp2, |
|
998 src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, |
|
999 x_increment); |
|
1000 y2 = (j + 1); |
|
1001 vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, |
|
1002 tmp1, tmp2, dest->width, x); |
|
1003 } |
|
1004 } |
|
1005 |
|
1006 acc += y_increment; |
|
1007 } |
|
1008 } |
|
1009 |
|
1010 /* RGB555 */ |
|
1011 #ifdef __SYMBIAN32__ |
|
1012 EXPORT_C |
|
1013 #endif |
|
1014 |
|
1015 |
|
1016 void |
|
1017 vs_image_scale_nearest_RGB555 (const VSImage * dest, const VSImage * src, |
|
1018 uint8_t * tmpbuf) |
|
1019 { |
|
1020 int acc; |
|
1021 int y_increment; |
|
1022 int x_increment; |
|
1023 int i; |
|
1024 int j; |
|
1025 int x; |
|
1026 int xacc; |
|
1027 |
|
1028 if (dest->height == 1) |
|
1029 y_increment = 0; |
|
1030 else |
|
1031 y_increment = ((src->height - 1) << 16) / (dest->height - 1); |
|
1032 |
|
1033 if (dest->width == 1) |
|
1034 x_increment = 0; |
|
1035 else |
|
1036 x_increment = ((src->width - 1) << 16) / (dest->width - 1); |
|
1037 |
|
1038 acc = 0; |
|
1039 for (i = 0; i < dest->height; i++) { |
|
1040 j = acc >> 16; |
|
1041 x = acc & 0xffff; |
|
1042 |
|
1043 xacc = 0; |
|
1044 vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride, |
|
1045 src->pixels + j * src->stride, src->width, dest->width, &xacc, |
|
1046 x_increment); |
|
1047 |
|
1048 acc += y_increment; |
|
1049 } |
|
1050 } |
|
1051 #ifdef __SYMBIAN32__ |
|
1052 EXPORT_C |
|
1053 #endif |
|
1054 |
|
1055 |
|
1056 void |
|
1057 vs_image_scale_linear_RGB555 (const VSImage * dest, const VSImage * src, |
|
1058 uint8_t * tmpbuf) |
|
1059 { |
|
1060 int acc; |
|
1061 int y_increment; |
|
1062 int x_increment; |
|
1063 uint8_t *tmp1; |
|
1064 uint8_t *tmp2; |
|
1065 int y1; |
|
1066 int y2; |
|
1067 int i; |
|
1068 int j; |
|
1069 int x; |
|
1070 int dest_size; |
|
1071 int xacc; |
|
1072 |
|
1073 if (dest->height == 1) |
|
1074 y_increment = 0; |
|
1075 else |
|
1076 y_increment = ((src->height - 1) << 16) / (dest->height - 1); |
|
1077 |
|
1078 if (dest->width == 1) |
|
1079 x_increment = 0; |
|
1080 else |
|
1081 x_increment = ((src->width - 1) << 16) / (dest->width - 1); |
|
1082 |
|
1083 dest_size = dest->width * 2; |
|
1084 |
|
1085 tmp1 = tmpbuf; |
|
1086 tmp2 = tmpbuf + dest_size; |
|
1087 |
|
1088 acc = 0; |
|
1089 xacc = 0; |
|
1090 y2 = -1; |
|
1091 vs_scanline_resample_linear_RGB555 (tmp1, src->pixels, src->width, |
|
1092 dest->width, &xacc, x_increment); |
|
1093 y1 = 0; |
|
1094 for (i = 0; i < dest->height; i++) { |
|
1095 j = acc >> 16; |
|
1096 x = acc & 0xffff; |
|
1097 |
|
1098 if (x == 0) { |
|
1099 if (j == y1) { |
|
1100 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
|
1101 } else if (j == y2) { |
|
1102 memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); |
|
1103 } else { |
|
1104 xacc = 0; |
865 vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride, |
1105 vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride, |
866 dest->width, &xacc, x_increment); |
1106 src->width, dest->width, &xacc, x_increment); |
867 y1 = j; |
1107 y1 = j; |
868 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
1108 memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); |
869 } |
1109 } |
870 } else { |
1110 } else { |
871 if (j == y1) { |
1111 if (j == y1) { |
872 if (j + 1 != y2) { |
1112 if (j + 1 != y2) { |
873 xacc = 0; |
1113 xacc = 0; |
874 vs_scanline_resample_linear_RGB555 (tmp2, |
1114 vs_scanline_resample_linear_RGB555 (tmp2, |
875 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
1115 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
876 x_increment); |
1116 &xacc, x_increment); |
877 y2 = j + 1; |
1117 y2 = j + 1; |
878 } |
1118 } |
879 vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, |
1119 vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, |
880 tmp1, tmp2, dest->width, x); |
1120 tmp1, tmp2, dest->width, x); |
881 } else if (j == y2) { |
1121 } else if (j == y2) { |
882 if (j + 1 != y1) { |
1122 if (j + 1 != y1) { |
883 xacc = 0; |
1123 xacc = 0; |
884 vs_scanline_resample_linear_RGB555 (tmp1, |
1124 vs_scanline_resample_linear_RGB555 (tmp1, |
885 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
1125 src->pixels + (j + 1) * src->stride, src->width, dest->width, |
886 x_increment); |
1126 &xacc, x_increment); |
887 y1 = j + 1; |
1127 y1 = j + 1; |
888 } |
1128 } |
889 vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, |
1129 vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, |
890 tmp2, tmp1, dest->width, x); |
1130 tmp2, tmp1, dest->width, x); |
891 } else { |
1131 } else { |
892 xacc = 0; |
1132 xacc = 0; |
893 vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride, |
1133 vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride, |
894 dest->width, &xacc, x_increment); |
1134 src->width, dest->width, &xacc, x_increment); |
895 y1 = j; |
1135 y1 = j; |
896 xacc = 0; |
1136 xacc = 0; |
897 vs_scanline_resample_linear_RGB555 (tmp2, |
1137 vs_scanline_resample_linear_RGB555 (tmp2, |
898 src->pixels + (j + 1) * src->stride, dest->width, &xacc, |
1138 src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, |
899 x_increment); |
1139 x_increment); |
900 y2 = (j + 1); |
1140 y2 = (j + 1); |
901 vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, |
1141 vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, |
902 tmp1, tmp2, dest->width, x); |
1142 tmp1, tmp2, dest->width, x); |
903 } |
1143 } |