[vlc-commits] va_surface: set the AVCodecContext hwaccel_context in the final setup callback

Steve Lhomme git at videolan.org
Tue Oct 22 09:02:09 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Oct 22 08:09:45 2019 +0200| [99c9656cdd13b11badbe202be7dd580ffb05af54] | committer: Steve Lhomme

va_surface: set the AVCodecContext hwaccel_context in the final setup callback

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99c9656cdd13b11badbe202be7dd580ffb05af54
---

 modules/codec/avcodec/d3d11va.c             | 5 ++---
 modules/codec/avcodec/dxva2.c               | 5 ++---
 modules/codec/avcodec/va_surface.c          | 4 ++--
 modules/codec/avcodec/va_surface_internal.h | 4 ++--
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 265408dce1..cd754d52f2 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -129,13 +129,14 @@ static int DxCreateDecoderSurfaces(vlc_va_t *, int codec_id,
                                    const video_format_t *fmt, size_t surface_count);
 static void DxDestroySurfaces(void *);
 
-static void SetupAVCodecContext(void *opaque)
+static void SetupAVCodecContext(void *opaque, AVCodecContext *avctx)
 {
     vlc_va_sys_t *sys = opaque;
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface = sys->hw_surface;
     sys->hw.context_mutex = sys->d3d_dev.context_mutex;
     sys->hw.workaround = sys->selected_decoder->workaround;
+    avctx->hwaccel_context = &sys->hw;
 }
 
 static void d3d11va_pic_context_destroy(picture_context_t *opaque)
@@ -367,8 +368,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
         IDXGIAdapter_Release(p_adapter);
     }
 
-    ctx->hwaccel_context = &sys->hw;
-
     va->ops = &ops;
     *vtcx_out = sys->vctx;
     return VLC_SUCCESS;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index d50b887cf5..0e242b1905 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -152,12 +152,13 @@ static int DxCreateVideoDecoder(vlc_va_t *, int codec_id,
                                 const video_format_t *, size_t surface_count);
 static void DxDestroyVideoDecoder(void *);
 
-static void SetupAVCodecContext(void *opaque)
+static void SetupAVCodecContext(void *opaque, AVCodecContext *avctx)
 {
     vlc_va_sys_t *sys = opaque;
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface = sys->hw_surface;
     sys->hw.workaround = sys->selected_decoder->workaround;
+    avctx->hwaccel_context = &sys->hw;
 }
 
 static void dxva2_pic_context_destroy(picture_context_t *opaque)
@@ -348,8 +349,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
                     DxgiVendorStr(d3dai.VendorId), d3dai.VendorId, d3dai.DeviceId, d3dai.Revision);
     }
 
-    ctx->hwaccel_context = &sys->hw;
-
     va->ops = &ops;
     *vtcx_out = sys->vctx;
     return VLC_SUCCESS;
diff --git a/modules/codec/avcodec/va_surface.c b/modules/codec/avcodec/va_surface.c
index 974090ab71..d70e55eb3c 100644
--- a/modules/codec/avcodec/va_surface.c
+++ b/modules/codec/avcodec/va_surface.c
@@ -76,7 +76,7 @@ static void va_pool_Release(va_pool_t *va_pool)
 }
 
 /* */
-int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, const AVCodecContext *avctx,
+int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, AVCodecContext *avctx,
                          const video_format_t *fmt, size_t count)
 {
     if ( va_pool->surface_count >= count &&
@@ -109,7 +109,7 @@ int va_pool_SetupDecoder(vlc_va_t *va, va_pool_t *va_pool, const AVCodecContext
         surface->va_pool = va_pool;
     }
 done:
-    va_pool->callbacks.pf_setup_avcodec_ctx(va_pool->callbacks.opaque);
+    va_pool->callbacks.pf_setup_avcodec_ctx(va_pool->callbacks.opaque, avctx);
 
     return VLC_SUCCESS;
 }
diff --git a/modules/codec/avcodec/va_surface_internal.h b/modules/codec/avcodec/va_surface_internal.h
index 4ed38af02b..4558505182 100644
--- a/modules/codec/avcodec/va_surface_internal.h
+++ b/modules/codec/avcodec/va_surface_internal.h
@@ -52,14 +52,14 @@ struct va_pool_cfg {
     /**
      * Set the avcodec hw context after the decoder is created
      */
-    void (*pf_setup_avcodec_ctx)(void *opaque);
+    void (*pf_setup_avcodec_ctx)(void *opaque, AVCodecContext *avctx);
 
     void *opaque;
 };
 
 va_pool_t * va_pool_Create(vlc_va_t *, const struct va_pool_cfg *);
 void va_pool_Close(va_pool_t *);
-int va_pool_SetupDecoder(vlc_va_t *, va_pool_t *, const AVCodecContext *, const video_format_t *, size_t count);
+int va_pool_SetupDecoder(vlc_va_t *, va_pool_t *, AVCodecContext *, const video_format_t *, size_t count);
 vlc_va_surface_t *va_pool_Get(va_pool_t *);
 
 size_t va_surface_GetIndex(const vlc_va_surface_t *surface);



More information about the vlc-commits mailing list