diff options
author | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-09 11:34:30 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-09 11:34:30 +0100 |
commit | cd7590bac56800586c4aadef077d1effe03b00c4 (patch) | |
tree | 38863a4996a42301cb68becb88f137d2c28ccac3 /src | |
parent | cc74561cfaff3a4c8719b6972d4ec5c21be535ea (diff) | |
download | uca-cd7590bac56800586c4aadef077d1effe03b00c4.tar.gz uca-cd7590bac56800586c4aadef077d1effe03b00c4.tar.bz2 uca-cd7590bac56800586c4aadef077d1effe03b00c4.tar.xz uca-cd7590bac56800586c4aadef077d1effe03b00c4.zip |
Use correct number of bytes per pixel when allocating buffers
Diffstat (limited to 'src')
-rw-r--r-- | src/grabbers/me4.c | 4 | ||||
-rw-r--r-- | src/uca-cam.c | 5 | ||||
-rw-r--r-- | src/uca-grabber.h | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c index a833c07..647c5be 100644 --- a/src/grabbers/me4.c +++ b/src/grabbers/me4.c @@ -34,7 +34,7 @@ uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_property_i return Fg_getParameter(GET_FG(grabber), property, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL; } -uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t n_buffers) +uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t pixel_size, uint32_t n_buffers) { if (GET_MEM(grabber) != NULL) /* FIXME: invent better error code */ @@ -45,7 +45,7 @@ uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t n_buffers) uca_me4_get_property(grabber, FG_HEIGHT, &height); /* FIXME: get size of pixel */ - dma_mem *mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*sizeof(uint16_t), n_buffers); + dma_mem *mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers); if (mem != NULL) { ((struct uca_me4_grabber_t *) grabber->user)->mem = mem; return UCA_NO_ERROR; diff --git a/src/uca-cam.c b/src/uca-cam.c index b77d62b..31ad416 100644 --- a/src/uca-cam.c +++ b/src/uca-cam.c @@ -6,7 +6,10 @@ uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers) { - cam->grabber->alloc(cam->grabber, n_buffers); + uint32_t bitdepth; + cam->get_property(cam, UCA_PROP_BITDEPTH, &bitdepth); + const int pixel_size = bitdepth == 8 ? 1 : 2; + cam->grabber->alloc(cam->grabber, pixel_size, n_buffers); } enum uca_cam_state uca_cam_get_state(struct uca_camera_t *cam) diff --git a/src/uca-grabber.h b/src/uca-grabber.h index 4485b07..6ae7e8e 100644 --- a/src/uca-grabber.h +++ b/src/uca-grabber.h @@ -37,7 +37,7 @@ typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enu * \brief Allocate buffers with current width, height and bitdepth * \note Subsequent changes of width and height might corrupt memory */ -typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_t *grabber, uint32_t n_buffers); +typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_t *grabber, uint32_t pixel_size, uint32_t n_buffers); /** * \brief Begin acquiring frames |