From c01339b7b923523cc32d3e2d64688f7648d63972 Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Thu, 18 Apr 2024 18:51:02 +0200 Subject: [PATCH] SER should now work with RAW video data --- configuration.cc | 7 +------ configuration.h | 1 + convert.cc | 49 +++++++++--------------------------------------- debug.cc | 4 +++- gui.cc | 9 +++++++++ main.cc | 5 ++++- videoframe.cc | 40 --------------------------------------- 7 files changed, 27 insertions(+), 88 deletions(-) diff --git a/configuration.cc b/configuration.cc index 9d28ab2..82fab60 100644 --- a/configuration.cc +++ b/configuration.cc @@ -16,6 +16,7 @@ Configuration::Configuration() { debugpath = NULL; readdumppath = NULL; destpath = "./"; + show_debugwin = 0; }; @@ -362,12 +363,6 @@ void Configuration::LoadConfig(std::string filename) { } } - printf ("%s:%d show debug window\n", __FILE__, __LINE__); - GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "window-debug")); - if (wnd) { - gtk_widget_show (wnd); - } - setlocale (LC_ALL, s.c_str()); // we need to update the gui so floating numbers will displayed with the correct diff --git a/configuration.h b/configuration.h index 8ce3bb0..9b6bb62 100644 --- a/configuration.h +++ b/configuration.h @@ -27,6 +27,7 @@ public: char *debugpath; char *readdumppath; int debayer_mode = 0; // 0..simple mode, 1..bilinear + int show_debugwin = 0; Configuration(); ~Configuration(); diff --git a/convert.cc b/convert.cc index 27c722b..9d5c795 100644 --- a/convert.cc +++ b/convert.cc @@ -142,9 +142,6 @@ void convert_debug_dumpframe(unsigned char *ptrsrc, int srcsize, uint32_t pixelf * close file and reset all data */ void convert_debug_close() { - - printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); - if (convert_debug_fd != -1) { close (convert_debug_fd); convert_debug_fd = -1; @@ -513,11 +510,13 @@ int PixCopy(unsigned char *srcdata, uint32_t srcpixfmt, int srcw, int srch, switch (srcpixfmt) { case (V4L2_PIX_FMT_SGRBG8): + bytesperpixel = 1; + break; + case (V4L2_PIX_FMT_SGRBG16): bytesperpixel = 2; break; case (V4L2_PIX_FMT_BGR32): case (V4L2_PIX_FMT_RGB32): - case (V4L2_PIX_FMT_SGRBG16): bytesperpixel = 4; break; case (V4L2_PIX_FMT_BGR24): @@ -528,8 +527,6 @@ int PixCopy(unsigned char *srcdata, uint32_t srcpixfmt, int srcw, int srch, return 0; } - debug_drawraw(srcdata, srcpixfmt, srcw, srch); - // // calculate image size and allocate memory if needed dsize = (*dsth) * (*dstw) * bytesperpixel; @@ -540,46 +537,18 @@ int PixCopy(unsigned char *srcdata, uint32_t srcpixfmt, int srcw, int srch, } unsigned char *dptr, *sptr; - int y, dy, x, dx, i, d; + int y, dy, x, dx; + // debug_drawraw(srcdata, srcpixfmt, srcw, srch); for (y = regiony & (~1), dy = 0; dy < *dsth && y < srch; y++, dy++) { - for (x = regionx & (~1), dx = 0; dx < *dstw && x < srcw; x++, dx++) { - dptr = (*dstdataptr) + bytesperpixel * ( dy * *dstw + dx); - sptr = (srcdata) + bytesperpixel * ( y * srcw + x); - for (d = 0, i = 0; i < bytesperpixel; i++) { - dptr[i] = sptr[i]; - d += sptr[i]; - } -// printf (" %-3d",d); - } -// printf ("\n"); - } -// printf ("%s:%d\n", __FILE__, __LINE__); - -/* int dy, y = regiony & (~1); - int dx, x; - - for (dptr = *dstdataptr, dy = 0; dy < *dsth; dy++, y++) { x = regionx & (~1); - sptr = (srcdata + bytesperpixel * (y * srcw + x)); -// printf ("\n"); - for (dx = 0; dx < (*dstw * bytesperpixel); dx++, dptr++, sptr++) { + dptr = (*dstdataptr) + bytesperpixel * (dy * *dstw); + sptr = (srcdata) + bytesperpixel * ( y * srcw + x); + for (dx = (*dstw*bytesperpixel); dx > 0; dx--, dptr++, sptr++) *dptr = *sptr; - - // printf ("%x[%x] ", *dptr, *sptr); - int x1, x2, y1, y2; - - y1 = (sptr - srcdata) / (bytesperpixel * srcw); - x1 = ((sptr - srcdata) % (bytesperpixel * srcw)) / bytesperpixel; - - y2 = (dptr - *dstdataptr) / (bytesperpixel * (*dstw)); - x2 = ((dptr - *dstdataptr) % (bytesperpixel * (*dstw))) / bytesperpixel; - - printf ("copy [%d , %d] ---> [ %d , %d] (%d , %d) Value: %d -> %d\n", x1,y1, x2, y2, dx, dy, *sptr, *dptr); - } } -*/ + if (config.show_debugwin) debug_drawraw(*dstdataptr, srcpixfmt, *dstw, *dsth); return 1; } diff --git a/debug.cc b/debug.cc index d0d3b42..0d43dc2 100644 --- a/debug.cc +++ b/debug.cc @@ -115,11 +115,13 @@ void debug_drawraw(unsigned char *data, int pixfmt, int w, int h) { switch (pixfmt) { case (V4L2_PIX_FMT_SGRBG8): + bytesperpixel = 1; + break; + case (V4L2_PIX_FMT_SGRBG16): bytesperpixel = 2; break; case (V4L2_PIX_FMT_BGR32): case (V4L2_PIX_FMT_RGB32): - case (V4L2_PIX_FMT_SGRBG16): bytesperpixel = 4; break; case (V4L2_PIX_FMT_BGR24): diff --git a/gui.cc b/gui.cc index 0ada65d..aef89b8 100644 --- a/gui.cc +++ b/gui.cc @@ -81,6 +81,15 @@ void cb_window_show (GtkWidget *widget, gpointer data) { // // load config and setup elements config.LoadDefault(); + + // + // show debug output window. + if (config.show_debugwin) { + printf ("%s:%d show debug window\n", __FILE__, __LINE__); + GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "window-debug")); + if (wnd) gtk_widget_show (wnd); + } + GtkWidget *cfg_rgbenc = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "menu-settings-bilinearrgb")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(cfg_rgbenc), (config.debayer_mode != 0)); diff --git a/main.cc b/main.cc index d46dd04..3df575f 100644 --- a/main.cc +++ b/main.cc @@ -40,6 +40,7 @@ int main (int argc, char **argv) { printf ("Command Line Options for testing purpose:\n"); printf (" -d destination for video debugging path\n"); printf (" -dd disable debugging path\n"); + printf (" -dw show debug window\n"); printf ("\n"); printf (" -rd read video from dumpfile folder\n"); printf ("\n"); @@ -51,9 +52,11 @@ int main (int argc, char **argv) { config.debugpath = argv[i]; } if (strcmp (argv[i], "-dd") == 0) { - i++; config.debugpath = NULL; } + if (strcmp (argv[i], "-dw") == 0) { + config.show_debugwin = 1; + } if (strcmp (argv[i], "-rd") == 0) { i++; config.readdumppath = argv[i]; diff --git a/videoframe.cc b/videoframe.cc index d2a6a29..d7bdcea 100644 --- a/videoframe.cc +++ b/videoframe.cc @@ -42,14 +42,6 @@ int VideoFrameRaw::CopyFrom(int spixfmt, int sw, int sh, int ssize, unsigned cha pixfmt = spixfmt; memcpy (data, sdata, ssize); -/* int i, x, y, d; - for (y = 0; y < w; y++) for (x = 0; x < w; x++) { - for (i = 0, d = 0; i < 4; i++) { - d += data[4* (y*w+x)]; - } - if (d > 1000) printf ("%d,%d -> %d\n", x, y, d); - } -*/ return 1; } @@ -98,37 +90,6 @@ int VideoFrameRaw::RectCopyFrom(VideoFrameRaw *src, int rectx, int recty, int re &data, &size, &w, &h, rectx, recty, rectw, recth); -/* - for (int i = 0; i < size; i++) if (data[i] > 0) { - printf ("%s:%d found data in destination.\n", __FILE__, __LINE__); - break; - } - - for (int i = 0; i < src->size; i++) if (src->data[i] > 0) { - printf ("%s:%d found data in source.\n", __FILE__, __LINE__); - break; - } - - int bytesperpixel = 3; - int dsize = 0; - - switch (src->pixfmt) { - case (V4L2_PIX_FMT_SGRBG8): - bytesperpixel = 2; - break; - case (V4L2_PIX_FMT_BGR32): - case (V4L2_PIX_FMT_RGB32): - case (V4L2_PIX_FMT_SGRBG16): - bytesperpixel = 4; - break; - case (V4L2_PIX_FMT_BGR24): - case (V4L2_PIX_FMT_RGB24): - bytesperpixel = 3; - break; - default: - return 0; - } - */ return res; } @@ -233,7 +194,6 @@ void VideoFrame::CopyTo(FloatImage *dest) { } - void VideoFrame::ToPixbuf(GdkPixbuf** dest) { int destw, desth, bytelen; unsigned char *destpixel;