Module: Mesa Branch: main Commit: fcfa68a632e5711cc657b103c9a0384928e9bf49 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fcfa68a632e5711cc657b103c9a0384928e9bf49
Author: David Rosca <[email protected]> Date: Mon Nov 13 12:08:59 2023 +0100 Revert "frontends/va: Alloc interlaced surface for interlaced pics" This reverts commit 578e10e1571b40c86f3348f2f36e080f34d1a4ed. The only reason for reallocating surfaces as interlaced (on drivers that supports both progressive and interlaced) was deinterlacing with postproc filter, but that now also supports interleaved surfaces. With this change interlaced surfaces are no longer used on radeonsi. Reviewed-by: Leo Liu <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26174> --- src/gallium/frontends/va/picture.c | 24 +---------------------- src/gallium/frontends/va/surface.c | 37 +++++++++++++---------------------- src/gallium/frontends/va/va_private.h | 2 +- 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index 12acf96641c..336e111da35 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -1011,23 +1011,6 @@ static bool vlVaQueryApplyFilmGrainAV1(vlVaContext *context, return true; } -static bool vlVaQueryDecodeInterlacedH264(vlVaContext *context) -{ - struct pipe_h264_picture_desc *h264 = NULL; - - if (u_reduce_video_profile(context->templat.profile) != PIPE_VIDEO_FORMAT_MPEG4_AVC || - context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) - return false; - - h264 = &context->desc.h264; - - if (h264->pps->sps->frame_mbs_only_flag) - return false; - - return h264->field_pic_flag || /* PAFF */ - h264->pps->sps->mb_adaptive_frame_field_flag; /* MBAFF */ -} - VAStatus vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) { @@ -1043,7 +1026,6 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) enum pipe_format format; struct pipe_video_buffer **out_target; int output_id; - bool decode_interlaced; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -1069,7 +1051,6 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) output_id = context->target_id; out_target = &context->target; apply_av1_fg = vlVaQueryApplyFilmGrainAV1(context, &output_id, &out_target); - decode_interlaced = vlVaQueryDecodeInterlacedH264(context); mtx_lock(&drv->mutex); surf = handle_table_get(drv->htab, output_id); @@ -1088,7 +1069,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) screen = context->decoder->context->screen; supported = screen->get_video_param(screen, context->decoder->profile, context->decoder->entrypoint, - decode_interlaced || surf->buffer->interlaced ? + surf->buffer->interlaced ? PIPE_VIDEO_CAP_SUPPORTS_INTERLACED : PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE); @@ -1097,9 +1078,6 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) context->decoder->profile, context->decoder->entrypoint, PIPE_VIDEO_CAP_PREFERS_INTERLACED); - realloc = surf->templat.interlaced != surf->buffer->interlaced; - } else if (decode_interlaced && !surf->buffer->interlaced) { - surf->templat.interlaced = true; realloc = true; } diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index baddba39bbc..d102ddb7f75 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -84,8 +84,6 @@ vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_sur } if (surf->buffer) surf->buffer->destroy(surf->buffer); - if (surf->deint_buffer) - surf->deint_buffer->destroy(surf->deint_buffer); if (surf->ctx) { assert(_mesa_set_search(surf->ctx->surfaces, surf)); _mesa_set_remove_key(surf->ctx->surfaces, surf); @@ -1540,7 +1538,6 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, struct pipe_screen *screen; VAStatus ret; unsigned int usage; - struct pipe_video_buffer *buffer; #ifdef _WIN32 if ((mem_type != VA_SURFACE_ATTRIB_MEM_TYPE_NTHANDLE) @@ -1565,24 +1562,16 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, return VA_STATUS_ERROR_INVALID_SURFACE; } - buffer = surf->buffer; - - if (buffer->interlaced) { - struct pipe_video_buffer *interlaced = buffer; + if (surf->buffer->interlaced) { + struct pipe_video_buffer *interlaced = surf->buffer; struct u_rect src_rect, dst_rect; - if (!surf->deint_buffer) { - surf->templat.interlaced = false; - - ret = vlVaHandleSurfaceAllocate(drv, surf, &surf->templat, NULL, 0); - if (ret != VA_STATUS_SUCCESS) { - mtx_unlock(&drv->mutex); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } + surf->templat.interlaced = false; - surf->deint_buffer = surf->buffer; - surf->buffer = interlaced; - surf->templat.interlaced = true; + ret = vlVaHandleSurfaceAllocate(drv, surf, &surf->templat, NULL, 0); + if (ret != VA_STATUS_SUCCESS) { + mtx_unlock(&drv->mutex); + return VA_STATUS_ERROR_ALLOCATION_FAILED; } src_rect.x0 = dst_rect.x0 = 0; @@ -1591,14 +1580,16 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, src_rect.y1 = dst_rect.y1 = surf->templat.height; vl_compositor_yuv_deint_full(&drv->cstate, &drv->compositor, - interlaced, surf->deint_buffer, + interlaced, surf->buffer, &src_rect, &dst_rect, VL_COMPOSITOR_WEAVE); + if (interlaced->codec && interlaced->codec->update_decoder_target) + interlaced->codec->update_decoder_target(interlaced->codec, interlaced, surf->buffer); - buffer = surf->deint_buffer; + interlaced->destroy(interlaced); } - surfaces = buffer->get_surfaces(buffer); + surfaces = surf->buffer->get_surfaces(surf->buffer); usage = 0; if (flags & VA_EXPORT_SURFACE_WRITE_ONLY) @@ -1627,7 +1618,7 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, #else VADRMPRIMESurfaceDescriptor *desc = descriptor; - desc->fourcc = PipeFormatToVaFourcc(buffer->buffer_format); + desc->fourcc = PipeFormatToVaFourcc(surf->buffer->buffer_format); desc->width = surf->templat.width; desc->height = surf->templat.height; @@ -1679,7 +1670,7 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, desc->num_objects = p; if (flags & VA_EXPORT_SURFACE_COMPOSED_LAYERS) { - uint32_t drm_format = pipe_format_to_drm_format(buffer->buffer_format); + uint32_t drm_format = pipe_format_to_drm_format(surf->buffer->buffer_format); if (drm_format == DRM_FORMAT_INVALID) { ret = VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; goto fail; diff --git a/src/gallium/frontends/va/va_private.h b/src/gallium/frontends/va/va_private.h index df80a60623c..a25cd56673c 100644 --- a/src/gallium/frontends/va/va_private.h +++ b/src/gallium/frontends/va/va_private.h @@ -386,7 +386,7 @@ typedef struct { } vlVaConfig; typedef struct { - struct pipe_video_buffer templat, *buffer, *deint_buffer; + struct pipe_video_buffer templat, *buffer; struct util_dynarray subpics; /* vlVaSubpicture */ vlVaContext *ctx; vlVaBuffer *coded_buf;
