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);
self->strips = g_slist_reverse(self->strips);
fpi_do_movement_estimation(&assembling_ctx, self->strips);
img = fpi_assemble_frames(&assembling_ctx, self->strips,
self->strips_len);
img = fpi_assemble_frames(&assembling_ctx, self->strips);
g_slist_free_full(self->strips, g_free);
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);
fpi_do_movement_estimation(&assembling_ctx, self->strips);
img = fpi_assemble_frames(&assembling_ctx,
self->strips,
self->strips_len);
self->strips);
g_slist_free_full(self->strips, g_free);
self->strips = NULL;
self->strips_len = 0;

View file

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

View file

@ -312,7 +312,7 @@ static void capture_set_idle_cmd_cb(FpiUsbTransfer *transfer, FpDevice *device,
FpImage *img;
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_free(priv->strips);
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)
{
FpiDeviceElan *self = FPI_DEVICE_ELAN(dev);
int num_frames;
GSList *raw_frames;
GSList *frames = NULL;
FpImage *img;
G_DEBUG_HERE();
num_frames = self->num_frames - ELAN_SKIP_LAST_FRAMES;
raw_frames = g_slist_nth(self->frames, ELAN_SKIP_LAST_FRAMES);
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;
g_slist_foreach(raw_frames, (GFunc) self->process_frame, &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);
}

View file

@ -269,48 +269,37 @@ aes_blit_stripe (struct fpi_frame_asmbl_ctx *ctx,
* fpi_assemble_frames:
* @ctx: #fpi_frame_asmbl_ctx - frame assembling context
* @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.
* 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.
*/
FpImage *
fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes, size_t num_stripes)
GSList *stripes)
{
GSList *stripe;
GSList *l;
FpImage *img;
int height = 0;
int i, y, x;
int y, x;
gboolean reverse = FALSE;
struct fpi_frame *fpi_frame;
//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);
/* Calculate height */
i = 0;
stripe = stripes;
/* No offset for 1st image */
fpi_frame = stripe->data;
fpi_frame = stripes->data;
fpi_frame->delta_x = 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;
i++;
stripe = g_slist_next (stripe);
}
while (i < num_stripes);
fp_dbg ("height is %d", height);
@ -331,14 +320,12 @@ fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
img->height = height;
/* Assemble stripes */
i = 0;
stripe = stripes;
y = reverse ? (height - ctx->frame_height) : 0;
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)
{
@ -353,11 +340,7 @@ fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
y += fpi_frame->delta_y;
x += fpi_frame->delta_x;
}
stripe = g_slist_next (stripe);
i++;
}
while (i < num_stripes);
return img;
}

View file

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