SyntekUSBVideoCamera
stk11xx-bayer.c
Go to the documentation of this file.
1 
34 #include <linux/module.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/version.h>
38 #include <linux/errno.h>
39 #include <linux/slab.h>
40 #include <linux/kref.h>
41 
42 #include <linux/usb.h>
43 #include <media/v4l2-common.h>
44 
45 #include "stk11xx.h"
46 
47 
48 #define MAX(a,b) ((a)>(b)?(a):(b))
49 #define MIN(a,b) ((a)<(b)?(a):(b))
50 #define CLIP(a,low,high) MAX((low),MIN((high),(a)))
51 
52 
53 void stk11xx_b2rgb24(uint8_t *, uint8_t *,
54  struct stk11xx_coord *, struct stk11xx_coord *,
55  const int, const int, const int);
56 void stk11xx_b2rgb32(uint8_t *, uint8_t *,
57  struct stk11xx_coord *, struct stk11xx_coord *,
58  const int, const int, const int);
59 void stk11xx_b2bgr24(uint8_t *, uint8_t *,
60  struct stk11xx_coord *, struct stk11xx_coord *,
61  const int, const int, const int);
62 void stk11xx_b2bgr32(uint8_t *, uint8_t *,
63  struct stk11xx_coord *, struct stk11xx_coord *,
64  const int, const int, const int);
65 
66 void stk11xx_b2uyvy(uint8_t *, uint8_t *,
67  struct stk11xx_coord *, struct stk11xx_coord *,
68  const int, const int, const int);
69 void stk11xx_b2yuyv(uint8_t *, uint8_t *,
70  struct stk11xx_coord *, struct stk11xx_coord *,
71  const int, const int, const int);
72 
73 
74 void stk11xx_correct_brightness(uint8_t *, const int, const int,
75  const int, int, int);
76 
77 
78 static signed short stk11xx_yuv_interp[256][8] = {
79  {0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,1,0,0,0,1,0,0},{0,1,0,0,0,1,-1,0},
80  {1,2,0,0,-1,2,-1,0},{1,2,0,0,-1,2,-2,0},{1,3,0,-1,-1,3,-2,0},{2,3,0,-1,-2,3,-2,0},
81  {2,4,0,-1,-2,4,-3,0},{2,5,1,-1,-2,4,-3,0},{2,5,1,-1,-3,5,-4,0},{3,6,1,-1,-3,5,-4,0},
82  {3,6,1,-2,-3,6,-5,0},{3,7,1,-2,-4,6,-5,-1},{4,7,1,-2,-4,7,-5,-1},{4,8,1,-2,-4,7,-6,-1},
83  {4,9,1,-2,-5,8,-6,-1},{5,9,1,-2,-5,8,-7,-1},{5,10,2,-3,-5,9,-7,-1},{5,10,2,-3,-6,9,-7,-1},
84  {5,11,2,-3,-6,10,-8,-1},{6,11,2,-3,-6,10,-8,-1},{6,12,2,-3,-7,11,-9,-1},{6,13,2,-3,-7,11,-9,-1},
85  {7,13,2,-4,-7,12,-10,-1},{7,14,2,-4,-8,12,-10,-2},{7,14,2,-4,-8,13,-10,-2},{8,15,3,-4,-8,13,-11,-2},
86  {8,15,3,-4,-9,14,-11,-2},{8,16,3,-4,-9,14,-12,-2},{8,17,3,-5,-9,15,-12,-2},{9,17,3,-5,-10,15,-12,-2},
87  {9,18,3,-5,-10,16,-13,-2},{9,18,3,-5,-10,16,-13,-2},{10,19,3,-5,-11,17,-14,-2},{10,19,3,-5,-11,17,-14,-2},
88  {10,20,4,-6,-11,18,-15,-2},{11,20,4,-6,-12,18,-15,-3},{11,21,4,-6,-12,19,-15,-3},{11,22,4,-6,-12,19,-16,-3},
89  {11,22,4,-6,-13,20,-16,-3},{12,23,4,-6,-13,20,-17,-3},{12,23,4,-7,-13,21,-17,-3},{12,24,4,-7,-14,21,-18,-3},
90  {13,24,5,-7,-14,22,-18,-3},{13,25,5,-7,-14,22,-18,-3},{13,26,5,-7,-15,23,-19,-3},{14,26,5,-7,-15,23,-19,-3},
91  {14,27,5,-8,-15,24,-20,-3},{14,27,5,-8,-16,24,-20,-3},{14,28,5,-8,-16,25,-20,-4},{15,28,5,-8,-16,25,-21,-4},
92  {15,29,5,-8,-17,26,-21,-4},{15,30,6,-8,-17,26,-22,-4},{16,30,6,-9,-17,27,-22,-4},{16,31,6,-9,-18,27,-23,-4},
93  {16,31,6,-9,-18,28,-23,-4},{17,32,6,-9,-18,28,-23,-4},{17,32,6,-9,-19,29,-24,-4},{17,33,6,-9,-19,29,-24,-4},
94  {17,34,6,-10,-19,30,-25,-4},{18,34,6,-10,-20,30,-25,-4},{18,35,7,-10,-20,31,-25,-5},{18,35,7,-10,-20,31,-26,-5},
95  {19,36,7,-10,-21,32,-26,-5},{19,36,7,-10,-21,32,-27,-5},{19,37,7,-11,-21,33,-27,-5},{20,37,7,-11,-22,33,-28,-5},
96  {20,38,7,-11,-22,34,-28,-5},{20,39,7,-11,-22,34,-28,-5},{20,39,7,-11,-23,35,-29,-5},{21,40,8,-11,-23,35,-29,-5},
97  {21,40,8,-12,-23,36,-30,-5},{21,41,8,-12,-24,36,-30,-5},{22,41,8,-12,-24,37,-30,-6},{22,42,8,-12,-24,37,-31,-6},
98  {22,43,8,-12,-25,38,-31,-6},{23,43,8,-12,-25,38,-32,-6},{23,44,8,-13,-25,39,-32,-6},{23,44,9,-13,-26,39,-33,-6},
99  {23,45,9,-13,-26,40,-33,-6},{24,45,9,-13,-26,40,-33,-6},{24,46,9,-13,-27,41,-34,-6},{24,47,9,-14,-27,41,-34,-6},
100  {25,47,9,-14,-27,42,-35,-6},{25,48,9,-14,-28,42,-35,-6},{25,48,9,-14,-28,43,-36,-6},{26,49,9,-14,-28,43,-36,-7},
101  {26,49,10,-14,-29,44,-36,-7},{26,50,10,-15,-29,44,-37,-7},{26,51,10,-15,-29,45,-37,-7},{27,51,10,-15,-30,45,-38,-7},
102  {27,52,10,-15,-30,46,-38,-7},{27,52,10,-15,-30,46,-38,-7},{28,53,10,-15,-31,47,-39,-7},{28,53,10,-16,-31,47,-39,-7},
103  {28,54,10,-16,-31,48,-40,-7},{29,54,11,-16,-32,48,-40,-7},{29,55,11,-16,-32,49,-41,-7},{29,56,11,-16,-32,49,-41,-8},
104  {29,56,11,-16,-33,50,-41,-8},{30,57,11,-17,-33,50,-42,-8},{30,57,11,-17,-33,51,-42,-8},{30,58,11,-17,-34,51,-43,-8},
105  {31,58,11,-17,-34,52,-43,-8},{31,59,11,-17,-34,52,-43,-8},{31,60,12,-17,-35,53,-44,-8},{31,60,12,-18,-35,53,-44,-8},
106  {32,61,12,-18,-35,54,-45,-8},{32,61,12,-18,-36,54,-45,-8},{32,62,12,-18,-36,55,-46,-8},{33,62,12,-18,-36,55,-46,-9},
107  {33,63,12,-18,-37,56,-46,-9},{33,64,12,-19,-37,56,-47,-9},{34,64,12,-19,-37,57,-47,-9},{34,65,13,-19,-38,57,-48,-9},
108  {34,65,13,-19,-38,58,-48,-9},{34,66,13,-19,-38,58,-48,-9},{35,66,13,-19,-39,59,-49,-9},{35,67,13,-20,-39,59,-49,-9},
109  {35,68,13,-20,-39,60,-50,-9},{36,68,13,-20,-40,60,-50,-9},{36,69,13,-20,-40,61,-51,-9},{36,69,14,-20,-40,61,-51,-9},
110  {37,70,14,-20,-41,62,-51,-10},{37,70,14,-21,-41,62,-52,-10},{37,71,14,-21,-41,63,-52,-10},{37,72,14,-21,-42,63,-53,-10},
111  {38,72,14,-21,-42,64,-53,-10},{38,73,14,-21,-42,64,-54,-10},{38,73,14,-21,-43,65,-54,-10},{39,74,14,-22,-43,65,-54,-10},
112  {39,74,15,-22,-43,66,-55,-10},{39,75,15,-22,-44,66,-55,-10},{40,75,15,-22,-44,67,-56,-10},{40,76,15,-22,-44,67,-56,-10},
113  {40,77,15,-22,-45,68,-56,-11},{40,77,15,-23,-45,68,-57,-11},{41,78,15,-23,-45,69,-57,-11},{41,78,15,-23,-46,69,-58,-11},
114  {41,79,15,-23,-46,70,-58,-11},{42,79,16,-23,-46,70,-59,-11},{42,80,16,-23,-47,71,-59,-11},{42,81,16,-24,-47,71,-59,-11},
115  {43,81,16,-24,-47,72,-60,-11},{43,82,16,-24,-48,72,-60,-11},{43,82,16,-24,-48,73,-61,-11},{43,83,16,-24,-48,73,-61,-11},
116  {44,83,16,-24,-49,74,-61,-12},{44,84,16,-25,-49,74,-62,-12},{44,85,17,-25,-49,75,-62,-12},{45,85,17,-25,-50,75,-63,-12},
117  {45,86,17,-25,-50,76,-63,-12},{45,86,17,-25,-50,76,-64,-12},{46,87,17,-25,-51,77,-64,-12},{46,87,17,-26,-51,77,-64,-12},
118  {46,88,17,-26,-51,78,-65,-12},{46,89,17,-26,-52,78,-65,-12},{47,89,18,-26,-52,79,-66,-12},{47,90,18,-26,-52,79,-66,-12},
119  {47,90,18,-26,-53,80,-66,-13},{48,91,18,-27,-53,80,-67,-13},{48,91,18,-27,-53,81,-67,-13},{48,92,18,-27,-54,81,-68,-13},
120  {49,92,18,-27,-54,82,-68,-13},{49,93,18,-27,-54,82,-69,-13},{49,94,18,-28,-54,83,-69,-13},{49,94,19,-28,-55,83,-69,-13},
121  {50,95,19,-28,-55,84,-70,-13},{50,95,19,-28,-55,84,-70,-13},{50,96,19,-28,-56,85,-71,-13},{51,96,19,-28,-56,85,-71,-13},
122  {51,97,19,-29,-56,86,-72,-13},{51,98,19,-29,-57,86,-72,-14},{52,98,19,-29,-57,87,-72,-14},{52,99,19,-29,-57,87,-73,-14},
123  {52,99,20,-29,-58,88,-73,-14},{52,100,20,-29,-58,88,-74,-14},{53,100,20,-30,-58,89,-74,-14},{53,101,20,-30,-59,89,-74,-14},
124  {53,102,20,-30,-59,90,-75,-14},{54,102,20,-30,-59,90,-75,-14},{54,103,20,-30,-60,91,-76,-14},{54,103,20,-30,-60,91,-76,-14},
125  {55,104,20,-31,-60,92,-77,-14},{55,104,21,-31,-61,92,-77,-15},{55,105,21,-31,-61,93,-77,-15},{55,106,21,-31,-61,93,-78,-15},
126  {56,106,21,-31,-62,94,-78,-15},{56,107,21,-31,-62,94,-79,-15},{56,107,21,-32,-62,95,-79,-15},{57,108,21,-32,-63,95,-79,-15},
127  {57,108,21,-32,-63,96,-80,-15},{57,109,22,-32,-63,96,-80,-15},{58,109,22,-32,-64,97,-81,-15},{58,110,22,-32,-64,97,-81,-15},
128  {58,111,22,-33,-64,98,-82,-15},{58,111,22,-33,-65,98,-82,-16},{59,112,22,-33,-65,99,-82,-16},{59,112,22,-33,-65,99,-83,-16},
129  {59,113,22,-33,-66,100,-83,-16},{60,113,22,-33,-66,100,-84,-16},{60,114,23,-34,-66,101,-84,-16},{60,115,23,-34,-67,101,-84,-16},
130  {60,115,23,-34,-67,102,-85,-16},{61,116,23,-34,-67,102,-85,-16},{61,116,23,-34,-68,103,-86,-16},{61,117,23,-34,-68,103,-86,-16},
131  {62,117,23,-35,-68,104,-87,-16},{62,118,23,-35,-69,104,-87,-16},{62,119,23,-35,-69,105,-87,-17},{63,119,24,-35,-69,105,-88,-17},
132  {63,120,24,-35,-70,106,-88,-17},{63,120,24,-35,-70,106,-89,-17},{63,121,24,-36,-70,107,-89,-17},{64,121,24,-36,-71,107,-90,-17},
133  {64,122,24,-36,-71,108,-90,-17},{64,123,24,-36,-71,108,-90,-17},{65,123,24,-36,-72,109,-91,-17},{65,124,24,-36,-72,109,-91,-17},
134  {65,124,25,-37,-72,110,-92,-17},{66,125,25,-37,-73,110,-92,-17},{66,125,25,-37,-73,111,-92,-18},{66,126,25,-37,-73,111,-93,-18},
135  {66,127,25,-37,-74,112,-93,-18},{67,127,25,-37,-74,112,-94,-18},{67,128,25,-38,-74,113,-94,-18},{67,128,25,-38,-75,113,-95,-18},
136  {68,129,25,-38,-75,114,-95,-18},{68,129,26,-38,-75,114,-95,-18},{68,130,26,-38,-76,115,-96,-18},{69,130,26,-38,-76,115,-96,-18},
137  {69,131,26,-39,-76,116,-97,-18},{69,132,26,-39,-77,116,-97,-18},{69,132,26,-39,-77,117,-97,-19},{70,133,26,-39,-77,117,-98,-19},
138  {70,133,26,-39,-78,118,-98,-19},{70,134,27,-39,-78,118,-99,-19},{71,134,27,-40,-78,119,-99,-19},{71,135,27,-40,-79,119,-100,-19},
139  {71,136,27,-40,-79,120,-100,-19},{72,136,27,-40,-79,120,-100,-19},{72,137,27,-40,-80,121,-101,-19},{72,137,27,-40,-80,121,-101,-19},
140  {72,138,27,-41,-80,122,-102,-19},{73,138,27,-41,-81,122,-102,-19},{73,139,28,-41,-81,123,-103,-19},{73,140,28,-41,-81,123,-103,-20},
141  {74,140,28,-41,-82,124,-103,-20},{74,141,28,-42,-82,124,-104,-20},{74,141,28,-42,-82,125,-104,-20},{75,142,28,-42,-83,125,-105,-20},
142  {75,142,28,-42,-83,126,-105,-20},{75,143,28,-42,-83,126,-105,-20},{75,144,28,-42,-84,127,-106,-20},{76,144,29,-43,-84,127,-106,-20}
143 };
144 
145 
156 {
157  int factor;
158 
159  void *data;
160  void *image;
161  struct stk11xx_frame_buf *framebuf;
162 
163  if (dev == NULL)
164  return -EFAULT;
165 
166  framebuf = dev->read_frame;
167 
168  if (framebuf == NULL)
169  return -EFAULT;
170 
171  image = dev->image_data;
172  image += dev->images[dev->fill_image].offset;
173 
174  data = framebuf->data;
175 
176  switch (dev->resolution) {
177  case STK11XX_80x60:
178  factor = 8;
179  break;
180 
181  case STK11XX_128x96:
182  factor = 5;
183  break;
184 
185  case STK11XX_160x120:
186  factor = 4;
187  break;
188 
189  case STK11XX_213x160:
190  factor = 3;
191  break;
192 
193  case STK11XX_320x240:
194  factor = 2;
195  break;
196 
197  case STK11XX_640x480:
198  factor = 1;
199  break;
200 
201  case STK11XX_800x600:
202  factor = 1;
203  break;
204 
205  case STK11XX_1024x768:
206  factor = 1;
207  break;
208 
209  case STK11XX_1280x1024:
210  factor = 1;
211  break;
212 
213  default:
214  return -EFAULT;
215  }
216 
217 
218  switch (dev->vsettings.palette) {
219  case STK11XX_PALETTE_RGB24:
220  stk11xx_b2rgb24(data, image, &dev->image, &dev->view,
221  dev->vsettings.hflip, dev->vsettings.vflip, factor);
222  break;
223 
224  case STK11XX_PALETTE_RGB32:
225  stk11xx_b2rgb32(data, image, &dev->image, &dev->view,
226  dev->vsettings.hflip, dev->vsettings.vflip, factor);
227  break;
228 
229  case STK11XX_PALETTE_BGR24:
230  stk11xx_b2bgr24(data, image, &dev->image, &dev->view,
231  dev->vsettings.hflip, dev->vsettings.vflip, factor);
232  break;
233 
234  case STK11XX_PALETTE_BGR32:
235  stk11xx_b2bgr32(data, image, &dev->image, &dev->view,
236  dev->vsettings.hflip, dev->vsettings.vflip, factor);
237  break;
238 
239  case STK11XX_PALETTE_UYVY:
240  stk11xx_b2uyvy(data, image, &dev->image, &dev->view,
241  dev->vsettings.hflip, dev->vsettings.vflip, factor);
242  break;
243 
244  case STK11XX_PALETTE_YUYV:
245  stk11xx_b2yuyv(data, image, &dev->image, &dev->view,
246  dev->vsettings.hflip, dev->vsettings.vflip, factor);
247  break;
248  }
249 
250  stk11xx_correct_brightness(image, dev->view.x, dev->view.y,
252 
253  return 0;
254 }
255 
256 
270 void stk11xx_correct_brightness(uint8_t *img, const int width, const int height,
271  const int brightness, int palette, int depth)
272 {
273  int i;
274  int x;
275 
276 
277  switch (palette) {
278  case STK11XX_PALETTE_RGB24:
279  case STK11XX_PALETTE_BGR24:
280  case STK11XX_PALETTE_RGB32:
281  case STK11XX_PALETTE_BGR32:
282  depth = (depth == 24) ? 3 : 4;
283 
284  if (brightness >= 32767) {
285  x = (brightness - 32767) / 256;
286 
287  for (i = 0; i < (width * height * depth); i++) {
288  if ((*(img + i) + (unsigned char) x) > 255)
289  *(img + i) = 255;
290  else
291  *(img + i) += (unsigned char) x;
292  }
293  }
294  else {
295  x = (32767 - brightness) / 256;
296 
297  for (i = 0; i < (width * height * depth); i++) {
298  if ((unsigned char) x > *(img + i))
299  *(img + i) = 0;
300  else
301  *(img + i) -= (unsigned char) x;
302  }
303  }
304 
305  break;
306 
307  case STK11XX_PALETTE_UYVY:
308  depth = 2;
309 
310  if (brightness >= 32767) {
311  x = (brightness - 32767) / 256;
312 
313  for (i = 1; i < (width * height * depth); i=i+depth) {
314  if ((*(img + i) + (unsigned char) x) > 255)
315  *(img + i) = 255;
316  else
317  *(img + i) += (unsigned char) x;
318  }
319  }
320  else {
321  x = (32767 - brightness) / 256;
322 
323  for (i = 1; i < (width * height * depth); i=i+depth) {
324  if ((unsigned char) x > *(img + i))
325  *(img + i) = 0;
326  else
327  *(img + i) -= (unsigned char) x;
328  }
329  }
330 
331  break;
332 
333  case STK11XX_PALETTE_YUYV:
334  depth = 2;
335 
336  if (brightness >= 32767) {
337  x = (brightness - 32767) / 256;
338 
339  for (i = 0; i < (width * height * depth); i=i+depth) {
340  if ((*(img + i) + (unsigned char) x) > 255)
341  *(img + i) = 255;
342  else
343  *(img + i) += (unsigned char) x;
344  }
345  }
346  else {
347  x = (32767 - brightness) / 256;
348 
349  for (i = 0; i < (width * height * depth); i=i+depth) {
350  if ((unsigned char) x > *(img + i))
351  *(img + i) = 0;
352  else
353  *(img + i) -= (unsigned char) x;
354  }
355  }
356 
357  break;
358  }
359 }
360 
361 
374 void stk11xx_b2rgb24(uint8_t *bayer, uint8_t *rgb,
375  struct stk11xx_coord *image,
376  struct stk11xx_coord *view,
377  const int hflip, const int vflip,
378  const int factor) {
379  uint8_t *b;
380 
381  int x, y; // Position in bayer image
382  int i, j; // Position in rgb image
383 
384  int width = image->x;
385  int height = image->y;
386 
387  int nwidth = width / factor;
388  int nheight = height / factor;
389 
390  int offset;
391  int startx, stepx;
392  int starty, stepy;
393 
394 
395  // Calculate the initial position (on Y axis)
396  if (vflip) {
397  starty = height - 2;
398  stepy = -factor;
399  }
400  else {
401  starty = 0;
402  stepy = factor;
403  }
404 
405  // Calculate the initial position (on X axis)
406  if (hflip) {
407  startx = width - 1;
408  stepx = -factor;
409  offset = width - 2;
410  }
411  else {
412  startx = 0;
413  stepx = factor;
414  offset = 1;
415  }
416 
417 
418  // Skip the first line
419  bayer += width;
420 
421  // To center vertically the image in the view
422  rgb += ((view->y - nheight) / 2) * view->x * 3;
423 
424  // To center horizontally the image in the view
425  rgb += ((view->x - nwidth) / 2) * 3;
426 
427  // Clean the first line
428  memset(rgb, 0, nwidth * 3);
429  rgb += nwidth * 3;
430 
431 
432  // For each rgb line without the borders (first and last line)
433  for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
434  // Go to the start of line
435  b = bayer + y * width + offset;
436 
437  // Offset to center horizontally the image in the view
438  rgb += (view->x - nwidth) * 3;
439 
440  if (y & 0x1) {
441  // Skip the first pixel
442  *rgb++ = 0;
443  *rgb++ = 0;
444  *rgb++ = 0;
445 
446  // GBGBGB : Line process...
447  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
448  if (x & 0x1) {
449  *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
450  *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
451  *rgb++ = *b;
452  }
453  else {
454  *rgb++ = (*(b-width) + *(b+width)) >> 1;
455  *rgb++ = *b;
456  *rgb++ = (*(b-1) + *(b+1)) >> 1;
457  }
458 
459  b += stepx;
460  }
461 
462  // Skip the last pixel
463  *rgb++ = 0;
464  *rgb++ = 0;
465  *rgb++ = 0;
466  }
467  else {
468  // Skip the first pixel
469  *rgb++ = 0;
470  *rgb++ = 0;
471  *rgb++ = 0;
472 
473  // RGRGRG : Line process...
474  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
475  if (x & 0x1) {
476  *rgb++ = (*(b-1) + *(b+1)) >> 1;
477  *rgb++ = *b;
478  *rgb++ = (*(b-width) + *(b+width)) >> 1;
479  }
480  else {
481  *rgb++ = *b;
482  *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
483  *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
484  }
485 
486  b += stepx;
487  }
488 
489  // Skip the last pixel
490  *rgb++ = 0;
491  *rgb++ = 0;
492  *rgb++ = 0;
493  }
494  }
495 
496  // Clean the last line
497  memset(rgb, 0, nwidth * 3);
498 }
499 
500 
513 void stk11xx_b2rgb32(uint8_t *bayer, uint8_t *rgb,
514  struct stk11xx_coord *image,
515  struct stk11xx_coord *view,
516  const int hflip, const int vflip,
517  const int factor) {
518  uint8_t *b;
519 
520  int x, y; // Position in bayer image
521  int i, j; // Position in rgb image
522 
523  int width = image->x;
524  int height = image->y;
525 
526  int nwidth = width / factor;
527  int nheight = height / factor;
528 
529  int offset;
530  int startx, stepx;
531  int starty, stepy;
532 
533 
534  // Calculate the initial position (on Y axis)
535  if (vflip) {
536  starty = height - 2;
537  stepy = -factor;
538  }
539  else {
540  starty = 0;
541  stepy = factor;
542  }
543 
544  // Calculate the initial position (on X axis)
545  if (hflip) {
546  startx = width - 1;
547  stepx = -factor;
548  offset = width - 2;
549  }
550  else {
551  startx = 0;
552  stepx = factor;
553  offset = 1;
554  }
555 
556 
557  // Skip the first line
558  bayer += width;
559 
560  // To center vertically the image in the view
561  rgb += ((view->y - nheight) / 2) * view->x * 4;
562 
563  // To center horizontally the image in the view
564  rgb += ((view->x - nwidth) / 2) * 4;
565 
566  // Clean the first line
567  memset(rgb, 0, nwidth * 4);
568  rgb += nwidth * 4;
569 
570 
571  // For each rgb line without the borders (first and last line)
572  for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
573  // Go to the start of line
574  b = bayer + y * width + offset;
575 
576  // Offset to center horizontally the image in the view
577  rgb += (view->x - nwidth) * 4;
578 
579  if (y & 0x1) {
580  // Skip the first pixel
581  *rgb++ = 0;
582  *rgb++ = 0;
583  *rgb++ = 0;
584  *rgb++ = 0;
585 
586  // GBGBGB : Line process...
587  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
588  if (x & 0x1) {
589  *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
590  *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
591  *rgb++ = *b;
592  *rgb++ = 0;
593  }
594  else {
595  *rgb++ = (*(b-width) + *(b+width)) >> 1;
596  *rgb++ = *b;
597  *rgb++ = (*(b-1) + *(b+1)) >> 1;
598  *rgb++ = 0;
599  }
600 
601  b += stepx;
602  }
603 
604  // Skip the last pixel
605  *rgb++ = 0;
606  *rgb++ = 0;
607  *rgb++ = 0;
608  *rgb++ = 0;
609  }
610  else {
611  // Skip the first pixel
612  *rgb++ = 0;
613  *rgb++ = 0;
614  *rgb++ = 0;
615  *rgb++ = 0;
616 
617  // RGRGRG : Line process...
618  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
619  if (x & 0x1) {
620  *rgb++ = (*(b-1) + *(b+1)) >> 1;
621  *rgb++ = *b;
622  *rgb++ = (*(b-width) + *(b+width)) >> 1;
623  *rgb++ = 0;
624  }
625  else {
626  *rgb++ = *b;
627  *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
628  *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
629  *rgb++ = 0;
630  }
631 
632  b += stepx;
633  }
634 
635  // Skip the last pixel
636  *rgb++ = 0;
637  *rgb++ = 0;
638  *rgb++ = 0;
639  *rgb++ = 0;
640  }
641  }
642 
643  // Clean the last line
644  memset(rgb, 0, nwidth * 4);
645 }
646 
647 
660 void stk11xx_b2bgr24(uint8_t *bayer, uint8_t *bgr,
661  struct stk11xx_coord *image,
662  struct stk11xx_coord *view,
663  const int hflip, const int vflip,
664  const int factor) {
665  uint8_t *b;
666 
667  int x, y; // Position in bayer image
668  int i, j; // Position in bgr image
669 
670  int width = image->x;
671  int height = image->y;
672 
673  int nwidth = width / factor;
674  int nheight = height / factor;
675 
676  int offset;
677  int startx, stepx;
678  int starty, stepy;
679 
680 
681  // Calculate the initial position (on Y axis)
682  if (vflip) {
683  starty = height - 2;
684  stepy = -factor;
685  }
686  else {
687  starty = 0;
688  stepy = factor;
689  }
690 
691  // Calculate the initial position (on X axis)
692  if (hflip) {
693  startx = width - 1;
694  stepx = -factor;
695  offset = width - 2;
696  }
697  else {
698  startx = 0;
699  stepx = factor;
700  offset = 1;
701  }
702 
703 
704  // Skip the first line
705  bayer += width;
706 
707  // To center vertically the image in the view
708  bgr += ((view->y - nheight) / 2) * view->x * 3;
709 
710  // To center horizontally the image in the view
711  bgr += ((view->x - nwidth) / 2) * 3;
712 
713  // Clean the first line
714  memset(bgr, 0, nwidth * 3);
715  bgr += nwidth * 3;
716 
717 
718  // For each bgr line without the borders (first and last line)
719  for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
720  // Go to the start of line
721  b = bayer + y * width + offset;
722 
723  // Offset to center horizontally the image in the view
724  bgr += (view->x - nwidth) * 3;
725 
726  if (y & 0x1) {
727  // Skip the first pixel
728  *bgr++ = 0;
729  *bgr++ = 0;
730  *bgr++ = 0;
731 
732  // GBGBGB : Line process...
733  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
734  if (x & 0x1) {
735  *bgr++ = *b;
736  *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
737  *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
738  }
739  else {
740  *bgr++ = (*(b-1) + *(b+1)) >> 1;
741  *bgr++ = *b;
742  *bgr++ = (*(b-width) + *(b+width)) >> 1;
743  }
744 
745  b += stepx;
746  }
747 
748  // Skip the last pixel
749  *bgr++ = 0;
750  *bgr++ = 0;
751  *bgr++ = 0;
752  }
753  else {
754  // Skip the first pixel
755  *bgr++ = 0;
756  *bgr++ = 0;
757  *bgr++ = 0;
758 
759  // RGRGRG : Line process...
760  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
761  if (x & 0x1) {
762  *bgr++ = (*(b-width) + *(b+width)) >> 1;
763  *bgr++ = *b;
764  *bgr++ = (*(b-1) + *(b+1)) >> 1;
765  }
766  else {
767  *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
768  *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
769  *bgr++ = *b;
770  }
771 
772  b += stepx;
773  }
774 
775  // Skip the last pixel
776  *bgr++ = 0;
777  *bgr++ = 0;
778  *bgr++ = 0;
779  }
780  }
781 
782  // Clean the last line
783  memset(bgr, 0, nwidth * 3);
784 }
785 
786 
799 void stk11xx_b2bgr32(uint8_t *bayer, uint8_t *bgr,
800  struct stk11xx_coord *image,
801  struct stk11xx_coord *view,
802  const int hflip, const int vflip,
803  const int factor) {
804  uint8_t *b;
805 
806  int x, y; // Position in bayer image
807  int i, j; // Position in bgr image
808 
809  int width = image->x;
810  int height = image->y;
811 
812  int nwidth = width / factor;
813  int nheight = height / factor;
814 
815  int offset;
816  int startx, stepx;
817  int starty, stepy;
818 
819 
820  // Calculate the initial position (on Y axis)
821  if (vflip) {
822  starty = height - 2;
823  stepy = -factor;
824  }
825  else {
826  starty = 0;
827  stepy = factor;
828  }
829 
830  // Calculate the initial position (on X axis)
831  if (hflip) {
832  startx = width - 1;
833  stepx = -factor;
834  offset = width - 2;
835  }
836  else {
837  startx = 0;
838  stepx = factor;
839  offset = 1;
840  }
841 
842 
843  // Skip the first line
844  bayer += width;
845 
846  // To center vertically the image in the view
847  bgr += ((view->y - nheight) / 2) * view->x * 4;
848 
849  // To center horizontally the image in the view
850  bgr += ((view->x - nwidth) / 2) * 4;
851 
852  // Clean the first line
853  memset(bgr, 0, nwidth * 4);
854  bgr += nwidth * 4;
855 
856 
857  // For each bgr line without the borders (first and last line)
858  for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
859  // Go to the start of line
860  b = bayer + y * width + offset;
861 
862  // Offset to center horizontally the image in the view
863  bgr += (view->x - nwidth) * 4;
864 
865  if (y & 0x1) {
866  // Skip the first pixel
867  *bgr++ = 0;
868  *bgr++ = 0;
869  *bgr++ = 0;
870  *bgr++ = 0;
871 
872  // GBGBGB : Line process...
873  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
874  if (x & 0x1) {
875  *bgr++ = *b;
876  *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
877  *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
878  *bgr++ = 0;
879  }
880  else {
881  *bgr++ = (*(b-1) + *(b+1)) >> 1;
882  *bgr++ = *b;
883  *bgr++ = (*(b-width) + *(b+width)) >> 1;
884  *bgr++ = 0;
885  }
886 
887  b += stepx;
888  }
889 
890  // Skip the last pixel
891  *bgr++ = 0;
892  *bgr++ = 0;
893  *bgr++ = 0;
894  *bgr++ = 0;
895  }
896  else {
897  // Skip the first pixel
898  *bgr++ = 0;
899  *bgr++ = 0;
900  *bgr++ = 0;
901  *bgr++ = 0;
902 
903  // RGRGRG : Line process...
904  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
905  if (x & 0x1) {
906  *bgr++ = (*(b-width) + *(b+width)) >> 1;
907  *bgr++ = *b;
908  *bgr++ = (*(b-1) + *(b+1)) >> 1;
909  *bgr++ = 0;
910  }
911  else {
912  *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
913  *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
914  *bgr++ = *b;
915  *bgr++ = 0;
916  }
917 
918  b += stepx;
919  }
920 
921  // Skip the last pixel
922  *bgr++ = 0;
923  *bgr++ = 0;
924  *bgr++ = 0;
925  *bgr++ = 0;
926  }
927  }
928 
929  // Clean the last line
930  memset(bgr, 0, nwidth * 4);
931 }
932 
933 
946 void stk11xx_b2uyvy(uint8_t *bayer, uint8_t *yuv,
947  struct stk11xx_coord *image,
948  struct stk11xx_coord *view,
949  const int hflip, const int vflip,
950  const int factor) {
951  uint8_t *b;
952 
953  int x, y; // Position in bayer image
954  int i, j; // Position in yuv image
955 
956  int pR, pG, pB;
957  int pY, pU, pV;
958 
959  int width = image->x;
960  int height = image->y;
961 
962  int nwidth = width / factor;
963  int nheight = height / factor;
964 
965  int offset;
966  int startx, stepx;
967  int starty, stepy;
968 
969 
970  // Calculate the initial position (on Y axis)
971  if (vflip) {
972  starty = height - 2;
973  stepy = -factor;
974  }
975  else {
976  starty = 0;
977  stepy = factor;
978  }
979 
980  // Calculate the initial position (on X axis)
981  if (hflip) {
982  startx = width - 1;
983  stepx = -factor;
984  offset = width - 2;
985  }
986  else {
987  startx = 0;
988  stepx = factor;
989  offset = 1;
990  }
991 
992  // Background color...
993  memset(yuv, 16, width * 2);
994  for (i=0; i<width*2; i=i+2, *(yuv+i)=128);
995  for (i=1; i<height; i++)
996  memcpy(yuv+i*width*2, yuv, width*2);
997 
998  // Skip the first line
999  bayer += width;
1000 
1001  // To center vertically the image in the view
1002  yuv += ((view->y - nheight) / 2) * view->x * 2;
1003 
1004  // To center horizontally the image in the view
1005  yuv += ((view->x - nwidth) / 2) * 2;
1006 
1007  // Clean the first line
1008  memset(yuv, 16, nwidth * 2);
1009  for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=128);
1010  yuv += nwidth * 2;
1011 
1012 
1013  // For each yuv line without the borders (first and last line)
1014  for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
1015  // Go to the start of line
1016  b = bayer + y * width + offset;
1017 
1018  // Offset to center horizontally the image in the view
1019  yuv += (view->x - nwidth) * 2;
1020 
1021  if (y & 0x1) {
1022  // Skip the first pixel
1023  *yuv++ = 128;
1024  *yuv++ = 16;
1025 
1026  // GBGBGB : Line process...
1027  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1028  if (x & 0x1) {
1029  pR = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1030  pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1031  pB = *b;
1032  }
1033  else {
1034  pR = (*(b-width) + *(b+width)) >> 1;
1035  pG = *b;
1036  pB = (*(b-1) + *(b+1)) >> 1;
1037  }
1038 
1039  pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1040  pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1041  pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1042 
1043  pY = CLIP(pY, 0,255);
1044  pU = CLIP(pU, -127,127);
1045  pV = CLIP(pV, -127,127);
1046 
1047  if (i % 2){
1048  *yuv++ = (112 * pU)/127 + 128; // U
1049  *yuv++ = (219 * pY)/255 + 16; // Y
1050  }
1051  else {
1052  *yuv++ = (112 * pV)/127 + 128; // V
1053  *yuv++ = (219 * pY)/255 + 16; // Y
1054  }
1055 
1056  b += stepx;
1057  }
1058 
1059  // Skip the last pixel
1060  *yuv++ = 128;
1061  *yuv++ = 16;
1062  }
1063  else {
1064  // Skip the first pixel
1065  *yuv++ = 128;
1066  *yuv++ = 16;
1067 
1068  // RGRGRG : Line process...
1069  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1070  if (x & 0x1) {
1071  pR = (*(b-1) + *(b+1)) >> 1;
1072  pG = *b;
1073  pB = (*(b-width) + *(b+width)) >> 1;
1074  }
1075  else {
1076  pR = *b;
1077  pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1078  pB = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1079  }
1080 
1081  pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1082  pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1083  pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1084 
1085  pY = CLIP(pY, 0,255);
1086  pU = CLIP(pU, -127,127);
1087  pV = CLIP(pV, -127,127);
1088 
1089  if (i % 2){
1090  *yuv++ = (112 * pU)/127 + 128; // U
1091  *yuv++ = (219 * pY)/255 + 16; // Y
1092  }
1093  else {
1094  *yuv++ = (112 * pV)/127 + 128; // V
1095  *yuv++ = (219 * pY)/255 + 16; // Y
1096  }
1097 
1098  b += stepx;
1099  }
1100 
1101  // Skip the last pixel
1102  *yuv++ = 128;
1103  *yuv++ = 16;
1104  }
1105  }
1106 
1107  // Clean the last line
1108  memset(yuv, 16, nwidth * 2);
1109  for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=128);
1110 }
1111 
1112 
1125 void stk11xx_b2yuyv(uint8_t *bayer, uint8_t *yuv,
1126  struct stk11xx_coord *image,
1127  struct stk11xx_coord *view,
1128  const int hflip, const int vflip,
1129  const int factor) {
1130  uint8_t *b;
1131 
1132  int x, y; // Position in bayer image
1133  int i, j; // Position in yuv image
1134 
1135  int pR, pG, pB;
1136  int pY, pU, pV;
1137 
1138  int width = image->x;
1139  int height = image->y;
1140 
1141  int nwidth = width / factor;
1142  int nheight = height / factor;
1143 
1144  int offset;
1145  int startx, stepx;
1146  int starty, stepy;
1147 
1148 
1149  // Calculate the initial position (on Y axis)
1150  if (vflip) {
1151  starty = height - 2;
1152  stepy = -factor;
1153  }
1154  else {
1155  starty = 0;
1156  stepy = factor;
1157  }
1158 
1159  // Calculate the initial position (on X axis)
1160  if (hflip) {
1161  startx = width - 1;
1162  stepx = -factor;
1163  offset = width - 2;
1164  }
1165  else {
1166  startx = 0;
1167  stepx = factor;
1168  offset = 1;
1169  }
1170 
1171  // Background color...
1172  memset(yuv, 128, width * 2);
1173  for (i=0; i<width*2; i=i+2, *(yuv+i)=16);
1174  for (i=1; i<height; i++)
1175  memcpy(yuv+i*width*2, yuv, width*2);
1176 
1177  // Skip the first line
1178  bayer += width;
1179 
1180  // To center vertically the image in the view
1181  yuv += ((view->y - nheight) / 2) * view->x * 2;
1182 
1183  // To center horizontally the image in the view
1184  yuv += ((view->x - nwidth) / 2) * 2;
1185 
1186  // Clean the first line
1187  memset(yuv, 128, nwidth * 2);
1188  for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=16);
1189  yuv += nwidth * 2;
1190 
1191 
1192  // For each yuv line without the borders (first and last line)
1193  for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
1194  // Go to the start of line
1195  b = bayer + y * width + offset;
1196 
1197  // Offset to center horizontally the image in the view
1198  yuv += (view->x - nwidth) * 2;
1199 
1200  if (y & 0x1) {
1201  // Skip the first pixel
1202  *yuv++ = 16;
1203  *yuv++ = 128;
1204 
1205  // GBGBGB : Line process...
1206  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1207  if (x & 0x1) {
1208  pR = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1209  pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1210  pB = *b;
1211  }
1212  else {
1213  pR = (*(b-width) + *(b+width)) >> 1;
1214  pG = *b;
1215  pB = (*(b-1) + *(b+1)) >> 1;
1216  }
1217 
1218  pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1219  pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1220  pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1221 
1222  pY = CLIP(pY, 0,255);
1223  pU = CLIP(pU, -127,127);
1224  pV = CLIP(pV, -127,127);
1225 
1226  if (i % 2){
1227  *yuv++ = (219 * pY)/255 + 16; // Y
1228  *yuv++ = (112 * pU)/127 + 128; // U
1229  }
1230  else {
1231  *yuv++ = (219 * pY)/255 + 16; // Y
1232  *yuv++ = (112 * pV)/127 + 128; // V
1233  }
1234 
1235  b += stepx;
1236  }
1237 
1238  // Skip the last pixel
1239  *yuv++ = 16;
1240  *yuv++ = 128;
1241  }
1242  else {
1243  // Skip the first pixel
1244  *yuv++ = 16;
1245  *yuv++ = 128;
1246 
1247  // RGRGRG : Line process...
1248  for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1249  if (x & 0x1) {
1250  pR = (*(b-1) + *(b+1)) >> 1;
1251  pG = *b;
1252  pB = (*(b-width) + *(b+width)) >> 1;
1253  }
1254  else {
1255  pR = *b;
1256  pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1257  pB = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1258  }
1259 
1260  pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1261  pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1262  pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1263 
1264  pY = CLIP(pY, 0,255);
1265  pU = CLIP(pU, -127,127);
1266  pV = CLIP(pV, -127,127);
1267 
1268  if (i % 2){
1269  *yuv++ = (219 * pY)/255 + 16; // Y
1270  *yuv++ = (112 * pU)/127 + 128; // U
1271  }
1272  else {
1273  *yuv++ = (219 * pY)/255 + 16; // Y
1274  *yuv++ = (112 * pV)/127 + 128; // V
1275  }
1276 
1277  b += stepx;
1278  }
1279 
1280  // Skip the last pixel
1281  *yuv++ = 16;
1282  *yuv++ = 128;
1283  }
1284  }
1285 
1286  // Clean the last line
1287  memset(yuv, 128, nwidth * 2);
1288  for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=16);
1289 }
1290 
1291 
stk11xx_b2bgr32
void stk11xx_b2bgr32(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to BGR32.
Definition: stk11xx-bayer.c:799
stk11xx_video::hflip
int hflip
Definition: stk11xx.h:285
stk11xx_video::brightness
int brightness
Definition: stk11xx.h:278
stk11xx_coord
Definition: stk11xx.h:267
stk11xx_coord::x
int x
Definition: stk11xx.h:268
stk11xx.h
Driver for Syntek USB video camera.
stk11xx_b2rgb32
void stk11xx_b2rgb32(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to RGB32.
Definition: stk11xx-bayer.c:513
stk11xx_b2uyvy
void stk11xx_b2uyvy(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to YUV (UYVY)
Definition: stk11xx-bayer.c:946
brightness
static int brightness
Definition: stk11xx-usb.c:1053
stk11xx_frame_buf
Definition: stk11xx.h:247
stk11xx_video::vflip
int vflip
Definition: stk11xx.h:286
stk11xx_image_buf::offset
unsigned long offset
Definition: stk11xx.h:259
stk11xx_video::palette
int palette
Definition: stk11xx.h:283
stk11xx_video::depth
int depth
Definition: stk11xx.h:282
stk11xx_b2yuyv
void stk11xx_b2yuyv(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to YUV (YUYV)
Definition: stk11xx-bayer.c:1125
stk11xx_b2bgr24
void stk11xx_b2bgr24(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to BGR24.
Definition: stk11xx-bayer.c:660
stk11xx_b2rgb24
void stk11xx_b2rgb24(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to RGB24.
Definition: stk11xx-bayer.c:374
stk11xx_decompress
int stk11xx_decompress(struct usb_stk11xx *dev)
Decompress a frame.
Definition: stk11xx-bayer.c:155
usb_stk11xx
Definition: stk11xx.h:301
vflip
static int vflip
Definition: stk11xx-usb.c:1047
usb_stk11xx::vsettings
struct stk11xx_video vsettings
Definition: stk11xx.h:319
stk11xx_coord::y
int y
Definition: stk11xx.h:269
hflip
static int hflip
Definition: stk11xx-usb.c:1041
stk11xx_correct_brightness
void stk11xx_correct_brightness(uint8_t *, const int, const int, const int, int, int)
Correct the brightness of an image.
Definition: stk11xx-bayer.c:270