libhb: simplify QSV filters check

This commit is contained in:
Damiano Galassi 2025-06-09 10:41:35 +02:00
parent bd93ed4d45
commit 81b437ce71
No known key found for this signature in database
GPG Key ID: 5452E231DFDBCA11
5 changed files with 34 additions and 67 deletions

View File

@ -61,7 +61,6 @@ static int format_init(hb_filter_object_t *filter, hb_filter_init_t *init)
#if HB_PROJECT_FEATURE_QSV && (defined( _WIN32 ) || defined( __MINGW32__ ))
if (hb_qsv_full_path_is_enabled(init->job))
{
init->job->qsv.ctx->num_hw_filters++;
hb_dict_set_string(avsettings, "format", format);
hb_dict_set_int(avsettings, "async_depth", init->job->qsv.async_depth);
init->pix_fmt = av_get_pix_fmt(format);

View File

@ -353,7 +353,6 @@ int hb_qsv_is_enabled(hb_job_t *job);
hb_qsv_context* hb_qsv_context_init();
void hb_qsv_context_uninit(hb_job_t *job);
int hb_qsv_are_filters_supported(hb_job_t *job);
int hb_qsv_sanitize_filter_list(hb_job_t *job);
int hb_qsv_get_memory_type(hb_job_t *job);
int hb_qsv_full_path_is_enabled(hb_job_t *job);
int hb_qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags);

View File

@ -320,8 +320,6 @@ typedef struct hb_qsv_context {
void *qsv_config;
int num_sw_filters;
int num_hw_filters;
int la_is_enabled;
int qsv_hw_filters_via_video_memory_are_enabled;
int qsv_hw_filters_via_system_memory_are_enabled;

View File

@ -2274,7 +2274,7 @@ int hb_qsv_full_path_is_enabled(hb_job_t *job)
qsv_full_path_is_enabled = (hb_qsv_decode_is_enabled(job) &&
info && hb_qsv_implementation_is_hardware(info->implementation) &&
job->qsv.ctx && !job->qsv.ctx->num_sw_filters);
job->qsv.ctx && hb_qsv_are_filters_supported(job));
#endif
return qsv_full_path_is_enabled;
}
@ -3997,64 +3997,46 @@ int hb_qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
int hb_qsv_are_filters_supported(hb_job_t *job)
{
hb_qsv_sanitize_filter_list(job);
return job->qsv.ctx->num_sw_filters == 0;
}
int hb_qsv_sanitize_filter_list(hb_job_t *job)
{
/*
* When QSV's VPP is used for filtering, not all CPU filters
* are supported, so we need to do a little extra setup here.
*/
if (job->vcodec & HB_VCODEC_QSV_MASK)
int num_sw_filters = 0;
int num_hw_filters = 0;
if (job->list_filter != NULL && hb_list_count(job->list_filter) > 0)
{
int i = 0;
int num_sw_filters = 0;
int num_hw_filters = 0;
if (job->list_filter != NULL && hb_list_count(job->list_filter) > 0)
for (int i = 0; i < hb_list_count(job->list_filter); i++)
{
for (i = 0; i < hb_list_count(job->list_filter); i++)
hb_filter_object_t *filter = hb_list_item(job->list_filter, i);
switch (filter->id)
{
hb_filter_object_t *filter = hb_list_item(job->list_filter, i);
switch (filter->id)
// pixel format conversion is done via VPP filter
case HB_FILTER_FORMAT:
num_hw_filters++;
break;
// cropping and scaling always done via VPP filter
case HB_FILTER_CROP_SCALE:
num_hw_filters++;
break;
case HB_FILTER_ROTATE:
num_hw_filters++;
break;
case HB_FILTER_VFR:
{
// color conversion is done via VPP filter
case HB_FILTER_FORMAT:
num_hw_filters++;
break;
// cropping and scaling always done via VPP filter
case HB_FILTER_CROP_SCALE:
num_hw_filters++;
break;
case HB_FILTER_ROTATE:
num_hw_filters++;
break;
case HB_FILTER_VFR:
// Mode 0 doesn't require access to the frame data
int mode = hb_dict_get_int(filter->settings, "mode");
if (mode == 0)
{
// Mode 0 doesn't require access to the frame data
int mode = hb_dict_get_int(filter->settings, "mode");
if (mode == 0)
{
break;
}
break;
}
case HB_FILTER_AVFILTER:
num_hw_filters++;
break;
default:
// count only filters with access to frame data
num_sw_filters++;
break;
}
case HB_FILTER_AVFILTER:
num_hw_filters++;
break;
default:
// count only filters with access to frame data
num_sw_filters++;
break;
}
}
job->qsv.ctx->num_sw_filters = num_sw_filters;
job->qsv.ctx->num_hw_filters = num_hw_filters;
}
return 0;
return num_sw_filters == 0;
}
#else // other OS

View File

@ -1490,13 +1490,6 @@ static void sanitize_filter_list_pre(hb_job_t *job, hb_geometry_t src_geo)
}
}
}
#if HB_PROJECT_FEATURE_QSV && (defined( _WIN32 ) || defined( __MINGW32__ ))
if (hb_qsv_is_enabled(job))
{
hb_qsv_sanitize_filter_list(job);
}
#endif
}
static enum AVPixelFormat match_pix_fmt(enum AVPixelFormat pix_fmt,
@ -1812,6 +1805,8 @@ static void do_job(hb_job_t *job)
job->hw_pix_fmt = hb_get_best_hw_pix_fmt(job);
job->input_pix_fmt = hb_get_best_pix_fmt(job);
sanitize_dynamic_hdr_metadata_passthru(job);
// Init hwaccel context if needed
if (hb_hwaccel_decode_is_enabled(job))
{
@ -1821,7 +1816,6 @@ static void do_job(hb_job_t *job)
job);
}
sanitize_dynamic_hdr_metadata_passthru(job);
sanitize_filter_list_post(job);
memset(&init, 0, sizeof(init));
@ -1840,12 +1834,7 @@ static void do_job(hb_job_t *job)
(job->dovi.dv_profile == 5 ||
(job->dovi.dv_profile == 10 && job->dovi.dv_bl_signal_compatibility_id == 0)) ?
title->color_range : AVCOL_RANGE_MPEG;
#if HB_PROJECT_FEATURE_QSV
if (hb_qsv_full_path_is_enabled(job))
{
init.color_range = (job->qsv.ctx->out_range == AVCOL_RANGE_UNSPECIFIED) ? title->color_range : job->qsv.ctx->out_range;
}
#endif
init.chroma_location = title->chroma_location;
init.geometry = title->geometry;
memset(init.crop, 0, sizeof(int[4]));