[vlc-commits] directx_va: check the chroma subpixel format of the source

Steve Lhomme git at videolan.org
Tue Oct 8 10:14:34 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct  4 11:13:30 2019 +0200| [895d174c9487b722cf76ab8ab832156a0ee097c9] | committer: Steve Lhomme

directx_va: check the chroma subpixel format of the source

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=895d174c9487b722cf76ab8ab832156a0ee097c9
---

 modules/codec/avcodec/directx_va.c | 143 ++++++++++++++++++++-----------------
 modules/codec/avcodec/directx_va.h |   4 ++
 2 files changed, 81 insertions(+), 66 deletions(-)

diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index d7862d51e3..381b0494da 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -162,102 +162,102 @@ DEFINE_GUID(DXVA_ModeVP9_VLD_Intel,                 0x76988a52, 0xdf13, 0x419a,
 /* XXX Prefered 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, 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 decoder, restricted profile A",                                         &DXVA_ModeMPEG1_A,                      8, {1, 1}, 0, NULL },
+    { "MPEG-2 decoder, restricted profile A",                                         &DXVA_ModeMPEG2_A,                      8, {1, 1}, 0, NULL },
+    { "MPEG-2 decoder, restricted profile B",                                         &DXVA_ModeMPEG2_B,                      8, {1, 1}, 0, NULL },
+    { "MPEG-2 decoder, restricted profile C",                                         &DXVA_ModeMPEG2_C,                      8, {1, 1}, 0, NULL },
+    { "MPEG-2 decoder, restricted profile D",                                         &DXVA_ModeMPEG2_D,                      8, {1, 1}, 0, NULL },
+
+    { "MPEG-2 variable-length decoder",                                               &DXVA2_ModeMPEG2_VLD,                   8, {1, 1}, AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN },
+    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA2_ModeMPEG2and1_VLD,               8, {1, 1}, AV_CODEC_ID_MPEG2VIDEO, PROF_MPEG2_MAIN },
+    { "MPEG-2 & MPEG-1 variable-length decoder",                                      &DXVA2_ModeMPEG2and1_VLD,               8, {1, 1}, AV_CODEC_ID_MPEG1VIDEO, NULL },
+    { "MPEG-2 motion compensation",                                                   &DXVA2_ModeMPEG2_MoComp,                8, {1, 1}, 0, NULL },
+    { "MPEG-2 inverse discrete cosine transform",                                     &DXVA2_ModeMPEG2_IDCT,                  8, {1, 1}, 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,                   8, 0, NULL },
+    { "MPEG-1 variable-length decoder, no D pictures",                                &DXVA2_ModeMPEG1_VLD,                   8, {1, 1}, 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,                      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 variable-length decoder, film grain technology",                         &DXVA2_ModeH264_F,                      8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "H.264 variable-length decoder, no film grain technology",                      &DXVA2_ModeH264_E,                      8, {1, 1}, AV_CODEC_ID_H264, PROF_H264_HIGH },
+    { "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 },
+    { "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 },
+    { "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 },
 
-    { "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 inverse discrete cosine transform, film grain technology",               &DXVA2_ModeH264_D,                      8, {1, 1}, 0, NULL },
+    { "H.264 inverse discrete cosine transform, no film grain technology",            &DXVA2_ModeH264_C,                      8, {1, 1}, 0, NULL },
+    { "H.264 inverse discrete cosine transform, no film grain technology (Intel)",    &DXVADDI_Intel_ModeH264_C,              8, {1, 1}, 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 },
+    { "H.264 motion compensation, film grain technology",                             &DXVA2_ModeH264_B,                      8, {1, 1}, 0, NULL },
+    { "H.264 motion compensation, no film grain technology",                          &DXVA2_ModeH264_A,                      8, {1, 1}, 0, NULL },
+    { "H.264 motion compensation, no film grain technology (Intel)",                  &DXVADDI_Intel_ModeH264_A,              8, {1, 1}, 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, 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 },
+    { "H.264 stereo high profile, mbs flag set",                                      &DXVA_ModeH264_VLD_Stereo_Progressive_NoFGT, 8, {1, 1}, 0, NULL },
+    { "H.264 stereo high profile",                                                    &DXVA_ModeH264_VLD_Stereo_NoFGT,             8, {1, 1}, 0, NULL },
+    { "H.264 multiview high profile",                                                 &DXVA_ModeH264_VLD_Multiview_NoFGT,          8, {1, 1}, 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,            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 },
+    { "H.264 scalable video coding, Scalable Baseline Profile",                       &DXVA_ModeH264_VLD_SVC_Scalable_Baseline,            8, {1, 1}, 0, NULL },
+    { "H.264 scalable video coding, Scalable Constrained Baseline Profile",           &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline, 8, {1, 1}, 0, NULL },
+    { "H.264 scalable video coding, Scalable High Profile",                           &DXVA_ModeH264_VLD_SVC_Scalable_High,                8, {1, 1}, 0, NULL },
+    { "H.264 scalable video coding, Scalable Constrained High Profile",               &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive, 8, {1, 1}, 0, NULL },
 
     /* WMV */
-    { "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 8 motion compensation",                                    &DXVA2_ModeWMV8_B,                      8, {1, 1}, 0, NULL },
+    { "Windows Media Video 8 post processing",                                        &DXVA2_ModeWMV8_A,                      8, {1, 1}, 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 },
+    { "Windows Media Video 9 IDCT",                                                   &DXVA2_ModeWMV9_C,                      8, {1, 1}, 0, NULL },
+    { "Windows Media Video 9 motion compensation",                                    &DXVA2_ModeWMV9_B,                      8, {1, 1}, 0, NULL },
+    { "Windows Media Video 9 post processing",                                        &DXVA2_ModeWMV9_A,                      8, {1, 1}, 0, NULL },
 
     /* VC-1 */
-    { "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 variable-length decoder",                                                 &DXVA2_ModeVC1_D,                       8, {1, 1}, AV_CODEC_ID_VC1, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D,                       8, {1, 1}, AV_CODEC_ID_WMV3, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D2010,                   8, {1, 1}, AV_CODEC_ID_VC1, NULL },
+    { "VC-1 variable-length decoder",                                                 &DXVA2_ModeVC1_D2010,                   8, {1, 1}, AV_CODEC_ID_WMV3, NULL },
+    { "VC-1 variable-length decoder 2 (Intel)",                                       &DXVA_Intel_VC1_ClearVideo_2,           8, {1, 1}, 0, NULL },
+    { "VC-1 variable-length decoder (Intel)",                                         &DXVA_Intel_VC1_ClearVideo,             8, {1, 1}, 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 },
+    { "VC-1 inverse discrete cosine transform",                                       &DXVA2_ModeVC1_C,                       8, {1, 1}, 0, NULL },
+    { "VC-1 motion compensation",                                                     &DXVA2_ModeVC1_B,                       8, {1, 1}, 0, NULL },
+    { "VC-1 post processing",                                                         &DXVA2_ModeVC1_A,                       8, {1, 1}, 0, NULL },
 
     /* Xvid/Divx: TODO */
-    { "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 },
+    { "MPEG-4 Part 2 nVidia bitstream decoder",                                       &DXVA_nVidia_MPEG4_ASP,                 8, {1, 1}, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple Profile",                        &DXVA_ModeMPEG4pt2_VLD_Simple,          8, {1, 1}, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, no GMC",       &DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, 8, {1, 1}, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, GMC",          &DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC,   8, {1, 1}, 0, NULL },
+    { "MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, Avivo",        &DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo, 8, {1, 1}, 0, NULL },
 
     /* HEVC */
-    { "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 },
+    { "HEVC Main profile",                                                            &DXVA_ModeHEVC_VLD_Main,                8, {1, 1}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN },
+    { "HEVC Main 10 profile",                                                         &DXVA_ModeHEVC_VLD_Main10,              10, {1, 1}, AV_CODEC_ID_HEVC, PROF_HEVC_MAIN10 },
 
     /* H.261 */
-    { "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.261 decoder, restricted profile A",                                          &DXVA_ModeH261_A,                       8, {1, 1}, 0, NULL },
+    { "H.261 decoder, restricted profile B",                                          &DXVA_ModeH261_B,                       8, {1, 1}, 0, NULL },
 
     /* H.263 */
-    { "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 },
+    { "H.263 decoder, restricted profile A",                                          &DXVA_ModeH263_A,                       8, {1, 1}, 0, NULL },
+    { "H.263 decoder, restricted profile B",                                          &DXVA_ModeH263_B,                       8, {1, 1}, 0, NULL },
+    { "H.263 decoder, restricted profile C",                                          &DXVA_ModeH263_C,                       8, {1, 1}, 0, NULL },
+    { "H.263 decoder, restricted profile D",                                          &DXVA_ModeH263_D,                       8, {1, 1}, 0, NULL },
+    { "H.263 decoder, restricted profile E",                                          &DXVA_ModeH263_E,                       8, {1, 1}, 0, NULL },
+    { "H.263 decoder, restricted profile F",                                          &DXVA_ModeH263_F,                       8, {1, 1}, 0, NULL },
 
     /* VPx */
-    { "VP8",                                                                          &DXVA_ModeVP8_VLD,                      8, 0, NULL },
+    { "VP8",                                                                          &DXVA_ModeVP8_VLD,                      8, {1, 1}, 0, NULL },
 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 57, 17, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
-    { "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 },
+    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, {1, 1}, AV_CODEC_ID_VP9, PROF_VP9_MAIN },
+    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, {1, 1}, AV_CODEC_ID_VP9, PROF_VP9_10 },
 #else
-    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, 0, NULL },
-    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, 0, NULL },
+    { "VP9 profile 0",                                                                &DXVA_ModeVP9_VLD_Profile0,             8, {1, 1}, 0, NULL },
+    { "VP9 profile 2",                                                                &DXVA_ModeVP9_VLD_10bit_Profile2,       10, {1, 1}, 0, NULL },
 #endif
-    { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                8, 0, NULL },
+    { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                8, {1, 1}, 0, NULL },
 
-    { NULL, NULL, 0, 0, NULL }
+    { NULL, NULL, 0, {0, 0}, 0, NULL }
 };
 
 static const directx_va_mode_t *FindVideoServiceConversion(vlc_va_t *, const directx_sys_t *, const es_format_t *, video_format_t *fmt_out,
@@ -429,6 +429,17 @@ static const directx_va_mode_t * FindVideoServiceConversion(vlc_va_t *va, const
             continue;
         }
 
+        if ( desc &&
+             ( desc->log2_chroma_w != mode->log2_chroma_w ||
+               desc->log2_chroma_h != mode->log2_chroma_h ) )
+        {
+            char *psz_name = directx_va_GetDecoderName(mode->guid);
+            msg_Warn( va, "Unsupported chroma subsampling 4:%d:%d for %s ",
+                    (2-desc->log2_chroma_w)*2, (2-desc->log2_chroma_w-desc->log2_chroma_h)*2, psz_name );
+            free( psz_name );
+            continue;
+        }
+
         if (!profile_supported( mode, fmt, avctx ))
         {
             msg_Warn( va, "Unsupported profile %d for %s ",
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index eb7de75d39..e714a324c1 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -53,6 +53,10 @@ typedef struct {
     const char   *name;
     const GUID   *guid;
     int           bit_depth;
+    struct {
+        uint8_t log2_chroma_w;
+        uint8_t log2_chroma_h;
+    };
     enum AVCodecID codec;
     const int    *p_profiles; // NULL or ends with 0
 } directx_va_mode_t;



More information about the vlc-commits mailing list