36 #define AVG(a,b) (((int)(a) + (int)(b)) >> 1)
37 #define AVG3(a,b,c) (((int)(a) + (int)(b) + (int)(c)) / 3)
38 #define AVG4(a,b,c,d) (((int)(a) + (int)(b) + (int)(c) + (int)(d)) >> 2)
39 #define WAVG4(a,b,c,d,x,y) ( ( ((int)(a) + (int)(b)) * (int)(x) + ((int)(c) + (int)(d)) * (int)(y) ) / ( 2 * ((int)(x) + (int(y))) ) )
46 unsigned width = bayer.cols;
47 unsigned height = bayer.rows;
48 unsigned rgb_line_step = color.step[0];
49 unsigned rgb_line_skip = rgb_line_step - width * 3;
50 int bayer_line_step = bayer.step[0];
51 int bayer_line_step2 = bayer_line_step * 2;
53 unsigned char* rgb_buffer = color.data;
54 unsigned char* bayer_pixel = bayer.data;
65 rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1];
66 rgb_buffer[1] = bayer_pixel[0];
67 rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
74 rgb_buffer[4] =
AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
75 rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
82 rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
83 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
91 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
97 for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
104 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
105 rgb_buffer[1] = bayer_pixel[0];
106 rgb_buffer[2] = bayer_pixel[bayer_line_step + 1];
112 rgb_buffer[3] = bayer_pixel[1];
113 rgb_buffer[4] =
AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
114 rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
121 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
122 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
123 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
129 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
130 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
140 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
141 rgb_buffer[1] = bayer_pixel[0];
142 rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
148 rgb_buffer[3] = bayer_pixel[1];
149 rgb_buffer[4] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
157 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
158 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
165 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
166 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
169 bayer_pixel += bayer_line_step + 2;
170 rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
172 for (yIdx = 2; yIdx < height - 2; yIdx += 2)
181 rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1];
182 rgb_buffer[1] = bayer_pixel[0];
183 rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
191 rgb_buffer[4] =
AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
192 rgb_buffer[5] =
AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
199 rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
200 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
201 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
208 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
209 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
214 for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
222 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
223 rgb_buffer[1] = bayer_pixel[0];
224 rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
232 dh = abs (bayer_pixel[0] - bayer_pixel[2]);
233 dv = abs (bayer_pixel[-bayer_line_step + 1] - bayer_pixel[bayer_line_step + 1]);
236 rgb_buffer[4] =
AVG (bayer_pixel[-bayer_line_step + 1], bayer_pixel[bayer_line_step + 1]);
238 rgb_buffer[4] =
AVG (bayer_pixel[0], bayer_pixel[2]);
240 rgb_buffer[4] =
AVG4 (bayer_pixel[-bayer_line_step + 1], bayer_pixel[bayer_line_step + 1], bayer_pixel[0], bayer_pixel[2]);
242 rgb_buffer[3] = bayer_pixel[1];
243 rgb_buffer[5] =
AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
251 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
252 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
254 dv = abs (bayer_pixel[0] - bayer_pixel[bayer_line_step2]);
255 dh = abs (bayer_pixel[bayer_line_step - 1] - bayer_pixel[bayer_line_step + 1]);
258 rgb_buffer[rgb_line_step + 1] =
AVG (bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
260 rgb_buffer[rgb_line_step + 1] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step2]);
262 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
269 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
270 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
271 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
281 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
282 rgb_buffer[1] = bayer_pixel[0];
283 rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
289 rgb_buffer[3] = bayer_pixel[1];
290 rgb_buffer[4] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
298 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
299 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
306 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
307 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
310 bayer_pixel += bayer_line_step + 2;
311 rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
320 rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1];
321 rgb_buffer[1] = bayer_pixel[0];
322 rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
329 rgb_buffer[4] =
AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
330 rgb_buffer[5] =
AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
338 rgb_buffer[rgb_line_step + 1] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
339 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
346 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
347 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
352 for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
359 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
360 rgb_buffer[1] = bayer_pixel[0];
361 rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
367 rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
368 rgb_buffer[4] =
AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
369 rgb_buffer[5] =
AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]);
376 rgb_buffer[rgb_line_step ] =
AVG (bayer_pixel[-1], bayer_pixel[1]);
377 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
378 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
386 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
387 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
396 rgb_buffer[rgb_line_step ] = rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
397 rgb_buffer[1] = bayer_pixel[0];
398 rgb_buffer[5] = rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
404 rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
405 rgb_buffer[4] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]);
414 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
415 rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
422 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
428 unsigned width = bayer.cols;
429 unsigned height = bayer.rows;
430 unsigned rgb_line_step = color.step[0];
431 unsigned rgb_line_skip = rgb_line_step - width * 3;
432 int bayer_line_step = bayer.step[0];
433 int bayer_line_step2 = bayer_line_step * 2;
435 unsigned char* rgb_buffer = color.data;
436 unsigned char* bayer_pixel = bayer.data;
447 rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1];
448 rgb_buffer[1] = bayer_pixel[0];
449 rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
456 rgb_buffer[4] =
AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
457 rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
464 rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
465 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
473 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
479 for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
486 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
487 rgb_buffer[1] = bayer_pixel[0];
488 rgb_buffer[2] = bayer_pixel[bayer_line_step + 1];
494 rgb_buffer[3] = bayer_pixel[1];
495 rgb_buffer[4] =
AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
496 rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
503 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
504 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
505 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
511 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
512 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
522 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
523 rgb_buffer[1] = bayer_pixel[0];
524 rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
530 rgb_buffer[3] = bayer_pixel[1];
531 rgb_buffer[4] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
539 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
540 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
547 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
548 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
551 bayer_pixel += bayer_line_step + 2;
552 rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
554 for (yIdx = 2; yIdx < height - 2; yIdx += 2)
563 rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1];
564 rgb_buffer[1] = bayer_pixel[0];
565 rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
573 rgb_buffer[4] =
AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
574 rgb_buffer[5] =
AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
581 rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
582 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
583 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
590 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
591 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
596 for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
604 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
605 rgb_buffer[1] = bayer_pixel[0];
606 rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
614 dh = abs (bayer_pixel[0] - bayer_pixel[2]);
615 dv = abs (bayer_pixel[-bayer_line_step + 1] - bayer_pixel[bayer_line_step + 1]);
617 if (dv == 0 && dh == 0)
618 rgb_buffer[4] =
AVG4 (bayer_pixel[1 - bayer_line_step], bayer_pixel[1 + bayer_line_step], bayer_pixel[0], bayer_pixel[2]);
620 rgb_buffer[4] =
WAVG4 (bayer_pixel[1 - bayer_line_step], bayer_pixel[1 + bayer_line_step], bayer_pixel[0], bayer_pixel[2], dh, dv);
621 rgb_buffer[3] = bayer_pixel[1];
622 rgb_buffer[5] =
AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
630 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
631 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
633 dv = abs (bayer_pixel[0] - bayer_pixel[bayer_line_step2]);
634 dh = abs (bayer_pixel[bayer_line_step - 1] - bayer_pixel[bayer_line_step + 1]);
636 if (dv == 0 && dh == 0)
637 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
639 rgb_buffer[rgb_line_step + 1] =
WAVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1], dh, dv);
646 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
647 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
648 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
658 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
659 rgb_buffer[1] = bayer_pixel[0];
660 rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
666 rgb_buffer[3] = bayer_pixel[1];
667 rgb_buffer[4] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
675 rgb_buffer[rgb_line_step ] =
AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
676 rgb_buffer[rgb_line_step + 1] =
AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
683 rgb_buffer[rgb_line_step + 3] =
AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
684 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
687 bayer_pixel += bayer_line_step + 2;
688 rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
697 rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1];
698 rgb_buffer[1] = bayer_pixel[0];
699 rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
706 rgb_buffer[4] =
AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
707 rgb_buffer[5] =
AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
715 rgb_buffer[rgb_line_step + 1] =
AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
716 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
723 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
724 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
729 for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
736 rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
737 rgb_buffer[1] = bayer_pixel[0];
738 rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
744 rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
745 rgb_buffer[4] =
AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
746 rgb_buffer[5] =
AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]);
753 rgb_buffer[rgb_line_step ] =
AVG (bayer_pixel[-1], bayer_pixel[1]);
754 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
755 rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
763 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
764 rgb_buffer[rgb_line_step + 5] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
773 rgb_buffer[rgb_line_step ] = rgb_buffer[0] =
AVG (bayer_pixel[1], bayer_pixel[-1]);
774 rgb_buffer[1] = bayer_pixel[0];
775 rgb_buffer[5] = rgb_buffer[2] =
AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
781 rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
782 rgb_buffer[4] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]);
791 rgb_buffer[rgb_line_step + 1] =
AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
792 rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
799 rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];