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

Rémi Denis-Courmont remi at remlab.net
Tue Oct 28 08:28:40 PDT 2014


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;
-- 
1.9.1



More information about the VDPAU mailing list