[Libva] [PATCH] vpp: use single path conversion if no scaling is required

Lionel Landwerlin lionel.g.landwerlin at intel.com
Fri Mar 20 07:43:06 PDT 2015


The VPP API can be used to do pixel format conversion and scaling. The
current implementation uses a 2 pass process where the first pass does
scaling and the second pass does pixel format conversion.

In the case where we just need pixel format conversion, we can get rid
of the first pass. This patch implements a fast path for this case.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/i965_post_processing.c | 63 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 59 insertions(+), 4 deletions(-)

diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c
index 3ee3f07..52be8a5 100755
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -5372,9 +5372,27 @@ static const int proc_frame_to_pp_frame[3] = {
     I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST
 };
 
-VAStatus 
-i965_proc_picture(VADriverContextP ctx, 
-                  VAProfile profile, 
+static bool
+_va_rectangles_equal(VARectangle *rect1, VARectangle *rect2)
+{
+    return (rect1->x == rect2->x &&
+            rect1->y == rect2->y &&
+            rect1->width == rect2->width &&
+            rect1->height == rect2->height);
+}
+
+static bool
+_fourcc_is_rgbx(unsigned int fourcc)
+{
+    return (fourcc == VA_FOURCC_RGBX ||
+            fourcc == VA_FOURCC_BGRX ||
+            fourcc == VA_FOURCC_BGRA ||
+            fourcc == VA_FOURCC_RGBA);
+}
+
+VAStatus
+i965_proc_picture(VADriverContextP ctx,
+                  VAProfile profile,
                   union codec_state *codec_state,
                   struct hw_context *hw_context)
 {
@@ -5382,7 +5400,7 @@ i965_proc_picture(VADriverContextP ctx,
     struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context;
     struct proc_state *proc_state = &codec_state->proc;
     VAProcPipelineParameterBuffer *pipeline_param = (VAProcPipelineParameterBuffer *)proc_state->pipeline_param->buffer;
-    struct object_surface *obj_surface;
+    struct object_surface *obj_surface, *dst_obj_surface;
     struct i965_surface src_surface, dst_surface;
     VARectangle src_rect, dst_rect;
     VAStatus status;
@@ -5415,6 +5433,43 @@ i965_proc_picture(VADriverContextP ctx,
         goto error;
     }
 
+    dst_obj_surface = SURFACE(proc_state->current_render_target);
+
+    if (pipeline_param->num_filters == 0 &&
+        _va_rectangles_equal(pipeline_param->surface_region,
+                             pipeline_param->output_region) &&
+        obj_surface->fourcc == VA_FOURCC_NV12 &&
+        _fourcc_is_rgbx(dst_obj_surface->fourcc)) {
+        i965_vpp_clear_surface(ctx,
+                               &proc_context->pp_context,
+                               dst_obj_surface,
+                               pipeline_param->output_background_color);
+
+        src_surface.base = (struct object_base *)obj_surface;
+        src_surface.type = I965_SURFACE_TYPE_SURFACE;
+        src_surface.flags = 0;
+        src_rect.x = pipeline_param->surface_region->x;
+        src_rect.y = pipeline_param->surface_region->y;
+        src_rect.width = pipeline_param->surface_region->width;
+        src_rect.height = pipeline_param->surface_region->height;
+
+        dst_surface.base = (struct object_base *)dst_obj_surface;
+        dst_surface.type = I965_SURFACE_TYPE_SURFACE;
+        dst_surface.flags = 0;
+        dst_rect.x = pipeline_param->output_region->x;
+        dst_rect.y = pipeline_param->output_region->y;
+        dst_rect.width = pipeline_param->output_region->width;
+        dst_rect.height = pipeline_param->output_region->height;
+
+        i965_post_processing_internal(ctx, &proc_context->pp_context,
+                                      &src_surface,
+                                      &src_rect,
+                                      &dst_surface,
+                                      &dst_rect,
+                                      PP_NV12_LOAD_SAVE_RGBX,
+                                      NULL);
+        return VA_STATUS_SUCCESS;
+    }
     in_width = obj_surface->orig_width;
     in_height = obj_surface->orig_height;
     dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
-- 
2.1.4



More information about the Libva mailing list