aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-08-17 12:27:11 (GMT)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-08-28 11:15:17 (GMT)
commitab69b8f5396b4d3cbbdfe1c4c732d3132c892fe2 (patch)
tree47e9b391537ef36904fa5acf34a57d82ab45d746
parentf533d5b9fcba2ae12282776c5c8bab2f91bb8c10 (diff)
v4l: Better name V4L bits per pixel field
At V4L, the depth for each video format is represented using bits per pixel. However, at Camorama, the filters use bytes per pixel instead. That caused a regression during the conversion to V4L2. In order to avoid further troubles, let's rename: cam->depth ===> cam->bpp Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-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.c2
-rw-r--r--src/v4l.c10
-rw-r--r--src/v4l.h2
7 files changed, 24 insertions, 24 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 1d8e1cb..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 / 8);
- camorama_filter_chain_apply(cam->filter_chain, cam->pic_buf, cam->width, cam->height, cam->depth / 8);
+ 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 / 8);
+ 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 / 8);
+ 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 da98050..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 / 8);
+ * 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 / 8, 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 / 8);
+ 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 / 8, 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 / 8);
+ //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..3ab3afd 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);
diff --git a/src/v4l.c b/src/v4l.c
index d48180a..cd10733 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -13,7 +13,7 @@ void print_cam(cam *cam){
printf("\nCamera Info\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, size = %d\n", cam->bpp, cam->desk_depth, cam->size);
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);
@@ -319,7 +319,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 +403,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 +515,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..27c737e 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];

Privacy Policy