summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2021-01-23 18:56:36 +0100
committerDamiano Galassi <[email protected]>2021-01-23 19:00:27 +0100
commitca260f666f0663997f72786a03a50f01ec7dc09f (patch)
tree44b4b1458903d77772a0b468108e1580ce433b90 /test
parent581f60136ad0c68b8849cd0b6f9331cf1283cb5c (diff)
libhb: re-implement colorspace filter with zimg, add tonemap, and expose the colorspace filter in the cli
Diffstat (limited to 'test')
-rw-r--r--test/test.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/test/test.c b/test/test.c
index 7c123c4bb..9bf8e90bf 100644
--- a/test/test.c
+++ b/test/test.c
@@ -57,6 +57,7 @@
#define HQDN3D_DEFAULT_PRESET "medium"
#define ROTATE_DEFAULT "angle=180:hflip=0"
#define DEBLOCK_DEFAULT_PRESET "medium"
+#define COLORSPACE_DEFAULT_PRESET "bt709"
/* Options */
static int debug = HB_DEBUG_ALL;
@@ -75,6 +76,9 @@ static int native_dub = 0;
static int twoPass = -1;
static int pad_disable = 0;
static char * pad = NULL;
+static int colorspace_disable = 0;
+static int colorspace_custom = 0;
+static char * colorspace = NULL;
static int deinterlace_disable = 0;
static int deinterlace_custom = 0;
static char * deinterlace = NULL;
@@ -1230,6 +1234,7 @@ static void showFilterDefault(FILE* const out, int filter_id)
case HB_FILTER_DEINTERLACE:
case HB_FILTER_NLMEANS:
case HB_FILTER_CHROMA_SMOOTH:
+ case HB_FILTER_COLORSPACE:
case HB_FILTER_UNSHARP:
case HB_FILTER_LAPSHARP:
case HB_FILTER_DECOMB:
@@ -1793,6 +1798,10 @@ static void ShowHelp()
" The position of image in pad may also be set.\n");
showFilterKeys(out, HB_FILTER_PAD);
fprintf( out,
+" --colorspace <string> Convert colorspace, transfer characteristics or color primaries.\n");
+ showFilterPresets(out, HB_FILTER_COLORSPACE);
+ showFilterKeys(out, HB_FILTER_COLORSPACE);
+ fprintf( out,
" -g, --grayscale Grayscale encoding\n"
" --no-grayscale Disable preset 'grayscale'\n"
"\n"
@@ -2164,7 +2173,8 @@ static int ParseOptions( int argc, char ** argv )
#define SSA_BURN 321
#define FILTER_CHROMA_SMOOTH 322
#define FILTER_CHROMA_SMOOTH_TUNE 323
- #define FILTER_DEBLOCK_TUNE 324
+ #define FILTER_DEBLOCK_TUNE 324
+ #define FILTER_COLORSPACE 325
for( ;; )
{
@@ -2284,6 +2294,8 @@ static int ParseOptions( int argc, char ** argv )
{ "no-loose-crop", no_argument, &loose_crop, 0 },
{ "pad", required_argument, NULL, PAD },
{ "no-pad", no_argument, &pad_disable, 1 },
+ { "colorspace", required_argument, NULL, FILTER_COLORSPACE},
+ { "no-colorspace", no_argument, &colorspace_disable, 1 },
// mapping of legacy option names for backwards compatibility
{ "qsv-preset", required_argument, NULL, ENCODER_PRESET, },
@@ -2734,6 +2746,17 @@ static int ParseOptions( int argc, char ** argv )
free(nlmeans_tune);
nlmeans_tune = strdup(optarg);
break;
+ case FILTER_COLORSPACE:
+ free(colorspace);
+ if (optarg != NULL)
+ {
+ colorspace = strdup(optarg);
+ }
+ else
+ {
+ colorspace = strdup(COLORSPACE_DEFAULT_PRESET);
+ }
+ break;
case FILTER_CHROMA_SMOOTH:
free(chroma_smooth);
if (optarg != NULL)
@@ -3169,6 +3192,31 @@ static int ParseOptions( int argc, char ** argv )
}
}
+ if (colorspace != NULL)
+ {
+ if (colorspace_disable)
+ {
+ fprintf(stderr,
+ "Incompatible options --colorspace and --no-colorspace\n");
+ return -1;
+ }
+ if (!hb_validate_filter_preset(HB_FILTER_COLORSPACE, colorspace, NULL, NULL))
+ {
+ // Nothing to do, but must validate preset before
+ // attempting to validate custom settings to prevent potential
+ // false positive
+ }
+ else if (!hb_validate_filter_string(HB_FILTER_COLORSPACE, colorspace))
+ {
+ colorspace_custom = 1;
+ }
+ else
+ {
+ fprintf(stderr, "Invalid colorspace option %s\n", colorspace);
+ return -1;
+ }
+ }
+
if (deinterlace != NULL)
{
if (deinterlace_disable)
@@ -4472,6 +4520,26 @@ static hb_dict_t * PreparePreset(const char *preset_name)
{
hb_dict_set(preset, "PicturePad", hb_value_string(pad));
}
+ if (colorspace_disable)
+ {
+ hb_dict_set(preset, "PictureColorspacePreset", hb_value_string("off"));
+ }
+ if (colorspace != NULL)
+ {
+ hb_dict_set(preset, "PictureColorspacePreset", hb_value_string(colorspace));
+ if (!colorspace_custom)
+ {
+ hb_dict_set(preset, "PictureColorspacePreset",
+ hb_value_string(colorspace));
+ }
+ else
+ {
+ hb_dict_set(preset, "PictureColorspacePreset",
+ hb_value_string("custom"));
+ hb_dict_set(preset, "PictureColorspaceCustom",
+ hb_value_string(colorspace));
+ }
+ }
return preset;
}