camorama r366 - in trunk: . src
- From: herzi svn gnome org
- To: svn-commits-list gnome org
- Subject: camorama r366 - in trunk: . src
- Date: Wed, 28 May 2008 14:21:02 +0000 (UTC)
Author: herzi
Date: Wed May 28 14:21:01 2008
New Revision: 366
URL: http://svn.gnome.org/viewvc/camorama?rev=366&view=rev
Log:
2008-05-28 Sven Herzberg <sven imendio com>
manage the "pic" buffer in the strategies, not globally
* src/capture-strategy-mmap.c: (mmap_constructed), (mmap_finalize),
(timeout_func): manage pic locally; fix memory usage
* src/capture-strategy-read.c: (read_constructed), (read_finalize),
(read_timeout_func): manage pic locally; fix memory usage
* src/main.c: (main): don't manage pic anymore
* src/v4l.h: drop the pic pointer
Modified:
trunk/ChangeLog
trunk/src/capture-strategy-mmap.c
trunk/src/capture-strategy-read.c
trunk/src/main.c
trunk/src/v4l.h
Modified: trunk/src/capture-strategy-mmap.c
==============================================================================
--- trunk/src/capture-strategy-mmap.c (original)
+++ trunk/src/capture-strategy-mmap.c Wed May 28 14:21:01 2008
@@ -29,7 +29,8 @@
struct _CaptureStrategyMmapPrivate {
// FIXME: get rid of this
- cam* cam;
+ cam * cam;
+ guchar* pic;
};
#define PRIV(i) (CAPTURE_STRATEGY_MMAP(i)->_private)
@@ -65,11 +66,10 @@
g_return_if_fail (PRIV (object)->cam);
- cam->pic =
- mmap (0, cam->vid_buf.size, PROT_READ | PROT_WRITE,
- MAP_SHARED, cam->dev, 0);
+ PRIV(object)->pic = mmap (0, cam->vid_buf.size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, cam->dev, 0);
- if ((unsigned char *) -1 == (unsigned char *) cam->pic) {
+ if ((unsigned char *) -1 == (unsigned char *) PRIV(object)->pic) {
if (cam->debug == TRUE) {
fprintf (stderr, "Unable to capture image (mmap).\n");
}
@@ -96,6 +96,7 @@
static void
mmap_finalize (GObject* object)
{
+ munmap (PRIV (object)->pic, PRIV(object)->cam->vid_buf.size);
PRIV (object)->cam = NULL;
G_OBJECT_CLASS (capture_strategy_mmap_parent_class)->finalize (object);
@@ -150,7 +151,7 @@
gint
timeout_func (cam * cam)
{
- int i, count = 0;
+ int i;
GdkGC *gc;
i = -1;
@@ -172,18 +173,15 @@
}
break;
}
- count++;
- /*
- * refer the frame
- */
- cam->pic_buf = cam->pic + cam->vid_buf.offsets[frame];
- if (cam->vid_pic.palette == VIDEO_PALETTE_YUV420P) {
- yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->x, cam->y, cam->depth);
- cam->pic_buf = cam->tmp;
- }
- apply_filters(cam);
+ /* reference the frame */
+ cam->pic_buf = PRIV(cam->capture)->pic + cam->vid_buf.offsets[frame];
+ if (cam->vid_pic.palette == VIDEO_PALETTE_YUV420P) {
+ yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->x, cam->y, cam->depth);
+ cam->pic_buf = cam->tmp;
+ }
+ apply_filters(cam);
gc = gdk_gc_new (cam->pixmap);
Modified: trunk/src/capture-strategy-read.c
==============================================================================
--- trunk/src/capture-strategy-read.c (original)
+++ trunk/src/capture-strategy-read.c Wed May 28 14:21:01 2008
@@ -26,7 +26,8 @@
#include "camorama-globals.h"
struct _CaptureStrategyReadPrivate {
- cam* cam;
+ cam * cam;
+ guchar* pic;
};
enum {
@@ -62,9 +63,8 @@
g_return_if_fail (PRIV (object)->cam);
- cam->pic =
- realloc (cam->pic,
- (cam->vid_cap.maxwidth * cam->vid_cap.maxheight * 3));
+ PRIV(object)->pic = realloc (PRIV(object)->pic,
+ cam->vid_cap.maxwidth * cam->vid_cap.maxheight * 3);
}
static void
@@ -72,6 +72,8 @@
{
PRIV(object)->cam = NULL;
+ free (PRIV(object)->pic);
+
G_OBJECT_CLASS (capture_strategy_read_parent_class)->finalize (object);
}
@@ -123,25 +125,23 @@
/*
* get image from cam - does all the work ;)
*/
-static
-gboolean
-read_timeout_func(cam* cam) {
- int i, count = 0;
+static gboolean
+read_timeout_func (cam* cam)
+{
+ int i;
GdkGC *gc;
- read (cam->dev, cam->pic, (cam->x * cam->y * 3));
+ read (cam->dev, PRIV(cam->capture)->pic, (cam->x * cam->y * 3));
frames2++;
/*
* update_rec.x = 0;
* update_rec.y = 0;
* update_rec.width = cam->x;
- * update_rec.height = cam->y;
+ * update_rec.height = cam->y;
*/
- count++;
- /*
- * refer the frame
- */
- cam->pic_buf = cam->pic; // + cam->vid_buf.offsets[frame];
+
+ /* reference the frame */
+ cam->pic_buf = PRIV(cam->capture)->pic;
if (cam->vid_pic.palette == VIDEO_PALETTE_YUV420P) {
yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->x, cam->y, cam->depth);
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Wed May 28 14:21:01 2008
@@ -98,7 +98,6 @@
cam = &cam_object;
/* set some default values */
cam->frame_number = 0;
- cam->pic = NULL;
cam->pixmap = NULL;
cam->size = PICHALF;
cam->video_dev = NULL;
Modified: trunk/src/v4l.h
==============================================================================
--- trunk/src/v4l.h (original)
+++ trunk/src/v4l.h Wed May 28 14:21:01 2008
@@ -52,7 +52,6 @@
struct video_mbuf vid_buf;
struct video_mmap vid_map;
char *video_dev;
- unsigned char *pic;
unsigned char *image;
gchar *capturefile, *rcapturefile;
gchar *pixdir, *rpixdir;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]