stk11xx-bayer.c

Go to the documentation of this file.
00001 
00034 #include <linux/module.h>
00035 #include <linux/init.h>
00036 #include <linux/kernel.h>
00037 #include <linux/errno.h>
00038 #include <linux/slab.h>
00039 #include <linux/kref.h>
00040 
00041 #include <linux/usb.h>
00042 //#include <linux/videodev2.h>
00043 #include <media/v4l2-common.h>
00044 
00045 #include "stk11xx.h"
00046 
00047 
00048 void stk11xx_b2rgb24(uint8_t *, uint8_t *,
00049         struct stk11xx_coord *, struct stk11xx_coord *,
00050         const int, const int, const int);
00051 void stk11xx_b2rgb32(uint8_t *, uint8_t *, 
00052         struct stk11xx_coord *, struct stk11xx_coord *, 
00053         const int, const int, const int);
00054 void stk11xx_b2bgr24(uint8_t *, uint8_t *,
00055         struct stk11xx_coord *, struct stk11xx_coord *,
00056         const int, const int, const int);
00057 void stk11xx_b2bgr32(uint8_t *, uint8_t *,
00058         struct stk11xx_coord *, struct stk11xx_coord *,
00059         const int, const int, const int);
00060 
00061 void stk11xx_b2yv12(uint8_t *, uint8_t *,
00062         struct stk11xx_coord *, struct stk11xx_coord *,
00063         const int, const int, const int);
00064 
00065 
00066 void stk11xx_correct_brightness(uint8_t *, const int, const int,
00067         const int, int);
00068 
00069 
00079 int stk11xx_decompress(struct usb_stk11xx *dev)
00080 {
00081     int factor;
00082 
00083     void *data;
00084     void *image;
00085     struct stk11xx_frame_buf *framebuf;
00086 
00087     if (dev == NULL)
00088         return -EFAULT;
00089 
00090     framebuf = dev->read_frame;
00091 
00092     if (framebuf == NULL)
00093         return -EFAULT;
00094 
00095     image  = dev->image_data;
00096     image += dev->images[dev->fill_image].offset;
00097 
00098     data = framebuf->data;
00099 
00100     switch (dev->resolution) {
00101         case STK11XX_80x60:
00102             factor = 8;
00103             break;
00104 
00105         case STK11XX_128x96:
00106             factor = 5;
00107             break;
00108 
00109         case STK11XX_160x120:
00110             factor = 4;
00111             break;
00112 
00113         case STK11XX_213x160:
00114             factor = 3;
00115             break;
00116 
00117         case STK11XX_320x240:
00118             factor = 2;
00119             break;
00120 
00121         case STK11XX_640x480:
00122             factor = 1;
00123             break;
00124 
00125         case STK11XX_800x600:
00126             factor = 1;
00127             break;
00128 
00129         case STK11XX_1024x768:
00130             factor = 1;
00131             break;
00132 
00133         case STK11XX_1280x1024:
00134             factor = 1;
00135             break;
00136 
00137         default:
00138             return -EFAULT;
00139     }
00140 
00141 
00142     switch (dev->vsettings.palette) {
00143         case STK11XX_PALETTE_RGB24:
00144             stk11xx_b2rgb24(data, image, &dev->image, &dev->view,
00145                 dev->vsettings.hflip, dev->vsettings.vflip, factor);
00146             break;
00147 
00148         case STK11XX_PALETTE_RGB32:
00149             stk11xx_b2rgb32(data, image, &dev->image, &dev->view,
00150                 dev->vsettings.hflip, dev->vsettings.vflip, factor);
00151             break;
00152 
00153         case STK11XX_PALETTE_BGR24:
00154             stk11xx_b2bgr24(data, image, &dev->image, &dev->view,
00155                 dev->vsettings.hflip, dev->vsettings.vflip, factor);
00156             break;
00157 
00158         case STK11XX_PALETTE_BGR32:
00159             stk11xx_b2bgr32(data, image, &dev->image, &dev->view,
00160                 dev->vsettings.hflip, dev->vsettings.vflip, factor);
00161             break;
00162     }
00163 
00164     stk11xx_correct_brightness(image, dev->view.x, dev->view.y,
00165         dev->vsettings.brightness, dev->vsettings.depth);
00166 
00167     return 0;
00168 }
00169 
00170 
00184 void stk11xx_correct_brightness(uint8_t *rgb, const int width, const int height, 
00185         const int brightness, int depth)
00186 {
00187     int i;
00188     int x;
00189 
00190     depth = (depth == 24) ? 3 : 4;
00191 
00192     if (brightness >= 32767) {
00193         x = (brightness - 32767) / 256;
00194 
00195         for (i = 0; i < (width * height * depth); i++) {
00196             if ((*(rgb + i) + (unsigned char) x) > 255)
00197                 *(rgb + i) = 255;
00198             else
00199                 *(rgb + i) += (unsigned char) x;
00200         }
00201     }
00202     else {
00203         x = (32767 - brightness) / 256;
00204 
00205         for (i = 0; i < (width * height * depth); i++) {
00206             if ((unsigned char) x > *(rgb + i))
00207                 *(rgb + i) = 0;
00208             else
00209                 *(rgb + i) -= (unsigned char) x;
00210         }
00211     }
00212 }
00213 
00214 
00227 void stk11xx_b2rgb24(uint8_t *bayer, uint8_t *rgb,
00228         struct stk11xx_coord *image,
00229         struct stk11xx_coord *view,
00230         const int hflip, const int vflip,
00231         const int factor) {
00232     uint8_t *b;
00233 
00234     int x, y; // Position in bayer image
00235     int i, j; // Position in rgb image
00236 
00237     int width = image->x;
00238     int height = image->y;
00239 
00240     int nwidth = width / factor;
00241     int nheight = height / factor;
00242 
00243     int offset;
00244     int startx, stepx;
00245     int starty, stepy;
00246 
00247 
00248     // Calculate the initial position (on Y axis)
00249     if (vflip) {
00250         starty = height - 2;
00251         stepy = -factor;
00252     }
00253     else {
00254         starty = 0;
00255         stepy = factor;
00256     }
00257 
00258     // Calculate the initial position (on X axis)
00259     if (hflip) {
00260         startx = width - 1;
00261         stepx = -factor;
00262         offset = width - 2;
00263     }
00264     else {
00265         startx = 0;
00266         stepx = factor;
00267         offset = 1;
00268     }
00269 
00270 
00271     // Skip the first line
00272     bayer += width;
00273 
00274     // To center vertically the image in the view
00275     rgb += ((view->y - nheight) / 2) * view->x * 3;
00276 
00277     // To center horizontally the image in the view
00278     rgb += ((view->x - nwidth) / 2) * 3;
00279 
00280     // Clean the first line
00281     memset(rgb, 0, nwidth * 3);
00282     rgb += nwidth * 3;
00283 
00284 
00285     // For each rgb line without the borders (first and last line)
00286     for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
00287         // Go to the start of line
00288         b = bayer + y * width + offset;
00289 
00290         // Offset to center horizontally the image in the view
00291         rgb += (view->x - nwidth) * 3;
00292 
00293         if (y & 0x1) {
00294             // Skip the first pixel
00295             *rgb++ = 0;
00296             *rgb++ = 0;
00297             *rgb++ = 0;
00298 
00299             // GBGBGB : Line process...
00300             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00301                 if (x & 0x1) {
00302                     *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00303                     *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00304                     *rgb++ = *b;
00305                 }
00306                 else {
00307                     *rgb++ = (*(b-width) + *(b+width)) >> 1;
00308                     *rgb++ = *b;
00309                     *rgb++ = (*(b-1) + *(b+1)) >> 1;
00310                 }
00311 
00312                 b += stepx;
00313             }
00314 
00315             // Skip the last pixel
00316             *rgb++ = 0;
00317             *rgb++ = 0;
00318             *rgb++ = 0;
00319         }
00320         else {
00321             // Skip the first pixel
00322             *rgb++ = 0;
00323             *rgb++ = 0;
00324             *rgb++ = 0;
00325 
00326             // RGRGRG : Line process...
00327             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00328                 if (x & 0x1) {
00329                     *rgb++ = (*(b-1) + *(b+1)) >> 1;
00330                     *rgb++ = *b;
00331                     *rgb++ = (*(b-width) + *(b+width)) >> 1;
00332                 }
00333                 else {
00334                     *rgb++ = *b;
00335                     *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00336                     *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00337                 }
00338     
00339                 b += stepx;
00340             }
00341 
00342             // Skip the last pixel
00343             *rgb++ = 0;
00344             *rgb++ = 0;
00345             *rgb++ = 0;
00346         }
00347     }
00348 
00349     // Clean the last line
00350     memset(rgb, 0, nwidth * 3);
00351 }
00352 
00353 
00366 void stk11xx_b2rgb32(uint8_t *bayer, uint8_t *rgb,
00367         struct stk11xx_coord *image,
00368         struct stk11xx_coord *view,
00369         const int hflip, const int vflip,
00370         const int factor) {
00371     uint8_t *b;
00372 
00373     int x, y; // Position in bayer image
00374     int i, j; // Position in rgb image
00375 
00376     int width = image->x;
00377     int height = image->y;
00378 
00379     int nwidth = width / factor;
00380     int nheight = height / factor;
00381 
00382     int offset;
00383     int startx, stepx;
00384     int starty, stepy;
00385 
00386 
00387     // Calculate the initial position (on Y axis)
00388     if (vflip) {
00389         starty = height - 2;
00390         stepy = -factor;
00391     }
00392     else {
00393         starty = 0;
00394         stepy = factor;
00395     }
00396 
00397     // Calculate the initial position (on X axis)
00398     if (hflip) {
00399         startx = width - 1;
00400         stepx = -factor;
00401         offset = width - 2;
00402     }
00403     else {
00404         startx = 0;
00405         stepx = factor;
00406         offset = 1;
00407     }
00408 
00409 
00410     // Skip the first line
00411     bayer += width;
00412 
00413     // To center vertically the image in the view
00414     rgb += ((view->y - nheight) / 2) * view->x * 4;
00415 
00416     // To center horizontally the image in the view
00417     rgb += ((view->x - nwidth) / 2) * 4;
00418 
00419     // Clean the first line
00420     memset(rgb, 0, nwidth * 4);
00421     rgb += nwidth * 4;
00422 
00423 
00424     // For each rgb line without the borders (first and last line)
00425     for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
00426         // Go to the start of line
00427         b = bayer + y * width + offset;
00428 
00429         // Offset to center horizontally the image in the view
00430         rgb += (view->x - nwidth) * 4;
00431 
00432         if (y & 0x1) {
00433             // Skip the first pixel
00434             *rgb++ = 0;
00435             *rgb++ = 0;
00436             *rgb++ = 0;
00437             *rgb++ = 0;
00438 
00439             // GBGBGB : Line process...
00440             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00441                 if (x & 0x1) {
00442                     *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00443                     *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00444                     *rgb++ = *b;
00445                     *rgb++ = 0;
00446                 }
00447                 else {
00448                     *rgb++ = (*(b-width) + *(b+width)) >> 1;
00449                     *rgb++ = *b;
00450                     *rgb++ = (*(b-1) + *(b+1)) >> 1;
00451                     *rgb++ = 0;
00452                 }
00453 
00454                 b += stepx;
00455             }
00456 
00457             // Skip the last pixel
00458             *rgb++ = 0;
00459             *rgb++ = 0;
00460             *rgb++ = 0;
00461             *rgb++ = 0;
00462         }
00463         else {
00464             // Skip the first pixel
00465             *rgb++ = 0;
00466             *rgb++ = 0;
00467             *rgb++ = 0;
00468             *rgb++ = 0;
00469 
00470             // RGRGRG : Line process...
00471             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00472                 if (x & 0x1) {
00473                     *rgb++ = (*(b-1) + *(b+1)) >> 1;
00474                     *rgb++ = *b;
00475                     *rgb++ = (*(b-width) + *(b+width)) >> 1;
00476                     *rgb++ = 0;
00477                 }
00478                 else {
00479                     *rgb++ = *b;
00480                     *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00481                     *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00482                     *rgb++ = 0;
00483                 }
00484     
00485                 b += stepx;
00486             }
00487 
00488             // Skip the last pixel
00489             *rgb++ = 0;
00490             *rgb++ = 0;
00491             *rgb++ = 0;
00492             *rgb++ = 0;
00493         }
00494     }
00495 
00496     // Clean the last line
00497     memset(rgb, 0, nwidth * 4);
00498 }
00499 
00500 
00513 void stk11xx_b2bgr24(uint8_t *bayer, uint8_t *bgr,
00514         struct stk11xx_coord *image,
00515         struct stk11xx_coord *view,
00516         const int hflip, const int vflip,
00517         const int factor) {
00518     uint8_t *b;
00519 
00520     int x, y; // Position in bayer image
00521     int i, j; // Position in bgr image
00522 
00523     int width = image->x;
00524     int height = image->y;
00525 
00526     int nwidth = width / factor;
00527     int nheight = height / factor;
00528 
00529     int offset;
00530     int startx, stepx;
00531     int starty, stepy;
00532 
00533 
00534     // Calculate the initial position (on Y axis)
00535     if (vflip) {
00536         starty = height - 2;
00537         stepy = -factor;
00538     }
00539     else {
00540         starty = 0;
00541         stepy = factor;
00542     }
00543 
00544     // Calculate the initial position (on X axis)
00545     if (hflip) {
00546         startx = width - 1;
00547         stepx = -factor;
00548         offset = width - 2;
00549     }
00550     else {
00551         startx = 0;
00552         stepx = factor;
00553         offset = 1;
00554     }
00555 
00556 
00557     // Skip the first line
00558     bayer += width;
00559 
00560     // To center vertically the image in the view
00561     bgr += ((view->y - nheight) / 2) * view->x * 3;
00562 
00563     // To center horizontally the image in the view
00564     bgr += ((view->x - nwidth) / 2) * 3;
00565 
00566     // Clean the first line
00567     memset(bgr, 0, nwidth * 3);
00568     bgr += nwidth * 3;
00569 
00570 
00571     // For each bgr line without the borders (first and last line)
00572     for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
00573         // Go to the start of line
00574         b = bayer + y * width + offset;
00575 
00576         // Offset to center horizontally the image in the view
00577         bgr += (view->x - nwidth) * 3;
00578 
00579         if (y & 0x1) {
00580             // Skip the first pixel
00581             *bgr++ = 0;
00582             *bgr++ = 0;
00583             *bgr++ = 0;
00584 
00585             // GBGBGB : Line process...
00586             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00587                 if (x & 0x1) {
00588                     *bgr++ = *b;
00589                     *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00590                     *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00591                 }
00592                 else {
00593                     *bgr++ = (*(b-1) + *(b+1)) >> 1;
00594                     *bgr++ = *b;
00595                     *bgr++ = (*(b-width) + *(b+width)) >> 1;
00596                 }
00597 
00598                 b += stepx;
00599             }
00600 
00601             // Skip the last pixel
00602             *bgr++ = 0;
00603             *bgr++ = 0;
00604             *bgr++ = 0;
00605         }
00606         else {
00607             // Skip the first pixel
00608             *bgr++ = 0;
00609             *bgr++ = 0;
00610             *bgr++ = 0;
00611 
00612             // RGRGRG : Line process...
00613             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00614                 if (x & 0x1) {
00615                     *bgr++ = (*(b-width) + *(b+width)) >> 1;
00616                     *bgr++ = *b;
00617                     *bgr++ = (*(b-1) + *(b+1)) >> 1;
00618                 }
00619                 else {
00620                     *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00621                     *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00622                     *bgr++ = *b;
00623                 }
00624     
00625                 b += stepx;
00626             }
00627 
00628             // Skip the last pixel
00629             *bgr++ = 0;
00630             *bgr++ = 0;
00631             *bgr++ = 0;
00632         }
00633     }
00634 
00635     // Clean the last line
00636     memset(bgr, 0, nwidth * 3);
00637 }
00638 
00639 
00652 void stk11xx_b2bgr32(uint8_t *bayer, uint8_t *bgr,
00653         struct stk11xx_coord *image,
00654         struct stk11xx_coord *view,
00655         const int hflip, const int vflip,
00656         const int factor) {
00657     uint8_t *b;
00658 
00659     int x, y; // Position in bayer image
00660     int i, j; // Position in bgr image
00661 
00662     int width = image->x;
00663     int height = image->y;
00664 
00665     int nwidth = width / factor;
00666     int nheight = height / factor;
00667 
00668     int offset;
00669     int startx, stepx;
00670     int starty, stepy;
00671 
00672 
00673     // Calculate the initial position (on Y axis)
00674     if (vflip) {
00675         starty = height - 2;
00676         stepy = -factor;
00677     }
00678     else {
00679         starty = 0;
00680         stepy = factor;
00681     }
00682 
00683     // Calculate the initial position (on X axis)
00684     if (hflip) {
00685         startx = width - 1;
00686         stepx = -factor;
00687         offset = width - 2;
00688     }
00689     else {
00690         startx = 0;
00691         stepx = factor;
00692         offset = 1;
00693     }
00694 
00695 
00696     // Skip the first line
00697     bayer += width;
00698 
00699     // To center vertically the image in the view
00700     bgr += ((view->y - nheight) / 2) * view->x * 4;
00701 
00702     // To center horizontally the image in the view
00703     bgr += ((view->x - nwidth) / 2) * 4;
00704 
00705     // Clean the first line
00706     memset(bgr, 0, nwidth * 4);
00707     bgr += nwidth * 4;
00708 
00709 
00710     // For each bgr line without the borders (first and last line)
00711     for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
00712         // Go to the start of line
00713         b = bayer + y * width + offset;
00714 
00715         // Offset to center horizontally the image in the view
00716         bgr += (view->x - nwidth) * 4;
00717 
00718         if (y & 0x1) {
00719             // Skip the first pixel
00720             *bgr++ = 0;
00721             *bgr++ = 0;
00722             *bgr++ = 0;
00723             *bgr++ = 0;
00724 
00725             // GBGBGB : Line process...
00726             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00727                 if (x & 0x1) {
00728                     *bgr++ = *b;
00729                     *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00730                     *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00731                     *bgr++ = 0;
00732                 }
00733                 else {
00734                     *bgr++ = (*(b-1) + *(b+1)) >> 1;
00735                     *bgr++ = *b;
00736                     *bgr++ = (*(b-width) + *(b+width)) >> 1;
00737                     *bgr++ = 0;
00738                 }
00739 
00740                 b += stepx;
00741             }
00742 
00743             // Skip the last pixel
00744             *bgr++ = 0;
00745             *bgr++ = 0;
00746             *bgr++ = 0;
00747             *bgr++ = 0;
00748         }
00749         else {
00750             // Skip the first pixel
00751             *bgr++ = 0;
00752             *bgr++ = 0;
00753             *bgr++ = 0;
00754             *bgr++ = 0;
00755 
00756             // RGRGRG : Line process...
00757             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00758                 if (x & 0x1) {
00759                     *bgr++ = (*(b-width) + *(b+width)) >> 1;
00760                     *bgr++ = *b;
00761                     *bgr++ = (*(b-1) + *(b+1)) >> 1;
00762                     *bgr++ = 0;
00763                 }
00764                 else {
00765                     *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00766                     *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00767                     *bgr++ = *b;
00768                     *bgr++ = 0;
00769                 }
00770     
00771                 b += stepx;
00772             }
00773 
00774             // Skip the last pixel
00775             *bgr++ = 0;
00776             *bgr++ = 0;
00777             *bgr++ = 0;
00778             *bgr++ = 0;
00779         }
00780     }
00781 
00782     // Clean the last line
00783     memset(bgr, 0, nwidth * 4);
00784 }
00785 
00786 
00799 void stk11xx_b2yv12(uint8_t *bayer, uint8_t *yuv,
00800         struct stk11xx_coord *image,
00801         struct stk11xx_coord *view,
00802         const int hflip, const int vflip,
00803         const int factor) {
00804 /*
00805     uint8_t *b;
00806 
00807     int x, y; // Position in bayer image
00808     int i, j; // Position in yuv image
00809 
00810     int width = image->x;
00811     int height = image->y;
00812 
00813     int nwidth = width / factor;
00814     int nheight = height / factor;
00815 
00816     int offset;
00817     int startx, stepx;
00818     int starty, stepy;
00819 
00820 
00821     // Calculate the initial position (on Y axis)
00822     if (vflip) {
00823         starty = height - 2;
00824         stepy = -factor;
00825     }
00826     else {
00827         starty = 0;
00828         stepy = factor;
00829     }
00830 
00831     // Calculate the initial position (on X axis)
00832     if (hflip) {
00833         startx = width - 1;
00834         stepx = -factor;
00835         offset = width - 2;
00836     }
00837     else {
00838         startx = 0;
00839         stepx = factor;
00840         offset = 1;
00841     }
00842 
00843 
00844     // Skip the first line
00845     bayer += width;
00846 
00847     // To center vertically the image in the view
00848     rgb += ((view->y - nheight) / 2) * view->x * 3;
00849 
00850     // To center horizontally the image in the view
00851     rgb += ((view->x - nwidth) / 2) * 3;
00852 
00853     // Clean the first line
00854     memset(rgb, 0, nwidth * 3);
00855     rgb += nwidth * 3;
00856 
00857 
00858     // For each rgb line without the borders (first and last line)
00859     for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
00860         // Go to the start of line
00861         b = bayer + y * width + offset;
00862 
00863         // Offset to center horizontally the image in the view
00864         rgb += (view->x - nwidth) * 3;
00865 
00866         if (y & 0x1) {
00867             // Skip the first pixel
00868             *rgb++ = 0;
00869             *rgb++ = 0;
00870             *rgb++ = 0;
00871 
00872             // GBGBGB : Line process...
00873             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00874                 if (x & 0x1) {
00875                     *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00876                     *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00877                     *rgb++ = *b;
00878                 }
00879                 else {
00880                     *rgb++ = (*(b-width) + *(b+width)) >> 1;
00881                     *rgb++ = *b;
00882                     *rgb++ = (*(b-1) + *(b+1)) >> 1;
00883                 }
00884 
00885                 b += stepx;
00886             }
00887 
00888             // Skip the last pixel
00889             *rgb++ = 0;
00890             *rgb++ = 0;
00891             *rgb++ = 0;
00892         }
00893         else {
00894             // Skip the first pixel
00895             *rgb++ = 0;
00896             *rgb++ = 0;
00897             *rgb++ = 0;
00898 
00899             // RGRGRG : Line process...
00900             for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
00901                 if (x & 0x1) {
00902                     *rgb++ = (*(b-1) + *(b+1)) >> 1;
00903                     *rgb++ = *b;
00904                     *rgb++ = (*(b-width) + *(b+width)) >> 1;
00905                 }
00906                 else {
00907                     *rgb++ = *b;
00908                     *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
00909                     *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
00910                 }
00911     
00912                 b += stepx;
00913             }
00914 
00915             // Skip the last pixel
00916             *rgb++ = 0;
00917             *rgb++ = 0;
00918             *rgb++ = 0;
00919         }
00920     }
00921 
00922     // Clean the last line
00923     memset(rgb, 0, nwidth * 3);
00924 */
00925 }
00926 
00927 

Generated on Tue Oct 2 06:18:12 2007 for SyntekUSBVideoCamera by  doxygen 1.5.3