Skip to content

Commit

Permalink
qsv: fix build
Browse files Browse the repository at this point in the history
I missed some of the qsv filter settings bits that needed changing.
  • Loading branch information
jstebbins committed Mar 11, 2016
1 parent c3c076a commit fc3a836
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 33 deletions.
1 change: 1 addition & 0 deletions libhb/decomb.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#define MODE_YADIF_ENABLE 1
#define MODE_YADIF_SPATIAL 2
#define MODE_YADIF_BOB 4
#define MODE_DEINTERLACE_QSV 8

#endif // HB_DECOMB_H
1 change: 1 addition & 0 deletions libhb/hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,7 @@ int hb_global_init()
hb_error("hb_qsv_info_init failed!");
return -1;
}
hb_param_configure_qsv();
#endif

/* libavcodec */
Expand Down
19 changes: 18 additions & 1 deletion libhb/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "param.h"
#include "common.h"
#include "colormap.h"
#ifdef USE_QSV
#include "qsv_common.h"
#endif
#include <regex.h>

static hb_filter_param_t nlmeans_presets[] =
Expand Down Expand Up @@ -106,10 +109,14 @@ static hb_filter_param_t deinterlace_presets[] =
{ 3, "Default", "default", "mode=3" },
{ 2, "Skip Spatial Check", "skip-spatial", "mode=1" },
{ 5, "Bob", "bob", "mode=7" },
#ifdef USE_QSV
{ 6, "QSV", "qsv", "mode=11" },
#endif
{ 0, NULL, NULL, NULL },
{ 2, "Fast", "fast", "mode=1" },
{ 3, "Slow", "slow", "mode=1" },
{ 4, "Slower", "slower", "mode=3" }
{ 4, "Slower", "slower", "mode=3" },
{ 7, "QSV", "qsv", "mode=3" }
};

typedef struct
Expand Down Expand Up @@ -143,6 +150,16 @@ static filter_param_map_t param_map[] =
{ HB_FILTER_INVALID, NULL, NULL, 0 }
};

void hb_param_configure_qsv(void)
{
#ifdef USE_QSV
if (!hb_qsv_available())
{
memset(&deinterlace_presets[4], 0, sizeof(hb_filter_param_t));
}
#endif
}

/* NL-means presets and tunes
*
* Presets adjust strength:
Expand Down
2 changes: 2 additions & 0 deletions libhb/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct hb_filter_param_s
const char *settings;
};

void hb_param_configure_qsv(void);

hb_dict_t * hb_generate_filter_settings(int filter_id, const char *preset,
const char *tune, const char *custom);
char * hb_generate_filter_settings_json(int filter_id, const char *preset,
Expand Down
40 changes: 21 additions & 19 deletions libhb/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,12 +1167,13 @@ static int sanitize_qsv( hb_job_t * job )

// CPU-based deinterlace (validated)
case HB_FILTER_DEINTERLACE:
if (filter->settings != NULL &&
strcasecmp(filter->settings, "qsv") != 0)
{
int mode = hb_dict_get_int(filter->settings, "mode");
if (!(mode & MODE_DEINTERLACE_QSV))
{
encode_only = 1;
}
break;
} break;

// other filters will be removed
default:
Expand Down Expand Up @@ -1217,19 +1218,19 @@ static int sanitize_qsv( hb_job_t * job )
{
// cropping and scaling always done via VPP filter
case HB_FILTER_CROP_SCALE:
if (filter->settings == NULL || *filter->settings == 0)
{
// VPP defaults were set above, so not a problem
// however, this should never happen, print an error
hb_error("do_job: '%s': no settings!", filter->name);
}
else
{
sscanf(filter->settings, "%d:%d:%d:%d:%d:%d",
&vpp_settings[0], &vpp_settings[1],
&vpp_settings[2], &vpp_settings[3],
&vpp_settings[4], &vpp_settings[5]);
}
hb_dict_extract_int(&vpp_settings[0], filter->settings,
"width");
hb_dict_extract_int(&vpp_settings[1], filter->settings,
"height");
hb_dict_extract_int(&vpp_settings[2], filter->settings,
"crop-top");
hb_dict_extract_int(&vpp_settings[3], filter->settings,
"crop-bottom");
hb_dict_extract_int(&vpp_settings[4], filter->settings,
"crop-left");
hb_dict_extract_int(&vpp_settings[5], filter->settings,
"crop-right");

// VPP crop/scale takes precedence over OpenCL scale too
if (job->use_opencl)
{
Expand All @@ -1242,8 +1243,9 @@ static int sanitize_qsv( hb_job_t * job )

// pick VPP or CPU deinterlace depending on settings
case HB_FILTER_DEINTERLACE:
if (filter->settings == NULL ||
strcasecmp(filter->settings, "qsv") == 0)
{
int mode = hb_dict_get_int(filter->settings, "mode");
if (mode & MODE_DEINTERLACE_QSV)
{
// deinterlacing via VPP filter
vpp_settings[6] = 1;
Expand All @@ -1255,7 +1257,7 @@ static int sanitize_qsv( hb_job_t * job )
// validated
num_cpu_filters++;
}
break;
} break;

// then, validated filters
case HB_FILTER_ROTATE: // TODO: use Media SDK for this
Expand Down
14 changes: 1 addition & 13 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,13 +912,6 @@ static void showFilterPresets(FILE* const out, int filter_id)
char * slash = "", * newline;
int ii, count = 0, linelen = 0;

#ifdef USE_QSV
if (filter_id == HB_FILTER_DEINTERLACE && hb_qsv_available())
{
count = 1;
}
#endif

// Count number of entries we want to display
for (ii = 0; names[ii] != NULL; ii++)
{
Expand Down Expand Up @@ -956,12 +949,7 @@ if (filter_id == HB_FILTER_DEINTERLACE && hb_qsv_available())
linelen += len;
slash = "/";
}
#ifdef USE_QSV
if (filter_id == HB_FILTER_DEINTERLACE && hb_qsv_available())
{
fprintf(out, "/qsv");
}
#endif

fprintf(out, ">\n");
hb_str_vfree(names);
}
Expand Down

0 comments on commit fc3a836

Please sign in to comment.