[vlc-devel] [PATCH] avcodec VA: try to reuse the current video acceleration

Steve Lhomme robUx4 at videolabs.io
Tue Apr 7 10:11:29 CEST 2015


--
when seeking we may reset the whole decoder and get new buffers, but avcodec doesn't seem to know old buffers changed and still use the released ones as reference

this is a workaround, a cleaner fix may be to ensure avcodec doesn't reuse buffers we released after a ffmpeg_GetFormat()
---
 modules/codec/avcodec/video.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index c4488c0..b40dd69 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1358,7 +1358,28 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
     vlc_va_t *p_va = p_sys->p_va;
 
     if( p_va != NULL )
+    {
+        for( size_t i = 0; pi_fmt[i] != PIX_FMT_NONE; i++ )
+        {
+            if( p_va->pix_fmt != pi_fmt[i] )
+                continue;
+
+            if( p_context->width <= 0 || p_context->height <= 0
+             || !vlc_va_Setup( p_va, p_context, &p_dec->fmt_out.video.i_chroma ) )
+            {
+                msg_Err( p_dec, "reusing acceleration failed" );
+                break;
+            }
+
+            if( p_va->description )
+                msg_Info( p_dec, "Reusing %s for hardware decoding.",
+                          p_va->description );
+
+            return pi_fmt[i];
+        }
+
         vlc_va_Delete( p_va, p_context );
+    }
 
     /* Enumerate available formats */
     bool can_hwaccel = false;
-- 
2.3.2




More information about the vlc-devel mailing list