improve integer version of filter
[libvpx.git] / vpx_scale / generic / gen_scalers.c
blobb54e334cb735aa9abbc74ade4749fd99cc247417
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 #include "vpx_scale/vpxscale.h"
13 #include "vpx_mem/vpx_mem.h"
14 /****************************************************************************
15 * Imports
16 ****************************************************************************/
18 /****************************************************************************
20 * ROUTINE : vp8cx_horizontal_line_4_5_scale_c
22 * INPUTS : const unsigned char *source : Pointer to source data.
23 * unsigned int source_width : Stride of source.
24 * unsigned char *dest : Pointer to destination data.
25 * unsigned int dest_width : Stride of destination (NOT USED).
27 * OUTPUTS : None.
29 * RETURNS : void
31 * FUNCTION : Copies horizontal line of pixels from source to
32 * destination scaling up by 4 to 5.
34 * SPECIAL NOTES : None.
36 ****************************************************************************/
37 void vp8cx_horizontal_line_4_5_scale_c
39 const unsigned char *source,
40 unsigned int source_width,
41 unsigned char *dest,
42 unsigned int dest_width
45 unsigned i;
46 unsigned int a, b, c;
47 unsigned char *des = dest;
48 const unsigned char *src = source;
50 (void) dest_width;
52 for (i = 0; i < source_width - 4; i += 4)
54 a = src[0];
55 b = src[1];
56 des [0] = (unsigned char) a;
57 des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
58 c = src[2] * 154;
59 a = src[3];
60 des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
61 des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
62 b = src[4];
63 des [4] = (unsigned char)((a * 205 + 51 * b + 128) >> 8);
65 src += 4;
66 des += 5;
69 a = src[0];
70 b = src[1];
71 des [0] = (unsigned char)(a);
72 des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
73 c = src[2] * 154;
74 a = src[3];
75 des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
76 des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
77 des [4] = (unsigned char)(a);
81 /****************************************************************************
83 * ROUTINE : vp8cx_vertical_band_4_5_scale_c
85 * INPUTS : unsigned char *dest : Pointer to destination data.
86 * unsigned int dest_pitch : Stride of destination data.
87 * unsigned int dest_width : Width of destination data.
89 * OUTPUTS : None.
91 * RETURNS : void
93 * FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
94 * height of the band scaled is 4-pixels.
96 * SPECIAL NOTES : The routine uses the first line of the band below
97 * the current band.
99 ****************************************************************************/
100 void vp8cx_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
102 unsigned int i;
103 unsigned int a, b, c, d;
104 unsigned char *des = dest;
106 for (i = 0; i < dest_width; i++)
108 a = des [0];
109 b = des [dest_pitch];
111 des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
113 c = des[dest_pitch*2] * 154;
114 d = des[dest_pitch*3];
116 des [dest_pitch*2] = (unsigned char)((b * 102 + c + 128) >> 8);
117 des [dest_pitch*3] = (unsigned char)((c + 102 * d + 128) >> 8);
119 /* First line in next band */
120 a = des [dest_pitch * 5];
121 des [dest_pitch * 4] = (unsigned char)((d * 205 + 51 * a + 128) >> 8);
123 des ++;
127 /****************************************************************************
129 * ROUTINE : vp8cx_last_vertical_band_4_5_scale_c
131 * INPUTS : unsigned char *dest : Pointer to destination data.
132 * unsigned int dest_pitch : Stride of destination data.
133 * unsigned int dest_width : Width of destination data.
135 * OUTPUTS : None.
137 * RETURNS : void
139 * FUNCTION : Scales last vertical band of pixels by scale 4 to 5. The
140 * height of the band scaled is 4-pixels.
142 * SPECIAL NOTES : The routine does not have available the first line of
143 * the band below the current band, since this is the
144 * last band.
146 ****************************************************************************/
147 void vp8cx_last_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
149 unsigned int i;
150 unsigned int a, b, c, d;
151 unsigned char *des = dest;
153 for (i = 0; i < dest_width; ++i)
155 a = des[0];
156 b = des[dest_pitch];
158 des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
160 c = des[dest_pitch*2] * 154;
161 d = des[dest_pitch*3];
163 des [dest_pitch*2] = (unsigned char)((b * 102 + c + 128) >> 8);
164 des [dest_pitch*3] = (unsigned char)((c + 102 * d + 128) >> 8);
166 /* No other line for interplation of this line, so .. */
167 des[dest_pitch*4] = (unsigned char) d;
169 des++;
173 /****************************************************************************
175 * ROUTINE : vp8cx_horizontal_line_2_3_scale_c
177 * INPUTS : const unsigned char *source : Pointer to source data.
178 * unsigned int source_width : Stride of source.
179 * unsigned char *dest : Pointer to destination data.
180 * unsigned int dest_width : Stride of destination (NOT USED).
182 * OUTPUTS : None.
184 * RETURNS : void
186 * FUNCTION : Copies horizontal line of pixels from source to
187 * destination scaling up by 2 to 3.
189 * SPECIAL NOTES : None.
192 ****************************************************************************/
193 void vp8cx_horizontal_line_2_3_scale_c
195 const unsigned char *source,
196 unsigned int source_width,
197 unsigned char *dest,
198 unsigned int dest_width
201 unsigned int i;
202 unsigned int a, b, c;
203 unsigned char *des = dest;
204 const unsigned char *src = source;
206 (void) dest_width;
208 for (i = 0; i < source_width - 2; i += 2)
210 a = src[0];
211 b = src[1];
212 c = src[2];
214 des [0] = (unsigned char)(a);
215 des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
216 des [2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
218 src += 2;
219 des += 3;
222 a = src[0];
223 b = src[1];
224 des [0] = (unsigned char)(a);
225 des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
226 des [2] = (unsigned char)(b);
230 /****************************************************************************
232 * ROUTINE : vp8cx_vertical_band_2_3_scale_c
234 * INPUTS : unsigned char *dest : Pointer to destination data.
235 * unsigned int dest_pitch : Stride of destination data.
236 * unsigned int dest_width : Width of destination data.
238 * OUTPUTS : None.
240 * RETURNS : void
242 * FUNCTION : Scales vertical band of pixels by scale 2 to 3. The
243 * height of the band scaled is 2-pixels.
245 * SPECIAL NOTES : The routine uses the first line of the band below
246 * the current band.
248 ****************************************************************************/
249 void vp8cx_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
251 unsigned int i;
252 unsigned int a, b, c;
253 unsigned char *des = dest;
255 for (i = 0; i < dest_width; i++)
257 a = des [0];
258 b = des [dest_pitch];
259 c = des[dest_pitch*3];
260 des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
261 des [dest_pitch*2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
263 des++;
267 /****************************************************************************
269 * ROUTINE : vp8cx_last_vertical_band_2_3_scale_c
271 * INPUTS : unsigned char *dest : Pointer to destination data.
272 * unsigned int dest_pitch : Stride of destination data.
273 * unsigned int dest_width : Width of destination data.
275 * OUTPUTS : None.
277 * RETURNS : void
279 * FUNCTION : Scales last vertical band of pixels by scale 2 to 3. The
280 * height of the band scaled is 2-pixels.
282 * SPECIAL NOTES : The routine does not have available the first line of
283 * the band below the current band, since this is the
284 * last band.
286 ****************************************************************************/
287 void vp8cx_last_vertical_band_2_3_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
289 unsigned int i;
290 unsigned int a, b;
291 unsigned char *des = dest;
293 for (i = 0; i < dest_width; ++i)
295 a = des [0];
296 b = des [dest_pitch];
298 des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
299 des [dest_pitch*2] = (unsigned char)(b);
300 des++;
304 /****************************************************************************
306 * ROUTINE : vp8cx_horizontal_line_3_5_scale_c
308 * INPUTS : const unsigned char *source : Pointer to source data.
309 * unsigned int source_width : Stride of source.
310 * unsigned char *dest : Pointer to destination data.
311 * unsigned int dest_width : Stride of destination (NOT USED).
313 * OUTPUTS : None.
315 * RETURNS : void
317 * FUNCTION : Copies horizontal line of pixels from source to
318 * destination scaling up by 3 to 5.
320 * SPECIAL NOTES : None.
323 ****************************************************************************/
324 void vp8cx_horizontal_line_3_5_scale_c
326 const unsigned char *source,
327 unsigned int source_width,
328 unsigned char *dest,
329 unsigned int dest_width
332 unsigned int i;
333 unsigned int a, b, c;
334 unsigned char *des = dest;
335 const unsigned char *src = source;
337 (void) dest_width;
339 for (i = 0; i < source_width - 3; i += 3)
341 a = src[0];
342 b = src[1];
343 des [0] = (unsigned char)(a);
344 des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
346 c = src[2] ;
347 des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
348 des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
350 a = src[3];
351 des [4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
353 src += 3;
354 des += 5;
357 a = src[0];
358 b = src[1];
359 des [0] = (unsigned char)(a);
361 des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
362 c = src[2] ;
363 des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
364 des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
366 des [4] = (unsigned char)(c);
369 /****************************************************************************
371 * ROUTINE : vp8cx_vertical_band_3_5_scale_c
373 * INPUTS : unsigned char *dest : Pointer to destination data.
374 * unsigned int dest_pitch : Stride of destination data.
375 * unsigned int dest_width : Width of destination data.
377 * OUTPUTS : None.
379 * RETURNS : void
381 * FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
382 * height of the band scaled is 3-pixels.
384 * SPECIAL NOTES : The routine uses the first line of the band below
385 * the current band.
387 ****************************************************************************/
388 void vp8cx_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
390 unsigned int i;
391 unsigned int a, b, c;
392 unsigned char *des = dest;
394 for (i = 0; i < dest_width; i++)
396 a = des [0];
397 b = des [dest_pitch];
398 des [dest_pitch] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
400 c = des[dest_pitch*2];
401 des [dest_pitch*2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
402 des [dest_pitch*3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
404 /* First line in next band... */
405 a = des [dest_pitch * 5];
406 des [dest_pitch * 4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
408 des++;
412 /****************************************************************************
414 * ROUTINE : vp8cx_last_vertical_band_3_5_scale_c
416 * INPUTS : unsigned char *dest : Pointer to destination data.
417 * unsigned int dest_pitch : Stride of destination data.
418 * unsigned int dest_width : Width of destination data.
420 * OUTPUTS : None.
422 * RETURNS : void
424 * FUNCTION : Scales last vertical band of pixels by scale 3 to 5. The
425 * height of the band scaled is 3-pixels.
427 * SPECIAL NOTES : The routine does not have available the first line of
428 * the band below the current band, since this is the
429 * last band.
431 ****************************************************************************/
432 void vp8cx_last_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
434 unsigned int i;
435 unsigned int a, b, c;
436 unsigned char *des = dest;
438 for (i = 0; i < dest_width; ++i)
440 a = des [0];
441 b = des [dest_pitch];
443 des [ dest_pitch ] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
445 c = des[dest_pitch*2];
446 des [dest_pitch*2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
447 des [dest_pitch*3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
449 /* No other line for interplation of this line, so .. */
450 des [ dest_pitch * 4 ] = (unsigned char)(c) ;
452 des++;
456 /****************************************************************************
458 * ROUTINE : vp8cx_horizontal_line_3_4_scale_c
460 * INPUTS : const unsigned char *source : Pointer to source data.
461 * unsigned int source_width : Stride of source.
462 * unsigned char *dest : Pointer to destination data.
463 * unsigned int dest_width : Stride of destination (NOT USED).
465 * OUTPUTS : None.
467 * RETURNS : void
469 * FUNCTION : Copies horizontal line of pixels from source to
470 * destination scaling up by 3 to 4.
472 * SPECIAL NOTES : None.
475 ****************************************************************************/
476 void vp8cx_horizontal_line_3_4_scale_c
478 const unsigned char *source,
479 unsigned int source_width,
480 unsigned char *dest,
481 unsigned int dest_width
484 unsigned int i;
485 unsigned int a, b, c;
486 unsigned char *des = dest;
487 const unsigned char *src = source;
489 (void) dest_width;
491 for (i = 0; i < source_width - 3; i += 3)
493 a = src[0];
494 b = src[1];
495 des [0] = (unsigned char)(a);
496 des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
498 c = src[2];
499 des [2] = (unsigned char)((b + c + 1) >> 1);
501 a = src[3];
502 des [3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
504 src += 3;
505 des += 4;
508 a = src[0];
509 b = src[1];
510 des [0] = (unsigned char)(a);
511 des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
513 c = src[2] ;
514 des [2] = (unsigned char)((b + c + 1) >> 1);
515 des [3] = (unsigned char)(c);
518 /****************************************************************************
520 * ROUTINE : vp8cx_vertical_band_3_4_scale_c
522 * INPUTS : unsigned char *dest : Pointer to destination data.
523 * unsigned int dest_pitch : Stride of destination data.
524 * unsigned int dest_width : Width of destination data.
526 * OUTPUTS : None.
528 * RETURNS : void
530 * FUNCTION : Scales vertical band of pixels by scale 3 to 4. The
531 * height of the band scaled is 3-pixels.
533 * SPECIAL NOTES : The routine uses the first line of the band below
534 * the current band.
536 ****************************************************************************/
537 void vp8cx_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
539 unsigned int i;
540 unsigned int a, b, c;
541 unsigned char *des = dest;
543 for (i = 0; i < dest_width; i++)
545 a = des [0];
546 b = des [dest_pitch];
547 des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
549 c = des[dest_pitch*2];
550 des [dest_pitch*2] = (unsigned char)((b + c + 1) >> 1);
552 /* First line in next band... */
553 a = des [dest_pitch*4];
554 des [dest_pitch*3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
556 des++;
560 /****************************************************************************
562 * ROUTINE : vp8cx_last_vertical_band_3_4_scale_c
564 * INPUTS : unsigned char *dest : Pointer to destination data.
565 * unsigned int dest_pitch : Stride of destination data.
566 * unsigned int dest_width : Width of destination data.
568 * OUTPUTS : None.
570 * RETURNS : void
572 * FUNCTION : Scales last vertical band of pixels by scale 3 to 4. The
573 * height of the band scaled is 3-pixels.
575 * SPECIAL NOTES : The routine does not have available the first line of
576 * the band below the current band, since this is the
577 * last band.
579 ****************************************************************************/
580 void vp8cx_last_vertical_band_3_4_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
582 unsigned int i;
583 unsigned int a, b, c;
584 unsigned char *des = dest;
586 for (i = 0; i < dest_width; ++i)
588 a = des [0];
589 b = des [dest_pitch];
591 des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
593 c = des[dest_pitch*2];
594 des [dest_pitch*2] = (unsigned char)((b + c + 1) >> 1);
596 /* No other line for interplation of this line, so .. */
597 des [dest_pitch*3] = (unsigned char)(c);
599 des++;
603 /****************************************************************************
605 * ROUTINE : vp8cx_horizontal_line_1_2_scale_c
607 * INPUTS : const unsigned char *source : Pointer to source data.
608 * unsigned int source_width : Stride of source.
609 * unsigned char *dest : Pointer to destination data.
610 * unsigned int dest_width : Stride of destination (NOT USED).
612 * OUTPUTS : None.
614 * RETURNS : void
616 * FUNCTION : Copies horizontal line of pixels from source to
617 * destination scaling up by 1 to 2.
619 * SPECIAL NOTES : None.
621 ****************************************************************************/
622 void vp8cx_horizontal_line_1_2_scale_c
624 const unsigned char *source,
625 unsigned int source_width,
626 unsigned char *dest,
627 unsigned int dest_width
630 unsigned int i;
631 unsigned int a, b;
632 unsigned char *des = dest;
633 const unsigned char *src = source;
635 (void) dest_width;
637 for (i = 0; i < source_width - 1; i += 1)
639 a = src[0];
640 b = src[1];
641 des [0] = (unsigned char)(a);
642 des [1] = (unsigned char)((a + b + 1) >> 1);
643 src += 1;
644 des += 2;
647 a = src[0];
648 des [0] = (unsigned char)(a);
649 des [1] = (unsigned char)(a);
652 /****************************************************************************
654 * ROUTINE : vp8cx_vertical_band_1_2_scale_c
656 * INPUTS : unsigned char *dest : Pointer to destination data.
657 * unsigned int dest_pitch : Stride of destination data.
658 * unsigned int dest_width : Width of destination data.
660 * OUTPUTS : None.
662 * RETURNS : void
664 * FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
665 * height of the band scaled is 1-pixel.
667 * SPECIAL NOTES : The routine uses the first line of the band below
668 * the current band.
670 ****************************************************************************/
671 void vp8cx_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
673 unsigned int i;
674 unsigned int a, b;
675 unsigned char *des = dest;
677 for (i = 0; i < dest_width; i++)
679 a = des [0];
680 b = des [dest_pitch * 2];
682 des[dest_pitch] = (unsigned char)((a + b + 1) >> 1);
684 des++;
688 /****************************************************************************
690 * ROUTINE : vp8cx_last_vertical_band_1_2_scale_c
692 * INPUTS : unsigned char *dest : Pointer to destination data.
693 * unsigned int dest_pitch : Stride of destination data.
694 * unsigned int dest_width : Width of destination data.
696 * OUTPUTS : None.
698 * RETURNS : void
700 * FUNCTION : Scales last vertical band of pixels by scale 1 to 2. The
701 * height of the band scaled is 1-pixel.
703 * SPECIAL NOTES : The routine does not have available the first line of
704 * the band below the current band, since this is the
705 * last band.
707 ****************************************************************************/
708 void vp8cx_last_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
710 unsigned int i;
711 unsigned char *des = dest;
713 for (i = 0; i < dest_width; ++i)
715 des[dest_pitch] = des[0];
716 des++;
724 /****************************************************************************
726 * ROUTINE : vp8cx_horizontal_line_4_5_scale_c
728 * INPUTS : const unsigned char *source : Pointer to source data.
729 * unsigned int source_width : Stride of source.
730 * unsigned char *dest : Pointer to destination data.
731 * unsigned int dest_width : Stride of destination (NOT USED).
733 * OUTPUTS : None.
735 * RETURNS : void
737 * FUNCTION : Copies horizontal line of pixels from source to
738 * destination scaling up by 4 to 5.
740 * SPECIAL NOTES : None.
742 ****************************************************************************/
743 void vp8cx_horizontal_line_5_4_scale_c
745 const unsigned char *source,
746 unsigned int source_width,
747 unsigned char *dest,
748 unsigned int dest_width
751 unsigned i;
752 unsigned int a, b, c, d, e;
753 unsigned char *des = dest;
754 const unsigned char *src = source;
756 (void) dest_width;
758 for (i = 0; i < source_width; i += 5)
760 a = src[0];
761 b = src[1];
762 c = src[2];
763 d = src[3];
764 e = src[4];
766 des[0] = (unsigned char) a;
767 des[1] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
768 des[2] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
769 des[3] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
771 src += 5;
772 des += 4;
779 void vp8cx_vertical_band_5_4_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
781 unsigned int i;
782 unsigned int a, b, c, d, e;
783 unsigned char *des = dest;
784 unsigned char *src = source;
786 for (i = 0; i < dest_width; i++)
789 a = src[0 * src_pitch];
790 b = src[1 * src_pitch];
791 c = src[2 * src_pitch];
792 d = src[3 * src_pitch];
793 e = src[4 * src_pitch];
795 des[0 * dest_pitch] = (unsigned char) a;
796 des[1 * dest_pitch] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
797 des[2 * dest_pitch] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
798 des[3 * dest_pitch] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
800 src ++;
801 des ++;
807 /*7***************************************************************************
809 * ROUTINE : vp8cx_horizontal_line_3_5_scale_c
811 * INPUTS : const unsigned char *source : Pointer to source data.
812 * unsigned int source_width : Stride of source.
813 * unsigned char *dest : Pointer to destination data.
814 * unsigned int dest_width : Stride of destination (NOT USED).
816 * OUTPUTS : None.
818 * RETURNS : void
820 * FUNCTION : Copies horizontal line of pixels from source to
821 * destination scaling up by 3 to 5.
823 * SPECIAL NOTES : None.
826 ****************************************************************************/
827 void vp8cx_horizontal_line_5_3_scale_c
829 const unsigned char *source,
830 unsigned int source_width,
831 unsigned char *dest,
832 unsigned int dest_width
835 unsigned int i;
836 unsigned int a, b, c, d , e;
837 unsigned char *des = dest;
838 const unsigned char *src = source;
840 (void) dest_width;
842 for (i = 0; i < source_width; i += 5)
844 a = src[0];
845 b = src[1];
846 c = src[2];
847 d = src[3];
848 e = src[4];
850 des[0] = (unsigned char) a;
851 des[1] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
852 des[2] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
854 src += 5;
855 des += 3;
860 void vp8cx_vertical_band_5_3_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
862 unsigned int i;
863 unsigned int a, b, c, d, e;
864 unsigned char *des = dest;
865 unsigned char *src = source;
867 for (i = 0; i < dest_width; i++)
870 a = src[0 * src_pitch];
871 b = src[1 * src_pitch];
872 c = src[2 * src_pitch];
873 d = src[3 * src_pitch];
874 e = src[4 * src_pitch];
876 des[0 * dest_pitch] = (unsigned char) a;
877 des[1 * dest_pitch] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
878 des[2 * dest_pitch] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
880 src ++;
881 des ++;
886 /****************************************************************************
888 * ROUTINE : vp8cx_horizontal_line_1_2_scale_c
890 * INPUTS : const unsigned char *source : Pointer to source data.
891 * unsigned int source_width : Stride of source.
892 * unsigned char *dest : Pointer to destination data.
893 * unsigned int dest_width : Stride of destination (NOT USED).
895 * OUTPUTS : None.
897 * RETURNS : void
899 * FUNCTION : Copies horizontal line of pixels from source to
900 * destination scaling up by 1 to 2.
902 * SPECIAL NOTES : None.
904 ****************************************************************************/
905 void vp8cx_horizontal_line_2_1_scale_c
907 const unsigned char *source,
908 unsigned int source_width,
909 unsigned char *dest,
910 unsigned int dest_width
913 unsigned int i;
914 unsigned int a;
915 unsigned char *des = dest;
916 const unsigned char *src = source;
918 (void) dest_width;
920 for (i = 0; i < source_width; i += 2)
922 a = src[0];
923 des [0] = (unsigned char)(a);
924 src += 2;
925 des += 1;
931 void vp8cx_vertical_band_2_1_scale_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
933 (void) dest_pitch;
934 (void) src_pitch;
935 vpx_memcpy(dest, source, dest_width);
938 void vp8cx_vertical_band_2_1_scale_i_c(unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
940 int i;
941 int temp;
942 int width = dest_width;
944 (void) dest_pitch;
946 for (i = 0; i < width; i++)
948 temp = 8;
949 temp += source[i-(int)src_pitch] * 3;
950 temp += source[i] * 10;
951 temp += source[i+src_pitch] * 3;
952 temp >>= 4 ;
953 dest[i] = (unsigned char)(temp);