aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-08-21 12:19:05 (GMT)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-08-21 12:19:05 (GMT)
commit4e0e3fc24f7884599c19b0672efb0f02e20cd25e (patch)
treeb542e892e40957b818b49e964091c1d6ece75fca
parent8b3967876f1c5feaba383f832660b2d74aff6391 (diff)
parent003564d7109424c3d2a788dd14b12b0cecfcb15e (diff)
Merge branch 'devel/fixes' into devel/gtkbuilder
* devel/fixes: v4l: make print_cam() useful v4l: Better name V4L bits per pixel field Fix depth on filters and fileio
-rw-r--r--demo.gifbin2237559 -> 2237559 bytes
-rw-r--r--demo.oggbin6018944 -> 6018944 bytes
-rw-r--r--src/callbacks.c20
-rw-r--r--src/fileio.c14
-rw-r--r--src/main.c6
-rw-r--r--src/v4l.c36
-rw-r--r--src/v4l.h3
7 files changed, 50 insertions, 29 deletions
diff --git a/demo.gif b/demo.gif
index b22401b..4b999d3 100644
--- a/demo.gif
+++ b/demo.gif
Binary files differ
diff --git a/demo.ogg b/demo.ogg
index a62e1bb..f90d965 100644
--- a/demo.ogg
+++ b/demo.ogg
Binary files differ
diff --git a/src/callbacks.c b/src/callbacks.c
index 8c7799d..3b30b92 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -487,8 +487,8 @@ static void
apply_filters(cam* cam) {
/* v4l has reverse rgb order from what camora expect so call the color
filter to fix things up before running the user selected filters */
- camorama_filter_color_filter(NULL, cam->pic_buf, cam->width, cam->height, cam->depth);
- camorama_filter_chain_apply(cam->filter_chain, cam->pic_buf, cam->width, cam->height, cam->depth);
+ camorama_filter_color_filter(NULL, cam->pic_buf, cam->width, cam->height, cam->bpp / 8);
+ camorama_filter_chain_apply(cam->filter_chain, cam->pic_buf, cam->width, cam->height, cam->bpp / 8);
#warning "FIXME: enable the threshold channel filter"
// if((effect_mask & CAMORAMA_FILTER_THRESHOLD_CHANNEL) != 0)
// threshold_channel (cam->pic_buf, cam->width, cam->height, cam->dither);
@@ -506,7 +506,7 @@ read_timeout_func(cam* cam) {
GdkGC *gc;
unsigned char *pic_buf = cam->pic_buf;
- v4l2_read (cam->dev, cam->pic_buf, (cam->width * cam->height * cam->depth / 8));
+ v4l2_read (cam->dev, cam->pic_buf, (cam->width * cam->height * cam->bpp / 8));
frames2++;
/*
* update_rec.x = 0;
@@ -520,7 +520,7 @@ read_timeout_func(cam* cam) {
*/
if (cam->pixformat == V4L2_PIX_FMT_YUV420) {
- yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->width, cam->height, cam->depth);
+ yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->width, cam->height, cam->bpp / 8);
pic_buf = cam->tmp;
}
@@ -531,7 +531,7 @@ read_timeout_func(cam* cam) {
gc, 0, 0,
cam->width, cam->height,
GDK_RGB_DITHER_NORMAL, pic_buf,
- cam->width * cam->depth / 8);
+ cam->width * cam->bpp / 8);
gtk_widget_queue_draw_area (glade_xml_get_widget (cam->xml, "da"), 0,
0, cam->width, cam->height);
@@ -552,7 +552,7 @@ gint timeout_func (cam * cam)
* refer the frame
*/
if (cam->pixformat == V4L2_PIX_FMT_YUV420) {
- yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->width, cam->height, cam->depth);
+ yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->width, cam->height, cam->bpp / 8);
pic_buf = cam->tmp;
}
@@ -565,7 +565,7 @@ gint timeout_func (cam * cam)
gc, 0, 0,
cam->width, cam->height,
GDK_RGB_DITHER_NORMAL, pic_buf,
- cam->width * cam->depth / 8);
+ cam->width * cam->bpp / 8);
gtk_widget_queue_draw_area (glade_xml_get_widget (cam->xml, "da"), 0,
0, cam->width, cam->height);
@@ -599,10 +599,10 @@ void capture_func (GtkWidget * widget, cam * cam)
if (cam->debug == TRUE) {
printf
("capture_func\nx = %d, y = %d, depth = %d, realloc size = %d\n",
- cam->width, cam->height, cam->depth, (cam->width * cam->height * cam->depth / 8));
+ cam->width, cam->height, cam->bpp, (cam->width * cam->height * cam->bpp / 8));
}
- memcpy (cam->tmp, cam->pic_buf, cam->width * cam->height * cam->depth / 8);
+ memcpy (cam->tmp, cam->pic_buf, cam->width * cam->height * cam->bpp / 8);
if (cam->rcap == TRUE) {
remote_save (cam);
@@ -631,7 +631,7 @@ gint timeout_capture_func (cam * cam)
pt2Function (cam);
}
- memcpy (cam->tmp, cam->pic_buf, cam->width * cam->height * cam->depth / 8);
+ memcpy (cam->tmp, cam->pic_buf, cam->width * cam->height * cam->bpp / 8);
if (cam->cap == TRUE) {
local_save (cam);
diff --git a/src/fileio.c b/src/fileio.c
index ff6897f..8a24334 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -130,7 +130,7 @@ void remote_save (cam * cam)
//g_free(ext);
pb = gdk_pixbuf_new_from_data (cam->tmp, GDK_COLORSPACE_RGB, FALSE, 8,
cam->width, cam->height,
- cam->width * cam->depth / 8, NULL,
+ cam->width * cam->bpp / 8, NULL,
NULL);
if (pb == NULL) {
@@ -174,10 +174,10 @@ void remote_save (cam * cam)
* exit (0);
* }
*
- * tmp = malloc (sizeof (char) * cam->width * cam->height * cam->depth * 2);
+ * tmp = malloc (sizeof (char) * cam->width * cam->height * cam->bpp * 2 / 8);
* while (!feof (fp))
* {
- * bytes += fread (tmp, 1, cam->width * cam->height * cam->depth, fp);
+ * bytes += fread (tmp, 1, cam->width * cam->height * cam->bpp / 8, fp);
* }
* fclose (fp);
*
@@ -280,9 +280,9 @@ void save_thread (cam * cam)
//exit (0);
}
- tmp = malloc (sizeof (char) * cam->width * cam->height * cam->depth * 2);
+ tmp = malloc (sizeof (char) * cam->width * cam->height * cam->bpp * 2 / 8);
while (!feof (fp)) {
- bytes += fread (tmp, 1, cam->width * cam->height * cam->depth, fp);
+ bytes += fread (tmp, 1, cam->width * cam->height * cam->bpp / 8, fp);
}
fclose (fp);
@@ -367,7 +367,7 @@ int local_save (cam * cam)
ext = g_strdup ((gchar *) "jpeg");
}
//cam->tmp = NULL;
- //memcpy (cam->tmp, cam->pic_buf, cam->width * cam->height * cam->depth);
+ //memcpy (cam->tmp, cam->pic_buf, cam->width * cam->height * cam->bpp / 8);
if (cam->timestamp == TRUE) {
add_rgb_text (cam->tmp, cam->width, cam->height, cam->ts_string,
@@ -422,7 +422,7 @@ int local_save (cam * cam)
pb = gdk_pixbuf_new_from_data (cam->tmp, GDK_COLORSPACE_RGB, FALSE, 8,
cam->width, cam->height,
- (cam->width * cam->depth / 8), NULL,
+ (cam->width * cam->bpp / 8), NULL,
NULL);
pbs = gdk_pixbuf_save (pb, filename, ext, NULL, NULL);
if (pbs == FALSE) {
diff --git a/src/main.c b/src/main.c
index 792bde8..5ad0145 100644
--- a/src/main.c
+++ b/src/main.c
@@ -224,7 +224,7 @@ main(int argc, char *argv[]) {
/* get picture attributes */
get_pic_info (cam);
- bufsize = cam->max_width * cam->max_height * cam->depth / 8;
+ bufsize = cam->max_width * cam->max_height * cam->bpp / 8;
cam->pic_buf = malloc (bufsize);
cam->tmp = malloc (bufsize);
@@ -274,6 +274,10 @@ main(int argc, char *argv[]) {
cam->idle_id = gtk_idle_add ((GSourceFunc) pt2Function, (gpointer) cam);
gtk_timeout_add (2000, (GSourceFunc) fps, cam->status);
+
+ if (cam->debug == TRUE)
+ print_cam(cam);
+
gtk_main ();
if (cam->read == FALSE) {
stop_streaming(cam);
diff --git a/src/v4l.c b/src/v4l.c
index d48180a..946fa6a 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -11,14 +11,30 @@ extern int errno;
void print_cam(cam *cam){
printf("\nCamera Info\n");
- printf("-------------\n");
+ printf("-----------\n");
printf("device = %s, x = %d, y = %d\n",cam->video_dev, cam->width,cam->height);
- printf("depth = %d, desk_depth = %d, size = %d\n",cam->depth,cam->desk_depth,cam->size);
+ printf("bits per pixel = %d, desk_depth = %d\n", cam->bpp, cam->desk_depth);
+ if(cam->width <= 0 || cam->height <= 0) {
+ switch (cam->size) {
+ case PICMAX:
+ printf("size = PICMAX\n");
+ break;
+ case PICMIN:
+ printf("size = PICMIN\n");
+ break;
+ case PICHALF:
+ default:
+ printf("size = PICHALF\n");
+ break;
+ }
+ }
printf("capture directory = %s, capture file = %s\n",cam->pixdir, cam->capturefile);
- printf("remote capture directory = %s, remote capture file = %s\n",cam->rpixdir, cam->rcapturefile);
- printf("remote host = %s, remote login = %s\n",cam->rhost,cam->rlogin);
- printf("timestamp = %s\n\n",cam->ts_string);
-
+ if (strcmp(cam->rhost, "yourdomain.org")) {
+ printf("remote host = %s, remote login = %s\n",cam->rhost,cam->rlogin);
+ printf("remote capture directory = %s, remote capture file = %s\n",cam->rpixdir, cam->rcapturefile);
+ }
+ if (strcmp(cam->ts_string, "Camorama!"))
+ printf("timestamp = %s\n\n",cam->ts_string);
}
void insert_resolution(cam * cam, int x, int y)
@@ -319,7 +335,7 @@ void get_win_info(cam * cam)
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420) {
cam->pixformat = fmt.fmt.pix.pixelformat;
- cam->depth = ((fmt.fmt.pix.bytesperline << 3) + (fmt.fmt.pix.width - 1)) / fmt.fmt.pix.width;
+ cam->bpp = ((fmt.fmt.pix.bytesperline << 3) + (fmt.fmt.pix.width - 1)) / fmt.fmt.pix.width;
cam->width = fmt.fmt.pix.width;
cam->height = fmt.fmt.pix.height;
cam->bytesperline = fmt.fmt.pix.bytesperline;
@@ -403,7 +419,7 @@ void set_win_info(cam * cam)
cam->pixformat = fmt.fmt.pix.pixelformat;
cam->bytesperline = fmt.fmt.pix.bytesperline;
- cam->depth = ((fmt.fmt.pix.bytesperline << 3) + (fmt.fmt.pix.width - 1)) / fmt.fmt.pix.width;
+ cam->bpp = ((fmt.fmt.pix.bytesperline << 3) + (fmt.fmt.pix.width - 1)) / fmt.fmt.pix.width;
cam->width = fmt.fmt.pix.width;
cam->height = fmt.fmt.pix.height;
@@ -515,8 +531,8 @@ void capture_buffers(cam * cam, unsigned char *outbuf, int len)
inbuf = cam->buffers[buf.index].start;
for (y = 0; y < cam->height; y++) {
- memcpy(outbuf, inbuf, cam->width * cam->depth / 8);
- outbuf += cam->width * cam->depth / 8;
+ memcpy(outbuf, inbuf, cam->width * cam->bpp / 8);
+ outbuf += cam->width * cam->bpp / 8;
inbuf += cam->bytesperline;
}
diff --git a/src/v4l.h b/src/v4l.h
index 1469b5d..65ed5c8 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -47,7 +47,7 @@ typedef struct camera {
int dev;
int width;
int height;
- int depth;
+ int bpp;
int desk_depth;
CamoImageSize size;
char name[32];
@@ -93,6 +93,7 @@ typedef struct camera {
} cam;
void camera_cap (cam *);
+void print_cam (cam *);
void try_set_win_info(cam * cam, int *x, int *y);
void set_win_info (cam * cam);
void get_pic_info (cam *);

Privacy Policy