| @@ -42,9 +42,40 @@ · 41 unmodified lines |
| 42 | #define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE 0x10 | 42 | #define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE 0x10 |
| 43 | #define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_FRAME_RATE_CONVERSION 0x20 | 43 | #define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_FRAME_RATE_CONVERSION 0x20 |
| 44 | | 44 | |
| | 45 | // For video procesor extensions identifiers reference see: |
| | 46 | // https://chromium.googlesource.com/chromium/src/+/5f354f38/ui/gl/swap_chain_presenter.cc |
| | 47 | |
| | 48 | #ifndef NVIDIA_PPE_INTERFACE_GUID |
| | 49 | DEFINE_GUID(NVIDIA_PPE_INTERFACE_GUID, |
| | 50 | 0xd43ce1b3, 0x1f4b, 0x48ac, 0xba, 0xee, |
| | 51 | 0xc3, 0xc2, 0x53, 0x75, 0xe6, 0xf7); |
| | 52 | #endif |
| | 53 | |
| | 54 | #ifndef INTEL_VPE_INTERFACE_GUID |
| | 55 | DEFINE_GUID(INTEL_VPE_INTERFACE_GUID, |
| | 56 | 0xedd1d4b9, 0x8659, 0x4cbc, 0xa4, 0xd6, |
| | 57 | 0x98, 0x31, 0xa2, 0x16, 0x3a, 0xc3); |
| | 58 | #endif |
| | 59 | |
| | 60 | static const unsigned int intel_vpe_fn_version = 0x1; |
| | 61 | static const unsigned int intel_vpe_version = 0x3; |
| | 62 | |
| | 63 | static const unsigned int intel_vpe_fn_scaling = 0x37; |
| | 64 | static const unsigned int intel_vpe_scaling_vsr = 0x2; |
| | 65 | |
| | 66 | static const unsigned int intel_vpe_fn_mode = 0x20; |
| | 67 | static const unsigned int intel_vpe_mode_preproc = 0x1; |
| | 68 | |
| | 69 | enum scaling_mode { |
| | 70 | SCALING_BASIC, |
| | 71 | SCALING_INTEL_VSR, |
| | 72 | SCALING_NVIDIA_RTX, |
| | 73 | }; |
| | 74 | |
| 45 | struct opts { | 75 | struct opts { |
| 46 | bool deint_enabled; | 76 | bool deint_enabled; |
| 47 | float scale; | 77 | float scale; |
| | 78 | int scaling_mode; |
| 48 | bool interlaced_only; | 79 | bool interlaced_only; |
| 49 | int mode; | 80 | int mode; |
| 50 | int field_parity; | 81 | int field_parity; |
| @@ -135,6 +166,74 @@ static void destroy_video_proc(struct mp_filter *vf) · 84 unmodified lines |
| 135 | p->vp_enum = NULL; | 166 | p->vp_enum = NULL; |
| 136 | } | 167 | } |
| 137 | | 168 | |
| | 169 | static void enable_nvidia_rtx_extension(struct mp_filter *vf) |
| | 170 | { |
| | 171 | struct priv *p = vf->priv; |
| | 172 | |
| | 173 | struct nvidia_ext { |
| | 174 | unsigned int version; |
| | 175 | unsigned int method; |
| | 176 | unsigned int enable; |
| | 177 | } ext = {1, 2, 1}; |
| | 178 | |
| | 179 | HRESULT hr = ID3D11VideoContext_VideoProcessorSetStreamExtension(p->video_ctx, |
| | 180 | p->video_proc, |
| | 181 | 0, |
| | 182 | &NVIDIA_PPE_INTERFACE_GUID, |
| | 183 | sizeof(ext), |
| | 184 | &ext); |
| | 185 | |
| | 186 | if (FAILED(hr)) { |
| | 187 | MP_WARN(vf, "Failed to enable NVIDIA RTX Super Resolution: %s\n", mp_HRESULT_to_str(hr)); |
| | 188 | } else { |
| | 189 | MP_VERBOSE(vf, "NVIDIA RTX Super Resolution enabled\n"); |
| | 190 | } |
| | 191 | } |
| | 192 | |
| | 193 | static void enable_intel_vsr_extension(struct mp_filter *vf) |
| | 194 | { |
| | 195 | struct priv *p = vf->priv; |
| | 196 | |
| | 197 | struct intel_vpe_ext { |
| | 198 | unsigned int function; |
| | 199 | const void* param; |
| | 200 | } ext; |
| | 201 | |
| | 202 | ext = (struct intel_vpe_ext){intel_vpe_fn_version, &intel_vpe_version}; |
| | 203 | HRESULT hr = ID3D11VideoContext_VideoProcessorSetOutputExtension(p->video_ctx, |
| | 204 | p->video_proc, |
| | 205 | &INTEL_VPE_INTERFACE_GUID, |
| | 206 | sizeof(ext), |
| | 207 | &ext); |
| | 208 | if (FAILED(hr)) |
| | 209 | goto failed; |
| | 210 | |
| | 211 | ext = (struct intel_vpe_ext){intel_vpe_fn_mode, &intel_vpe_mode_preproc}; |
| | 212 | hr = ID3D11VideoContext_VideoProcessorSetOutputExtension(p->video_ctx, |
| | 213 | p->video_proc, |
| | 214 | &INTEL_VPE_INTERFACE_GUID, |
| | 215 | sizeof(ext), |
| | 216 | &ext); |
| | 217 | if (FAILED(hr)) |
| | 218 | goto failed; |
| | 219 | |
| | 220 | ext = (struct intel_vpe_ext){intel_vpe_fn_scaling, &intel_vpe_scaling_vsr}; |
| | 221 | hr = ID3D11VideoContext_VideoProcessorSetStreamExtension(p->video_ctx, |
| | 222 | p->video_proc, |
| | 223 | 0, |
| | 224 | &INTEL_VPE_INTERFACE_GUID, |
| | 225 | sizeof(ext), |
| | 226 | &ext); |
| | 227 | if (FAILED(hr)) |
| | 228 | goto failed; |
| | 229 | |
| | 230 | MP_VERBOSE(vf, "Intel Video Super Resolution enabled\n"); |
| | 231 | return; |
| | 232 | |
| | 233 | failed: |
| | 234 | MP_WARN(vf, "Failed to enable Intel Video Super Resolution: %s\n", mp_HRESULT_to_str(hr)); |
| | 235 | } |
| | 236 | |
| 138 | static int recreate_video_proc(struct mp_filter *vf) | 237 | static int recreate_video_proc(struct mp_filter *vf) |
| 139 | { | 238 | { |
| 140 | struct priv *p = vf->priv; | 239 | struct priv *p = vf->priv; |
| @@ -222,6 +321,15 @@ static int recreate_video_proc(struct mp_filter *vf) · 81 unmodified lines |
| 222 | p->video_proc, | 321 | p->video_proc, |
| 223 | &csp); | 322 | &csp); |
| 224 | | 323 | |
| | 324 | switch (p->opts->scaling_mode) { |
| | 325 | case SCALING_INTEL_VSR: |
| | 326 | enable_intel_vsr_extension(vf); |
| | 327 | break; |
| | 328 | case SCALING_NVIDIA_RTX: |
| | 329 | enable_nvidia_rtx_extension(vf); |
| | 330 | break; |
| | 331 | } |
| | 332 | |
| 225 | return 0; | 333 | return 0; |
| 226 | fail: | 334 | fail: |
| 227 | destroy_video_proc(vf); | 335 | destroy_video_proc(vf); |
| @@ -499,6 +607,10 @@ fail: · 271 unmodified lines |
| 499 | static const m_option_t vf_opts_fields[] = { | 607 | static const m_option_t vf_opts_fields[] = { |
| 500 | {"deint", OPT_BOOL(deint_enabled)}, | 608 | {"deint", OPT_BOOL(deint_enabled)}, |
| 501 | {"scale", OPT_FLOAT(scale)}, | 609 | {"scale", OPT_FLOAT(scale)}, |
| | 610 | {"scaling-mode", OPT_CHOICE(scaling_mode, |
| | 611 | {"standard", SCALING_BASIC}, |
| | 612 | {"intel", SCALING_INTEL_VSR}, |
| | 613 | {"nvidia", SCALING_NVIDIA_RTX})}, |
| 502 | {"interlaced-only", OPT_BOOL(interlaced_only)}, | 614 | {"interlaced-only", OPT_BOOL(interlaced_only)}, |
| 503 | {"mode", OPT_CHOICE(mode, | 615 | {"mode", OPT_CHOICE(mode, |
| 504 | {"blend", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND}, | 616 | {"blend", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND}, |
| @@ -522,6 +634,7 @@ const struct mp_user_filter_entry vf_d3d11vpp = { · 17 unmodified lines |
| 522 | .priv_defaults = &(const OPT_BASE_STRUCT) { | 634 | .priv_defaults = &(const OPT_BASE_STRUCT) { |
| 523 | .deint_enabled = false, | 635 | .deint_enabled = false, |
| 524 | .scale = 1.0, | 636 | .scale = 1.0, |
| | 637 | .scaling_mode = SCALING_BASIC, |
| 525 | .mode = 0, | 638 | .mode = 0, |
| 526 | .field_parity = MP_FIELD_PARITY_AUTO, | 639 | .field_parity = MP_FIELD_PARITY_AUTO, |
| 527 | }, | 640 | }, |