[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: avcodec: va: pass the software format description to the VA

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Apr 7 08:10:32 UTC 2023



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
52939152 by Steve Lhomme at 2023-04-07T07:49:28+00:00
avcodec: va: pass the software format description to the VA

The codec profile alone doesn't always give information on the bit depth or
chroma subsampling (see HEVC Range Extension).

(cherry picked from commit c8a1298cec05f2947a5f9708fcb12c99e20490ca) (edited)

edited:
* on 3.0 the picture_sys_t is passed to the VA
* on 3.0 the directx_sys_t is not const
* on 4.0 FindVideoServiceConversion returns the matching decoder GUID

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -
e8b689c0 by Steve Lhomme at 2023-04-07T07:49:28+00:00
directx_va: check the bit depth matches what the decoder can handle

(cherry picked from commit 53b022588b40e7997564e5b75f416846c22651a2) (rebased)

rebased:
* in 3.0 the directx_sys_t is not passed as const

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -


9 changed files:

- modules/codec/avcodec/d3d11va.c
- modules/codec/avcodec/directx_va.c
- modules/codec/avcodec/directx_va.h
- modules/codec/avcodec/dxva2.c
- modules/codec/avcodec/va.c
- modules/codec/avcodec/va.h
- modules/codec/avcodec/vaapi.c
- modules/codec/avcodec/video.c
- modules/hw/vdpau/avcodec.c


Changes:

=====================================
modules/codec/avcodec/d3d11va.c
=====================================
@@ -55,7 +55,7 @@
 #define D3D_DecoderSurface  ID3D11VideoDecoderOutputView
 #include "directx_va.h"
 
-static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
+static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,
                 const es_format_t *, picture_sys_t *p_sys);
 static void Close(vlc_va_t *, void **);
 
@@ -307,7 +307,8 @@ static void Close(vlc_va_t *va, void **ctx)
     free(sys);
 }
 
-static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
+static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
+                enum PixelFormat pix_fmt,
                 const es_format_t *fmt, picture_sys_t *p_sys)
 {
     int err = VLC_EGENERIC;
@@ -398,7 +399,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     if (err!=VLC_SUCCESS)
         goto error;
 
-    err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt, isXboxHardware(&sys->d3d_dev));
+    err = directx_va_Setup(va, &sys->dx_sys, ctx, desc, fmt, isXboxHardware(&sys->d3d_dev));
     if (err != VLC_SUCCESS)
         goto error;
 


=====================================
modules/codec/avcodec/directx_va.c
=====================================
@@ -169,6 +169,7 @@ DEFINE_GUID(DXVA_ModeVP9_VLD_Intel,                 0x76988a52, 0xdf13, 0x419a,
 typedef struct {
     const char   *name;
     const GUID   *guid;
+    int           bit_depth;
     enum AVCodecID codec;
     const int    *p_profiles; // NULL or ends with 0
 } directx_va_mode_t;
@@ -176,105 +177,106 @@ typedef struct {
 /* XXX Preferred modes must come first */
 static const directx_va_mode_t DXVA_MODES[] = {
     /* MPEG-1/2 */
-    { "MPEG-1 decoder, restricted profile A",                                         &DXVA_ModeMPEG1_A,                      0, NULL },
-    { "MPEG-2 decoder, restricted profile A",                                         &DXVA_ModeMPEG2_A,                      0, NULL },
-    { "MPEG-2 decoder, restricted profile B",                                         &DXVA_ModeMPEG2_B,                      0, NULL },
-    { "MPEG-2 decoder, restricted profile C",                                         &DXVA_ModeMPEG2_C,                      0, NULL },
-    { "MPEG-2 decoder, restricted profile D",                                         &DXVA_ModeMPEG2_D,                      0, NULL },
-
-    { "MPEG-2 variable-length decoder",                                               &DXVA2_ModeMPEG2_VLD,                   AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN },
-    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA2_ModeMPEG2and1_VLD,               AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN },
-    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA2_ModeMPEG2and1_VLD,               AV_CODEC_ID_MPEG1VIDEO, NULL },
-    { "MPEG-2 motion compensation",                                                   &DXVA2_ModeMPEG2_MoComp,                0, NULL },
-    { "MPEG-2 inverse discrete cosine transform",                                     &DXVA2_ModeMPEG2_IDCT,                  0, NULL },
+    { "MPEG-1 decoder, restricted profile A",                                         &DXVA_ModeMPEG1_A,                      8, 0, NULL },
+    { "MPEG-2 decoder, restricted profile A",                                         &DXVA_ModeMPEG2_A,                      8, 0, NULL },
+    { "MPEG-2 decoder, restricted profile B",                                         &DXVA_ModeMPEG2_B,                      8, 0, NULL },
+    { "MPEG-2 decoder, restricted profile C",                                         &DXVA_ModeMPEG2_C,                      8, 0, NULL },
+    { "MPEG-2 decoder, restricted profile D",                                         &DXVA_ModeMPEG2_D,                      8, 0, NULL },
+
+    { "MPEG-2 variable-length decoder",                                               &DXVA2_ModeMPEG2_VLD,                   8, AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN },
+    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA2_ModeMPEG2and1_VLD,               8, AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN },
+    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA2_ModeMPEG2and1_VLD,               8, AV_CODEC_ID_MPEG1VIDEO, NULL },
+    { "MPEG-2 motion compensation",                                                   &DXVA2_ModeMPEG2_MoComp,                8, 0, NULL },
+    { "MPEG-2 inverse discrete cosine transform",                                     &DXVA2_ModeMPEG2_IDCT,                  8, 0, NULL },
 
     /* MPEG-1 http://download.microsoft.com/download/B/1/7/B172A3C8-56F2-4210-80F1-A97BEA9182ED/DXVA_MPEG1_VLD.pdf */
-    { "MPEG-1 variable-length decoder, no D pictures",                                &DXVA2_ModeMPEG1_VLD,                   0, NULL },
+    { "MPEG-1 variable-length decoder, no D pictures",                                &DXVA2_ModeMPEG1_VLD,                   8, 0, NULL },
 
     /* H.264 http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=3d1c290b-310b-4ea2-bf76-714063a6d7a6 */
-    { "H.264 variable-length decoder, film grain technology",                         &DXVA2_ModeH264_F,                      AV_CODEC_ID_H264, PROF_H264_HIGH },
-    { "H.264 variable-length decoder, no film grain technology",                      &DXVA2_ModeH264_E,                      AV_CODEC_ID_H264, PROF_H264_HIGH },
-    { "H.264 variable-length decoder, no film grain technology (Intel ClearVideo)",   &DXVA_Intel_H264_NoFGT_ClearVideo,      AV_CODEC_ID_H264, PROF_H264_HIGH },
-    { "H.264 variable-length decoder, no film grain technology, FMO/ASO",             &DXVA_ModeH264_VLD_WithFMOASO_NoFGT,    AV_CODEC_ID_H264, PROF_H264_HIGH },
-    { "H.264 variable-length decoder, no film grain technology, Flash",               &DXVA_ModeH264_VLD_NoFGT_Flash,         AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "H.264 variable-length decoder, film grain technology",                         &DXVA2_ModeH264_F,                      8, AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "H.264 variable-length decoder, no film grain technology",                      &DXVA2_ModeH264_E,                      8, AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "H.264 variable-length decoder, no film grain technology (Intel ClearVideo)",   &DXVA_Intel_H264_NoFGT_ClearVideo,      8, AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "H.264 variable-length decoder, no film grain technology, FMO/ASO",             &DXVA_ModeH264_VLD_WithFMOASO_NoFGT,    8, AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "H.264 variable-length decoder, no film grain technology, Flash",               &DXVA_ModeH264_VLD_NoFGT_Flash,         8, AV_CODEC_ID_H264, PROF_H264_HIGH },
 
-    { "H.264 inverse discrete cosine transform, film grain technology",               &DXVA2_ModeH264_D,                      0, NULL },
-    { "H.264 inverse discrete cosine transform, no film grain technology",            &DXVA2_ModeH264_C,                      0, NULL },
-    { "H.264 inverse discrete cosine transform, no film grain technology (Intel)",    &DXVADDI_Intel_ModeH264_C,              0, NULL },
+    { "H.264 inverse discrete cosine transform, film grain technology",               &DXVA2_ModeH264_D,                      8, 0, NULL },
+    { "H.264 inverse discrete cosine transform, no film grain technology",            &DXVA2_ModeH264_C,                      8, 0, NULL },
+    { "H.264 inverse discrete cosine transform, no film grain technology (Intel)",    &DXVADDI_Intel_ModeH264_C,              8, 0, NULL },
 
-    { "H.264 motion compensation, film grain technology",                             &DXVA2_ModeH264_B,                      0, NULL },
-    { "H.264 motion compensation, no film grain technology",                          &DXVA2_ModeH264_A,                      0, NULL },
-    { "H.264 motion compensation, no film grain technology (Intel)",                  &DXVADDI_Intel_ModeH264_A,              0, NULL },
+    { "H.264 motion compensation, film grain technology",                             &DXVA2_ModeH264_B,                      8, 0, NULL },
+    { "H.264 motion compensation, no film grain technology",                          &DXVA2_ModeH264_A,                      8, 0, NULL },
+    { "H.264 motion compensation, no film grain technology (Intel)",                  &DXVADDI_Intel_ModeH264_A,              8, 0, NULL },
 
     /* http://download.microsoft.com/download/2/D/0/2D02E72E-7890-430F-BA91-4A363F72F8C8/DXVA_H264_MVC.pdf */
-    { "H.264 stereo high profile, mbs flag set",                                      &DXVA_ModeH264_VLD_Stereo_Progressive_NoFGT, 0, NULL },
-    { "H.264 stereo high profile",                                                    &DXVA_ModeH264_VLD_Stereo_NoFGT,             0, NULL },
-    { "H.264 multiview high profile",                                                 &DXVA_ModeH264_VLD_Multiview_NoFGT,          0, NULL },
+    { "H.264 stereo high profile, mbs flag set",                                      &DXVA_ModeH264_VLD_Stereo_Progressive_NoFGT, 8, 0, NULL },
+    { "H.264 stereo high profile",                                                    &DXVA_ModeH264_VLD_Stereo_NoFGT,             8, 0, NULL },
+    { "H.264 multiview high profile",                                                 &DXVA_ModeH264_VLD_Multiview_NoFGT,          8, 0, NULL },
 
     /* SVC http://download.microsoft.com/download/C/8/A/C8AD9F1B-57D1-4C10-85A0-09E3EAC50322/DXVA_SVC_2012_06.pdf */
-    { "H.264 scalable video coding, Scalable Baseline Profile",                       &DXVA_ModeH264_VLD_SVC_Scalable_Baseline,            0, NULL },
-    { "H.264 scalable video coding, Scalable Constrained Baseline Profile",           &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline, 0, NULL },
-    { "H.264 scalable video coding, Scalable High Profile",                           &DXVA_ModeH264_VLD_SVC_Scalable_High,                0, NULL },
-    { "H.264 scalable video coding, Scalable Constrained High Profile",               &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive, 0, NULL },
+    { "H.264 scalable video coding, Scalable Baseline Profile",                       &DXVA_ModeH264_VLD_SVC_Scalable_Baseline,            8, 0, NULL },
+    { "H.264 scalable video coding, Scalable Constrained Baseline Profile",           &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline, 8, 0, NULL },
+    { "H.264 scalable video coding, Scalable High Profile",                           &DXVA_ModeH264_VLD_SVC_Scalable_High,                8, 0, NULL },
+    { "H.264 scalable video coding, Scalable Constrained High Profile",               &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive, 8, 0, NULL },
 
     /* WMV */
-    { "Windows Media Video 8 motion compensation",                                    &DXVA2_ModeWMV8_B,                      0, NULL },
-    { "Windows Media Video 8 post processing",                                        &DXVA2_ModeWMV8_A,                      0, NULL },
+    { "Windows Media Video 8 motion compensation",                                    &DXVA2_ModeWMV8_B,                      8, 0, NULL },
+    { "Windows Media Video 8 post processing",                                        &DXVA2_ModeWMV8_A,                      8, 0, NULL },
 
-    { "Windows Media Video 9 IDCT",                                                   &DXVA2_ModeWMV9_C,                      0, NULL },
-    { "Windows Media Video 9 motion compensation",                                    &DXVA2_ModeWMV9_B,                      0, NULL },
-    { "Windows Media Video 9 post processing",                                        &DXVA2_ModeWMV9_A,                      0, NULL },
+    { "Windows Media Video 9 IDCT",                                                   &DXVA2_ModeWMV9_C,                      8, 0, NULL },
+    { "Windows Media Video 9 motion compensation",                                    &DXVA2_ModeWMV9_B,                      8, 0, NULL },
+    { "Windows Media Video 9 post processing",                                        &DXVA2_ModeWMV9_A,                      8, 0, NULL },
 
     /* VC-1 */
-    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D,                       AV_CODEC_ID_VC1, NULL },
-    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D,                       AV_CODEC_ID_WMV3, NULL },
-    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D2010,                   AV_CODEC_ID_VC1, NULL },
-    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D2010,                   AV_CODEC_ID_WMV3, NULL },
-    { "VC-1 variable-length decoder 2 (Intel)",                                       &DXVA_Intel_VC1_ClearVideo_2,           0, NULL },
-    { "VC-1 variable-length decoder (Intel)",                                         &DXVA_Intel_VC1_ClearVideo,             0, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D,                       8, AV_CODEC_ID_VC1, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D,                       8, AV_CODEC_ID_WMV3, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D2010,                   8, AV_CODEC_ID_VC1, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D2010,                   8, AV_CODEC_ID_WMV3, NULL },
+    { "VC-1 variable-length decoder 2 (Intel)",                                       &DXVA_Intel_VC1_ClearVideo_2,           8, 0, NULL },
+    { "VC-1 variable-length decoder (Intel)",                                         &DXVA_Intel_VC1_ClearVideo,             8, 0, NULL },
 
-    { "VC-1 inverse discrete cosine transform",                                       &DXVA2_ModeVC1_C,                       0, NULL },
-    { "VC-1 motion compensation",                                                     &DXVA2_ModeVC1_B,                       0, NULL },
-    { "VC-1 post processing",                                                         &DXVA2_ModeVC1_A,                       0, NULL },
+    { "VC-1 inverse discrete cosine transform",                                       &DXVA2_ModeVC1_C,                       8, 0, NULL },
+    { "VC-1 motion compensation",                                                     &DXVA2_ModeVC1_B,                       8, 0, NULL },
+    { "VC-1 post processing",                                                         &DXVA2_ModeVC1_A,                       8, 0, NULL },
 
     /* Xvid/Divx: TODO */
-    { "MPEG-4 Part 2 nVidia bitstream decoder",                                       &DXVA_nVidia_MPEG4_ASP,                 0, NULL },
-    { "MPEG-4 Part 2 variable-length decoder, Simple Profile",                        &DXVA_ModeMPEG4pt2_VLD_Simple,          0, NULL },
-    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, no GMC",       &DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, 0, NULL },
-    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, GMC",          &DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC,   0, NULL },
-    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, Avivo",        &DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo, 0, NULL },
+    { "MPEG-4 Part 2 nVidia bitstream decoder",                                       &DXVA_nVidia_MPEG4_ASP,                 8, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple Profile",                        &DXVA_ModeMPEG4pt2_VLD_Simple,          8, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, no GMC",       &DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, 8, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, GMC",          &DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC,   8, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, Avivo",        &DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo, 8, 0, NULL },
 
     /* HEVC */
-    { "HEVC Main profile",                                                            &DXVA_ModeHEVC_VLD_Main,                AV_CODEC_ID_HEVC, PROF_HEVC_MAIN },
-    { "HEVC Main 10 profile",                                                         &DXVA_ModeHEVC_VLD_Main10,              AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10 },
+    { "HEVC Main profile",                                                            &DXVA_ModeHEVC_VLD_Main,                8, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN },
+    { "HEVC Main 10 profile",                                                         &DXVA_ModeHEVC_VLD_Main10,              10, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10 },
 
     /* H.261 */
-    { "H.261 decoder, restricted profile A",                                          &DXVA_ModeH261_A,                       0, NULL },
-    { "H.261 decoder, restricted profile B",                                          &DXVA_ModeH261_B,                       0, NULL },
+    { "H.261 decoder, restricted profile A",                                          &DXVA_ModeH261_A,                       8, 0, NULL },
+    { "H.261 decoder, restricted profile B",                                          &DXVA_ModeH261_B,                       8, 0, NULL },
 
     /* H.263 */
-    { "H.263 decoder, restricted profile A",                                          &DXVA_ModeH263_A,                       0, NULL },
-    { "H.263 decoder, restricted profile B",                                          &DXVA_ModeH263_B,                       0, NULL },
-    { "H.263 decoder, restricted profile C",                                          &DXVA_ModeH263_C,                       0, NULL },
-    { "H.263 decoder, restricted profile D",                                          &DXVA_ModeH263_D,                       0, NULL },
-    { "H.263 decoder, restricted profile E",                                          &DXVA_ModeH263_E,                       0, NULL },
-    { "H.263 decoder, restricted profile F",                                          &DXVA_ModeH263_F,                       0, NULL },
+    { "H.263 decoder, restricted profile A",                                          &DXVA_ModeH263_A,                       8, 0, NULL },
+    { "H.263 decoder, restricted profile B",                                          &DXVA_ModeH263_B,                       8, 0, NULL },
+    { "H.263 decoder, restricted profile C",                                          &DXVA_ModeH263_C,                       8, 0, NULL },
+    { "H.263 decoder, restricted profile D",                                          &DXVA_ModeH263_D,                       8, 0, NULL },
+    { "H.263 decoder, restricted profile E",                                          &DXVA_ModeH263_E,                       8, 0, NULL },
+    { "H.263 decoder, restricted profile F",                                          &DXVA_ModeH263_F,                       8, 0, NULL },
 
     /* VPx */
-    { "VP8",                                                                          &DXVA_ModeVP8_VLD,                      0, NULL },
+    { "VP8",                                                                          &DXVA_ModeVP8_VLD,                      8, 0, NULL },
 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 57, 17, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
-    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             AV_CODEC_ID_VP9, PROF_VP9_MAIN },
-    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       AV_CODEC_ID_VP9, PROF_VP9_10 },
+    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, AV_CODEC_ID_VP9, PROF_VP9_MAIN },
+    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, AV_CODEC_ID_VP9, PROF_VP9_10 },
 #else
-    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             0, NULL },
-    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       0, NULL },
+    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, 0, NULL },
+    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, 0, NULL },
 #endif
-    { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                0, NULL },
+    { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                8, 0, NULL },
 
-    { NULL, NULL, 0, NULL }
+    { NULL, NULL, 0, 0, NULL }
 };
 
-static int FindVideoServiceConversion(vlc_va_t *, directx_sys_t *, const es_format_t *, const AVCodecContext *);
+static int FindVideoServiceConversion(vlc_va_t *, directx_sys_t *, const es_format_t *,
+                                      const AVCodecContext *, const AVPixFmtDescriptor *);
 
 char *directx_va_GetDecoderName(const GUID *guid)
 {
@@ -290,11 +292,12 @@ char *directx_va_GetDecoderName(const GUID *guid)
 }
 
 /* */
-int directx_va_Setup(vlc_va_t *va, directx_sys_t *dx_sys, const AVCodecContext *avctx,
+int directx_va_Setup(vlc_va_t *va, directx_sys_t *dx_sys,
+                     const AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
                      const es_format_t *fmt, int flag_xbox)
 {
     /* */
-    if (FindVideoServiceConversion(va, dx_sys, fmt, avctx)) {
+    if (FindVideoServiceConversion(va, dx_sys, fmt, avctx, desc)) {
         msg_Err(va, "FindVideoServiceConversion failed");
         return VLC_EGENERIC;
     }
@@ -361,32 +364,32 @@ error:
 static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *fmt,
                               const AVCodecContext *avctx)
 {
-    bool is_supported = mode->p_profiles == NULL;
-    if (!is_supported)
+    if (mode->p_profiles == NULL)
+        return true;
+
+    int profile = fmt->i_profile >= 0 ? fmt->i_profile : avctx->profile;
+    if (mode->codec == AV_CODEC_ID_H264 && profile == -1)
     {
-        int profile = fmt->i_profile >= 0 ? fmt->i_profile : avctx->profile;
-        if (mode->codec == AV_CODEC_ID_H264 && profile == -1)
-        {
-            uint8_t h264_profile;
-            if ( h264_get_profile_level(fmt, &h264_profile, NULL, NULL) )
-                profile = h264_profile;
-        }
-        if (mode->codec == AV_CODEC_ID_HEVC && profile == -1)
-        {
-            uint8_t hevc_profile;
-            if (hevc_get_profile_level(fmt, &hevc_profile, NULL, NULL) )
-                profile = hevc_profile;
-        }
+        uint8_t h264_profile;
+        if ( h264_get_profile_level(fmt, &h264_profile, NULL, NULL) )
+            profile = h264_profile;
+    }
+    if (mode->codec == AV_CODEC_ID_HEVC && profile == -1)
+    {
+        uint8_t hevc_profile;
+        if (hevc_get_profile_level(fmt, &hevc_profile, NULL, NULL) )
+            profile = hevc_profile;
+    }
 
-        if (profile <= 0)
-            is_supported = true;
-        else for (const int *p_profile = &mode->p_profiles[0]; *p_profile != FF_PROFILE_UNKNOWN; ++p_profile)
+    bool is_supported = false;
+    if (profile <= 0)
+        is_supported = true;
+    else for (const int *p_profile = &mode->p_profiles[0]; *p_profile != FF_PROFILE_UNKNOWN; ++p_profile)
+    {
+        if (*p_profile == profile)
         {
-            if (*p_profile == profile)
-            {
-                is_supported = true;
-                break;
-            }
+            is_supported = true;
+            break;
         }
     }
     return is_supported;
@@ -396,7 +399,8 @@ static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *
  * Find the best suited decoder mode GUID and render format.
  */
 static int FindVideoServiceConversion(vlc_va_t *va, directx_sys_t *dx_sys,
-                                      const es_format_t *fmt, const AVCodecContext *avctx)
+                                      const es_format_t *fmt,
+                                      const AVCodecContext *avctx, const AVPixFmtDescriptor *desc)
 {
     input_list_t p_list = { 0 };
     int err = dx_sys->pf_get_input_list(va, &p_list);
@@ -427,19 +431,27 @@ static int FindVideoServiceConversion(vlc_va_t *va, directx_sys_t *dx_sys,
         for (const GUID *g = &p_list.list[0]; !is_supported && g < &p_list.list[p_list.count]; g++) {
             is_supported = IsEqualGUID(mode->guid, g);
         }
-        if ( is_supported )
+        if ( !is_supported )
+            continue;
+
+        int src_bit_depth = (desc && desc->nb_components) ? desc->comp[0].depth : 8;
+        if (src_bit_depth != mode->bit_depth)
         {
-            is_supported = profile_supported( mode, fmt, avctx );
-            if (!is_supported)
-            {
-                char *psz_name = directx_va_GetDecoderName(mode->guid);
-                msg_Warn( va, "Unsupported profile %d for %s ",
-                          fmt->i_profile, psz_name );
-                free( psz_name );
-            }
+            char *psz_name = directx_va_GetDecoderName(mode->guid);
+            msg_Warn( va, "Unsupported bitdepth %d for %s ",
+                    src_bit_depth, psz_name );
+            free( psz_name );
+            continue;
         }
-        if (!is_supported)
+
+        if (!profile_supported( mode, fmt, avctx ))
+        {
+            char *psz_name = directx_va_GetDecoderName(mode->guid);
+            msg_Warn( va, "Unsupported profile %d for %s ",
+                    fmt->i_profile, psz_name );
+            free( psz_name );
             continue;
+        }
 
         /* */
         msg_Dbg(va, "Trying to use '%s' as input", mode->name);


=====================================
modules/codec/avcodec/directx_va.h
=====================================
@@ -80,7 +80,8 @@ typedef struct
 
 int directx_va_Open(vlc_va_t *, directx_sys_t *);
 void directx_va_Close(vlc_va_t *, directx_sys_t *);
-int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *avctx, const es_format_t *, int flag_xbox);
+int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *, const AVPixFmtDescriptor *,
+                     const es_format_t *, int flag_xbox);
 char *directx_va_GetDecoderName(const GUID *guid);
 bool directx_va_canUseDecoder(vlc_va_t *, UINT VendorId, UINT DeviceId, const GUID *pCodec, UINT driverBuild);
 


=====================================
modules/codec/avcodec/dxva2.c
=====================================
@@ -43,7 +43,7 @@
 #define D3D_DecoderSurface  IDirect3DSurface9
 #include "directx_va.h"
 
-static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
+static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,
                 const es_format_t *, picture_sys_t *p_sys);
 static void Close(vlc_va_t *, void **);
 
@@ -254,7 +254,8 @@ static void Close(vlc_va_t *va, void **ctx)
     free(sys);
 }
 
-static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
+static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
+                enum PixelFormat pix_fmt,
                 const es_format_t *fmt, picture_sys_t *p_sys)
 {
     int err = VLC_EGENERIC;
@@ -315,7 +316,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     if (err!=VLC_SUCCESS)
         goto error;
 
-    err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt, 0);
+    err = directx_va_Setup(va, &sys->dx_sys, ctx, desc, fmt, 0);
     if (err != VLC_SUCCESS)
         goto error;
 


=====================================
modules/codec/avcodec/va.c
=====================================
@@ -96,13 +96,14 @@ static int vlc_va_Start(void *func, va_list ap)
 {
     vlc_va_t *va = va_arg(ap, vlc_va_t *);
     AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
+    const AVPixFmtDescriptor *src_desc = va_arg(ap, const AVPixFmtDescriptor *);
     enum PixelFormat pix_fmt = va_arg(ap, enum PixelFormat);
     const es_format_t *fmt = va_arg(ap, const es_format_t *);
     picture_sys_t *p_sys = va_arg(ap, picture_sys_t *);
-    int (*open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,
+    int (*open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,
                 const es_format_t *, picture_sys_t *) = func;
 
-    return open(va, ctx, pix_fmt, fmt, p_sys);
+    return open(va, ctx, src_desc, pix_fmt, fmt, p_sys);
 }
 
 static void vlc_va_Stop(void *func, va_list ap)
@@ -114,7 +115,8 @@ static void vlc_va_Stop(void *func, va_list ap)
     close(va, hwctx);
 }
 
-vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
+vlc_va_t *vlc_va_New(vlc_object_t *obj,
+                     AVCodecContext *avctx, const AVPixFmtDescriptor *src_desc,
                      enum PixelFormat pix_fmt, const es_format_t *fmt,
                      picture_sys_t *p_sys)
 {
@@ -125,7 +127,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
     char *modlist = var_InheritString(obj, "avcodec-hw");
 
     va->module = vlc_module_load(va, "hw decoder", modlist, true,
-                                 vlc_va_Start, va, avctx, pix_fmt, fmt, p_sys);
+                                 vlc_va_Start, va, avctx, src_desc, pix_fmt, fmt, p_sys);
     free(modlist);
     if (va->module == NULL)
     {


=====================================
modules/codec/avcodec/va.h
=====================================
@@ -25,6 +25,7 @@
 
 #ifndef VLC_AVCODEC_VA_H
 #define VLC_AVCODEC_VA_H 1
+#include <libavutil/pixdesc.h>
 
 typedef struct vlc_va_t vlc_va_t;
 typedef struct vlc_va_sys_t vlc_va_sys_t;
@@ -54,7 +55,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
  * @param fmt VLC format of the content to decode
  * @return a new VLC object on success, NULL on error.
  */
-vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
+vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *, const AVPixFmtDescriptor *,
                      enum PixelFormat, const es_format_t *fmt,
                      picture_sys_t *p_sys);
 


=====================================
modules/codec/avcodec/vaapi.c
=====================================
@@ -151,9 +151,11 @@ static void Delete(vlc_va_t *va, void **hwctx)
     free(sys);
 }
 
-static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
+static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
+                  enum PixelFormat pix_fmt,
                   const es_format_t *fmt, picture_sys_t *p_sys)
 {
+    VLC_UNUSED(desc);
     if (pix_fmt != AV_PIX_FMT_VAAPI || p_sys == NULL)
         return VLC_EGENERIC;
 


=====================================
modules/codec/avcodec/video.c
=====================================
@@ -1631,6 +1631,8 @@ no_reuse:
         AV_PIX_FMT_NONE,
     };
 
+    const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(swfmt);
+
     for( size_t i = 0; hwfmts[i] != AV_PIX_FMT_NONE; i++ )
     {
         enum PixelFormat hwfmt = AV_PIX_FMT_NONE;
@@ -1657,7 +1659,7 @@ no_reuse:
 
         picture_t *test_pic = decoder_NewPicture(p_dec);
         assert(!test_pic || test_pic->format.i_chroma == p_dec->fmt_out.video.i_chroma);
-        vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt,
+        vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, src_desc, hwfmt,
                                   &p_dec->fmt_in,
                                   test_pic ? test_pic->p_sys : NULL);
         if (test_pic)


=====================================
modules/hw/vdpau/avcodec.c
=====================================
@@ -108,7 +108,8 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
     return VLC_SUCCESS;
 }
 
-static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
+static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
+                enum PixelFormat pix_fmt,
                 const es_format_t *fmt, picture_sys_t *p_sys)
 {
     if (pix_fmt != AV_PIX_FMT_VDPAU)
@@ -116,6 +117,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
 
     (void) fmt;
     (void) p_sys;
+    (void) desc;
     void *func;
     VdpStatus err;
     VdpChromaType type;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb75641be04c01856e5d190e741e515909f1e49b...e8b689c0c1288a4921834029292333169d9ceff5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb75641be04c01856e5d190e741e515909f1e49b...e8b689c0c1288a4921834029292333169d9ceff5
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