@@ -960,10 +960,21 @@ static int setup_hwaccel_filters(producer_avformat self,
960960
961961 int scaled_width = (int ) (self -> video_frame -> width * scale_factor );
962962 int scaled_height = (int ) (self -> video_frame -> height * scale_factor );
963- char scale_args [32 ];
963+ char scale_args [64 ];
964964 scaled_width += scaled_width % 2 ;
965965 scaled_height += scaled_height % 2 ;
966- snprintf (scale_args , sizeof (scale_args ), "w=%d:h=%d" , scaled_width , scaled_height );
966+ if (self -> hwaccel .pix_fmt == AV_PIX_FMT_D3D11 ) {
967+ snprintf (scale_args ,
968+ sizeof (scale_args ),
969+ "width=%d:height=%d:format=%s" ,
970+ scaled_width ,
971+ scaled_height ,
972+ av_get_pix_fmt_name (AV_PIX_FMT_NV12 ));
973+ // scale_d3d11 source shows support for AV_PIX_FMT_P010 as well, but that
974+ // is generating an error for me: Could not create the texture (80070057)
975+ } else {
976+ snprintf (scale_args , sizeof (scale_args ), "w=%d:h=%d" , scaled_width , scaled_height );
977+ }
967978
968979 mlt_log_verbose (MLT_PRODUCER_SERVICE (producer ),
969980 "Attempting to set up %s filter: %dx%d -> %dx%d\n" ,
@@ -2766,9 +2777,17 @@ static int producer_get_image(mlt_frame frame,
27662777 self -> hwaccel .filters_initialized = 1 ;
27672778 }
27682779#endif
2769- if (self -> hwaccel .pix_fmt == AV_PIX_FMT_VAAPI
2780+ if (self -> hwaccel .pix_fmt == AV_PIX_FMT_D3D11
27702781 && !self -> hwaccel .filters_initialized
27712782 && !self -> vfilter_graph ) {
2783+ setup_hwaccel_filters (self ,
2784+ producer ,
2785+ "scale_d3d11" ,
2786+ consumer_scale );
2787+ self -> hwaccel .filters_initialized = 1 ;
2788+ } else if (self -> hwaccel .pix_fmt == AV_PIX_FMT_VAAPI
2789+ && !self -> hwaccel .filters_initialized
2790+ && !self -> vfilter_graph ) {
27722791 setup_hwaccel_filters (self ,
27732792 producer ,
27742793 "scale_vaapi" ,
@@ -2787,7 +2806,8 @@ static int producer_get_image(mlt_frame frame,
27872806
27882807 // Apply hardware scale filter if initialized successfully
27892808 // Only apply if frame is still in hardware format
2790- if ((self -> video_frame -> format == AV_PIX_FMT_VAAPI
2809+ if ((self -> video_frame -> format == AV_PIX_FMT_D3D11
2810+ || self -> video_frame -> format == AV_PIX_FMT_VAAPI
27912811 || self -> video_frame -> format == AV_PIX_FMT_VIDEOTOOLBOX
27922812 || self -> video_frame -> format == AV_PIX_FMT_VULKAN )
27932813 && self -> hwaccel .filters_initialized && self -> vfilter_graph
@@ -3108,8 +3128,8 @@ static int video_codec_init(producer_avformat self, int index, mlt_properties pr
31083128 goto skip_hwaccel ;
31093129 }
31103130
3111- int found_hw_pix_fmt = 0 , i ;
3112- for (i = 0 ;; i ++ ) {
3131+ int found_hw_pix_fmt = 0 ;
3132+ for (int i = 0 ;; i ++ ) {
31133133 const AVCodecHWConfig * config = avcodec_get_hw_config (codec , i );
31143134 if (!config )
31153135 break ;
0 commit comments