Skip to content

Conversation

dashsantosh-mcw
Copy link
Contributor

Description of Change:
Adds support for scale_d3d11 hardware scaling filter when using MediaFoundation encoders on Windows ARM64 devices

Patch A38 in contrib/ffmpeg fixes the static pool size exceeded error when using the full Hardware pipleine (#6523)

Tested on:

  • Windows 10+ (via MinGW)
  • macOS 10.13+
  • Ubuntu Linux

{
hb_dict_set_int(avsettings, "width", width);
hb_dict_set_int(avsettings, "height", height);
hb_dict_set(avfilter, "scale_d3d11", avsettings);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can scale_d3d11 convert from one color range to another? If not the output will not be correct if the source color range is not the same as the output one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, scale_d3d11 does not handle color range conversion. Would it be okay to disable the full hardware pipeline in this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are some seriously broken video out there that can change the color range mid-stream, so in those cases it would still break, but yes we can disable it for now.

@dashsantosh-mcw dashsantosh-mcw force-pushed the vpblt-rebased branch 3 times, most recently from 8964316 to 7424c76 Compare August 13, 2025 06:59
libhb/work.c Outdated
hb_hwaccel_t *hwaccel = hb_get_hwaccel(job->hw_pix_fmt);

if (hb_video_encoder_pix_fmt_is_supported(job->vcodec, job->input_pix_fmt, job->encoder_profile) == 0 ||
(hwaccel && (hwaccel->caps & HB_HWACCEL_CAP_FORMAT_REQUIRED)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should check if job->hw_pix_fmt is not AV_PIX_FMT_NONE too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's actually job->hw_decode i believe. updated above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

job->hw_pix_fmt is the right one to check if the full hw accelerated pipeline is enabled or not.

@galad87
Copy link
Contributor

galad87 commented Aug 13, 2025

Here's a sample file that changes resolution many times, to test if the scale filter in decavcodec.c works: https://www.swisstransfer.com/d/ff8e07db-72d3-421c-b214-5ce931217ae3

@dashsantosh-mcw
Copy link
Contributor Author

reinit_filters in decavcodec.c seems to be failing with this clip. will fix and update. thanks

@dashsantosh-mcw
Copy link
Contributor Author

@galad87 After the commit FFmpeg#a7fe27f, the following in hbavfilter.c seems to fail

result = avfilter_graph_create_filter(&graph->input, avfilter_get_by_name("buffer"), "in",
filter_args, NULL, graph->avgraph);

Error:

[in @ 0000017897cf84d0] Setting BufferSourceContext.pix_fmt to a HW format requires hw_frames_ctx to be non-NULL!
ERROR: hb_avfilter_graph_init: failed to create buffer source filter
[01:13:01] Failure to initialise filter 'AVFilter', disabling

Do you know what might be causing this?

@galad87
Copy link
Contributor

galad87 commented Aug 19, 2025

Maybe the hw frames context needs to be passed at the creation time, it added after the creation right now.

@dashsantosh-mcw
Copy link
Contributor Author

graph->input is being allocated within avfilter_graph_create_filter
calling av_buffersrc_parameters_set before this crashes since graph->input is NULL 🙃

result = avfilter_graph_create_filter(&graph->input, avfilter_get_by_name("buffer"), "in",
filter_args, NULL, graph->avgraph);
free(filter_args);
if (result < 0)
{
hb_error("hb_avfilter_graph_init: failed to create buffer source filter");
goto fail;
}
if (par)
{
result = av_buffersrc_parameters_set(graph->input, par);
if (result < 0)
{
goto fail;
}
}

@galad87
Copy link
Contributor

galad87 commented Aug 22, 2025

Try to rebase it on #7201, it might or not improve the situation.

@dashsantosh-mcw
Copy link
Contributor Author

Thanks, lemme try ✅

@dashsantosh-mcw
Copy link
Contributor Author

@galad87 #7201 helped fix the issue. thanks

@dashsantosh-mcw dashsantosh-mcw marked this pull request as ready for review August 25, 2025 06:03
@dashsantosh-mcw
Copy link
Contributor Author

@galad87 rebased to master. could you please review? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants