lib: Remove num_stripes from fpi_assemble_frames()

This commit is contained in:
Bastien Nocera 2019-09-05 15:26:16 +02:00 committed by Benjamin Berg
parent 3b480caab1
commit f25d0a0dc9
7 changed files with 15 additions and 38 deletions

View file

@ -591,8 +591,7 @@ static void capture_read_strip_cb(FpiUsbTransfer *transfer, FpDevice *device,
aes_write_regv(dev, capture_stop, G_N_ELEMENTS(capture_stop), stub_capture_stop_cb, NULL); aes_write_regv(dev, capture_stop, G_N_ELEMENTS(capture_stop), stub_capture_stop_cb, NULL);
self->strips = g_slist_reverse(self->strips); self->strips = g_slist_reverse(self->strips);
fpi_do_movement_estimation(&assembling_ctx, self->strips); fpi_do_movement_estimation(&assembling_ctx, self->strips);
img = fpi_assemble_frames(&assembling_ctx, self->strips, img = fpi_assemble_frames(&assembling_ctx, self->strips);
self->strips_len);
g_slist_free_full(self->strips, g_free); g_slist_free_full(self->strips, g_free);
self->strips = NULL; self->strips = NULL;

View file

@ -437,8 +437,7 @@ static void capture_read_strip_cb(FpiUsbTransfer *transfer, FpDevice *_dev,
self->strips = g_slist_reverse(self->strips); self->strips = g_slist_reverse(self->strips);
fpi_do_movement_estimation(&assembling_ctx, self->strips); fpi_do_movement_estimation(&assembling_ctx, self->strips);
img = fpi_assemble_frames(&assembling_ctx, img = fpi_assemble_frames(&assembling_ctx,
self->strips, self->strips);
self->strips_len);
g_slist_free_full(self->strips, g_free); g_slist_free_full(self->strips, g_free);
self->strips = NULL; self->strips = NULL;
self->strips_len = 0; self->strips_len = 0;

View file

@ -227,8 +227,7 @@ static void capture_set_idle_reqs_cb(FpiUsbTransfer *transfer,
FpImage *img; FpImage *img;
self->strips = g_slist_reverse(self->strips); self->strips = g_slist_reverse(self->strips);
img = fpi_assemble_frames(&assembling_ctx, img = fpi_assemble_frames(&assembling_ctx, self->strips);
self->strips, self->strips_len);
g_slist_free_full(self->strips, g_free); g_slist_free_full(self->strips, g_free);
self->strips = NULL; self->strips = NULL;
self->strips_len = 0; self->strips_len = 0;

View file

@ -312,7 +312,7 @@ static void capture_set_idle_cmd_cb(FpiUsbTransfer *transfer, FpDevice *device,
FpImage *img; FpImage *img;
priv->strips = g_slist_reverse(priv->strips); priv->strips = g_slist_reverse(priv->strips);
img = fpi_assemble_frames(cls->assembling_ctx, priv->strips, priv->strips_len); img = fpi_assemble_frames(cls->assembling_ctx, priv->strips);
g_slist_foreach(priv->strips, (GFunc) g_free, NULL); g_slist_foreach(priv->strips, (GFunc) g_free, NULL);
g_slist_free(priv->strips); g_slist_free(priv->strips);
priv->strips = NULL; priv->strips = NULL;

View file

@ -288,14 +288,12 @@ static void elan_process_frame_thirds(unsigned short *raw_frame,
static void elan_submit_image(FpImageDevice *dev) static void elan_submit_image(FpImageDevice *dev)
{ {
FpiDeviceElan *self = FPI_DEVICE_ELAN(dev); FpiDeviceElan *self = FPI_DEVICE_ELAN(dev);
int num_frames;
GSList *raw_frames; GSList *raw_frames;
GSList *frames = NULL; GSList *frames = NULL;
FpImage *img; FpImage *img;
G_DEBUG_HERE(); G_DEBUG_HERE();
num_frames = self->num_frames - ELAN_SKIP_LAST_FRAMES;
raw_frames = g_slist_nth(self->frames, ELAN_SKIP_LAST_FRAMES); raw_frames = g_slist_nth(self->frames, ELAN_SKIP_LAST_FRAMES);
assembling_ctx.frame_width = self->frame_width; assembling_ctx.frame_width = self->frame_width;
@ -303,7 +301,7 @@ static void elan_submit_image(FpImageDevice *dev)
assembling_ctx.image_width = self->frame_width * 3 / 2; assembling_ctx.image_width = self->frame_width * 3 / 2;
g_slist_foreach(raw_frames, (GFunc) self->process_frame, &frames); g_slist_foreach(raw_frames, (GFunc) self->process_frame, &frames);
fpi_do_movement_estimation(&assembling_ctx, frames); fpi_do_movement_estimation(&assembling_ctx, frames);
img = fpi_assemble_frames(&assembling_ctx, frames, num_frames); img = fpi_assemble_frames(&assembling_ctx, frames);
fpi_image_device_image_captured(dev, img); fpi_image_device_image_captured(dev, img);
} }

View file

@ -269,48 +269,37 @@ aes_blit_stripe (struct fpi_frame_asmbl_ctx *ctx,
* fpi_assemble_frames: * fpi_assemble_frames:
* @ctx: #fpi_frame_asmbl_ctx - frame assembling context * @ctx: #fpi_frame_asmbl_ctx - frame assembling context
* @stripes: linked list of #fpi_frame * @stripes: linked list of #fpi_frame
* @num_stripes: number of items in @stripes to process
* *
* fpi_assemble_frames() assembles individual frames into a single image. * fpi_assemble_frames() assembles individual frames into a single image.
* It expects @delta_x and @delta_y of #fpi_frame to be populated. * It expects @delta_x and @delta_y of #fpi_frame to be populated.
* *
* Note that @num_stripes might be shorter than the length of the list,
* if some stripes should be skipped.
*
* Returns: a newly allocated #fp_img. * Returns: a newly allocated #fp_img.
*/ */
FpImage * FpImage *
fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx, fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes, size_t num_stripes) GSList *stripes)
{ {
GSList *stripe; GSList *l;
FpImage *img; FpImage *img;
int height = 0; int height = 0;
int i, y, x; int y, x;
gboolean reverse = FALSE; gboolean reverse = FALSE;
struct fpi_frame *fpi_frame; struct fpi_frame *fpi_frame;
//FIXME g_return_if_fail //FIXME g_return_if_fail
BUG_ON (num_stripes == 0); g_return_val_if_fail (stripes != NULL, NULL);
BUG_ON (ctx->image_width < ctx->frame_width); BUG_ON (ctx->image_width < ctx->frame_width);
/* Calculate height */
i = 0;
stripe = stripes;
/* No offset for 1st image */ /* No offset for 1st image */
fpi_frame = stripe->data; fpi_frame = stripes->data;
fpi_frame->delta_x = 0; fpi_frame->delta_x = 0;
fpi_frame->delta_y = 0; fpi_frame->delta_y = 0;
do for (l = stripes; l != NULL; l = l->next)
{ {
fpi_frame = stripe->data; fpi_frame = l->data;
height += fpi_frame->delta_y; height += fpi_frame->delta_y;
i++;
stripe = g_slist_next (stripe);
} }
while (i < num_stripes);
fp_dbg ("height is %d", height); fp_dbg ("height is %d", height);
@ -331,14 +320,12 @@ fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
img->height = height; img->height = height;
/* Assemble stripes */ /* Assemble stripes */
i = 0;
stripe = stripes;
y = reverse ? (height - ctx->frame_height) : 0; y = reverse ? (height - ctx->frame_height) : 0;
x = (ctx->image_width - ctx->frame_width) / 2; x = (ctx->image_width - ctx->frame_width) / 2;
do for (l = stripes; l != NULL; l = l->next)
{ {
fpi_frame = stripe->data; fpi_frame = l->data;
if(reverse) if(reverse)
{ {
@ -353,11 +340,7 @@ fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
y += fpi_frame->delta_y; y += fpi_frame->delta_y;
x += fpi_frame->delta_x; x += fpi_frame->delta_x;
} }
stripe = g_slist_next (stripe);
i++;
} }
while (i < num_stripes);
return img; return img;
} }

View file

@ -68,8 +68,7 @@ void fpi_do_movement_estimation (struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes); GSList *stripes);
FpImage *fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx, FpImage *fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes, GSList *stripes);
size_t num_stripes);
/** /**
* fpi_line_asmbl_ctx: * fpi_line_asmbl_ctx: