<div dir="ltr">This patch is:<br>Reviewed-by: Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>><br>Tested-by: Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>><div class="gmail_extra"><br><div class="gmail_quote">On 11 December 2015 at 12:33, Christian König <span dir="ltr"><<a href="mailto:deathsimple@vodafone.de" target="_blank">deathsimple@vodafone.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><br>
<br>
Usefull for mpv and GStreamer.<br>
<br>
Signed-off-by: Indrajit-kumar Das <<a href="mailto:Indrajit-kumar.Das@amd.com">Indrajit-kumar.Das@amd.com</a>><br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><br>
---<br>
src/gallium/state_trackers/va/picture.c | 10 +-<br>
src/gallium/state_trackers/va/postproc.c | 152 ++++++++++++++++++++++++-------<br>
2 files changed, 125 insertions(+), 37 deletions(-)<br>
<br>
diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c<br>
index 7b30bf8..b5e1ebc 100644<br>
--- a/src/gallium/state_trackers/va/picture.c<br>
+++ b/src/gallium/state_trackers/va/picture.c<br>
@@ -63,11 +63,11 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende<br>
if (!context->decoder) {<br>
/* VPP */<br>
if (context->templat.profile == PIPE_VIDEO_PROFILE_UNKNOWN &&<br>
- ((context->target->buffer_format != PIPE_FORMAT_B8G8R8A8_UNORM &&<br>
- context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM &&<br>
- context->target->buffer_format != PIPE_FORMAT_B8G8R8X8_UNORM &&<br>
- context->target->buffer_format != PIPE_FORMAT_R8G8B8X8_UNORM) ||<br>
- context->target->interlaced))<br>
+ context->target->buffer_format != PIPE_FORMAT_B8G8R8A8_UNORM &&<br>
+ context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM &&<br>
+ context->target->buffer_format != PIPE_FORMAT_B8G8R8X8_UNORM &&<br>
+ context->target->buffer_format != PIPE_FORMAT_R8G8B8X8_UNORM &&<br>
+ context->target->buffer_format != PIPE_FORMAT_NV12)<br>
return VA_STATUS_ERROR_UNIMPLEMENTED;<br>
<br>
return VA_STATUS_SUCCESS;<br>
diff --git a/src/gallium/state_trackers/va/postproc.c b/src/gallium/state_trackers/va/postproc.c<br>
index 1ee3587..c6cfd3a 100644<br>
--- a/src/gallium/state_trackers/va/postproc.c<br>
+++ b/src/gallium/state_trackers/va/postproc.c<br>
@@ -27,6 +27,8 @@<br>
<br>
#include "util/u_handle_table.h"<br>
<br>
+#include "vl/vl_defines.h"<br>
+<br>
#include "va_private.h"<br>
<br>
static const VARectangle *<br>
@@ -44,43 +46,21 @@ vlVaRegionDefault(const VARectangle *region, struct pipe_video_buffer *buf,<br>
return def;<br>
}<br>
<br>
-VAStatus<br>
-vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)<br>
+static VAStatus<br>
+vlVaPostProcCompositor(vlVaDriver *drv, vlVaContext *context,<br>
+ const VARectangle *src_region,<br>
+ const VARectangle *dst_region,<br>
+ struct pipe_video_buffer *src,<br>
+ struct pipe_video_buffer *dst)<br>
{<br>
- VARectangle def_src_region, def_dst_region;<br>
- const VARectangle *src_region, *dst_region;<br>
+ struct pipe_surface **surfaces;<br>
struct u_rect src_rect;<br>
struct u_rect dst_rect;<br>
- vlVaSurface *src_surface;<br>
- VAProcPipelineParameterBuffer *pipeline_param;<br>
- struct pipe_surface **surfaces;<br>
- struct pipe_surface *psurf;<br>
-<br>
- if (!drv || !context)<br>
- return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
-<br>
- if (!buf || !buf->data)<br>
- return VA_STATUS_ERROR_INVALID_BUFFER;<br>
-<br>
- if (!context->target)<br>
- return VA_STATUS_ERROR_INVALID_SURFACE;<br>
-<br>
- pipeline_param = (VAProcPipelineParameterBuffer *)buf->data;<br>
-<br>
- src_surface = handle_table_get(drv->htab, pipeline_param->surface);<br>
- if (!src_surface || !src_surface->buffer)<br>
- return VA_STATUS_ERROR_INVALID_SURFACE;<br>
-<br>
- surfaces = context->target->get_surfaces(context->target);<br>
<br>
+ surfaces = dst->get_surfaces(dst);<br>
if (!surfaces || !surfaces[0])<br>
return VA_STATUS_ERROR_INVALID_SURFACE;<br>
<br>
- psurf = surfaces[0];<br>
-<br>
- src_region = vlVaRegionDefault(pipeline_param->surface_region, src_surface->buffer, &def_src_region);<br>
- dst_region = vlVaRegionDefault(pipeline_param->output_region, context->target, &def_dst_region);<br>
-<br>
src_rect.x0 = src_region->x;<br>
src_rect.y0 = src_region->y;<br>
src_rect.x1 = src_region->x + src_region->width;<br>
@@ -92,11 +72,119 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex<br>
dst_rect.y1 = dst_region->y + dst_region->height;<br>
<br>
vl_compositor_clear_layers(&drv->cstate);<br>
- vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, src_surface->buffer, &src_rect, NULL, VL_COMPOSITOR_WEAVE);<br>
+ vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, src,<br>
+ &src_rect, NULL, VL_COMPOSITOR_WEAVE);<br>
vl_compositor_set_layer_dst_area(&drv->cstate, 0, &dst_rect);<br>
- vl_compositor_render(&drv->cstate, &drv->compositor, psurf, NULL, false);<br>
+ vl_compositor_render(&drv->cstate, &drv->compositor, surfaces[0], NULL, false);<br>
+<br>
+ return VA_STATUS_SUCCESS;<br>
+}<br>
+<br>
+static void vlVaBoxAdjust(struct pipe_video_buffer *buf, unsigned idx,<br>
+ struct pipe_box *box)<br>
+{<br>
+ if (buf->interlaced) {<br>
+ box->y /= 2;<br>
+ box->height /= 2;<br>
+ }<br>
+ if (idx > buf->interlaced) {<br>
+ /* we assume chroma format 420 here */<br>
+ box->x /= 2;<br>
+ box->y /= 2;<br>
+ box->width /= 2;<br>
+ box->height /= 2;<br>
+ }<br>
+}<br>
+<br>
+static VAStatus vlVaPostProcBlit(vlVaDriver *drv, vlVaContext *context,<br>
+ const VARectangle *src_region,<br>
+ const VARectangle *dst_region,<br>
+ struct pipe_video_buffer *src,<br>
+ struct pipe_video_buffer *dst)<br>
+{<br>
+ struct pipe_surface **src_surfaces;<br>
+ struct pipe_surface **dst_surfaces;<br>
+ unsigned i;<br>
+<br>
+ if (src->interlaced != dst->interlaced)<br>
+ return VA_STATUS_ERROR_INVALID_SURFACE;<br>
+<br>
+ src_surfaces = src->get_surfaces(src);<br>
+ if (!src_surfaces || !src_surfaces[0])<br>
+ return VA_STATUS_ERROR_INVALID_SURFACE;<br>
+<br>
+ dst_surfaces = dst->get_surfaces(dst);<br>
+ if (!dst_surfaces || !dst_surfaces[0])<br>
+ return VA_STATUS_ERROR_INVALID_SURFACE;<br>
+<br>
+ for (i = 0; i < VL_MAX_SURFACES; ++i) {<br>
+ struct pipe_blit_info blit;<br>
+<br>
+ if (!src_surfaces[i] || !dst_surfaces[i])<br>
+ continue;<br>
+<br>
+ memset(&blit, 0, sizeof(blit));<br>
+ blit.src.resource = src_surfaces[i]->texture;<br>
+ blit.src.format = src_surfaces[i]->format;<br>
+ blit.src.level = 0;<br>
+ blit.src.box.x = src_region->x;<br>
+ blit.src.box.y = src_region->y;<br>
+ blit.src.box.z = src_surfaces[i]->u.tex.first_layer;<br>
+ blit.src.box.width = src_region->width;<br>
+ blit.src.box.height = src_region->height;<br>
+ blit.src.box.depth = 1;<br>
+ vlVaBoxAdjust(src, i, &blit.src.box);<br>
+<br>
+ blit.dst.resource = dst_surfaces[i]->texture;<br>
+ blit.dst.format = dst_surfaces[i]->format;<br>
+ blit.dst.level = 0;<br>
+ blit.dst.box.x = dst_region->x;<br>
+ blit.dst.box.y = dst_region->y;<br>
+ blit.dst.box.z = dst_surfaces[i]->u.tex.first_layer;<br>
+ blit.dst.box.width = dst_region->width;<br>
+ blit.dst.box.height = dst_region->height;<br>
+ blit.dst.box.depth = 1;<br>
+ vlVaBoxAdjust(dst, i, &blit.dst.box);<br>
+<br>
+ blit.mask = PIPE_MASK_RGBA;<br>
+ blit.filter = PIPE_TEX_MIPFILTER_LINEAR;<br>
+<br>
+ drv->pipe->blit(drv->pipe, &blit);<br>
+ }<br>
<br>
return VA_STATUS_SUCCESS;<br>
}<br>
<br>
+VAStatus<br>
+vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)<br>
+{<br>
+ VARectangle def_src_region, def_dst_region;<br>
+ const VARectangle *src_region, *dst_region;<br>
+ VAProcPipelineParameterBuffer *param;<br>
+ vlVaSurface *src_surface;<br>
+<br>
+ if (!drv || !context)<br>
+ return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
+<br>
+ if (!buf || !buf->data)<br>
+ return VA_STATUS_ERROR_INVALID_BUFFER;<br>
<br>
+ if (!context->target)<br>
+ return VA_STATUS_ERROR_INVALID_SURFACE;<br>
+<br>
+ param = buf->data;<br>
+<br>
+ src_surface = handle_table_get(drv->htab, param->surface);<br>
+ if (!src_surface || !src_surface->buffer)<br>
+ return VA_STATUS_ERROR_INVALID_SURFACE;<br>
+<br>
+ src_region = vlVaRegionDefault(param->surface_region, src_surface->buffer, &def_src_region);<br>
+ dst_region = vlVaRegionDefault(param->output_region, context->target, &def_dst_region);<br>
+<br>
+ if (context->target->buffer_format != PIPE_FORMAT_NV12)<br>
+ return vlVaPostProcCompositor(drv, context, src_region, dst_region,<br>
+ src_surface->buffer, context->target);<br>
+ else<br>
+ return vlVaPostProcBlit(drv, context, src_region, dst_region,<br>
+ src_surface->buffer, context->target);<br>
+}<br>
<span class=""><font color="#888888">--<br>
2.5.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>