summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/va/context.c
diff options
context:
space:
mode:
authorJulien Isorce <j.isorce@samsung.com>2015-10-30 11:42:48 +0000
committerChristian König <christian.koenig@amd.com>2015-10-30 13:20:10 +0100
commit0b868807e4d6f209d5fec9948a5994936138ffcc (patch)
tree5c4e0fee220b7804c3de9b3451f60c6ba184dfe8 /src/gallium/state_trackers/va/context.c
parent05b6ce42097d6ebd2820129e8155113abce0bb42 (diff)
downloadexternal_mesa3d-0b868807e4d6f209d5fec9948a5994936138ffcc.zip
external_mesa3d-0b868807e4d6f209d5fec9948a5994936138ffcc.tar.gz
external_mesa3d-0b868807e4d6f209d5fec9948a5994936138ffcc.tar.bz2
st/va: add colospace conversion through Video Post Processing
Add support for VPP in the following functions: vlVaCreateContext vlVaDestroyContext vlVaBeginPicture vlVaRenderPicture vlVaEndPicture Add support for VAProcFilterNone in: vlVaQueryVideoProcFilters vlVaQueryVideoProcFilterCaps vlVaQueryVideoProcPipelineCaps Add handleVAProcPipelineParameterBufferType helper. One application is: VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA Signed-off-by: Julien Isorce <j.isorce@samsung.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'src/gallium/state_trackers/va/context.c')
-rw-r--r--src/gallium/state_trackers/va/context.c124
1 files changed, 74 insertions, 50 deletions
diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c
index 9cc402e..a107cc4 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -87,6 +87,14 @@ static struct VADriverVTable vtable =
&vlVaQuerySurfaceAttributes
};
+static struct VADriverVTableVPP vtable_vpp =
+{
+ 1,
+ &vlVaQueryVideoProcFilters,
+ &vlVaQueryVideoProcFilterCaps,
+ &vlVaQueryVideoProcPipelineCaps
+};
+
PUBLIC VAStatus
VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
{
@@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
ctx->version_major = 0;
ctx->version_minor = 1;
*ctx->vtable = vtable;
+ *ctx->vtable_vpp = vtable_vpp;
ctx->max_profiles = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - PIPE_VIDEO_PROFILE_UNKNOWN;
ctx->max_entrypoints = 1;
ctx->max_attributes = 1;
@@ -151,11 +160,15 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
struct pipe_video_codec templat = {};
vlVaDriver *drv;
vlVaContext *context;
+ int is_vpp;
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
- if (!(picture_width && picture_height))
+ is_vpp = config_id == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width &&
+ !picture_height && !flag && !render_targets && !num_render_targets;
+
+ if (!(picture_width && picture_height) && !is_vpp)
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
drv = VL_VA_DRIVER(ctx);
@@ -163,52 +176,60 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
if (!context)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
- templat.profile = config_id;
- templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
- templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
- templat.width = picture_width;
- templat.height = picture_height;
- templat.max_references = num_render_targets;
- templat.expect_chunked_decode = true;
-
- if (u_reduce_video_profile(templat.profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC)
- templat.level = u_get_h264_level(templat.width, templat.height,
- &templat.max_references);
-
- context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat);
- if (!context->decoder) {
- FREE(context);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
- }
-
- if (u_reduce_video_profile(context->decoder->profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC) {
- context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps);
- if (!context->desc.h264.pps) {
+ if (is_vpp) {
+ context->decoder = NULL;
+ if (!drv->compositor.upload) {
FREE(context);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
}
- context->desc.h264.pps->sps = CALLOC_STRUCT(pipe_h264_sps);
- if (!context->desc.h264.pps->sps) {
- FREE(context->desc.h264.pps);
+ } else {
+ templat.profile = config_id;
+ templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
+ templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
+ templat.width = picture_width;
+ templat.height = picture_height;
+ templat.max_references = num_render_targets;
+ templat.expect_chunked_decode = true;
+
+ if (u_reduce_video_profile(templat.profile) ==
+ PIPE_VIDEO_FORMAT_MPEG4_AVC)
+ templat.level = u_get_h264_level(templat.width, templat.height,
+ &templat.max_references);
+
+ context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat);
+ if (!context->decoder) {
FREE(context);
return VA_STATUS_ERROR_ALLOCATION_FAILED;
}
- }
- if (u_reduce_video_profile(context->decoder->profile) ==
- PIPE_VIDEO_FORMAT_HEVC) {
- context->desc.h265.pps = CALLOC_STRUCT(pipe_h265_pps);
- if (!context->desc.h265.pps) {
- FREE(context);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ if (u_reduce_video_profile(context->decoder->profile) ==
+ PIPE_VIDEO_FORMAT_MPEG4_AVC) {
+ context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps);
+ if (!context->desc.h264.pps) {
+ FREE(context);
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+ context->desc.h264.pps->sps = CALLOC_STRUCT(pipe_h264_sps);
+ if (!context->desc.h264.pps->sps) {
+ FREE(context->desc.h264.pps);
+ FREE(context);
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
}
- context->desc.h265.pps->sps = CALLOC_STRUCT(pipe_h265_sps);
- if (!context->desc.h265.pps->sps) {
- FREE(context->desc.h265.pps);
- FREE(context);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+ if (u_reduce_video_profile(context->decoder->profile) ==
+ PIPE_VIDEO_FORMAT_HEVC) {
+ context->desc.h265.pps = CALLOC_STRUCT(pipe_h265_pps);
+ if (!context->desc.h265.pps) {
+ FREE(context);
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+ context->desc.h265.pps->sps = CALLOC_STRUCT(pipe_h265_sps);
+ if (!context->desc.h265.pps->sps) {
+ FREE(context->desc.h265.pps);
+ FREE(context);
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
}
}
@@ -229,17 +250,20 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id)
drv = VL_VA_DRIVER(ctx);
context = handle_table_get(drv->htab, context_id);
- if (u_reduce_video_profile(context->decoder->profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC) {
- FREE(context->desc.h264.pps->sps);
- FREE(context->desc.h264.pps);
- }
- if (u_reduce_video_profile(context->decoder->profile) ==
- PIPE_VIDEO_FORMAT_HEVC) {
- FREE(context->desc.h265.pps->sps);
- FREE(context->desc.h265.pps);
+
+ if (context->decoder) {
+ if (u_reduce_video_profile(context->decoder->profile) ==
+ PIPE_VIDEO_FORMAT_MPEG4_AVC) {
+ FREE(context->desc.h264.pps->sps);
+ FREE(context->desc.h264.pps);
+ }
+ if (u_reduce_video_profile(context->decoder->profile) ==
+ PIPE_VIDEO_FORMAT_HEVC) {
+ FREE(context->desc.h265.pps->sps);
+ FREE(context->desc.h265.pps);
+ }
+ context->decoder->destroy(context->decoder);
}
- context->decoder->destroy(context->decoder);
FREE(context);
handle_table_remove(drv->htab, context_id);