diff options
author | Julien Isorce <[email protected]> | 2015-11-26 08:29:54 +0000 |
---|---|---|
committer | Julien Isorce <[email protected]> | 2015-12-01 08:21:20 +0000 |
commit | b4fb6d76161d86c67697cf28a221d7913b8d084d (patch) | |
tree | aea77ec502b933e140d9b85450ef34c8be3ccf94 /src/gallium/state_trackers/va/context.c | |
parent | 750393ff7d6162372f368f5ed726b23f4cae49a0 (diff) |
st/va: delay decoder creation until max_references is known
In general max_references cannot be based on num_render_targets.
This patch allows to allocate buffers with an accurate size.
I.e. no more than necessary. For other codecs it is a fixed
value 2.
This is similar behaviour as vaapi/vdpau-driver.
For now HEVC case defaults to num_render_targets as before.
But it could also benefits this change by setting a more
accurate max_references number in handlePictureParameterBuffer.
Signed-off-by: Julien Isorce <[email protected]>
Reviewed-by: Christian König <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/va/context.c')
-rw-r--r-- | src/gallium/state_trackers/va/context.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index f0051e5f6a5..192794fefaa 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -187,7 +187,6 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, int picture_height, int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context_id) { - struct pipe_video_codec templat = {}; vlVaDriver *drv; vlVaContext *context; int is_vpp; @@ -213,27 +212,22 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, return VA_STATUS_ERROR_INVALID_CONTEXT; } } 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_MPEG4_AVC) { + context->templat.profile = config_id; + context->templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; + context->templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; + context->templat.width = picture_width; + context->templat.height = picture_height; + context->templat.expect_chunked_decode = true; + + switch (u_reduce_video_profile(context->templat.profile)) { + case PIPE_VIDEO_FORMAT_MPEG12: + case PIPE_VIDEO_FORMAT_VC1: + case PIPE_VIDEO_FORMAT_MPEG4: + context->templat.max_references = 2; + break; + + case PIPE_VIDEO_FORMAT_MPEG4_AVC: + context->templat.max_references = 0; context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); if (!context->desc.h264.pps) { FREE(context); @@ -245,10 +239,10 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, FREE(context); return VA_STATUS_ERROR_ALLOCATION_FAILED; } - } + break; - if (u_reduce_video_profile(context->decoder->profile) == - PIPE_VIDEO_FORMAT_HEVC) { + case PIPE_VIDEO_FORMAT_HEVC: + context->templat.max_references = num_render_targets; context->desc.h265.pps = CALLOC_STRUCT(pipe_h265_pps); if (!context->desc.h265.pps) { FREE(context); @@ -260,6 +254,10 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, FREE(context); return VA_STATUS_ERROR_ALLOCATION_FAILED; } + break; + + default: + break; } } |