[vlc-commits] [Git][videolan/vlc][master] 7 commits: directx_va: use ARRAY_SIZE() and to finish with an empty element

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Oct 7 13:20:49 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b15c18b3 by Steve Lhomme at 2024-10-07T13:01:56+00:00
directx_va: use ARRAY_SIZE() and to finish with an empty element

- - - - -
484d57f5 by Steve Lhomme at 2024-10-07T13:01:56+00:00
directx_va: use a macro to DXVA/lavc mapping

- - - - -
1f6bc7da by Steve Lhomme at 2024-10-07T13:01:56+00:00
directx_va: enable AV1 mapping in a single place

- - - - -
1c621264 by Steve Lhomme at 2024-10-07T13:01:56+00:00
directx_va: use a macro for common 8-bit 4:2:0 codecs+profiles

- - - - -
03ef898c by Steve Lhomme at 2024-10-07T13:01:56+00:00
directx_va: use a macro for common 10-bit 4:2:0 codecs+profiles

- - - - -
4e157d4d by Steve Lhomme at 2024-10-07T13:01:56+00:00
directx_va: use a macro for common unsupported 8-bit 4:2:0 codecs

- - - - -
0dd67938 by Steve Lhomme at 2024-10-07T13:01:56+00:00
direct_va: don't set a workaround for newer libavcodec

Since 349ce30e4ea3ded1e776270976d291d2adec608d the defines are
not public anymore (!).
We can't guarantee the values we set match what is used internally.
lavc will pick the workarounds based on the decoder GUID.

The Intel HEVC will need to be handled in a patched version of lavc.
For now that's not what we build with.

(cherry picked from commit 1aaf7d1c1ef271ddb00fe57a6df5bf971e3bb9d2)

- - - - -


4 changed files:

- modules/codec/avcodec/d3d11va.c
- modules/codec/avcodec/directx_va.c
- modules/codec/avcodec/directx_va.h
- modules/codec/avcodec/dxva2.c


Changes:

=====================================
modules/codec/avcodec/d3d11va.c
=====================================
@@ -110,7 +110,9 @@ static void SetupAVCodecContext(void *opaque, AVCodecContext *avctx)
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface = sys->hw_surface;
     sys->hw.context_mutex = sys->d3d_dev->context_mutex;
+#ifndef FF_DXVA_WORKAROUND_GONE
     sys->hw.workaround = sys->selected_decoder->workaround;
+#endif
     avctx->hwaccel_context = &sys->hw;
 }
 


=====================================
modules/codec/avcodec/directx_va.c
=====================================
@@ -43,10 +43,6 @@
 # error bogus libavcodec DXVA support
 #endif
 
-#ifndef FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
-# define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 // moved to libavcodec/dxva2_internal.h :/
-#endif
-
 #include "directx_va.h"
 #include <vlc_codecs.h> // GUID_FMT/GUID_PRINT
 
@@ -75,8 +71,15 @@ static const int PROF_HEVC_MAIN_REXT[]  = { FF_PROFILE_HEVC_REXT,
 static const int PROF_VP9_MAIN[]    = { FF_PROFILE_VP9_0, FF_PROFILE_UNKNOWN };
 static const int PROF_VP9_10[]      = { FF_PROFILE_VP9_2, FF_PROFILE_UNKNOWN };
 
+#if LIBAVCODEC_VERSION_CHECK( 58, 112, 103 )
+#define ENABLED_AV1_CODECID  AV_CODEC_ID_AV1
 static const int PROF_AV1_MAIN[]    = { FF_PROFILE_AV1_MAIN, FF_PROFILE_UNKNOWN };
 static const int PROF_AV1_HIGH[]    = { FF_PROFILE_AV1_HIGH, FF_PROFILE_AV1_MAIN, FF_PROFILE_UNKNOWN };
+#else
+#define ENABLED_AV1_CODECID  0
+#define PROF_AV1_MAIN      NULL
+#define PROF_AV1_HIGH      NULL
+#endif
 
 #if defined(__MINGW64_VERSION_MAJOR) // mingw-w64 doesn't have all the standard GUIDs
 
@@ -198,126 +201,133 @@ DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2, 0x17127009, 0xa00f, 0x4ce1, 0x99, 0
 DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e, 0xe8);
 #endif // !_DIRECTX_AV1_VA_
 
+#ifndef FF_DXVA_WORKAROUND_GONE
+#define DEF_DXVA_MODE(name, guid, bitdepth, chroma_w, chroma_h, avcodecid, profiles, workaround) \
+    { name, guid, bitdepth, { chroma_w, chroma_h }, avcodecid, profiles, workaround }
+#else
+#define DEF_DXVA_MODE(name, guid, bitdepth, chroma_w, chroma_h, avcodecid, profiles, workaround) \
+    { name, guid, bitdepth, { chroma_w, chroma_h }, avcodecid, profiles }
+#endif
+
+#define DEF_DXVA_MODE_420_8B(name, guid, avcodecid, profiles) \
+    DEF_DXVA_MODE(name, guid, 8, 1, 1, avcodecid, profiles, 0)
+#define DEF_DXVA_MODE_420_10B(name, guid, avcodecid, profiles) \
+    DEF_DXVA_MODE(name, guid, 10, 1, 1, avcodecid, profiles, 0)
+#define DEF_DXVA_MODE_420_8B_UNSUPPORTED(name, guid) \
+    DEF_DXVA_MODE(name, guid, 8, 1, 1, 0, NULL, 0)
+
+
 /* 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,                      8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-2 decoder, restricted profile A",                                         &DXVA_ModeMPEG2_A,                      8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-2 decoder, restricted profile B",                                         &DXVA_ModeMPEG2_B,                      8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-2 decoder, restricted profile C",                                         &DXVA_ModeMPEG2_C,                      8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-2 decoder, restricted profile D",                                         &DXVA_ModeMPEG2_D,                      8, {1, 1}, 0, NULL, 0 },
-
-    { "MPEG-2 variable-length decoder",                                               &DXVA2_ModeMPEG2_VLD,                   8, {1, 1}, AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN, 0 },
-    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA_ModeMPEG2and1_VLD,                8, {1, 1}, AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN, 0 },
-    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA_ModeMPEG2and1_VLD,                8, {1, 1}, AV_CODEC_ID_MPEG1VIDEO, NULL, 0 },
-    { "MPEG-2 motion compensation",                                                   &DXVA2_ModeMPEG2_MoComp,                8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-2 inverse discrete cosine transform",                                     &DXVA2_ModeMPEG2_IDCT,                  8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-1 decoder, restricted profile A",               &DXVA_ModeMPEG1_A ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-2 decoder, restricted profile A",               &DXVA_ModeMPEG2_A ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-2 decoder, restricted profile B",               &DXVA_ModeMPEG2_B ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-2 decoder, restricted profile C",               &DXVA_ModeMPEG2_C ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-2 decoder, restricted profile D",               &DXVA_ModeMPEG2_D ),
+
+    DEF_DXVA_MODE_420_8B( "MPEG-2 variable-length decoder",                                 &DXVA2_ModeMPEG2_VLD,                   AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN ),
+    DEF_DXVA_MODE_420_8B( "MPEG-2 & MPEG-1 variable-length decoder",                        &DXVA_ModeMPEG2and1_VLD,                AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN ),
+    DEF_DXVA_MODE_420_8B( "MPEG-2 & MPEG-1 variable-length decoder",                        &DXVA_ModeMPEG2and1_VLD,                AV_CODEC_ID_MPEG1VIDEO, NULL ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-2 motion compensation",                         &DXVA2_ModeMPEG2_MoComp ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-2 inverse discrete cosine transform",           &DXVA2_ModeMPEG2_IDCT ),
 
     /* 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",                                &DXVA_ModeMPEG1_VLD,                   8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-1 variable-length decoder, no D pictures",      &DXVA_ModeMPEG1_VLD ),
 
     /* 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",                         &DXVA_ModeH264_F,                       8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH, 0 },
-    { "H.264 variable-length decoder, no film grain technology",                      &DXVA_ModeH264_E,                       8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH, 0 },
+    DEF_DXVA_MODE_420_8B( "H.264 variable-length decoder, film grain technology",           &DXVA_ModeH264_F,                       AV_CODEC_ID_H264, PROF_H264_HIGH ),
+    DEF_DXVA_MODE_420_8B( "H.264 variable-length decoder, no film grain technology",        &DXVA_ModeH264_E,                       AV_CODEC_ID_H264, PROF_H264_HIGH ),
 #if !(defined(_GAMING_XBOX_SCARLETT) || defined(_GAMING_XBOX_XBOXONE) || defined(_XBOX_ONE)) && defined(FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
-    { "H.264 variable-length decoder, no film grain technology (Intel ClearVideo)",   &DXVA_Intel_H264_NoFGT_ClearVideo,      8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH, FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO },
+    DEF_DXVA_MODE( "H.264 variable-length decoder, no film grain technology (Intel ClearVideo)",   &DXVA_Intel_H264_NoFGT_ClearVideo,      8, 1, 1, AV_CODEC_ID_H264, PROF_H264_HIGH, FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO ),
 #endif
-    { "H.264 variable-length decoder, no film grain technology, FMO/ASO",             &DXVA_ModeH264_VLD_WithFMOASO_NoFGT,    8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH, 0 },
-    { "H.264 variable-length decoder, no film grain technology, Flash",               &DXVA_ModeH264_VLD_NoFGT_Flash,         8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH, 0 },
+    DEF_DXVA_MODE_420_8B( "H.264 variable-length decoder, no film grain technology, FMO/ASO",             &DXVA_ModeH264_VLD_WithFMOASO_NoFGT,    AV_CODEC_ID_H264, PROF_H264_HIGH ),
+    DEF_DXVA_MODE_420_8B( "H.264 variable-length decoder, no film grain technology, Flash",               &DXVA_ModeH264_VLD_NoFGT_Flash,         AV_CODEC_ID_H264, PROF_H264_HIGH ),
 
-    { "H.264 inverse discrete cosine transform, film grain technology",               &DXVA_ModeH264_D,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.264 inverse discrete cosine transform, no film grain technology",            &DXVA_ModeH264_C,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.264 inverse discrete cosine transform, no film grain technology (Intel)",    &DXVADDI_Intel_ModeH264_C,              8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 inverse discrete cosine transform, film grain technology",     &DXVA_ModeH264_D ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 inverse discrete cosine transform, no film grain technology",  &DXVA_ModeH264_C ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 inverse discrete cosine transform, no film grain technology (Intel)", &DXVADDI_Intel_ModeH264_C ),
 
-    { "H.264 motion compensation, film grain technology",                             &DXVA_ModeH264_B,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.264 motion compensation, no film grain technology",                          &DXVA_ModeH264_A,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.264 motion compensation, no film grain technology (Intel)",                  &DXVADDI_Intel_ModeH264_A,              8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 motion compensation, film grain technology",                   &DXVA_ModeH264_B ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 motion compensation, no film grain technology",                &DXVA_ModeH264_A ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 motion compensation, no film grain technology (Intel)",        &DXVADDI_Intel_ModeH264_A ),
 
     /* 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, 8, {1, 1}, 0, NULL, 0 },
-    { "H.264 stereo high profile",                                                    &DXVA_ModeH264_VLD_Stereo_NoFGT,             8, {1, 1}, 0, NULL, 0 },
-    { "H.264 multiview high profile",                                                 &DXVA_ModeH264_VLD_Multiview_NoFGT,          8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 stereo high profile, mbs flag set",                            &DXVA_ModeH264_VLD_Stereo_Progressive_NoFGT ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 stereo high profile",                                          &DXVA_ModeH264_VLD_Stereo_NoFGT ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 multiview high profile",                                       &DXVA_ModeH264_VLD_Multiview_NoFGT ),
 
     /* 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,            8, {1, 1}, 0, NULL, 0 },
-    { "H.264 scalable video coding, Scalable Constrained Baseline Profile",           &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline, 8, {1, 1}, 0, NULL, 0 },
-    { "H.264 scalable video coding, Scalable High Profile",                           &DXVA_ModeH264_VLD_SVC_Scalable_High,                8, {1, 1}, 0, NULL, 0 },
-    { "H.264 scalable video coding, Scalable Constrained High Profile",               &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive, 8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 scalable video coding, Scalable Baseline Profile",             &DXVA_ModeH264_VLD_SVC_Scalable_Baseline ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 scalable video coding, Scalable Constrained Baseline Profile", &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 scalable video coding, Scalable High Profile",                 &DXVA_ModeH264_VLD_SVC_Scalable_High ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.264 scalable video coding, Scalable Constrained High Profile",     &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive ),
 
     /* WMV */
-    { "Windows Media Video 8 motion compensation",                                    &DXVA_ModeWMV8_B,                       8, {1, 1}, 0, NULL, 0 },
-    { "Windows Media Video 8 post processing",                                        &DXVA_ModeWMV8_A,                       8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "Windows Media Video 8 motion compensation",          &DXVA_ModeWMV8_B ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "Windows Media Video 8 post processing",              &DXVA_ModeWMV8_A ),
 
-    { "Windows Media Video 9 IDCT",                                                   &DXVA_ModeWMV9_C,                       8, {1, 1}, 0, NULL, 0 },
-    { "Windows Media Video 9 motion compensation",                                    &DXVA_ModeWMV9_B,                       8, {1, 1}, 0, NULL, 0 },
-    { "Windows Media Video 9 post processing",                                        &DXVA_ModeWMV9_A,                       8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "Windows Media Video 9 IDCT",                         &DXVA_ModeWMV9_C ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "Windows Media Video 9 motion compensation",          &DXVA_ModeWMV9_B ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "Windows Media Video 9 post processing",              &DXVA_ModeWMV9_A ),
 
     /* VC-1 */
-    { "VC-1 variable-length decoder",                                                 &DXVA_ModeVC1_D,                        8, {1, 1}, AV_CODEC_ID_VC1, NULL, 0 },
-    { "VC-1 variable-length decoder",                                                 &DXVA_ModeVC1_D,                        8, {1, 1}, AV_CODEC_ID_WMV3, NULL, 0 },
-    { "VC-1 variable-length decoder",                                                 &DXVA_ModeVC1_D2010,                    8, {1, 1}, AV_CODEC_ID_VC1, NULL, 0 },
-    { "VC-1 variable-length decoder",                                                 &DXVA_ModeVC1_D2010,                    8, {1, 1}, AV_CODEC_ID_WMV3, NULL, 0 },
-    { "VC-1 variable-length decoder 2 (Intel)",                                       &DXVA_Intel_VC1_ClearVideo_2,           8, {1, 1}, 0, NULL, 0 },
-    { "VC-1 variable-length decoder (Intel)",                                         &DXVA_Intel_VC1_ClearVideo,             8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B( "VC-1 variable-length decoder",                                   &DXVA_ModeVC1_D,                        AV_CODEC_ID_VC1, NULL ),
+    DEF_DXVA_MODE_420_8B( "VC-1 variable-length decoder",                                   &DXVA_ModeVC1_D,                        AV_CODEC_ID_WMV3, NULL ),
+    DEF_DXVA_MODE_420_8B( "VC-1 variable-length decoder",                                   &DXVA_ModeVC1_D2010,                    AV_CODEC_ID_VC1, NULL ),
+    DEF_DXVA_MODE_420_8B( "VC-1 variable-length decoder",                                   &DXVA_ModeVC1_D2010,                    AV_CODEC_ID_WMV3, NULL ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VC-1 variable-length decoder 2 (Intel)",             &DXVA_Intel_VC1_ClearVideo_2 ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VC-1 variable-length decoder (Intel)",               &DXVA_Intel_VC1_ClearVideo ),
 
-    { "VC-1 inverse discrete cosine transform",                                       &DXVA_ModeVC1_C,                        8, {1, 1}, 0, NULL, 0 },
-    { "VC-1 motion compensation",                                                     &DXVA_ModeVC1_B,                        8, {1, 1}, 0, NULL, 0 },
-    { "VC-1 post processing",                                                         &DXVA_ModeVC1_A,                        8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VC-1 inverse discrete cosine transform",             &DXVA_ModeVC1_C ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VC-1 motion compensation",                           &DXVA_ModeVC1_B ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VC-1 post processing",                               &DXVA_ModeVC1_A ),
 
     /* Xvid/Divx: TODO */
-    { "MPEG-4 Part 2 nVidia bitstream decoder",                                       &DXVA_nVidia_MPEG4_ASP,                 8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-4 Part 2 variable-length decoder, Simple Profile",                        &DXVA_ModeMPEG4pt2_VLD_Simple,          8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, no GMC",       &DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, 8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, GMC",          &DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC,   8, {1, 1}, 0, NULL, 0 },
-    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, Avivo",        &DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo, 8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-4 Part 2 nVidia bitstream decoder",                                    &DXVA_nVidia_MPEG4_ASP ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-4 Part 2 variable-length decoder, Simple Profile",                     &DXVA_ModeMPEG4pt2_VLD_Simple ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, no GMC",    &DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, GMC",       &DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC   ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, Avivo",     &DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo ),
 
     /* HEVC */
     // Intel specific GUID support
-    { "HEVC Main profile (Intel)",                                                    &DXVA_ModeHEVC_VLD_Main_Intel,           8, {1, 1}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN, 0 },
-    { "HEVC Main 10 profile (Intel)",                                                 &DXVA_ModeHEVC_VLD_Main10_Intel,        10, {1, 1}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10, 0 },
+    DEF_DXVA_MODE_420_8B( "HEVC Main profile (Intel)",                                      &DXVA_ModeHEVC_VLD_Main_Intel,           AV_CODEC_ID_HEVC, PROF_HEVC_MAIN ),
+    DEF_DXVA_MODE_420_10B( "HEVC Main 10 profile (Intel)",                                  &DXVA_ModeHEVC_VLD_Main10_Intel,         AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10 ),
 #ifdef FF_DXVA2_WORKAROUND_HEVC_REXT
-    { "HEVC Main profile 4:2:2 Range Extension (Intel)",                              &DXVA_ModeHEVC_VLD_Main12_Intel,         8, {1, 0}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT },
-    { "HEVC Main 10 profile 4:2:2 Range Extension (Intel)",                           &DXVA_ModeHEVC_VLD_Main422_10_Intel,    10, {1, 0}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT },
-    { "HEVC Main 12 profile 4:2:2 Range Extension (Intel)",                           &DXVA_ModeHEVC_VLD_Main422_12_Intel,    12, {1, 0}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT },
-    { "HEVC Main profile 4:4:4 Range Extension (Intel)",                              &DXVA_ModeHEVC_VLD_Main444_Intel,        8, {0, 0}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT },
-    { "HEVC Main 10 profile 4:4:4 Range Extension (Intel)",                           &DXVA_ModeHEVC_VLD_Main444_10_Intel,    10, {0, 0}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT },
-    { "HEVC Main 12 profile 4:4:4 Range Extension (Intel)",                           &DXVA_ModeHEVC_VLD_Main444_12_Intel,    12, {0, 0}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT },
+    DEF_DXVA_MODE( "HEVC Main profile 4:2:2 Range Extension (Intel)",                       &DXVA_ModeHEVC_VLD_Main12_Intel,         8, 1, 0, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT ),
+    DEF_DXVA_MODE( "HEVC Main 10 profile 4:2:2 Range Extension (Intel)",                    &DXVA_ModeHEVC_VLD_Main422_10_Intel,    10, 1, 0, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT ),
+    DEF_DXVA_MODE( "HEVC Main 12 profile 4:2:2 Range Extension (Intel)",                    &DXVA_ModeHEVC_VLD_Main422_12_Intel,    12, 1, 0, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT ),
+    DEF_DXVA_MODE( "HEVC Main profile 4:4:4 Range Extension (Intel)",                       &DXVA_ModeHEVC_VLD_Main444_Intel,        8, 0, 0, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT ),
+    DEF_DXVA_MODE( "HEVC Main 10 profile 4:4:4 Range Extension (Intel)",                    &DXVA_ModeHEVC_VLD_Main444_10_Intel,    10, 0, 0, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT ),
+    DEF_DXVA_MODE( "HEVC Main 12 profile 4:4:4 Range Extension (Intel)",                    &DXVA_ModeHEVC_VLD_Main444_12_Intel,    12, 0, 0, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN_REXT, FF_DXVA2_WORKAROUND_HEVC_REXT ),
 #endif
-    { "HEVC Main profile",                                                            &DXVA_ModeHEVC_VLD_Main,                8, {1, 1}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN, 0 },
-    { "HEVC Main 10 profile",                                                         &DXVA_ModeHEVC_VLD_Main10,              10, {1, 1}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10, 0 },
+    DEF_DXVA_MODE_420_8B( "HEVC Main profile",                                              &DXVA_ModeHEVC_VLD_Main,                AV_CODEC_ID_HEVC, PROF_HEVC_MAIN ),
+    DEF_DXVA_MODE_420_10B( "HEVC Main 10 profile",                                          &DXVA_ModeHEVC_VLD_Main10,              AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10 ),
 
     /* H.261 */
-    { "H.261 decoder, restricted profile A",                                          &DXVA_ModeH261_A,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.261 decoder, restricted profile B",                                          &DXVA_ModeH261_B,                       8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.261 decoder, restricted profile A",                &DXVA_ModeH261_A ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.261 decoder, restricted profile B",                &DXVA_ModeH261_B ),
 
     /* H.263 */
-    { "H.263 decoder, restricted profile A",                                          &DXVA_ModeH263_A,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.263 decoder, restricted profile B",                                          &DXVA_ModeH263_B,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.263 decoder, restricted profile C",                                          &DXVA_ModeH263_C,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.263 decoder, restricted profile D",                                          &DXVA_ModeH263_D,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.263 decoder, restricted profile E",                                          &DXVA_ModeH263_E,                       8, {1, 1}, 0, NULL, 0 },
-    { "H.263 decoder, restricted profile F",                                          &DXVA_ModeH263_F,                       8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.263 decoder, restricted profile A",                &DXVA_ModeH263_A ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.263 decoder, restricted profile B",                &DXVA_ModeH263_B ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.263 decoder, restricted profile C",                &DXVA_ModeH263_C ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.263 decoder, restricted profile D",                &DXVA_ModeH263_D ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.263 decoder, restricted profile E",                &DXVA_ModeH263_E ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "H.263 decoder, restricted profile F",                &DXVA_ModeH263_F ),
 
     /* VPx */
-    { "VP8",                                                                          &DXVA_ModeVP8_VLD,                      8, {1, 1}, 0, NULL, 0 },
-    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, {1, 1}, AV_CODEC_ID_VP9, PROF_VP9_MAIN, 0 },
-    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, {1, 1}, AV_CODEC_ID_VP9, PROF_VP9_10, 0 },
-    { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                8, {1, 1}, 0, NULL, 0 },
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VP8",                                                &DXVA_ModeVP8_VLD ),
+    DEF_DXVA_MODE_420_8B( "VP9 profile 0",                                                  &DXVA_ModeVP9_VLD_Profile0,             AV_CODEC_ID_VP9, PROF_VP9_MAIN ),
+    DEF_DXVA_MODE_420_10B( "VP9 profile 2",                                                 &DXVA_ModeVP9_VLD_10bit_Profile2,       AV_CODEC_ID_VP9, PROF_VP9_10 ),
+    DEF_DXVA_MODE_420_8B_UNSUPPORTED( "VP9 profile Intel",                                  &DXVA_ModeVP9_VLD_Intel ),
 
     /* AV1 */
-#if LIBAVCODEC_VERSION_CHECK( 58, 112, 103 )
-    { "AV1 Main profile 8",                                                           &DXVA_ModeAV1_VLD_Profile0,             8, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_MAIN, 0 },
-    { "AV1 Main profile 10",                                                          &DXVA_ModeAV1_VLD_Profile0,            10, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_MAIN, 0 },
-    { "AV1 High profile 8",                                                           &DXVA_ModeAV1_VLD_Profile1,             8, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_HIGH, 0 },
-    { "AV1 High profile 10",                                                          &DXVA_ModeAV1_VLD_Profile1,            10, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_HIGH, 0 },
-#else
-    { "AV1 Main profile 8",                                                           &DXVA_ModeAV1_VLD_Profile0,             8, {1, 1}, 0, NULL, 0 },
-    { "AV1 Main profile 10",                                                          &DXVA_ModeAV1_VLD_Profile0,            10, {1, 1}, 0, NULL, 0 },
-    { "AV1 High profile 8",                                                           &DXVA_ModeAV1_VLD_Profile1,             8, {1, 1}, 0, NULL, 0 },
-    { "AV1 High profile 10",                                                          &DXVA_ModeAV1_VLD_Profile1,            10, {1, 1}, 0, NULL, 0 },
-#endif
-
-    { NULL, NULL, 0, {0, 0}, 0, NULL, 0 }
+    DEF_DXVA_MODE_420_8B( "AV1 Main profile 8",                                             &DXVA_ModeAV1_VLD_Profile0,             ENABLED_AV1_CODECID, PROF_AV1_MAIN ),
+    DEF_DXVA_MODE_420_10B( "AV1 Main profile 10",                                           &DXVA_ModeAV1_VLD_Profile0,             ENABLED_AV1_CODECID, PROF_AV1_MAIN ),
+    DEF_DXVA_MODE_420_8B( "AV1 High profile 8",                                             &DXVA_ModeAV1_VLD_Profile1,             ENABLED_AV1_CODECID, PROF_AV1_HIGH ),
+    DEF_DXVA_MODE_420_10B( "AV1 High profile 10",                                           &DXVA_ModeAV1_VLD_Profile1,             ENABLED_AV1_CODECID, PROF_AV1_HIGH ),
 };
 
 static const directx_va_mode_t *FindVideoServiceConversion(vlc_va_t *, const directx_sys_t *, const es_format_t *, video_format_t *fmt_out,
@@ -325,7 +335,7 @@ static const directx_va_mode_t *FindVideoServiceConversion(vlc_va_t *, const dir
 
 static char *directx_va_GetDecoderName(const GUID *guid)
 {
-    for (unsigned i = 0; DXVA_MODES[i].name; i++) {
+    for (size_t i = 0; i < ARRAY_SIZE(DXVA_MODES); i++) {
         if (IsEqualGUID(DXVA_MODES[i].guid, guid))
             return strdup(DXVA_MODES[i].name);
     }
@@ -475,8 +485,8 @@ static const directx_va_mode_t * FindVideoServiceConversion(vlc_va_t *va, const
     }
 
     /* Try all supported mode by our priority */
-    const directx_va_mode_t *mode = DXVA_MODES;
-    for (; mode->name; ++mode) {
+    for (size_t i=0; i<ARRAY_SIZE(DXVA_MODES); ++i) {
+        const directx_va_mode_t *mode = &DXVA_MODES[i];
         if (!mode->codec || mode->codec != avctx->codec_id)
             continue;
 


=====================================
modules/codec/avcodec/directx_va.h
=====================================
@@ -43,6 +43,10 @@
 extern "C" {
 #endif
 
+#ifndef FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
+#define FF_DXVA_WORKAROUND_GONE 1
+#endif
+
 typedef struct input_list_t {
     void (*pf_release)(struct input_list_t *);
     GUID *list;
@@ -59,7 +63,9 @@ typedef struct {
     };
     enum AVCodecID codec;
     const int    *p_profiles; // NULL or ends with 0
+#ifndef FF_DXVA_WORKAROUND_GONE
     int           workaround;
+#endif
 } directx_va_mode_t;
 
 #define MAX_SURFACE_COUNT (64)


=====================================
modules/codec/avcodec/dxva2.c
=====================================
@@ -104,7 +104,9 @@ static void SetupAVCodecContext(void *opaque, AVCodecContext *avctx)
     vlc_va_sys_t *sys = opaque;
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface = sys->hw_surface;
+#ifndef FF_DXVA_WORKAROUND_GONE
     sys->hw.workaround = sys->selected_decoder->workaround;
+#endif
     avctx->hwaccel_context = &sys->hw;
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e547beb37dd4775122feb2c1172fb20cce0d76b...0dd67938c02ed9a6cfe3f17fe314bc3c99998fae

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e547beb37dd4775122feb2c1172fb20cce0d76b...0dd67938c02ed9a6cfe3f17fe314bc3c99998fae
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