[vlc-commits] [Git][videolan/vlc][master] 5 commits: d3d11_decoder: use proper decoder return codes

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Feb 13 13:52:03 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c4b6633a by Steve Lhomme at 2023-02-13T13:30:54+00:00
d3d11_decoder: use proper decoder return codes

- - - - -
35c15157 by Steve Lhomme at 2023-02-13T13:30:54+00:00
d3d11_fmt: support legacy shared textures

- - - - -
ac59ee7b by Steve Lhomme at 2023-02-13T13:30:54+00:00
d3d11_decoder: use proper OpenSharedResource depending on sharing mode

- - - - -
05b9037e by Steve Lhomme at 2023-02-13T13:30:54+00:00
d3d11_fmt: add helper to set a ID3D11Texture inside a picture

- - - - -
daac9a10 by Steve Lhomme at 2023-02-13T13:30:54+00:00
d3d11_surface: add mapping VLC_CODEC_D3D11_OPAQUE_RGBA to VLC_CODEC_RGBA10

It reprensents both DXGI_FORMAT_R8G8B8A8_UNORM and DXGI_FORMAT_R10G10B10A2_UNORM.
The latter being mapped to VLC_CODEC_RGBA10.

- - - - -


4 changed files:

- modules/hw/d3d11/d3d11_decoder.cpp
- modules/hw/d3d11/d3d11_surface.c
- modules/video_chroma/d3d11_fmt.c
- modules/video_chroma/d3d11_fmt.h


Changes:

=====================================
modules/hw/d3d11/d3d11_decoder.cpp
=====================================
@@ -123,7 +123,7 @@ static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
         {
             msg_Err(p_dec, "Unknown texture format %d", outDesc.Format);
             block_Release( p_block );
-            return VLC_EGENERIC;
+            return VLCDEC_ECRITICAL;
         }
     }
 
@@ -134,14 +134,14 @@ static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
         if (!p_sys->vctx)
         {
             block_Release( p_block );
-            return VLC_EGENERIC;
+            return VLCDEC_ECRITICAL;
         }
         DxgiFormatMask( p_sys->output_format->formatTexture, &p_dec->fmt_out.video );
 
         if( decoder_UpdateVideoOutput( p_dec, p_sys->vctx ) )
         {
             block_Release( p_block );
-            return VLCDEC_SUCCESS;
+            return VLCDEC_ECRITICAL;
         }
     }
 
@@ -167,17 +167,23 @@ static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
     assert(src_sys->texture[1] == nullptr);
 
     d3d11_decoder_device_t *dev_sys = GetD3D11OpaqueDevice(p_sys->dec_dev);
-    ComPtr<ID3D11Device1> d3d11VLC1;
-    dev_sys->d3d_dev.d3ddevice->QueryInterface(IID_GRAPHICS_PPV_ARGS(&d3d11VLC1));
-
+    ID3D11Texture2D* sharedTex;
     picture_sys_d3d11_t *pic_sys = ActiveD3D11PictureSys(p_pic);
+    if (pic_sys->ownHandle)
+    {
+        ComPtr<ID3D11Device1> d3d11VLC1;
+        dev_sys->d3d_dev.d3ddevice->QueryInterface(IID_GRAPHICS_PPV_ARGS(&d3d11VLC1));
 
-    ID3D11Texture2D* sharedTex;
-    hr = d3d11VLC1->OpenSharedResource1(pic_sys->sharedHandle, IID_GRAPHICS_PPV_ARGS(&sharedTex));
+        hr = d3d11VLC1->OpenSharedResource1(pic_sys->sharedHandle, IID_GRAPHICS_PPV_ARGS(&sharedTex));
+    }
+    else
+    {
+        hr = dev_sys->d3d_dev.d3ddevice->OpenSharedResource(pic_sys->sharedHandle, IID_GRAPHICS_PPV_ARGS(&sharedTex));
+    }
     if (unlikely(FAILED(hr)))
     {
         block_Release( p_block );
-        return VLCDEC_SUCCESS;
+        return VLCDEC_ECRITICAL;
     }
 
     ID3D11Texture2D *srcTex = src_sys->texture[0];


=====================================
modules/hw/d3d11/d3d11_surface.c
=====================================
@@ -728,6 +728,7 @@ int D3D11OpenConverter( filter_t *p_filter )
         pixel_bytes = 2;
         break;
     case VLC_CODEC_RGBA:
+    case VLC_CODEC_RGBA10:
         if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_RGBA )
             return VLC_EGENERIC;
         p_filter->ops = &D3D11_RGBA_ops;


=====================================
modules/video_chroma/d3d11_fmt.c
=====================================
@@ -781,6 +781,46 @@ const d3d_format_t *(FindD3D11Format)(vlc_object_t *o,
     return NULL;
 }
 
+void D3D11_PictureAttach(picture_t *pic, ID3D11Texture2D *slicedTexture, const d3d_format_t *cfg)
+{
+    struct d3d11_pic_context *pic_ctx = D3D11_PICCONTEXT_FROM_PICCTX(pic->context);
+    D3D11_TEXTURE2D_DESC texDesc;
+    ID3D11Texture2D_GetDesc(slicedTexture, &texDesc);
+
+    if (texDesc.CPUAccessFlags != 0)
+    {
+        const video_format_t *fmt = &pic->format;
+
+        const vlc_chroma_description_t *p_chroma_desc = vlc_fourcc_GetChromaDescription( fmt->i_chroma );
+        if( !p_chroma_desc )
+            return;
+
+        for( unsigned i = 0; i < p_chroma_desc->plane_count; i++ )
+        {
+            plane_t *p = &pic->p[i];
+
+            p->i_lines         = fmt->i_height * p_chroma_desc->p[i].h.num / p_chroma_desc->p[i].h.den;
+            p->i_visible_lines = fmt->i_visible_height * p_chroma_desc->p[i].h.num / p_chroma_desc->p[i].h.den;
+            p->i_pitch         = fmt->i_width * p_chroma_desc->p[i].w.num / p_chroma_desc->p[i].w.den * p_chroma_desc->pixel_size;
+            p->i_visible_pitch = fmt->i_visible_width * p_chroma_desc->p[i].w.num / p_chroma_desc->p[i].w.den * p_chroma_desc->pixel_size;
+            p->i_pixel_pitch   = p_chroma_desc->pixel_size;
+        }
+    }
+
+    for (unsigned plane = 0; plane < DXGI_MAX_SHADER_VIEW; plane++)
+    {
+        if (!cfg->resourceFormat[plane])
+        {
+            pic_ctx->picsys.texture[plane] = NULL;
+        }
+        else
+        {
+            pic_ctx->picsys.texture[plane] = slicedTexture;
+            ID3D11Texture2D_AddRef(slicedTexture);
+        }
+    }
+}
+
 #undef AllocateTextures
 int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
                       const d3d_format_t *cfg, const video_format_t *fmt, bool shared,
@@ -927,7 +967,7 @@ void d3d11_pic_context_destroy(picture_context_t *ctx)
 {
     struct d3d11_pic_context *pic_ctx = D3D11_PICCONTEXT_FROM_PICCTX(ctx);
     ReleaseD3D11PictureSys(&pic_ctx->picsys);
-    if (pic_ctx->picsys.sharedHandle != INVALID_HANDLE_VALUE)
+    if (pic_ctx->picsys.sharedHandle != INVALID_HANDLE_VALUE && pic_ctx->picsys.ownHandle)
         CloseHandle(pic_ctx->picsys.sharedHandle);
     free(pic_ctx);
 }
@@ -985,6 +1025,7 @@ picture_t *D3D11_AllocPicture(vlc_object_t *obj,
             IDXGIResource1_CreateSharedHandle(sharedResource, NULL,
                                               DXGI_SHARED_RESOURCE_READ/*|DXGI_SHARED_RESOURCE_WRITE*/,
                                               NULL, &pic_ctx->picsys.sharedHandle);
+            pic_ctx->picsys.ownHandle = true;
             IDXGIResource1_Release(sharedResource);
         }
     }


=====================================
modules/video_chroma/d3d11_fmt.h
=====================================
@@ -74,6 +74,7 @@ typedef struct
     ID3D11VideoProcessorOutputView *processorOutput; /* when used as processor output */
     ID3D11ShaderResourceView      *renderSrc[DXGI_MAX_SHADER_VIEW];
     HANDLE                        sharedHandle;
+    bool                          ownHandle;
 } picture_sys_d3d11_t;
 
 struct d3d11_pic_context
@@ -207,6 +208,8 @@ picture_t *D3D11_AllocPicture(vlc_object_t *,
                               const video_format_t *, vlc_video_context *,
                               bool, const d3d_format_t *);
 
+void D3D11_PictureAttach(picture_t *, ID3D11Texture2D *textures, const d3d_format_t *cfg);
+
 #ifdef __cplusplus
 }
 #endif



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/86cb8fd2e2df1eac9dcdc93c5123583f71d33731...daac9a10cb3cf98697dda96a334610694a470ea2

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/86cb8fd2e2df1eac9dcdc93c5123583f71d33731...daac9a10cb3cf98697dda96a334610694a470ea2
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list