quickdebayer.c 751 B

12345678910111213141516171819202122232425262728293031
  1. #include "quickdebayer.h"
  2. // Fast but bad debayer method that scales and rotates by skipping source pixels and
  3. // doesn't interpolate any values at all
  4. void
  5. quick_debayer_bggr8(const uint8_t *source, uint8_t *destination, int width, int height, int skip)
  6. {
  7. int byteskip = 2 * skip;
  8. int input_size = width * height;
  9. int output_size = (width/byteskip) * (height/byteskip);
  10. int i;
  11. int j=0;
  12. int row_left = width;
  13. // B G
  14. // G R
  15. for(i=0;i<input_size;) {
  16. destination[j++] = source[i+width+1];
  17. destination[j++] = source[i+1];
  18. destination[j++] = source[i];
  19. i = i + byteskip;
  20. row_left = row_left - byteskip;
  21. if(row_left < byteskip){
  22. i = i + row_left;
  23. row_left = width;
  24. i = i + width;
  25. i = i + (width * 2 * (skip-1));
  26. }
  27. }
  28. }