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@gmail.com>
Reviewed-by: Thong Thai <thong.thai@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8481>
This commit is contained in:
Alexander Kapshuk 2021-01-13 19:17:02 +00:00 committed by Marge Bot
parent 5939a64b15
commit 88fc4e26b6

View file

@ -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