Support for hardware resolultion change
[microdia.git] / microdia-decoder.c
blob1474d3f5069235bb86c4df915d4cbd11c986c1e2
1 /**
2 * @file microdia-decoder.c
3 * @author Nicolas VIVIEN
4 * @date 2008-02-01
5 * @version v0.0.0
7 * @brief Driver for Microdia USB video camera
9 * @note Copyright (C) Nicolas VIVIEN
11 * @par Licences
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/kernel.h>
31 #include <linux/version.h>
32 #include <linux/errno.h>
33 #include <linux/slab.h>
34 #include <linux/kref.h>
36 #include <linux/usb.h>
37 #include <media/v4l2-common.h>
39 #include "microdia.h"
40 #include "sn9c20x.h"
42 #define MAX(a, b) ((a) > (b) ? (a) : (b))
43 #define MIN(a, b) ((a) < (b) ? (a) : (b))
44 #define CLIP(a, low, high) MAX((low), MIN((high), (a)))
46 void raw6270_2i420(uint8_t *, uint8_t *, int,
47 int, const int, const int);
49 void raw6270_2RGB24(uint8_t *raw, uint8_t *rgb, int width,
50 int height, const int hflip,
51 const int vflip);
53 void raw6270_2BGR24(uint8_t *raw, uint8_t *rgb, int width,
54 int height, const int hflip,
55 const int vflip);
57 void microdia_getraw(uint8_t *, uint8_t *, int);
59 void microdia_raw2i420(uint8_t *, uint8_t *, int,
60 int, const int, const int);
62 void microdia_raw2bgr24(uint8_t *, uint8_t *, int,
63 int, const int, const int);
64 /**
65 * @brief Decompress a frame
67 * This function permits to decompress a frame from the video stream.
69 * @param dev Device structure
70 * @param buffer Image data
72 * @returns 0 if all is OK
74 int microdia_decompress(struct usb_microdia *dev, struct v4l2_buffer *buffer)
76 int factor;
77 int vflip;
78 int hflip;
79 int width, height;
80 int ret = 0;
82 void *data;
83 void *image;
85 if (dev == NULL) {
86 ret = -EFAULT;
87 goto done;
90 if (dev->flip_detect)
91 dev->flip_detect(dev);
93 if (dev->set_hvflip) {
94 hflip = 0;
95 vflip = 0;
96 } else {
97 hflip = dev->vsettings.hflip;
98 vflip = dev->vsettings.vflip;
101 image = dev->queue.scratch;
103 data = dev->queue.mem + buffer->m.offset;
104 memcpy(image, data, MICRODIA_FRAME_SIZE);
106 factor = 1;
108 width = dev->vsettings.format.width;
109 height = dev->vsettings.format.height;
111 switch (dev->vsettings.format.pixelformat) {
112 case V4L2_PIX_FMT_RGB24:
113 if (dev->webcam_model ==
114 CAMERA_MODEL(USB_0C45_VID, USB_6270_PID) ||
115 dev->webcam_model ==
116 CAMERA_MODEL(USB_0C45_VID, USB_627B_PID) ||
117 dev->webcam_model ==
118 CAMERA_MODEL(USB_0C45_VID, USB_6288_PID) ||
119 dev->webcam_model ==
120 CAMERA_MODEL(USB_0C45_VID, USB_62B3_PID) ||
121 dev->webcam_model ==
122 CAMERA_MODEL(USB_0C45_VID, USB_62BB_PID) ||
123 dev->webcam_model ==
124 CAMERA_MODEL(USB_145F_VID, USB_013D_PID)) {
125 raw6270_2RGB24(image, data, width,
126 height, hflip, vflip);
128 break;
129 case V4L2_PIX_FMT_BGR24:
130 if (dev->webcam_model ==
131 CAMERA_MODEL(USB_0C45_VID, USB_6270_PID) ||
132 dev->webcam_model ==
133 CAMERA_MODEL(USB_0C45_VID, USB_627B_PID) ||
134 dev->webcam_model ==
135 CAMERA_MODEL(USB_0C45_VID, USB_6288_PID) ||
136 dev->webcam_model ==
137 CAMERA_MODEL(USB_0C45_VID, USB_62B3_PID) ||
138 dev->webcam_model ==
139 CAMERA_MODEL(USB_0C45_VID, USB_62BB_PID) ||
140 dev->webcam_model ==
141 CAMERA_MODEL(USB_145F_VID, USB_013D_PID)) {
142 raw6270_2BGR24(image, data, width,
143 height, hflip, vflip);
144 } else {
145 microdia_raw2bgr24(image, data, width,
146 height, hflip, vflip);
148 break;
149 case V4L2_PIX_FMT_YUV420:
150 if (dev->webcam_model ==
151 CAMERA_MODEL(USB_0C45_VID, USB_6270_PID) ||
152 dev->webcam_model ==
153 CAMERA_MODEL(USB_0C45_VID, USB_627B_PID) ||
154 dev->webcam_model ==
155 CAMERA_MODEL(USB_0C45_VID, USB_6288_PID) ||
156 dev->webcam_model ==
157 CAMERA_MODEL(USB_0C45_VID, USB_62B3_PID) ||
158 dev->webcam_model ==
159 CAMERA_MODEL(USB_0C45_VID, USB_62BB_PID) ||
160 dev->webcam_model ==
161 CAMERA_MODEL(USB_145F_VID, USB_013D_PID)) {
162 raw6270_2i420(image, data, width,
163 height, hflip, vflip);
164 } else {
165 microdia_raw2i420(image, data, width,
166 height, hflip, vflip);
168 break;
169 case V4L2_PIX_FMT_YUYV:
170 default:
171 break;
174 buffer->bytesused = dev->vsettings.format.sizeimage;
175 done:
176 return ret;
180 * @brief This function permits to get the raw data. (without treatments)
182 * @param bayer Buffer with the bayer data
183 * @param size Length of bayer buffer
185 * @retval raw Buffer with the data from video sensor
187 void microdia_getraw(uint8_t *bayer, uint8_t *raw,
188 int size) {
189 memcpy(raw, bayer, size);
192 /* Table to translate Y offset to UV offset */
193 static int UVTranslate[32] = {
194 0, 1, 2, 3,
195 8, 9, 10, 11,
196 16, 17, 18, 19,
197 24, 25, 26, 27,
198 4, 5, 6, 7,
199 12, 13, 14, 15,
200 20, 21, 22, 23,
201 28, 29, 30, 31
204 static int Y_coords_624x[128][2] = {
205 { 0, 0}, { 1, 0}, { 2, 0}, { 3, 0}, { 4, 0}, { 5, 0}, { 6, 0}, { 7, 0},
206 { 0, 1}, { 1, 1}, { 2, 1}, { 3, 1}, { 4, 1}, { 5, 1}, { 6, 1}, { 7, 1},
207 { 0, 2}, { 1, 2}, { 2, 2}, { 3, 2}, { 4, 2}, { 5, 2}, { 6, 2}, { 7, 2},
208 { 0, 3}, { 1, 3}, { 2, 3}, { 3, 3}, { 4, 3}, { 5, 3}, { 6, 3}, { 7, 3},
210 { 0, 4}, { 1, 4}, { 2, 4}, { 3, 4}, { 4, 4}, { 5, 4}, { 6, 4}, { 7, 4},
211 { 0, 5}, { 1, 5}, { 2, 5}, { 3, 5}, { 4, 5}, { 5, 5}, { 6, 5}, { 7, 5},
212 { 0, 6}, { 1, 6}, { 2, 6}, { 3, 6}, { 4, 6}, { 5, 6}, { 6, 6}, { 7, 6},
213 { 0, 7}, { 1, 7}, { 2, 7}, { 3, 7}, { 4, 7}, { 5, 7}, { 6, 7}, { 7, 7},
215 { 8, 0}, { 9, 0}, {10, 0}, {11, 0}, {12, 0}, {13, 0}, {14, 0}, {15, 0},
216 { 8, 1}, { 9, 1}, {10, 1}, {11, 1}, {12, 1}, {13, 1}, {14, 1}, {15, 1},
217 { 8, 2}, { 9, 2}, {10, 2}, {11, 2}, {12, 2}, {13, 2}, {14, 2}, {15, 2},
218 { 8, 3}, { 9, 3}, {10, 3}, {11, 3}, {12, 3}, {13, 3}, {14, 3}, {15, 3},
220 { 8, 4}, { 9, 4}, {10, 4}, {11, 4}, {12, 4}, {13, 4}, {14, 4}, {15, 4},
221 { 8, 5}, { 9, 5}, {10, 5}, {11, 5}, {12, 5}, {13, 5}, {14, 5}, {15, 5},
222 { 8, 6}, { 9, 6}, {10, 6}, {11, 6}, {12, 6}, {13, 6}, {14, 6}, {15, 6},
223 { 8, 7}, { 9, 7}, {10, 7}, {11, 7}, {12, 7}, {13, 7}, {14, 7}, {15, 7}
226 void microdia_raw2bgr24(uint8_t *raw, uint8_t *rgb,
227 int width, int height, const int hflip,
228 const int vflip)
230 int i = 0, x = 0, y = 0;
231 unsigned char *buf = raw;
232 unsigned char *buf3 = rgb;
234 while (i < (width * height + (width * height) / 2)) {
235 int tile = 0;
236 for (tile = 0; tile < 4; tile++) {
237 int subX = 0;
238 int subY = 0;
239 for (subY = 0; subY < 4; subY++) {
240 for (subX = 0; subX < 8; subX++) {
241 int subI = i + tile * 32 + 8 * subY + subX;
242 int subU = i + 128 + UVTranslate[tile * 8 + 4 * (subY >> 1) + (subX >> 1)];
243 int subV = subU + 32;
245 int relX = x + (((tile == 0) || (tile == 1)) ? 0 : 8) + subX; /* tile 0, 1 to into left column*/
246 int relY = y + (((tile == 0) || (tile == 2)) ? 0 : 4) + subY; /* tile 0, 2 go into top row */
248 if (hflip)
249 relX = width - relX;
250 if (vflip)
251 relY = height - relY;
253 if ((relX < width) && (relY < height)) {
254 unsigned char *ptr;
255 int c, d, e;
256 c = buf[subI] - 16;
257 d = buf[subU] - 128;
258 e = buf[subV] - 128;
260 ptr = buf3 + relY * width * 3 + relX * 3;
261 *ptr = CLIP((298 * c + 516 * d + 128) >> 8, 0, 255);
262 ptr++;
263 *ptr = CLIP((298 * c - 100 * d - 208 * e + 128) >> 8, 0, 255);
264 ptr++;
265 *ptr = CLIP((298 * c + 409 * e + 128) >> 8, 0, 255);
271 i += 192;
272 x += 16;
273 if (x >= width) {
274 x = 0;
275 y += 8;
280 void microdia_raw2i420(uint8_t *raw, uint8_t *i420,
281 int width, int height, const int hflip,
282 const int vflip)
284 int i = 0, x = 0, y = 0, j, relX, relY, x_div2, y_div2;
285 unsigned char *buf = raw, *ptr;
286 unsigned char *buf3 = i420;
287 int view_size = width * height;
288 int view_size_div4 = view_size >> 2;
289 int image_x_div2 = width >> 1;
290 int image_y_div2 = height >> 1;
291 int view_x_div2 = width >> 1;
293 while (i < (width * height + (width * height) / 2)) {
294 for (j = 0; j < 128; j++) {
295 relX = x + Y_coords_624x[j][0];
296 relY = y + Y_coords_624x[j][1];
297 if (hflip)
298 relX = width - relX - 1;
299 if (vflip)
300 relY = height - relY - 1;
302 if ((relX < width) && (relY < height)) {
303 ptr = buf3 + relY * width + relX;
304 *ptr = buf[i + j];
308 x_div2 = x >> 1;
309 y_div2 = y >> 1;
310 for (j = 0; j < 32; j++) {
311 relX = (x_div2) + (j & 0x07);
312 relY = (y_div2) + (j >> 3);
313 if (hflip)
314 relX = image_x_div2 - relX - 1;
315 if (vflip)
316 relY = image_y_div2 - relY - 1;
318 if ((relX < width) && (relY < height)) {
319 ptr = buf3 + view_size +
320 relY * (view_x_div2) + relX;
321 *ptr = buf[i + 128 + j];
322 ptr += view_size_div4;
323 *ptr = buf[i + 160 + j];
328 i += 192;
329 x += 16;
330 if (x >= width) {
331 x = 0;
332 y += 8;
339 * @brief This function permits to convert an image from 6270 raw format to i420
340 * @param raw Buffer with the bayer data
341 * @param image Size of image
342 * @param view Size of view
343 * @param hflip Horizontal flip - not implemented
344 * @param vflip Vertical flip - not implemented
346 * @retval i420 Buffer with the i420 data
347 * Format of stream is uvyy,uvyy - repeated 320 times for 640x480
348 y - repeated 640 times for 640x480
349 First 1280 bytes is maybe dummy ***FIXME***
352 void raw6270_2i420(uint8_t *raw, uint8_t *i420, int width,
353 int height, const int hflip,
354 const int vflip)
356 int i, j, YIndex = 0, UVIndex = 0;
357 unsigned char *y, *u, *v;
358 uint8_t *buf;
359 /* For fast calculations */
360 int x_div_2, y_div_2;
361 /* Skip first 1280 bytes strange dummy bytes */
362 raw += 1280;
364 x_div_2 = width / 2; /* for fast calculation if x=640 x_div_2=320 */
365 y_div_2 = height / 2; /* for fast calculation if y=480 y_div_4=240 */
366 buf = raw;
367 y = i420;
368 u = i420 + width * height;
369 v = i420 + width * height + (width >> 1) * (height >> 1);
371 YIndex = 0;
372 UVIndex = 0;
373 /* we skipped 1280 bytes, it's almost two lines */
374 for (i = 0; i < y_div_2 - 1; i++) {
375 for (j = 0; j < x_div_2; j++) {
376 u[UVIndex] = *buf;
377 buf++;
378 v[UVIndex] = *buf;
379 buf++;
380 y[YIndex] = *buf;
381 buf++;
382 YIndex += 1;
383 y[YIndex] = *buf;
384 buf++;
385 YIndex += 1;
386 UVIndex += 1;
388 YIndex -= width;
389 YIndex += width;
391 for (j = 0; j < width; j++) {
392 y[YIndex] = *buf;
393 buf++;
394 YIndex += 1;
396 YIndex -= width;
397 YIndex += width;
399 UVIndex -= x_div_2;
400 UVIndex += (width >> 1);
406 * @brief This function permits to convert an image from 6270 rawformat to BGR24
407 * @param raw Buffer with the bayer data
408 * @param image Size of image
409 * @param view Size of view
410 * @param hflip Horizontal flip - not implemented yet
411 * @param vflip Vertical flip - not implemented yet
413 * @retval rgb Buffer with the rgb data
414 Format of stream is uvyy,uvyy - repeated 320 times for 640x480
415 y - repeated 640 times for 640x480
416 First 1280 bytes is maybe dumy ***FIXME***
419 void raw6270_2BGR24(uint8_t *raw, uint8_t *rgb, int width,
420 int height, const int hflip,
421 const int vflip)
423 int i, j, incX;
424 /* Maybe is not necesery to use long variables but I not sure in this moment */
425 long y11, y12, y21, y22, u, v, y, C, D, E;
426 long ScaleIncX, ScaleIncY;
427 long pointerIncX, pointerIncY;
428 uint8_t *bufUVYY;
429 uint8_t *bufY;
430 uint8_t *out_row1;
431 uint8_t *out_row2;
433 /* For fast calculations*/
434 int x_div_2, y_div_2;
435 /* Skip first 1280 bytes strange dummy bytes */
436 raw += 1280;
438 x_div_2 = width / 2; /* for fast calculation if x=640 x_div_2=320 */
439 y_div_2 = height / 2; /* for fast calculation if y=480 y_div_4=240 */
440 incX = 3 * width; /* Incrementation koeficient for next row*/
441 bufUVYY = raw;
442 bufY = raw + 2 * width;
445 // Because I can't use float ratio is multiply by 1000
446 // then 1000 is equal of increment image (X or Y) with 1
448 ScaleIncX = (1000 * width) / width;
449 ScaleIncY = (1000 * height) / height;
451 out_row1 = rgb;
452 out_row2 = out_row1 + incX;
453 /* we skipped 1280 bytes, it's almost two lines*/
454 pointerIncY = 1000;
455 for (i = 0; i < y_div_2-1; i++) {
456 pointerIncX = 1000;
457 for (j = 0; j < x_div_2; j++) {
458 pointerIncX += ScaleIncX;
460 u = (unsigned char)(*bufUVYY);
461 bufUVYY++;
463 v = (unsigned char)(*bufUVYY);
464 bufUVYY++;
466 y11 = (unsigned char)(*bufUVYY);
467 bufUVYY++;
469 y12 = (unsigned char)(*bufUVYY);
470 bufUVYY++;
472 y21 = (unsigned char)(*bufY);
473 bufY++;
475 y22 = (unsigned char)(*bufY);
476 bufY++;
478 if ((pointerIncX > 999) && (pointerIncY > 499)) {
479 pointerIncX -= 1001;
480 y = y11;
481 C = y - 16;
482 D = u - 128;
483 E = v - 128;
485 *out_row1 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
486 out_row1++;
487 *out_row1 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
488 out_row1++;
489 *out_row1 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
490 out_row1++;
492 y = y12;
494 C = y - 16;
495 D = u - 128;
496 E = v - 128;
499 *out_row1 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
500 out_row1++;
501 *out_row1 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
502 out_row1++;
503 *out_row1 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
504 out_row1++;
507 // Second row of stream is displayed only
508 // if image is greath than half
510 if (ScaleIncY > 501) {
511 y = y21;
513 C = y - 16;
514 D = u - 128;
515 E = v - 128;
517 *out_row2 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
518 out_row2++;
519 *out_row2 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
520 out_row2++;
521 *out_row2 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
522 out_row2++;
524 y = y22;
526 C = y - 16;
527 D = u - 128;
528 E = v - 128;
530 *out_row2 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
531 out_row2++;
532 *out_row2 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
533 out_row2++;
534 *out_row2 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
535 out_row2++;
540 // this comparation can be optimized and moved in
541 // if((pointerIncX>999)&&(pointerIncY>499))
543 if (pointerIncY > 499)
544 pointerIncY -= 500;
546 // Use 2 rows only if
547 // vertical ratio > 0.5 (increment is ratio*1000)
549 if (ScaleIncY > 501) {
550 out_row1 = out_row1 + incX;
551 out_row2 = out_row2 + incX;
554 pointerIncY += ScaleIncY;
555 bufUVYY = bufUVYY + width;
556 bufY = bufY + 2 * width;
562 * @brief This function permits to convert an image from 6270 rawformat to RGB24
563 * @brief The same function as convert to BGR24 but only B and R is change order
564 * @param raw Buffer with the bayer data
565 * @param image Size of image
566 * @param view Size of view
567 * @param hflip Horizontal flip
568 * @param vflip Vertical flip
570 * @retval rgb Buffer with the rgb data
571 Format of stream is uvyy,uvyy - repeated 320 times for 640x480
572 y - repeated 640 times for 640x480
573 First 1280 bytes is maybe dumy ***FIXME***
576 void raw6270_2RGB24(uint8_t *raw, uint8_t *rgb, int width,
577 int height, const int hflip,
578 const int vflip)
580 int i, j, incX;
581 /* Maybe is not necesery to use long variables but I not sure in this moment */
582 long y11, y12, y21, y22, u, v, y, C, D, E;
583 long ScaleIncX, ScaleIncY;
584 long pointerIncX, pointerIncY;
585 uint8_t *bufUVYY;
586 uint8_t *bufY;
587 uint8_t *out_row1;
588 uint8_t *out_row2;
590 /* For fast calculations */
591 int x_div_2, y_div_2;
592 /* Skip first 1280 bytes strange dummy bytes */
593 raw += 1280;
595 x_div_2 = width / 2; /* for fast calculation if x=640 x_div_2=320 */
596 y_div_2 = height / 2; /* for fast calculation if y=480 y_div_4=240 */
597 incX = 3 * width;
598 bufUVYY = raw;
599 bufY = raw + 2 * width;
602 // Because I can't use float ratio is multiply by 1000 then
603 // 1000 is equal of increment image (X or Y) with 1
605 ScaleIncX = (1000 * width) / width;
606 ScaleIncY = (1000 * height) / height;
608 out_row1 = rgb;
609 out_row2 = out_row1 + incX;
610 /* we skipped 1280 bytes, it's almost two lines */
611 pointerIncY = 1000;
612 for (i = 0; i < y_div_2-1; i++) {
613 pointerIncX = 1000;
614 for (j = 0; j < x_div_2; j++) {
615 pointerIncX += ScaleIncX;
617 u = (unsigned char)(*bufUVYY);
618 bufUVYY++;
620 v = (unsigned char)(*bufUVYY);
621 bufUVYY++;
623 y11 = (unsigned char)(*bufUVYY);
624 bufUVYY++;
626 y12 = (unsigned char)(*bufUVYY);
627 bufUVYY++;
629 y21 = (unsigned char)(*bufY);
630 bufY++;
632 y22 = (unsigned char)(*bufY);
633 bufY++;
635 if ((pointerIncX > 999) && (pointerIncY > 499)) {
636 pointerIncX -= 1001;
637 y = y11;
638 C = y - 16;
639 D = u - 128;
640 E = v - 128;
642 *out_row1 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
643 out_row1++;
644 *out_row1 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
645 out_row1++;
646 *out_row1 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
647 out_row1++;
649 y = y12;
651 C = y - 16;
652 D = u - 128;
653 E = v - 128;
655 *out_row1 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
656 out_row1++;
657 *out_row1 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
658 out_row1++;
659 *out_row1 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
660 out_row1++;
663 // Second row of stream is displayed only
664 // if image is greath than half
666 if (ScaleIncY > 501) {
667 y = y21;
669 C = y - 16;
670 D = u - 128;
671 E = v - 128;
673 *out_row2 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
674 out_row2++;
675 *out_row2 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
676 out_row2++;
677 *out_row2 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
678 out_row2++;
680 y = y22;
682 C = y - 16;
683 D = u - 128;
684 E = v - 128;
686 *out_row2 = CLIP((298 * C + 409 * E + 128) >> 8, 0, 255);
687 out_row2++;
688 *out_row2 = CLIP((298 * C - 100 * D - 208 * E + 128) >> 8, 0, 255);
689 out_row2++;
690 *out_row2 = CLIP((298 * C + 516 * D + 128) >> 8, 0, 255);
691 out_row2++;
696 // this comparation can be optimized and moved in
697 // if((pointerIncX>999)&&(pointerIncY>499))
699 if (pointerIncY > 499)
700 pointerIncY -= 500;
701 /* Use 2 rows only if vertical ratio > 0.5 (increment is ratio*1000) */
702 if (ScaleIncY > 501) {
703 out_row1 = out_row1 + incX;
704 out_row2 = out_row2 + incX;
707 pointerIncY += ScaleIncY;
708 bufUVYY = bufUVYY + width;
709 bufY = bufY + 2 * width;