]> git.sesse.net Git - ffmpeg/commitdiff
hwaccel: Deinitialize hardware acceleration early enough
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 29 Oct 2014 17:07:20 +0000 (19:07 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 4 Nov 2014 21:15:17 +0000 (22:15 +0100)
The application will destroy the underlying hardware handles when
get_format() gets called again. Also this ensures the
deinitialization takes place if the get_format callback returns an
error.

Regression from 1c80c9d7ef809180042257200c7b5f6b81d0b0e2.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/utils.c

index 95d2193abc80bc4bd609b06c11d3e367926af702..61893da4291f4468d380763b1dbe2f8f35013cd6 100644 (file)
@@ -948,6 +948,11 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
     memcpy(choices, fmt, (n + 1) * sizeof(*choices));
 
     for (;;) {
+        if (avctx->hwaccel && avctx->hwaccel->uninit)
+            avctx->hwaccel->uninit(avctx);
+        av_freep(&avctx->internal->hwaccel_priv_data);
+        avctx->hwaccel = NULL;
+
         ret = avctx->get_format(avctx, choices);
 
         desc = av_pix_fmt_desc_get(ret);
@@ -956,11 +961,6 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
             break;
         }
 
-        if (avctx->hwaccel && avctx->hwaccel->uninit)
-            avctx->hwaccel->uninit(avctx);
-        av_freep(&avctx->internal->hwaccel_priv_data);
-        avctx->hwaccel = NULL;
-
         if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
             break;