[VDPAU] [PATCH 3/3] vdpau_wrapper: wrap decoder_create and decoder_query_capabilities

José Hiram Soltren jsoltren at nvidia.com
Tue Oct 28 11:56:48 PDT 2014


This is of course technically fine, and a future version of the NVIDIA VDPAU
driver (libvdpau_nvidia.so) could implement this natively.

I worry, though, that this workaround is always enabled, even on new drivers
supporting the new attributes you added in patch 2 of this patch set? Now that
I think about it more, patch 2 should also increment VDPAU_VERSION so that a
video player can use VdpGetApiVersion() to see if the new profiles are supported.

Would it make sense to condition this functionality on a new config attribute
defined in init_config(), such as enable_h264_profile_workaround, that we
default to either true or false? Users and/or distribution maintainers could
then toggle the workaround with vdpau_wrapper.cfg.

In addition, the wrapper itself could check the reported VDPAU version API, and
enable this workaround conditionally. This could be in conjunction with, or
instead of, the config option.

NACK for now (sorry) until the versioning comment above is addressed.

Thanks,
--José

On 10/28/2014 10:28 AM, Rémi Denis-Courmont wrote:
> From: Rémi Denis-Courmont <remid at nvidia.com>
> 
> This provides backward compatibility between new application using new
> H.264 profile values and old drivers not supporting them.
> 
> Signed-off-by: Rémi Denis-Courmont <remid at nvidia.com>
> ---
>  src/vdpau_wrapper.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 143 insertions(+), 16 deletions(-)
> 
> diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
> index 3b88120..77dbda3 100644
> --- a/src/vdpau_wrapper.c
> +++ b/src/vdpau_wrapper.c
> @@ -235,6 +235,8 @@ static void _vdp_close_driver(void)
>  
>  static VdpGetProcAddress * _imp_get_proc_address;
>  static VdpVideoSurfacePutBitsYCbCr * _imp_vid_put_bits_y_cb_cr;
> +static VdpDecoderQueryCapabilities * _imp_decoder_query_capabilities;
> +static VdpDecoderCreate * _imp_decoder_create;
>  static VdpPresentationQueueSetBackgroundColor * _imp_pq_set_bg_color;
>  static int _inited_fixes;
>  static int _running_under_flash;
> @@ -273,6 +275,127 @@ static VdpStatus vid_put_bits_y_cb_cr_swapped(
>      );
>  }
>  
> +static VdpStatus decoder_query_capabilities(
> +    VdpDevice         device,
> +    VdpDecoderProfile profile,
> +    VdpBool *         is_supported,
> +    uint32_t *        max_level,
> +    uint32_t *        max_macroblocks,
> +    uint32_t *        max_width,
> +    uint32_t *        max_height
> +)
> +{
> +    VdpStatus status;
> +
> +    status = _imp_decoder_query_capabilities(device, profile, is_supported,
> +        max_level, max_macroblocks, max_width, max_height);
> +    if (status == VDP_STATUS_OK && *is_supported == VDP_TRUE)
> +        return VDP_STATUS_OK;
> +
> +    /* If the VDPAU driver can do more, it can do less. */
> +    switch (profile) {
> +    case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE:
> +        /* The H.264 Constrained Baseline Profile is the common subset of the
> +         * Main Profile and the Baseline Profile. */
> +        status = _imp_decoder_query_capabilities(device,
> +            VDP_DECODER_PROFILE_H264_BASELINE, is_supported,
> +            max_level, max_macroblocks, max_width, max_height);
> +        if (status == VDP_STATUS_OK && *is_supported == VDP_TRUE)
> +            break;
> +
> +        status = _imp_decoder_query_capabilities(device,
> +            VDP_DECODER_PROFILE_H264_MAIN, is_supported,
> +            max_level, max_macroblocks, max_width, max_height);
> +        if (status == VDP_STATUS_OK && *is_supported == VDP_TRUE)
> +            break;
> +
> +        /* fall through */
> +    case VDP_DECODER_PROFILE_H264_MAIN:
> +        /* The H.264 Main Profile is a subset of the High Profile. */
> +        status = _imp_decoder_query_capabilities(device,
> +            VDP_DECODER_PROFILE_H264_HIGH, is_supported,
> +            max_level, max_macroblocks, max_width, max_height);
> +        break;
> +
> +    case VDP_DECODER_PROFILE_H264_CONSTRAINED_HIGH:
> +        /* The H.264 Constrained High Profile is a subset of the
> +         * Progressive High Profile. */
> +        status = _imp_decoder_query_capabilities(device,
> +            VDP_DECODER_PROFILE_H264_PROGRESSIVE_HIGH, is_supported,
> +            max_level, max_macroblocks, max_width, max_height);
> +        if (status == VDP_STATUS_OK && *is_supported == VDP_TRUE)
> +            break;
> +
> +        /* fall through */
> +    case VDP_DECODER_PROFILE_H264_PROGRESSIVE_HIGH:
> +        /* The H.264 Progressive High Profile is a subset of the
> +         * High Profile. */
> +        status = _imp_decoder_query_capabilities(device,
> +            VDP_DECODER_PROFILE_H264_HIGH, is_supported,
> +            max_level, max_macroblocks, max_width, max_height);
> +        break;
> +    }
> +
> +    return status;
> +}
> +
> +static VdpStatus decoder_create(
> +    VdpDevice         device,
> +    VdpDecoderProfile profile,
> +    uint32_t          width,
> +    uint32_t          height,
> +    uint32_t          max_references,
> +    VdpDecoder *      decoder
> +)
> +{
> +    VdpStatus status;
> +
> +    status = _imp_decoder_create(device, profile, width, height,
> +        max_references, decoder);
> +    if (status == VDP_STATUS_OK)
> +        return VDP_STATUS_OK;
> +
> +    /* See also decoder_query_capabilities(). */
> +    switch (profile) {
> +    case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE:
> +        status = _imp_decoder_create(device,
> +            VDP_DECODER_PROFILE_H264_BASELINE, width, height,
> +            max_references, decoder);
> +        if (status == VDP_STATUS_OK)
> +            break;
> +
> +        status = _imp_decoder_create(device,
> +            VDP_DECODER_PROFILE_H264_MAIN, width, height,
> +            max_references, decoder);
> +        if (status == VDP_STATUS_OK)
> +            break;
> +
> +        /* fall through */
> +    case VDP_DECODER_PROFILE_H264_MAIN:
> +        status = _imp_decoder_create(device,
> +            VDP_DECODER_PROFILE_H264_HIGH, width, height,
> +            max_references, decoder);
> +        break;
> +
> +    case VDP_DECODER_PROFILE_H264_CONSTRAINED_HIGH:
> +        status = _imp_decoder_create(device,
> +            VDP_DECODER_PROFILE_H264_PROGRESSIVE_HIGH, width, height,
> +            max_references, decoder);
> +        if (status == VDP_STATUS_OK)
> +            break;
> +
> +        /* fall through */
> +    case VDP_DECODER_PROFILE_H264_PROGRESSIVE_HIGH:
> +        status = _imp_decoder_create(device,
> +            VDP_DECODER_PROFILE_H264_HIGH, width, height,
> +            max_references, decoder);
> +        break;
> +    }
> +
> +    return status;
> +}
> +
> +
>  static VdpStatus pq_set_bg_color_noop(
>      VdpPresentationQueue presentation_queue,
>      VdpColor * const     background_color
> @@ -295,23 +418,27 @@ static VdpStatus vdp_wrapper_get_proc_address(
>          return status;
>      }
>  
> -    if (_running_under_flash) {
> -        switch (function_id) {
> -        case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR:
> -            if (_enable_flash_uv_swap) {
> -                _imp_vid_put_bits_y_cb_cr = *function_pointer;
> -                *function_pointer = vid_put_bits_y_cb_cr_swapped;
> -            }
> -            break;
> -        case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR:
> -            if (_disable_flash_pq_bg_color) {
> -                _imp_pq_set_bg_color = *function_pointer;
> -                *function_pointer = pq_set_bg_color_noop;
> -            }
> -            break;
> -        default:
> -            break;
> +    switch (function_id) {
> +    case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR:
> +        if (_running_under_flash && _enable_flash_uv_swap) {
> +            _imp_vid_put_bits_y_cb_cr = *function_pointer;
> +            *function_pointer = vid_put_bits_y_cb_cr_swapped;
> +        }
> +        break;
> +    case VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES:
> +        _imp_decoder_query_capabilities = *function_pointer;
> +        *function_pointer = decoder_query_capabilities;
> +        break;
> +    case VDP_FUNC_ID_DECODER_CREATE:
> +        _imp_decoder_create = *function_pointer;
> +        *function_pointer = decoder_create;
> +        break;
> +    case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR:
> +        if (_running_under_flash && _disable_flash_pq_bg_color) {
> +            _imp_pq_set_bg_color = *function_pointer;
> +            *function_pointer = pq_set_bg_color_noop;
>          }
> +        break;
>      }
>  
>      return VDP_STATUS_OK;
> 


More information about the VDPAU mailing list