OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 | 11 |
12 #include "vpx_scale/vpxscale.h" | 12 #include "vpx_scale/vpxscale.h" |
13 #include "vpx_mem/vpx_mem.h" | 13 #include "vpx_mem/vpx_mem.h" |
14 /**************************************************************************** | 14 /**************************************************************************** |
15 * Imports | 15 * Imports |
16 ****************************************************************************/ | 16 ****************************************************************************/ |
17 | 17 |
18 /**************************************************************************** | 18 /**************************************************************************** |
19 * | 19 * |
20 * ROUTINE : vp8_horizontal_line_4_5_scale_c | |
21 * | 20 * |
22 * INPUTS : const unsigned char *source : Pointer to source data. | 21 * INPUTS : const unsigned char *source : Pointer to source data. |
23 * unsigned int source_width : Stride of source. | 22 * unsigned int source_width : Stride of source. |
24 * unsigned char *dest : Pointer to destination data. | 23 * unsigned char *dest : Pointer to destination data. |
25 * unsigned int dest_width : Stride of destination (NOT US
ED). | 24 * unsigned int dest_width : Stride of destination (NOT US
ED). |
26 * | 25 * |
27 * OUTPUTS : None. | 26 * OUTPUTS : None. |
28 * | 27 * |
29 * RETURNS : void | 28 * RETURNS : void |
30 * | 29 * |
31 * FUNCTION : Copies horizontal line of pixels from source to | 30 * FUNCTION : Copies horizontal line of pixels from source to |
32 * destination scaling up by 4 to 5. | 31 * destination scaling up by 4 to 5. |
33 * | 32 * |
34 * SPECIAL NOTES : None. | 33 * SPECIAL NOTES : None. |
35 * | 34 * |
36 ****************************************************************************/ | 35 ****************************************************************************/ |
37 void vp8_horizontal_line_4_5_scale_c(const unsigned char *source, | |
38 unsigned int source_width, | |
39 unsigned char *dest, | |
40 unsigned int dest_width) { | |
41 unsigned i; | |
42 unsigned int a, b, c; | |
43 unsigned char *des = dest; | |
44 const unsigned char *src = source; | |
45 | |
46 (void) dest_width; | |
47 | |
48 for (i = 0; i < source_width - 4; i += 4) { | |
49 a = src[0]; | |
50 b = src[1]; | |
51 des [0] = (unsigned char) a; | |
52 des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8); | |
53 c = src[2] * 154; | |
54 a = src[3]; | |
55 des [2] = (unsigned char)((b * 102 + c + 128) >> 8); | |
56 des [3] = (unsigned char)((c + 102 * a + 128) >> 8); | |
57 b = src[4]; | |
58 des [4] = (unsigned char)((a * 205 + 51 * b + 128) >> 8); | |
59 | |
60 src += 4; | |
61 des += 5; | |
62 } | |
63 | |
64 a = src[0]; | |
65 b = src[1]; | |
66 des [0] = (unsigned char)(a); | |
67 des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8); | |
68 c = src[2] * 154; | |
69 a = src[3]; | |
70 des [2] = (unsigned char)((b * 102 + c + 128) >> 8); | |
71 des [3] = (unsigned char)((c + 102 * a + 128) >> 8); | |
72 des [4] = (unsigned char)(a); | |
73 | |
74 } | |
75 | |
76 /**************************************************************************** | |
77 * | |
78 * ROUTINE : vp8_vertical_band_4_5_scale_c | |
79 * | |
80 * INPUTS : unsigned char *dest : Pointer to destination data. | |
81 * unsigned int dest_pitch : Stride of destination data. | |
82 * unsigned int dest_width : Width of destination data. | |
83 * | |
84 * OUTPUTS : None. | |
85 * | |
86 * RETURNS : void | |
87 * | |
88 * FUNCTION : Scales vertical band of pixels by scale 4 to 5. The | |
89 * height of the band scaled is 4-pixels. | |
90 * | |
91 * SPECIAL NOTES : The routine uses the first line of the band below | |
92 * the current band. | |
93 * | |
94 ****************************************************************************/ | |
95 void vp8_vertical_band_4_5_scale_c(unsigned char *dest, | |
96 unsigned int dest_pitch, | |
97 unsigned int dest_width) { | |
98 unsigned int i; | |
99 unsigned int a, b, c, d; | |
100 unsigned char *des = dest; | |
101 | |
102 for (i = 0; i < dest_width; i++) { | |
103 a = des [0]; | |
104 b = des [dest_pitch]; | |
105 | |
106 des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8); | |
107 | |
108 c = des[dest_pitch * 2] * 154; | |
109 d = des[dest_pitch * 3]; | |
110 | |
111 des [dest_pitch * 2] = (unsigned char)((b * 102 + c + 128) >> 8); | |
112 des [dest_pitch * 3] = (unsigned char)((c + 102 * d + 128) >> 8); | |
113 | |
114 /* First line in next band */ | |
115 a = des [dest_pitch * 5]; | |
116 des [dest_pitch * 4] = (unsigned char)((d * 205 + 51 * a + 128) >> 8); | |
117 | |
118 des++; | |
119 } | |
120 } | |
121 | |
122 /**************************************************************************** | |
123 * | |
124 * ROUTINE : vp8_last_vertical_band_4_5_scale_c | |
125 * | |
126 * INPUTS : unsigned char *dest : Pointer to destination data. | |
127 * unsigned int dest_pitch : Stride of destination data. | |
128 * unsigned int dest_width : Width of destination data. | |
129 * | |
130 * OUTPUTS : None. | |
131 * | |
132 * RETURNS : void | |
133 * | |
134 * FUNCTION : Scales last vertical band of pixels by scale 4 to 5. The | |
135 * height of the band scaled is 4-pixels. | |
136 * | |
137 * SPECIAL NOTES : The routine does not have available the first line of | |
138 * the band below the current band, since this is the | |
139 * last band. | |
140 * | |
141 ****************************************************************************/ | |
142 void vp8_last_vertical_band_4_5_scale_c(unsigned char *dest, | |
143 unsigned int dest_pitch, | |
144 unsigned int dest_width) { | |
145 unsigned int i; | |
146 unsigned int a, b, c, d; | |
147 unsigned char *des = dest; | |
148 | |
149 for (i = 0; i < dest_width; ++i) { | |
150 a = des[0]; | |
151 b = des[dest_pitch]; | |
152 | |
153 des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8); | |
154 | |
155 c = des[dest_pitch * 2] * 154; | |
156 d = des[dest_pitch * 3]; | |
157 | |
158 des [dest_pitch * 2] = (unsigned char)((b * 102 + c + 128) >> 8); | |
159 des [dest_pitch * 3] = (unsigned char)((c + 102 * d + 128) >> 8); | |
160 | |
161 /* No other line for interplation of this line, so .. */ | |
162 des[dest_pitch * 4] = (unsigned char) d; | |
163 | |
164 des++; | |
165 } | |
166 } | |
167 | |
168 /**************************************************************************** | |
169 * | |
170 * ROUTINE : vp8_horizontal_line_2_3_scale_c | |
171 * | |
172 * INPUTS : const unsigned char *source : Pointer to source data. | |
173 * unsigned int source_width : Stride of source. | |
174 * unsigned char *dest : Pointer to destination data. | |
175 * unsigned int dest_width : Stride of destination (NOT US
ED). | |
176 * | |
177 * OUTPUTS : None. | |
178 * | |
179 * RETURNS : void | |
180 * | |
181 * FUNCTION : Copies horizontal line of pixels from source to | |
182 * destination scaling up by 2 to 3. | |
183 * | |
184 * SPECIAL NOTES : None. | |
185 * | |
186 * | |
187 ****************************************************************************/ | |
188 void vp8_horizontal_line_2_3_scale_c(const unsigned char *source, | |
189 unsigned int source_width, | |
190 unsigned char *dest, | |
191 unsigned int dest_width) { | |
192 unsigned int i; | |
193 unsigned int a, b, c; | |
194 unsigned char *des = dest; | |
195 const unsigned char *src = source; | |
196 | |
197 (void) dest_width; | |
198 | |
199 for (i = 0; i < source_width - 2; i += 2) { | |
200 a = src[0]; | |
201 b = src[1]; | |
202 c = src[2]; | |
203 | |
204 des [0] = (unsigned char)(a); | |
205 des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8); | |
206 des [2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8); | |
207 | |
208 src += 2; | |
209 des += 3; | |
210 } | |
211 | |
212 a = src[0]; | |
213 b = src[1]; | |
214 des [0] = (unsigned char)(a); | |
215 des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8); | |
216 des [2] = (unsigned char)(b); | |
217 } | |
218 | |
219 | |
220 /**************************************************************************** | |
221 * | |
222 * ROUTINE : vp8_vertical_band_2_3_scale_c | |
223 * | |
224 * INPUTS : unsigned char *dest : Pointer to destination data. | |
225 * unsigned int dest_pitch : Stride of destination data. | |
226 * unsigned int dest_width : Width of destination data. | |
227 * | |
228 * OUTPUTS : None. | |
229 * | |
230 * RETURNS : void | |
231 * | |
232 * FUNCTION : Scales vertical band of pixels by scale 2 to 3. The | |
233 * height of the band scaled is 2-pixels. | |
234 * | |
235 * SPECIAL NOTES : The routine uses the first line of the band below | |
236 * the current band. | |
237 * | |
238 ****************************************************************************/ | |
239 void vp8_vertical_band_2_3_scale_c(unsigned char *dest, | |
240 unsigned int dest_pitch, | |
241 unsigned int dest_width) { | |
242 unsigned int i; | |
243 unsigned int a, b, c; | |
244 unsigned char *des = dest; | |
245 | |
246 for (i = 0; i < dest_width; i++) { | |
247 a = des [0]; | |
248 b = des [dest_pitch]; | |
249 c = des[dest_pitch * 3]; | |
250 des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8); | |
251 des [dest_pitch * 2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8); | |
252 | |
253 des++; | |
254 } | |
255 } | |
256 | |
257 /**************************************************************************** | |
258 * | |
259 * ROUTINE : vp8_last_vertical_band_2_3_scale_c | |
260 * | |
261 * INPUTS : unsigned char *dest : Pointer to destination data. | |
262 * unsigned int dest_pitch : Stride of destination data. | |
263 * unsigned int dest_width : Width of destination data. | |
264 * | |
265 * OUTPUTS : None. | |
266 * | |
267 * RETURNS : void | |
268 * | |
269 * FUNCTION : Scales last vertical band of pixels by scale 2 to 3. The | |
270 * height of the band scaled is 2-pixels. | |
271 * | |
272 * SPECIAL NOTES : The routine does not have available the first line of | |
273 * the band below the current band, since this is the | |
274 * last band. | |
275 * | |
276 ****************************************************************************/ | |
277 void vp8_last_vertical_band_2_3_scale_c(unsigned char *dest, | |
278 unsigned int dest_pitch, | |
279 unsigned int dest_width) { | |
280 unsigned int i; | |
281 unsigned int a, b; | |
282 unsigned char *des = dest; | |
283 | |
284 for (i = 0; i < dest_width; ++i) { | |
285 a = des [0]; | |
286 b = des [dest_pitch]; | |
287 | |
288 des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8); | |
289 des [dest_pitch * 2] = (unsigned char)(b); | |
290 des++; | |
291 } | |
292 } | |
293 | |
294 /**************************************************************************** | |
295 * | |
296 * ROUTINE : vp8_horizontal_line_3_5_scale_c | |
297 * | |
298 * INPUTS : const unsigned char *source : Pointer to source data. | |
299 * unsigned int source_width : Stride of source. | |
300 * unsigned char *dest : Pointer to destination data. | |
301 * unsigned int dest_width : Stride of destination (NOT US
ED). | |
302 * | |
303 * OUTPUTS : None. | |
304 * | |
305 * RETURNS : void | |
306 * | |
307 * FUNCTION : Copies horizontal line of pixels from source to | |
308 * destination scaling up by 3 to 5. | |
309 * | |
310 * SPECIAL NOTES : None. | |
311 * | |
312 * | |
313 ****************************************************************************/ | |
314 void vp8_horizontal_line_3_5_scale_c(const unsigned char *source, | |
315 unsigned int source_width, | |
316 unsigned char *dest, | |
317 unsigned int dest_width) { | |
318 unsigned int i; | |
319 unsigned int a, b, c; | |
320 unsigned char *des = dest; | |
321 const unsigned char *src = source; | |
322 | |
323 (void) dest_width; | |
324 | |
325 for (i = 0; i < source_width - 3; i += 3) { | |
326 a = src[0]; | |
327 b = src[1]; | |
328 des [0] = (unsigned char)(a); | |
329 des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8); | |
330 | |
331 c = src[2]; | |
332 des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8); | |
333 des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8); | |
334 | |
335 a = src[3]; | |
336 des [4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8); | |
337 | |
338 src += 3; | |
339 des += 5; | |
340 } | |
341 | |
342 a = src[0]; | |
343 b = src[1]; | |
344 des [0] = (unsigned char)(a); | |
345 | |
346 des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8); | |
347 c = src[2]; | |
348 des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8); | |
349 des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8); | |
350 | |
351 des [4] = (unsigned char)(c); | |
352 } | |
353 | |
354 /**************************************************************************** | |
355 * | |
356 * ROUTINE : vp8_vertical_band_3_5_scale_c | |
357 * | |
358 * INPUTS : unsigned char *dest : Pointer to destination data. | |
359 * unsigned int dest_pitch : Stride of destination data. | |
360 * unsigned int dest_width : Width of destination data. | |
361 * | |
362 * OUTPUTS : None. | |
363 * | |
364 * RETURNS : void | |
365 * | |
366 * FUNCTION : Scales vertical band of pixels by scale 3 to 5. The | |
367 * height of the band scaled is 3-pixels. | |
368 * | |
369 * SPECIAL NOTES : The routine uses the first line of the band below | |
370 * the current band. | |
371 * | |
372 ****************************************************************************/ | |
373 void vp8_vertical_band_3_5_scale_c(unsigned char *dest, | |
374 unsigned int dest_pitch, | |
375 unsigned int dest_width) { | |
376 unsigned int i; | |
377 unsigned int a, b, c; | |
378 unsigned char *des = dest; | |
379 | |
380 for (i = 0; i < dest_width; i++) { | |
381 a = des [0]; | |
382 b = des [dest_pitch]; | |
383 des [dest_pitch] = (unsigned char)((a * 102 + 154 * b + 128) >> 8); | |
384 | |
385 c = des[dest_pitch * 2]; | |
386 des [dest_pitch * 2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8); | |
387 des [dest_pitch * 3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8); | |
388 | |
389 /* First line in next band... */ | |
390 a = des [dest_pitch * 5]; | |
391 des [dest_pitch * 4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8); | |
392 | |
393 des++; | |
394 } | |
395 } | |
396 | |
397 /**************************************************************************** | |
398 * | |
399 * ROUTINE : vp8_last_vertical_band_3_5_scale_c | |
400 * | |
401 * INPUTS : unsigned char *dest : Pointer to destination data. | |
402 * unsigned int dest_pitch : Stride of destination data. | |
403 * unsigned int dest_width : Width of destination data. | |
404 * | |
405 * OUTPUTS : None. | |
406 * | |
407 * RETURNS : void | |
408 * | |
409 * FUNCTION : Scales last vertical band of pixels by scale 3 to 5. The | |
410 * height of the band scaled is 3-pixels. | |
411 * | |
412 * SPECIAL NOTES : The routine does not have available the first line of | |
413 * the band below the current band, since this is the | |
414 * last band. | |
415 * | |
416 ****************************************************************************/ | |
417 void vp8_last_vertical_band_3_5_scale_c(unsigned char *dest, | |
418 unsigned int dest_pitch, | |
419 unsigned int dest_width) { | |
420 unsigned int i; | |
421 unsigned int a, b, c; | |
422 unsigned char *des = dest; | |
423 | |
424 for (i = 0; i < dest_width; ++i) { | |
425 a = des [0]; | |
426 b = des [dest_pitch]; | |
427 | |
428 des [ dest_pitch ] = (unsigned char)((a * 102 + 154 * b + 128) >> 8); | |
429 | |
430 c = des[dest_pitch * 2]; | |
431 des [dest_pitch * 2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8); | |
432 des [dest_pitch * 3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8); | |
433 | |
434 /* No other line for interplation of this line, so .. */ | |
435 des [ dest_pitch * 4 ] = (unsigned char)(c); | |
436 | |
437 des++; | |
438 } | |
439 } | |
440 | |
441 /**************************************************************************** | |
442 * | |
443 * ROUTINE : vp8_horizontal_line_3_4_scale_c | |
444 * | |
445 * INPUTS : const unsigned char *source : Pointer to source data. | |
446 * unsigned int source_width : Stride of source. | |
447 * unsigned char *dest : Pointer to destination data. | |
448 * unsigned int dest_width : Stride of destination (NOT US
ED). | |
449 * | |
450 * OUTPUTS : None. | |
451 * | |
452 * RETURNS : void | |
453 * | |
454 * FUNCTION : Copies horizontal line of pixels from source to | |
455 * destination scaling up by 3 to 4. | |
456 * | |
457 * SPECIAL NOTES : None. | |
458 * | |
459 * | |
460 ****************************************************************************/ | |
461 void vp8_horizontal_line_3_4_scale_c(const unsigned char *source, | |
462 unsigned int source_width, | |
463 unsigned char *dest, | |
464 unsigned int dest_width) { | |
465 unsigned int i; | |
466 unsigned int a, b, c; | |
467 unsigned char *des = dest; | |
468 const unsigned char *src = source; | |
469 | |
470 (void) dest_width; | |
471 | |
472 for (i = 0; i < source_width - 3; i += 3) { | |
473 a = src[0]; | |
474 b = src[1]; | |
475 des [0] = (unsigned char)(a); | |
476 des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8); | |
477 | |
478 c = src[2]; | |
479 des [2] = (unsigned char)((b + c + 1) >> 1); | |
480 | |
481 a = src[3]; | |
482 des [3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8); | |
483 | |
484 src += 3; | |
485 des += 4; | |
486 } | |
487 | |
488 a = src[0]; | |
489 b = src[1]; | |
490 des [0] = (unsigned char)(a); | |
491 des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8); | |
492 | |
493 c = src[2]; | |
494 des [2] = (unsigned char)((b + c + 1) >> 1); | |
495 des [3] = (unsigned char)(c); | |
496 } | |
497 | |
498 /**************************************************************************** | |
499 * | |
500 * ROUTINE : vp8_vertical_band_3_4_scale_c | |
501 * | |
502 * INPUTS : unsigned char *dest : Pointer to destination data. | |
503 * unsigned int dest_pitch : Stride of destination data. | |
504 * unsigned int dest_width : Width of destination data. | |
505 * | |
506 * OUTPUTS : None. | |
507 * | |
508 * RETURNS : void | |
509 * | |
510 * FUNCTION : Scales vertical band of pixels by scale 3 to 4. The | |
511 * height of the band scaled is 3-pixels. | |
512 * | |
513 * SPECIAL NOTES : The routine uses the first line of the band below | |
514 * the current band. | |
515 * | |
516 ****************************************************************************/ | |
517 void vp8_vertical_band_3_4_scale_c(unsigned char *dest, | |
518 unsigned int dest_pitch, | |
519 unsigned int dest_width) { | |
520 unsigned int i; | |
521 unsigned int a, b, c; | |
522 unsigned char *des = dest; | |
523 | |
524 for (i = 0; i < dest_width; i++) { | |
525 a = des [0]; | |
526 b = des [dest_pitch]; | |
527 des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8); | |
528 | |
529 c = des[dest_pitch * 2]; | |
530 des [dest_pitch * 2] = (unsigned char)((b + c + 1) >> 1); | |
531 | |
532 /* First line in next band... */ | |
533 a = des [dest_pitch * 4]; | |
534 des [dest_pitch * 3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8); | |
535 | |
536 des++; | |
537 } | |
538 } | |
539 | |
540 /**************************************************************************** | |
541 * | |
542 * ROUTINE : vp8_last_vertical_band_3_4_scale_c | |
543 * | |
544 * INPUTS : unsigned char *dest : Pointer to destination data. | |
545 * unsigned int dest_pitch : Stride of destination data. | |
546 * unsigned int dest_width : Width of destination data. | |
547 * | |
548 * OUTPUTS : None. | |
549 * | |
550 * RETURNS : void | |
551 * | |
552 * FUNCTION : Scales last vertical band of pixels by scale 3 to 4. The | |
553 * height of the band scaled is 3-pixels. | |
554 * | |
555 * SPECIAL NOTES : The routine does not have available the first line of | |
556 * the band below the current band, since this is the | |
557 * last band. | |
558 * | |
559 ****************************************************************************/ | |
560 void vp8_last_vertical_band_3_4_scale_c(unsigned char *dest, | |
561 unsigned int dest_pitch, | |
562 unsigned int dest_width) { | |
563 unsigned int i; | |
564 unsigned int a, b, c; | |
565 unsigned char *des = dest; | |
566 | |
567 for (i = 0; i < dest_width; ++i) { | |
568 a = des [0]; | |
569 b = des [dest_pitch]; | |
570 | |
571 des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8); | |
572 | |
573 c = des[dest_pitch * 2]; | |
574 des [dest_pitch * 2] = (unsigned char)((b + c + 1) >> 1); | |
575 | |
576 /* No other line for interplation of this line, so .. */ | |
577 des [dest_pitch * 3] = (unsigned char)(c); | |
578 | |
579 des++; | |
580 } | |
581 } | |
582 | |
583 /**************************************************************************** | |
584 * | |
585 * ROUTINE : vp8_horizontal_line_1_2_scale_c | |
586 * | |
587 * INPUTS : const unsigned char *source : Pointer to source data. | |
588 * unsigned int source_width : Stride of source. | |
589 * unsigned char *dest : Pointer to destination data. | |
590 * unsigned int dest_width : Stride of destination (NOT US
ED). | |
591 * | |
592 * OUTPUTS : None. | |
593 * | |
594 * RETURNS : void | |
595 * | |
596 * FUNCTION : Copies horizontal line of pixels from source to | |
597 * destination scaling up by 1 to 2. | |
598 * | |
599 * SPECIAL NOTES : None. | |
600 * | |
601 ****************************************************************************/ | |
602 void vp8_horizontal_line_1_2_scale_c(const unsigned char *source, | |
603 unsigned int source_width, | |
604 unsigned char *dest, | |
605 unsigned int dest_width) { | |
606 unsigned int i; | |
607 unsigned int a, b; | |
608 unsigned char *des = dest; | |
609 const unsigned char *src = source; | |
610 | |
611 (void) dest_width; | |
612 | |
613 for (i = 0; i < source_width - 1; i += 1) { | |
614 a = src[0]; | |
615 b = src[1]; | |
616 des [0] = (unsigned char)(a); | |
617 des [1] = (unsigned char)((a + b + 1) >> 1); | |
618 src += 1; | |
619 des += 2; | |
620 } | |
621 | |
622 a = src[0]; | |
623 des [0] = (unsigned char)(a); | |
624 des [1] = (unsigned char)(a); | |
625 } | |
626 | |
627 /**************************************************************************** | |
628 * | |
629 * ROUTINE : vp8_vertical_band_1_2_scale_c | |
630 * | |
631 * INPUTS : unsigned char *dest : Pointer to destination data. | |
632 * unsigned int dest_pitch : Stride of destination data. | |
633 * unsigned int dest_width : Width of destination data. | |
634 * | |
635 * OUTPUTS : None. | |
636 * | |
637 * RETURNS : void | |
638 * | |
639 * FUNCTION : Scales vertical band of pixels by scale 1 to 2. The | |
640 * height of the band scaled is 1-pixel. | |
641 * | |
642 * SPECIAL NOTES : The routine uses the first line of the band below | |
643 * the current band. | |
644 * | |
645 ****************************************************************************/ | |
646 void vp8_vertical_band_1_2_scale_c(unsigned char *dest, | |
647 unsigned int dest_pitch, | |
648 unsigned int dest_width) { | |
649 unsigned int i; | |
650 unsigned int a, b; | |
651 unsigned char *des = dest; | |
652 | |
653 for (i = 0; i < dest_width; i++) { | |
654 a = des [0]; | |
655 b = des [dest_pitch * 2]; | |
656 | |
657 des[dest_pitch] = (unsigned char)((a + b + 1) >> 1); | |
658 | |
659 des++; | |
660 } | |
661 } | |
662 | |
663 /**************************************************************************** | |
664 * | |
665 * ROUTINE : vp8_last_vertical_band_1_2_scale_c | |
666 * | |
667 * INPUTS : unsigned char *dest : Pointer to destination data. | |
668 * unsigned int dest_pitch : Stride of destination data. | |
669 * unsigned int dest_width : Width of destination data. | |
670 * | |
671 * OUTPUTS : None. | |
672 * | |
673 * RETURNS : void | |
674 * | |
675 * FUNCTION : Scales last vertical band of pixels by scale 1 to 2. The | |
676 * height of the band scaled is 1-pixel. | |
677 * | |
678 * SPECIAL NOTES : The routine does not have available the first line of | |
679 * the band below the current band, since this is the | |
680 * last band. | |
681 * | |
682 ****************************************************************************/ | |
683 void vp8_last_vertical_band_1_2_scale_c(unsigned char *dest, | |
684 unsigned int dest_pitch, | |
685 unsigned int dest_width) { | |
686 unsigned int i; | |
687 unsigned char *des = dest; | |
688 | |
689 for (i = 0; i < dest_width; ++i) { | |
690 des[dest_pitch] = des[0]; | |
691 des++; | |
692 } | |
693 } | |
694 | |
695 | |
696 | |
697 | |
698 | |
699 /**************************************************************************** | |
700 * | |
701 * ROUTINE : vp8_horizontal_line_4_5_scale_c | |
702 * | |
703 * INPUTS : const unsigned char *source : Pointer to source data. | |
704 * unsigned int source_width : Stride of source. | |
705 * unsigned char *dest : Pointer to destination data. | |
706 * unsigned int dest_width : Stride of destination (NOT US
ED). | |
707 * | |
708 * OUTPUTS : None. | |
709 * | |
710 * RETURNS : void | |
711 * | |
712 * FUNCTION : Copies horizontal line of pixels from source to | |
713 * destination scaling up by 4 to 5. | |
714 * | |
715 * SPECIAL NOTES : None. | |
716 * | |
717 ****************************************************************************/ | |
718 void vp8_horizontal_line_5_4_scale_c(const unsigned char *source, | 36 void vp8_horizontal_line_5_4_scale_c(const unsigned char *source, |
719 unsigned int source_width, | 37 unsigned int source_width, |
720 unsigned char *dest, | 38 unsigned char *dest, |
721 unsigned int dest_width) { | 39 unsigned int dest_width) { |
722 unsigned i; | 40 unsigned i; |
723 unsigned int a, b, c, d, e; | 41 unsigned int a, b, c, d, e; |
724 unsigned char *des = dest; | 42 unsigned char *des = dest; |
725 const unsigned char *src = source; | 43 const unsigned char *src = source; |
726 | 44 |
727 (void) dest_width; | 45 (void) dest_width; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 | 231 |
914 for (i = 0; i < width; i++) { | 232 for (i = 0; i < width; i++) { |
915 temp = 8; | 233 temp = 8; |
916 temp += source[i - (int)src_pitch] * 3; | 234 temp += source[i - (int)src_pitch] * 3; |
917 temp += source[i] * 10; | 235 temp += source[i] * 10; |
918 temp += source[i + src_pitch] * 3; | 236 temp += source[i + src_pitch] * 3; |
919 temp >>= 4; | 237 temp >>= 4; |
920 dest[i] = (unsigned char)(temp); | 238 dest[i] = (unsigned char)(temp); |
921 } | 239 } |
922 } | 240 } |
OLD | NEW |