[vlc-commits] [Git][videolan/vlc][master] 2 commits: contrib: wine: add DXVA AV1 support

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jun 29 08:53:27 UTC 2021



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e04655d5 by Steve Lhomme at 2021-06-28T08:28:33+00:00
contrib: wine: add DXVA AV1 support

The GUID are found in D3D12 and the structures are from the DXVA AV1 specs.

There's no "stable" SDK yet with these values. So it's not merged upstream yet.

- - - - -
50aeffdf by Steve Lhomme at 2021-06-28T08:28:33+00:00
directx_va: allow AV1 decoding

- - - - -


3 changed files:

- + contrib/src/wine-headers/0001-include-add-AV1-support-to-dxva.h.patch
- contrib/src/wine-headers/rules.mak
- modules/codec/avcodec/directx_va.c


Changes:

=====================================
contrib/src/wine-headers/0001-include-add-AV1-support-to-dxva.h.patch
=====================================
@@ -0,0 +1,309 @@
+From 0f774f5d37e8e1627e2a225c55d8f468e279a5b5 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at gmail.com>
+Date: Mon, 7 Sep 2020 15:35:31 +0200
+Subject: [PATCH] include: add AV1 support to dxva.h
+
+Based on the DXVA AV1 specs
+https://www.microsoft.com/en-us/download/details.aspx?id=101577
+
+The structures and the associated define are available in Windows SDK
+since at least 10.0.20231.0.
+
+The GUIDs were present in previous SDKs as well.
+---
+ include/dxva.h | 279 +++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 279 insertions(+)
+
+diff --git a/include/dxva.h b/include/dxva.h
+index 25354f58879..3c532b45905 100644
+--- a/include/dxva.h
++++ b/include/dxva.h
+@@ -563,6 +563,285 @@ typedef struct _DXVA_Status_VPx
+     USHORT wNumMbsAffected;
+ } DXVA_Status_VPx, *LPDXVA_Status_VPx;
+ 
++
++#define _DIRECTX_AV1_VA_
++
++/* AV1 decoder GUIDs */ 
++DEFINE_GUID(DXVA_ModeAV1_VLD_Profile0,           0xb8be4ccb, 0xcf53, 0x46ba, 0x8d, 0x59, 0xd6, 0xb8, 0xa6, 0xda, 0x5d, 0x2a);
++DEFINE_GUID(DXVA_ModeAV1_VLD_Profile1,           0x6936ff0f, 0x45b1, 0x4163, 0x9c, 0xc1, 0x64, 0x6e, 0xf6, 0x94, 0x61, 0x08);
++DEFINE_GUID(DXVA_ModeAV1_VLD_Profile2,           0x0c5f2aa1, 0xe541, 0x4089, 0xbb, 0x7b, 0x98, 0x11, 0x0a, 0x19, 0xd7, 0xc8);
++DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2,     0x17127009, 0xa00f, 0x4ce1, 0x99, 0x4e, 0xbf, 0x40, 0x81, 0xf6, 0xf3, 0xf0);
++DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e, 0xe8);
++
++/* AV1 picture entry data structure */
++typedef struct _DXVA_PicEntry_AV1 {
++    UINT width;
++    UINT height;
++
++    // Global motion parameters
++    INT wmmat[6];
++    union {
++        struct {
++            UCHAR wminvalid : 1;
++            UCHAR wmtype : 2;
++            UCHAR Reserved : 5;
++        };
++        UCHAR GlobalMotionFlags;
++    };
++    UCHAR Index;
++    USHORT Reserved16Bits;
++} DXVA_PicEntry_AV1, *LPDXVA_PicEntry_AV1;
++
++/* AV1 picture parameters data structure */
++typedef struct _DXVA_PicParams_AV1 {
++    UINT width;
++    UINT height;
++
++    UINT max_width;
++    UINT max_height;
++
++    UCHAR CurrPicTextureIndex;
++    UCHAR superres_denom;
++    UCHAR bitdepth;
++    UCHAR seq_profile;
++
++    // Tiles:
++    struct {
++        UCHAR cols;
++        UCHAR rows;
++        USHORT context_update_id;
++        USHORT widths[64];
++        USHORT heights[64];
++    } tiles;
++
++    // Coding Tools
++    union {
++        struct {
++            UINT use_128x128_superblock : 1;
++            UINT intra_edge_filter : 1;
++            UINT interintra_compound : 1;
++            UINT masked_compound : 1;
++            UINT warped_motion : 1;
++            UINT dual_filter : 1;
++            UINT jnt_comp : 1;
++            UINT screen_content_tools : 1;
++            UINT integer_mv : 1;
++            UINT cdef : 1;
++            UINT restoration : 1;
++            UINT film_grain : 1;
++            UINT intrabc : 1;
++            UINT high_precision_mv : 1;
++            UINT switchable_motion_mode : 1;
++            UINT filter_intra : 1;
++            UINT disable_frame_end_update_cdf : 1;
++            UINT disable_cdf_update : 1;
++            UINT reference_mode : 1;
++            UINT skip_mode : 1;
++            UINT reduced_tx_set : 1;
++            UINT superres : 1;
++            UINT tx_mode : 2;
++            UINT use_ref_frame_mvs : 1;
++            UINT enable_ref_frame_mvs : 1;
++            UINT reference_frame_update : 1;
++            UINT Reserved : 5;
++        };
++        UINT32 CodingParamToolFlags;
++    } coding;
++
++    // Format & Picture Info flags
++    union {
++        struct {
++            UCHAR frame_type : 2;
++            UCHAR show_frame : 1;
++            UCHAR showable_frame : 1;
++            UCHAR subsampling_x : 1;
++            UCHAR subsampling_y : 1;
++            UCHAR mono_chrome : 1;
++            UCHAR Reserved : 1;
++        };
++        UCHAR FormatAndPictureInfoFlags;
++    } format;
++
++    // References
++    UCHAR primary_ref_frame;
++    UCHAR order_hint;
++    UCHAR order_hint_bits;
++
++    DXVA_PicEntry_AV1 frame_refs[7];
++    UCHAR RefFrameMapTextureIndex[8];
++
++    // Loop filter parameters
++    struct {
++        UCHAR filter_level[2];
++        UCHAR filter_level_u;
++        UCHAR filter_level_v;
++
++        UCHAR sharpness_level;
++        union {
++            struct {
++                UCHAR mode_ref_delta_enabled : 1;
++                UCHAR mode_ref_delta_update : 1;
++                UCHAR delta_lf_multi : 1;
++                UCHAR delta_lf_present : 1;
++                UCHAR Reserved : 4;
++            };
++            UCHAR ControlFlags;
++        } DUMMYUNIONNAME;
++        CHAR ref_deltas[8];
++        CHAR mode_deltas[2];
++        UCHAR delta_lf_res;
++        UCHAR frame_restoration_type[3];
++        USHORT log2_restoration_unit_size[3];
++        UINT16 Reserved16Bits;
++    } loop_filter;
++
++    // Quantization
++    struct {
++        union {
++            struct {
++                UCHAR delta_q_present : 1;
++                UCHAR delta_q_res : 2;
++                UCHAR Reserved : 5;
++            };
++            UCHAR ControlFlags;
++        } DUMMYUNIONNAME;
++
++        UCHAR base_qindex;
++        CHAR y_dc_delta_q;
++        CHAR u_dc_delta_q;
++        CHAR v_dc_delta_q;
++        CHAR u_ac_delta_q;
++        CHAR v_ac_delta_q;
++        // using_qmatrix:
++        UCHAR qm_y;
++        UCHAR qm_u;
++        UCHAR qm_v;
++        UINT16 Reserved16Bits;
++    } quantization;
++
++    // Cdef parameters
++    struct {
++        union {
++            struct {
++                UCHAR damping : 2;
++                UCHAR bits : 2;
++                UCHAR Reserved : 4;
++            };
++            UCHAR ControlFlags;
++        } DUMMYUNIONNAME;
++
++        union {
++            struct {
++                UCHAR primary : 6;
++                UCHAR secondary : 2;
++            };
++            UCHAR combined;
++        } y_strengths[8];
++
++        union {
++            struct {
++                UCHAR primary : 6;
++                UCHAR secondary : 2;
++            };
++            UCHAR combined;
++        } uv_strengths[8];
++
++    } cdef;
++
++    UCHAR interp_filter;
++
++    // Segmentation
++    struct {
++        union {
++            struct {
++                UCHAR enabled : 1;
++                UCHAR update_map : 1;
++                UCHAR update_data : 1;
++                UCHAR temporal_update : 1;
++                UCHAR Reserved : 4;
++            };
++            UCHAR ControlFlags;
++        } DUMMYUNIONNAME;
++        UCHAR Reserved24Bits[3];
++
++        union {
++            struct {
++                UCHAR alt_q : 1;
++                UCHAR alt_lf_y_v : 1;
++                UCHAR alt_lf_y_h : 1;
++                UCHAR alt_lf_u : 1;
++                UCHAR alt_lf_v : 1;
++                UCHAR ref_frame : 1;
++                UCHAR skip : 1;
++                UCHAR globalmv : 1;
++            };
++            UCHAR mask;
++        } feature_mask[8];
++
++        SHORT feature_data[8][8];
++
++    } segmentation;
++
++    struct {
++        union {
++            struct {
++                USHORT apply_grain : 1;
++                USHORT scaling_shift_minus8 : 2;
++                USHORT chroma_scaling_from_luma : 1;
++                USHORT ar_coeff_lag : 2;
++                USHORT ar_coeff_shift_minus6 : 2;
++                USHORT grain_scale_shift : 2;
++                USHORT overlap_flag : 1;
++                USHORT clip_to_restricted_range : 1;
++                USHORT matrix_coeff_is_identity : 1;
++                USHORT Reserved : 3;
++            };
++            USHORT ControlFlags;
++        } DUMMYUNIONNAME;
++
++        USHORT grain_seed;
++        UCHAR scaling_points_y[14][2];
++        UCHAR num_y_points;
++        UCHAR scaling_points_cb[10][2];
++        UCHAR num_cb_points;
++        UCHAR scaling_points_cr[10][2];
++        UCHAR num_cr_points;
++        UCHAR ar_coeffs_y[24];
++        UCHAR ar_coeffs_cb[25];
++        UCHAR ar_coeffs_cr[25];
++        UCHAR cb_mult;
++        UCHAR cb_luma_mult;
++        UCHAR cr_mult;
++        UCHAR cr_luma_mult;
++        UCHAR Reserved8Bits;
++        SHORT cb_offset;
++        SHORT cr_offset;
++    } film_grain;
++
++    UINT   Reserved32Bits;
++    UINT   StatusReportFeedbackNumber;
++} DXVA_PicParams_AV1, *LPDXVA_PicParams_AV1;
++
++/* AV1 tile data structure */
++typedef struct _DXVA_Tile_AV1 {
++    UINT   DataOffset;
++    UINT   DataSize;
++    USHORT row;
++    USHORT column;
++    USHORT Reserved16Bits;
++    UCHAR  anchor_frame;
++    UCHAR Reserved8Bits;
++} DXVA_Tile_AV1, *LPDXVA_Tile_AV1;
++
++typedef struct _DXVA_Status_AV1 {
++    UINT  StatusReportFeedbackNumber;
++    DXVA_PicEntry_AV1 CurrPic;
++    UCHAR  bBufType;
++    UCHAR  bStatus;
++    UCHAR  bReserved8Bits;
++    USHORT wNumMbsAffected;
++} DXVA_Status_AV1, *LPDXVA_Status_AV1;
++
+ #include <poppack.h>
+ 
+ #ifdef __cplusplus
+-- 
+2.27.0.windows.1
+


=====================================
contrib/src/wine-headers/rules.mak
=====================================
@@ -28,6 +28,7 @@ $(TARBALLS)/wine-$(WINE_VERSION).tar.xz:
 wine-headers: wine-$(WINE_VERSION).tar.xz .sum-wine-headers
 	$(UNPACK)
 	$(APPLY) $(SRC)/wine-headers/0001-include-add-HEVC-and-VP8-VP9-support-to-dxva.h.patch
+	$(APPLY) $(SRC)/wine-headers/0001-include-add-AV1-support-to-dxva.h.patch
 	$(MOVE)
 
 wine_widl = echo "GEN $(1)" && \


=====================================
modules/codec/avcodec/directx_va.c
=====================================
@@ -68,6 +68,9 @@ 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 };
 
+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 };
+
 #include <winapifamily.h>
 #if defined(WINAPI_FAMILY)
 # undef WINAPI_FAMILY
@@ -142,6 +145,14 @@ DEFINE_GUID(DXVA_ModeVP9_VLD_Profile0,              0x463707f8, 0xa1d0, 0x4585,
 DEFINE_GUID(DXVA_ModeVP9_VLD_10bit_Profile2,        0xa4c749ef, 0x6ecf, 0x48aa, 0x84, 0x48, 0x50, 0xa7, 0xa1, 0x16, 0x5f, 0xf7);
 DEFINE_GUID(DXVA_ModeVP9_VLD_Intel,                 0x76988a52, 0xdf13, 0x419a, 0x8e, 0x64, 0xff, 0xcf, 0x4a, 0x33, 0x6c, 0xf5);
 
+#ifndef _DIRECTX_AV1_VA_
+DEFINE_GUID(DXVA_ModeAV1_VLD_Profile0, 0xb8be4ccb, 0xcf53, 0x46ba, 0x8d, 0x59, 0xd6, 0xb8, 0xa6, 0xda, 0x5d, 0x2a);
+DEFINE_GUID(DXVA_ModeAV1_VLD_Profile1, 0x6936ff0f, 0x45b1, 0x4163, 0x9c, 0xc1, 0x64, 0x6e, 0xf6, 0x94, 0x61, 0x08);
+DEFINE_GUID(DXVA_ModeAV1_VLD_Profile2, 0x0c5f2aa1, 0xe541, 0x4089, 0xbb, 0x7b, 0x98, 0x11, 0x0a, 0x19, 0xd7, 0xc8);
+DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2, 0x17127009, 0xa00f, 0x4ce1, 0x99, 0x4e, 0xbf, 0x40, 0x81, 0xf6, 0xf3, 0xf0);
+DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e, 0xe8);
+#endif
+
 /* XXX Prefered modes must come first */
 static const directx_va_mode_t DXVA_MODES[] = {
     /* MPEG-1/2 */
@@ -251,6 +262,19 @@ static const directx_va_mode_t DXVA_MODES[] = {
 #endif
     { "VP9 profile Intel",                                                            &DXVA_ModeVP9_VLD_Intel,                8, {1, 1}, 0, NULL, 0 },
 
+    /* AV1 */
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 58, 112, 103 ) && LIBAVCODEC_VERSION_MICRO >= 100
+    { "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 }
 };
 
@@ -304,6 +328,10 @@ const directx_va_mode_t *directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_
     case AV_CODEC_ID_VP9:
         surface_count += 8 + 1;
         break;
+    case AV_CODEC_ID_AV1:
+        surface_alignment = 128;
+        surface_count += 8 + 1;
+        break;
     default:
         surface_count += 2;
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2497347f29c9338124f79cad98ac52cabbc19545...50aeffdf10f99f5ef351d08a73e59449c994700c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2497347f29c9338124f79cad98ac52cabbc19545...50aeffdf10f99f5ef351d08a73e59449c994700c
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list