Mesa (master): st/vdpau: recreate video buffer if decode doesn't like it

Christian König deathsimple at kemper.freedesktop.org
Sun Jan 15 04:28:29 PST 2012


Module: Mesa
Branch: master
Commit: 020a6f6cd8c3c8632f68e1f47ba3c63f2315e47e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=020a6f6cd8c3c8632f68e1f47ba3c63f2315e47e

Author: Christian König <deathsimple at vodafone.de>
Date:   Tue Jan 10 15:06:44 2012 +0100

st/vdpau: recreate video buffer if decode doesn't like it

Recreate the video buffer if the decoder can't handle it.

Signed-off-by: Christian König <deathsimple at vodafone.de>

---

 src/gallium/state_trackers/vdpau/decode.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index d618fff..00232ad 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -391,6 +391,7 @@ vlVdpDecoderRender(VdpDecoder decoder,
    vlVdpDecoder *vldecoder;
    vlVdpSurface *vlsurf;
    VdpStatus ret;
+   struct pipe_screen *screen;
    struct pipe_video_decoder *dec;
    unsigned i;
    union {
@@ -410,6 +411,7 @@ vlVdpDecoderRender(VdpDecoder decoder,
    if (!vldecoder)
       return VDP_STATUS_INVALID_HANDLE;
    dec = vldecoder->decoder;
+   screen = dec->context->screen;
 
    vlsurf = (vlVdpSurface *)vlGetDataHTAB(target);
    if (!vlsurf)
@@ -418,10 +420,28 @@ vlVdpDecoderRender(VdpDecoder decoder,
    if (vlsurf->device != vldecoder->device)
       return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
 
-   if (vlsurf->video_buffer->chroma_format != dec->chroma_format)
+   if (vlsurf->video_buffer != NULL && vlsurf->video_buffer->chroma_format != dec->chroma_format)
       // TODO: Recreate decoder with correct chroma
       return VDP_STATUS_INVALID_CHROMA_TYPE;
 
+   if (vlsurf->video_buffer == NULL ||
+       !screen->is_video_format_supported(screen, vlsurf->video_buffer->buffer_format, dec->profile)) {
+
+      /* destroy the old one */
+      if (vlsurf->video_buffer)
+         vlsurf->video_buffer->destroy(vlsurf->video_buffer);
+
+      /* set the buffer format to the prefered one */
+      vlsurf->templat.buffer_format = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_CAP_PREFERED_FORMAT);
+
+      /* and recreate the video buffer */
+      vlsurf->video_buffer = dec->context->create_video_buffer(dec->context, &vlsurf->templat);
+
+      /* still no luck? get me out of here... */
+      if (!vlsurf->video_buffer)
+         return VDP_STATUS_NO_IMPLEMENTATION;
+   }
+
    memset(&desc, 0, sizeof(desc));
    desc.base.profile = dec->profile;
    switch (u_reduce_video_profile(dec->profile)) {



More information about the mesa-commit mailing list