d3d11_fmt: avoid a cast between ID3D11Texture2D* and ID3D11Resource*
authorSteve Lhomme <robUx4@videolabs.io>
Thu, 2 Feb 2017 13:54:15 +0000 (14:54 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 8 Feb 2017 12:49:59 +0000 (13:49 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/avcodec/d3d11va.c
modules/video_chroma/d3d11_fmt.h
modules/video_chroma/d3d11_surface.c
modules/video_output/win32/direct3d11.c

index e44fe91..4e90d86 100644 (file)
@@ -265,7 +265,7 @@ static int Extract(vlc_va_t *va, picture_t *output, uint8_t *data)
                 };
 
                 HRESULT hr = ID3D11VideoDevice_CreateVideoProcessorOutputView((ID3D11VideoDevice*) sys->dx_sys.d3ddec,
-                                                                 (ID3D11Resource*) p_sys_out->texture,
+                                                                 p_sys_out->resource,
                                                                  sys->procEnumerator,
                                                                  &outDesc,
                                                                  (ID3D11VideoProcessorOutputView**) &p_sys_out->decoder);
@@ -302,15 +302,15 @@ static int Extract(vlc_va_t *va, picture_t *output, uint8_t *data)
             ID3D11VideoDecoderOutputView_GetDesc( src, &viewDesc );
 
             D3D11_TEXTURE2D_DESC dstDesc;
-            ID3D11Texture2D_GetDesc( (ID3D11Texture2D*) p_sys_out->texture, &dstDesc);
+            ID3D11Texture2D_GetDesc( p_sys_out->texture, &dstDesc);
 
             /* copy decoder slice to surface */
             D3D11_BOX copyBox = {
                 .right = dstDesc.Width, .bottom = dstDesc.Height, .back = 1,
             };
-            ID3D11DeviceContext_CopySubresourceRegion(sys->d3dctx, (ID3D11Resource*) p_sys_out->texture,
+            ID3D11DeviceContext_CopySubresourceRegion(sys->d3dctx, p_sys_out->resource,
                                                       p_sys_out->slice_index, 0, 0, 0,
-                                                      (ID3D11Resource*) p_sys_in->texture,
+                                                      p_sys_in->resource,
                                                       viewDesc.Texture2D.ArraySlice,
                                                       &copyBox);
         }
@@ -452,7 +452,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
 
             assert(p_sys->texture != NULL);
             D3D11_TEXTURE2D_DESC dstDesc;
-            ID3D11Texture2D_GetDesc( (ID3D11Texture2D*) p_sys->texture, &dstDesc);
+            ID3D11Texture2D_GetDesc( p_sys->texture, &dstDesc);
             sys->render = dstDesc.Format;
         }
     }
@@ -998,7 +998,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id, const video_forma
 
             viewDesc.Texture2D.ArraySlice = pic->p_sys->slice_index;
             hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( (ID3D11VideoDevice*) dx_sys->d3ddec,
-                                                                 (ID3D11Resource*) pic->p_sys->texture,
+                                                                 pic->p_sys->resource,
                                                                  &viewDesc,
                                                                  &pic->p_sys->decoder );
             if (FAILED(hr)) {
@@ -1177,7 +1177,7 @@ static picture_t *DxAllocPicture(vlc_va_t *va, const video_format_t *fmt, unsign
         return NULL;
 
     pic_sys->decoder  = (ID3D11VideoDecoderOutputView*) sys->dx_sys.hw_surface[index];
-    ID3D11VideoDecoderOutputView_GetResource(pic_sys->decoder, (ID3D11Resource**) &pic_sys->texture);
+    ID3D11VideoDecoderOutputView_GetResource(pic_sys->decoder, &pic_sys->resource);
     pic_sys->context  = sys->d3dctx;
 
     if (sys->procEnumerator)
@@ -1190,7 +1190,7 @@ static picture_t *DxAllocPicture(vlc_va_t *va, const video_format_t *fmt, unsign
         };
 
         HRESULT hr = ID3D11VideoDevice_CreateVideoProcessorInputView((ID3D11VideoDevice*) sys->dx_sys.d3ddec,
-                                                        (ID3D11Resource*) pic_sys->texture,
+                                                        pic_sys->resource,
                                                         sys->procEnumerator,
                                                         &inDesc,
                                                         &pic_sys->inputView);
index 5fbab72..354a4bc 100644 (file)
 struct picture_sys_t
 {
     ID3D11VideoDecoderOutputView  *decoder; /* may be NULL for pictures from the pool */
-    ID3D11Texture2D               *texture;
+    union {
+        ID3D11Texture2D           *texture;
+        ID3D11Resource            *resource;
+    };
     ID3D11DeviceContext           *context;
     unsigned                      slice_index;
     ID3D11VideoProcessorInputView *inputView; /* when used as processor input */
index 6413ba5..655c697 100644 (file)
@@ -110,7 +110,7 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
 
     ID3D11DeviceContext_CopySubresourceRegion(p_sys->context, (ID3D11Resource*) sys->staging,
                                               0, 0, 0, 0,
-                                              (ID3D11Resource*) p_sys->texture, viewDesc.Texture2D.ArraySlice,
+                                              p_sys->resource, viewDesc.Texture2D.ArraySlice,
                                               NULL);
 
     HRESULT hr = ID3D11DeviceContext_Map(p_sys->context, (ID3D11Resource*) sys->staging,
@@ -191,7 +191,7 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
 
     ID3D11DeviceContext_CopySubresourceRegion(p_sys->context, (ID3D11Resource*) sys->staging,
                                               0, 0, 0, 0,
-                                              (ID3D11Resource*) p_sys->texture, viewDesc.Texture2D.ArraySlice,
+                                              p_sys->resource, viewDesc.Texture2D.ArraySlice,
                                               NULL);
 
     HRESULT hr = ID3D11DeviceContext_Map(p_sys->context, (ID3D11Resource*) sys->staging,
index 52a5cc1..eea5d59 100644 (file)
@@ -1106,7 +1106,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         ID3D11DeviceContext_CopySubresourceRegion(sys->d3dcontext,
                                                   (ID3D11Resource*) sys->picQuad.pTexture,
                                                   0, 0, 0, 0,
-                                                  (ID3D11Resource*) p_sys->texture,
+                                                  p_sys->resource,
                                                   p_sys->slice_index, &box);
         if ( sys->context_lock != INVALID_HANDLE_VALUE)
             ReleaseMutex( sys->context_lock );