Chromium Code Reviews| Index: third_party/qcms/src/tests/qcms_test_ntsc_gamut.c |
| diff --git a/third_party/qcms/src/tests/qcms_test_ntsc_gamut.c b/third_party/qcms/src/tests/qcms_test_ntsc_gamut.c |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e025594923016e63bf5b2dd081ddb489750c7efa |
| --- /dev/null |
| +++ b/third_party/qcms/src/tests/qcms_test_ntsc_gamut.c |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
Noel Gordon
2016/02/17 10:42:24
nit: 2015 -> 2016.
radu.velea
2016/02/17 11:31:00
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the Chromium LICENSE file. |
| + |
| +#include "qcms_test_util.h" |
| + |
| +#include <stdio.h> |
| +#include <stdlib.h> |
| +#include <time.h> |
| + |
| +static qcms_bool invalid_rgb_color_profile(qcms_profile *profile) |
| +{ |
| + return rgbData != qcms_profile_get_color_space(profile) || qcms_profile_is_bogus(profile); |
| +} |
| + |
| +static int qcms_test_ntsc_gamut(size_t width, |
| + size_t height, |
| + int iterations, |
| + const char *input_path, |
| + const char *referece_path, |
| + const int force_software) |
| +{ |
| + qcms_profile *input_profile; |
| + qcms_profile *reference_profile = qcms_profile_sRGB(); |
| + qcms_transform *transform; |
| + float input_gamut_metric, reference_gamut_metric; |
| + |
| + if (input_path == NULL) { |
|
Noel Gordon
2016/02/17 10:42:25
if (!input_path)
radu.velea
2016/02/17 11:31:00
Done.
|
| + fprintf(stderr, "%s: please provide valid ICC profiles via -i/o options\n", __FUNCTION__); |
| + return EXIT_FAILURE; |
| + } |
| + |
| + input_profile = qcms_profile_from_path(input_path); |
| + if (!input_profile || invalid_rgb_color_profile(input_profile)) { |
| + fprintf(stderr, "Invalid input profile\n"); |
| + return EXIT_FAILURE; |
| + } |
| + |
| + transform = qcms_transform_create(input_profile, QCMS_DATA_RGBA_8, reference_profile, QCMS_DATA_RGBA_8, QCMS_INTENT_DEFAULT); |
| + if (!transform) { |
| + fprintf(stderr, "Could not create transform\n"); |
| + return EXIT_FAILURE; |
| + } |
| + else if (!(transform->transform_flags & TRANSFORM_FLAG_MATRIX)) { |
|
Noel Gordon
2016/02/17 10:42:24
nite: space before this line and then write it as
radu.velea
2016/02/17 11:31:00
Done.
|
| + fprintf(stderr, "Transform is not matrix\n"); |
| + qcms_transform_release(transform); |
| + qcms_profile_release(input_profile); |
| + qcms_profile_release(reference_profile); |
| + return EXIT_FAILURE; |
| + } |
| + |
| + printf("NTSC 1953 relative gamut area test\n"); |
| + |
| + input_gamut_metric = qcms_profile_ntsc_relative_gamut_size(input_profile); |
| + printf("Input profile\n\tDescription: %s\n\tNTSC relative gamut area: %.3f %%\n", |
| + input_profile->description, input_gamut_metric); |
| + |
| + reference_gamut_metric = qcms_profile_ntsc_relative_gamut_size(reference_profile); |
| + printf("Internal reference profile\n\tDescription: %s\n\tNTSC relative gamut area: %.3f %%\n", |
| + reference_profile->description, reference_gamut_metric); |
| + |
| + qcms_transform_release(transform); |
| + qcms_profile_release(input_profile); |
| + qcms_profile_release(reference_profile); |
| + |
| + return 0; |
| +} |
| + |
| +struct qcms_test_case qcms_test_ntsc_gamut_info = { |
| + "qcms_test_ntsc_gamut", |
| + qcms_test_ntsc_gamut, |
| + QCMS_TEST_DISABLED |
| +}; |