[Mesa-dev] [PATCH 1/2] st/va: move YUV content to deinterlaced buffer when reallocated for encoder

Christian König deathsimple at vodafone.de
Thu Aug 24 06:52:09 UTC 2017


Am 23.08.2017 um 23:41 schrieb Leo Liu:
> Signed-off-by: Leo Liu <leo.liu at amd.com>
> ---
>   src/gallium/state_trackers/va/picture.c | 40 +++++++++++++++++++++++++++++----
>   1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
> index 47e63d3b30..3c5eb5de97 100644
> --- a/src/gallium/state_trackers/va/picture.c
> +++ b/src/gallium/state_trackers/va/picture.c
> @@ -626,9 +626,12 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
>                                           PIPE_VIDEO_CAP_SUPPORTS_INTERLACED);
>   
>      if (surf->buffer->interlaced != interlaced) {
> -      surf->templat.interlaced = screen->get_video_param(screen, context->decoder->profile,
> -                                                         PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
> -                                                         PIPE_VIDEO_CAP_PREFERS_INTERLACED);
> +      surf->templat.interlaced =
> +         (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) ?
> +         interlaced :
> +         screen->get_video_param(screen, context->decoder->profile,
> +                                 PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
> +                                 PIPE_VIDEO_CAP_PREFERS_INTERLACED);

Why not just:
> screen->get_video_param(screen, context->decoder->profile,
>     context->decoder->entrypoint,
>     PIPE_VIDEO_CAP_PREFERS_INTERLACED);
?

>         realloc = true;
>      }
>   
> @@ -657,13 +660,42 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
>      }
>   
>      if (realloc) {
> -      surf->buffer->destroy(surf->buffer);
> +      struct pipe_video_buffer *old_buf = surf->buffer;
>   
>         if (vlVaHandleSurfaceAllocate(ctx, surf, &surf->templat) != VA_STATUS_SUCCESS) {
>            mtx_unlock(&drv->mutex);
>            return VA_STATUS_ERROR_ALLOCATION_FAILED;
>         }
>   
> +      if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
> +         struct vl_compositor *compositor = &drv->compositor;
> +         struct vl_compositor_state *s = &drv->cstate;
> +         struct pipe_surface **dst_surface;
> +         struct u_rect dst_rect;
> +
> +         dst_surface = surf->buffer->get_surfaces(surf->buffer);
> +         vl_compositor_clear_layers(s);
> +
> +         dst_rect.x0 = 0;
> +         dst_rect.x1 = old_buf->width;
> +         dst_rect.y0 = 0;
> +         dst_rect.y1 = old_buf->height;
> +
> +         vl_compositor_set_yuv_layer(s, compositor, 0, old_buf, NULL, NULL, true);
> +         vl_compositor_set_layer_dst_area(s, 0, &dst_rect);
> +         vl_compositor_render(s, compositor, dst_surface[0], NULL, false);
> +
> +         dst_rect.x1 /= 2;
> +         dst_rect.y1 /= 2;
> +
> +         vl_compositor_set_yuv_layer(s, compositor, 0, old_buf, NULL, NULL, false);
> +         vl_compositor_set_layer_dst_area(s, 0, &dst_rect);
> +         vl_compositor_render(s, compositor, dst_surface[1], NULL, false);
> +
> +         context->decoder->context->flush(context->decoder->context, NULL, 0);

Looks like we have mostly the same in the OMX state tracker, would it 
make sense to have a helper for this?

Apart from that looks good to me,
Christian.

> +      }
> +
> +      old_buf->destroy(old_buf);
>         context->target = surf->buffer;
>      }
>   




More information about the mesa-dev mailing list