Mesa (master): frontends/va/image: Eliminate repetitive code on error paths
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 16 19:29:26 UTC 2021
Module: Mesa
Branch: master
Commit: 88fc4e26b6c2a35447fde1ee7da5e7d5ff4ff471
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=88fc4e26b6c2a35447fde1ee7da5e7d5ff4ff471
Author: Alexander Kapshuk <alexander.kapshuk at gmail.com>
Date: Wed Jan 13 19:17:02 2021 +0000
frontends/va/image: Eliminate repetitive code on error paths
Removes repetitive code in exit on error paths in the derive image function.
Signed-off-by: Alexander Kapshuk <alexander.kapshuk at gmail.com>
Reviewed-by: Thong Thai <thong.thai at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8481>
---
src/gallium/frontends/va/image.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/gallium/frontends/va/image.c b/src/gallium/frontends/va/image.c
index 7a0d391e470..76cb403ed99 100644
--- a/src/gallium/frontends/va/image.c
+++ b/src/gallium/frontends/va/image.c
@@ -200,6 +200,7 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
vlVaSurface *surf;
vlVaBuffer *img_buf;
VAImage *img;
+ VAStatus status;
struct pipe_screen *screen;
struct pipe_surface **surfaces;
struct pipe_video_buffer *new_buffer = NULL;
@@ -243,10 +244,9 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
if ((strcmp(derive_interlaced_allowlist[i], proc) == 0))
break;
- if (i >= ARRAY_SIZE(derive_interlaced_allowlist))
- return VA_STATUS_ERROR_OPERATION_FAILED;
-
- if (!screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+ if (i >= ARRAY_SIZE(derive_interlaced_allowlist) ||
+ !screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
+ PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE))
return VA_STATUS_ERROR_OPERATION_FAILED;
}
@@ -318,9 +318,8 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
/* not all devices support non-interlaced buffers */
if (!new_buffer) {
- FREE(img);
- mtx_unlock(&drv->mutex);
- return VA_STATUS_ERROR_OPERATION_FAILED;
+ status = VA_STATUS_ERROR_OPERATION_FAILED;
+ goto exit_on_error;
}
/* convert the interlaced to the progressive */
@@ -357,16 +356,14 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
default:
/* VaDeriveImage only supports contiguous planes. But there is now a
more generic api vlVaExportSurfaceHandle. */
- FREE(img);
- mtx_unlock(&drv->mutex);
- return VA_STATUS_ERROR_OPERATION_FAILED;
+ status = VA_STATUS_ERROR_OPERATION_FAILED;
+ goto exit_on_error;
}
img_buf = CALLOC(1, sizeof(vlVaBuffer));
if (!img_buf) {
- FREE(img);
- mtx_unlock(&drv->mutex);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ status = VA_STATUS_ERROR_ALLOCATION_FAILED;
+ goto exit_on_error;
}
img->image_id = handle_table_add(drv->htab, img);
@@ -384,6 +381,11 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
*image = *img;
return VA_STATUS_SUCCESS;
+
+exit_on_error:
+ FREE(img);
+ mtx_unlock(&drv->mutex);
+ return status;
}
VAStatus
More information about the mesa-commit
mailing list