Message ID | 20190814115444.13024-2-p.zabel@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/7] gpu: ipu-v3: image-convert: fix output seam valid interval | expand |
On Wed, 2019-08-14 at 13:54 +0200, Philipp Zabel wrote: > This reduces code duplication and allows to easily calculate the valid > interval for the input seam position in the same place. > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> > --- > drivers/gpu/ipu-v3/ipu-image-convert.c | 30 +++++++++++--------------- > 1 file changed, 12 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c > index c9909f1c9ffb..4ac7377cfe5c 100644 > --- a/drivers/gpu/ipu-v3/ipu-image-convert.c > +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c [...] > @@ -722,12 +726,7 @@ static void find_seams(struct ipu_image_convert_ctx *ctx, > * horizontally. > */ > > - /* Start within 1024 pixels of the right edge */ > - out_start = max_t(int, col * out_left_align, out_right - 1024); > - /* End before having to add more columns to the left */ > - out_end = min_t(unsigned int, out_right, col * 1024 + 1); > - > - find_best_seam(ctx, out_start, out_end, > + find_best_seam(ctx, col, > in_right, out_right, > in_left_align, out_left_align, > allow_in_overshoot ? 1 : 8 /* burst length */, > @@ -767,12 +766,7 @@ static void find_seams(struct ipu_image_convert_ctx *ctx, > unsigned int in_top; > unsigned int out_top; > > - /* Start within 1024 lines of the bottom edge */ > - out_start = max_t(int, row * out_top_align, out_bottom - 1024); > - /* End before having to add more rows above */ > - out_end = min_t(unsigned int, out_bottom, row * 1024 + 1); > - > - find_best_seam(ctx, out_start, out_end, > + find_best_seam(ctx, row, > in_bottom, out_bottom, > in_top_align, out_top_align, > 1, allow_overshoot ? 1 : out_height_align, ----------8<---------- From ccb75184975c6418a368762c2466441600f94a09 Mon Sep 17 00:00:00 2001 From: Philipp Zabel <p.zabel@pengutronix.de> Date: Wed, 14 Aug 2019 17:05:59 +0200 Subject: [PATCH] fixup! gpu: ipu-v3: image-convert: move output seam valid interval calculation into find_best_seam --- drivers/gpu/ipu-v3/ipu-image-convert.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c index f499509d72f2..eeca50d9a1ee 100644 --- a/drivers/gpu/ipu-v3/ipu-image-convert.c +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -753,8 +753,6 @@ static void find_seams(struct ipu_image_convert_ctx *ctx, !(ctx->rot_mode & IPU_ROT_BIT_HFLIP); bool allow_out_overshoot = (col < in->num_cols - 1) && !(ctx->rot_mode & IPU_ROT_BIT_HFLIP); - unsigned int out_start; - unsigned int out_end; unsigned int in_left; unsigned int out_left; @@ -798,8 +796,6 @@ static void find_seams(struct ipu_image_convert_ctx *ctx, for (row = in->num_rows - 1; row > 0; row--) { bool allow_overshoot = row < in->num_rows - 1; - unsigned int out_start; - unsigned int out_end; unsigned int in_top; unsigned int out_top;
diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c index c9909f1c9ffb..4ac7377cfe5c 100644 --- a/drivers/gpu/ipu-v3/ipu-image-convert.c +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -442,12 +442,10 @@ static int calc_image_resize_coefficients(struct ipu_image_convert_ctx *ctx, #define round_closest(x, y) round_down((x) + (y)/2, (y)) /* - * Find the best aligned seam position in the inverval [out_start, out_end]. + * Find the best aligned seam position for the given column / row index. * Rotation and image offsets are out of scope. * - * @out_start: start of inverval, must be within 1024 pixels / lines - * of out_end - * @out_end: end of interval, smaller than or equal to out_edge + * @index: column / row index, used to calculate valid interval * @in_edge: input right / bottom edge * @out_edge: output right / bottom edge * @in_align: input alignment, either horizontal 8-byte line start address @@ -463,8 +461,7 @@ static int calc_image_resize_coefficients(struct ipu_image_convert_ctx *ctx, * @_out_seam: aligned output seam position return value */ static void find_best_seam(struct ipu_image_convert_ctx *ctx, - unsigned int out_start, - unsigned int out_end, + unsigned int index, unsigned int in_edge, unsigned int out_edge, unsigned int in_align, @@ -482,6 +479,13 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx, unsigned int out_seam = 0; unsigned int in_seam = 0; unsigned int min_diff = UINT_MAX; + unsigned int out_start; + unsigned int out_end; + + /* Start within 1024 pixels of the right / bottom edge */ + out_start = max_t(int, index * out_align, out_edge - 1024); + /* End before having to add more columns to the left / rows above */ + out_end = min_t(unsigned int, out_edge, index * 1024 + 1); /* * Output tiles must start at a multiple of 8 bytes horizontally and @@ -722,12 +726,7 @@ static void find_seams(struct ipu_image_convert_ctx *ctx, * horizontally. */ - /* Start within 1024 pixels of the right edge */ - out_start = max_t(int, col * out_left_align, out_right - 1024); - /* End before having to add more columns to the left */ - out_end = min_t(unsigned int, out_right, col * 1024 + 1); - - find_best_seam(ctx, out_start, out_end, + find_best_seam(ctx, col, in_right, out_right, in_left_align, out_left_align, allow_in_overshoot ? 1 : 8 /* burst length */, @@ -767,12 +766,7 @@ static void find_seams(struct ipu_image_convert_ctx *ctx, unsigned int in_top; unsigned int out_top; - /* Start within 1024 lines of the bottom edge */ - out_start = max_t(int, row * out_top_align, out_bottom - 1024); - /* End before having to add more rows above */ - out_end = min_t(unsigned int, out_bottom, row * 1024 + 1); - - find_best_seam(ctx, out_start, out_end, + find_best_seam(ctx, row, in_bottom, out_bottom, in_top_align, out_top_align, 1, allow_overshoot ? 1 : out_height_align,
This reduces code duplication and allows to easily calculate the valid interval for the input seam position in the same place. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> --- drivers/gpu/ipu-v3/ipu-image-convert.c | 30 +++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-)