Added quick'n'bad debayer implementation for previews
This commit is contained in:
parent
5c0611c64f
commit
243ef89cb5
11
main.c
11
main.c
|
@ -15,6 +15,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "ini.h"
|
#include "ini.h"
|
||||||
#include "bayer.h"
|
#include "bayer.h"
|
||||||
|
#include "quickdebayer.h"
|
||||||
|
|
||||||
enum io_method {
|
enum io_method {
|
||||||
IO_METHOD_READ,
|
IO_METHOD_READ,
|
||||||
|
@ -370,12 +371,14 @@ process_image(const int *p, int size)
|
||||||
method = DC1394_BAYER_METHOD_SIMPLE;
|
method = DC1394_BAYER_METHOD_SIMPLE;
|
||||||
// method = DC1394_BAYER_METHOD_VNG is slightly sharper but takes 10 seconds;
|
// method = DC1394_BAYER_METHOD_VNG is slightly sharper but takes 10 seconds;
|
||||||
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, current_width, current_height);
|
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, current_width, current_height);
|
||||||
} else {
|
|
||||||
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, current_width / 2, current_height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
pixels = gdk_pixbuf_get_pixels(pixbuf);
|
pixels = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
dc1394_bayer_decoding_8bit((const uint8_t *) p, pixels, current_width, current_height, filter, method);
|
dc1394_bayer_decoding_8bit((const uint8_t *) p, pixels, current_width, current_height, filter, method);
|
||||||
|
} else {
|
||||||
|
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, current_width / 6, current_height / 6);
|
||||||
|
pixels = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
|
quick_debayer_bggr8((const uint8_t *)p, pixels, current_width, current_height, 3);
|
||||||
|
}
|
||||||
|
|
||||||
if (current_rotate == 0) {
|
if (current_rotate == 0) {
|
||||||
pixbufrot = pixbuf;
|
pixbufrot = pixbuf;
|
||||||
} else if (current_rotate == 90) {
|
} else if (current_rotate == 90) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ gtkdep = dependency('gtk+-3.0')
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
libm = cc.find_library('m', required: false)
|
libm = cc.find_library('m', required: false)
|
||||||
|
|
||||||
executable('megapixels', 'main.c', 'ini.c', 'bayer.c', dependencies : [gtkdep, libm], install : true)
|
executable('megapixels', 'main.c', 'ini.c', 'bayer.c', 'quickdebayer.c', dependencies : [gtkdep, libm], install : true)
|
||||||
|
|
||||||
install_data(['camera.glade', 'camera.css'],
|
install_data(['camera.glade', 'camera.css'],
|
||||||
install_dir : get_option('datadir') / 'megapixels/ui')
|
install_dir : get_option('datadir') / 'megapixels/ui')
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "quickdebayer.h"
|
||||||
|
|
||||||
|
// Fast but bad debayer method that scales and rotates by skipping source pixels and
|
||||||
|
// doesn't interpolate any values at all
|
||||||
|
|
||||||
|
void
|
||||||
|
quick_debayer_bggr8(const uint8_t *source, uint8_t *destination, int width, int height, int skip)
|
||||||
|
{
|
||||||
|
int byteskip = 2 * skip;
|
||||||
|
int input_size = width * height;
|
||||||
|
int i;
|
||||||
|
int j=0;
|
||||||
|
int row_left = width;
|
||||||
|
|
||||||
|
// B G
|
||||||
|
// G R
|
||||||
|
for(i=0;i<input_size;) {
|
||||||
|
destination[j++] = source[i+width+1];
|
||||||
|
destination[j++] = source[i+1];
|
||||||
|
destination[j++] = source[i];
|
||||||
|
i = i + byteskip;
|
||||||
|
row_left = row_left - byteskip;
|
||||||
|
if(row_left <= 0){
|
||||||
|
row_left = width;
|
||||||
|
i = i+width;
|
||||||
|
i = i + (width * 2 * (skip-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void quick_debayer_bggr8(const uint8_t *source, uint8_t *destination, int width, int height, int skip);
|
||||||
|
|
Loading…
Reference in New Issue