[vlc-devel] [PATCH 39/39] directx_va: no need to allocate dummy pictures anymore

Steve Lhomme robux4 at videolabs.io
Fri Jun 2 16:46:42 CEST 2017


We don't use their local picture_sys_t anymore
---
 modules/codec/avcodec/d3d11va.c    | 41 --------------------------------------
 modules/codec/avcodec/directx_va.c |  7 +------
 modules/codec/avcodec/directx_va.h |  7 -------
 modules/codec/avcodec/dxva2.c      | 24 ----------------------
 4 files changed, 1 insertion(+), 78 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index cb6bdc2f7f..2ed3b3f132 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -150,8 +150,6 @@ static int DxCreateDecoderSurfaces(vlc_va_t *, int codec_id, const video_format_
 static void DxDestroySurfaces(vlc_va_t *);
 static void SetupAVCodecContext(vlc_va_t *);
 
-static picture_t *DxAllocPicture(vlc_va_t *, const video_format_t *, unsigned index);
-
 /* */
 static void Setup(vlc_va_t *va, vlc_fourcc_t *chroma)
 {
@@ -385,7 +383,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     dx_sys->pf_setup_avcodec_ctx       = SetupAVCodecContext;
     dx_sys->pf_get_input_list          = DxGetInputList;
     dx_sys->pf_setup_output            = DxSetupOutput;
-    dx_sys->pf_alloc_surface_pic       = DxAllocPicture;
     dx_sys->psz_decoder_dll            = TEXT("D3D11.DLL");
 
     va->sys = sys;
@@ -993,41 +990,3 @@ static void DxDestroySurfaces(vlc_va_t *va)
         }
     }
 }
-
-static void DestroyPicture(picture_t *picture)
-{
-    picture_sys_t *p_sys = picture->p_sys;
-    ReleasePictureSys(p_sys);
-    free(p_sys);
-    free(picture);
-}
-
-static picture_t *DxAllocPicture(vlc_va_t *va, const video_format_t *fmt, unsigned index)
-{
-    vlc_va_sys_t *sys = va->sys;
-    if (sys->b_extern_pool)
-        return sys->extern_pics[index];
-
-    video_format_t src_fmt = *fmt;
-    src_fmt.i_chroma = sys->i_chroma;
-    picture_sys_t *pic_sys = calloc(1, sizeof(*pic_sys));
-    if (unlikely(pic_sys == NULL))
-        return NULL;
-
-    pic_sys->decoder = sys->dx_sys.hw_surface[index];
-    ID3D11VideoDecoderOutputView_GetResource(pic_sys->decoder, &pic_sys->resource[KNOWN_DXGI_INDEX]);
-    pic_sys->context  = sys->d3dctx;
-
-    picture_resource_t res = {
-        .p_sys      = pic_sys,
-        .pf_destroy = DestroyPicture,
-    };
-    picture_t *pic = picture_NewFromResource(&src_fmt, &res);
-    if (unlikely(pic == NULL))
-    {
-        free(pic_sys);
-        return NULL;
-    }
-    return pic;
-}
-
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 9caeb8996d..085f1a401b 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -351,7 +351,6 @@ int directx_va_Setup(vlc_va_t *va, directx_sys_t *dx_sys, AVCodecContext *avctx)
             return VLC_ENOMEM;
         }
         atomic_init(&surface->refcount, 1);
-        surface->p_pic = dx_sys->pf_alloc_surface_pic(va, &fmt, i);
         dx_sys->surface[i] = surface;
     }
 
@@ -366,12 +365,8 @@ void DestroyVideoDecoder(vlc_va_t *va, directx_sys_t *dx_sys)
     dx_sys->pf_destroy_surfaces(va);
 
     for (int i = 0; i < dx_sys->surface_count; i++)
-        IUnknown_Release( dx_sys->hw_surface[i] );
-
-    for (int i = 0; i < dx_sys->surface_count; i++)
     {
-        if (dx_sys->surface[i]->p_pic)
-            picture_Release(dx_sys->surface[i]->p_pic);
+        IUnknown_Release( dx_sys->hw_surface[i] );
         directx_va_Release(dx_sys->surface[i]);
     }
 
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index d1ed39b641..a53d62695d 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -45,7 +45,6 @@
 /* */
 struct vlc_va_surface_t {
     atomic_uintptr_t     refcount;
-    picture_t          *p_pic;
     AVVA_DecoderSurface  *decoderSurface;
 };
 
@@ -121,12 +120,6 @@ typedef struct
      * Set the avcodec hw context after the decoder is created
      */
     void (*pf_setup_avcodec_ctx)(vlc_va_t *);
-    /**
-     * @brief pf_alloc_surface_pic
-     * @param fmt
-     * @return
-     */
-    picture_t *(*pf_alloc_surface_pic)(vlc_va_t *, const video_format_t *, unsigned);
 
 } directx_sys_t;
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 4d2a0cc1fa..390054c78a 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -134,8 +134,6 @@ struct vlc_va_sys_t
     struct dxva_context hw;
 };
 
-static picture_t *DxAllocPicture(vlc_va_t *, const video_format_t *, unsigned index);
-
 
 /* */
 static int D3dCreateDevice(vlc_va_t *);
@@ -303,7 +301,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     dx_sys->pf_setup_avcodec_ctx       = SetupAVCodecContext;
     dx_sys->pf_get_input_list          = DxGetInputList;
     dx_sys->pf_setup_output            = DxSetupOutput;
-    dx_sys->pf_alloc_surface_pic       = DxAllocPicture;
     dx_sys->psz_decoder_dll            = TEXT("DXVA2.DLL");
 
     va->sys = sys;
@@ -778,24 +775,3 @@ static int DxResetVideoDecoder(vlc_va_t *va)
     msg_Err(va, "DxResetVideoDecoder unimplemented");
     return VLC_EGENERIC;
 }
-
-static picture_t *DxAllocPicture(vlc_va_t *va, const video_format_t *fmt, unsigned index)
-{
-    video_format_t src_fmt = *fmt;
-    src_fmt.i_chroma = va->sys->i_chroma;
-    picture_sys_t *pic_sys = calloc(1, sizeof(*pic_sys));
-    if (unlikely(pic_sys == NULL))
-        return NULL;
-    pic_sys->surface = va->sys->dx_sys.hw_surface[index];
-
-    picture_resource_t res = {
-        .p_sys = pic_sys,
-    };
-    picture_t *pic = picture_NewFromResource(&src_fmt, &res);
-    if (unlikely(pic == NULL))
-    {
-        free(pic_sys);
-        return NULL;
-    }
-    return pic;
-}
-- 
2.12.1



More information about the vlc-devel mailing list