From: Carl Hetherington Date: Sun, 18 Aug 2013 21:11:59 +0000 (+0100) Subject: Add colour conversion identifier to video identifier. X-Git-Tag: v2.0.48~1337^2~55 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=b89cc774a89867caa97db4b082655569c7d69432;p=dcpomatic.git Add colour conversion identifier to video identifier. --- diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index cc25ccc67..5f8064dab 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -23,6 +23,7 @@ #include #include "config.h" #include "colour_conversion.h" +#include "util.h" #include "i18n.h" @@ -116,6 +117,26 @@ ColourConversion::preset () const return i; } +string +ColourConversion::identifier () const +{ + double numbers[12]; + + int n = 0; + numbers[n++] = input_gamma; + numbers[n++] = input_gamma_linearised; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + numbers[n++] = matrix (i, j); + } + } + numbers[n++] = output_gamma; + + assert (n == 12); + + return md5_digest (numbers, 12 * sizeof (double)); +} + PresetColourConversion::PresetColourConversion () : name (_("Untitled")) { diff --git a/src/lib/colour_conversion.h b/src/lib/colour_conversion.h index f6b5bc9f3..893148466 100644 --- a/src/lib/colour_conversion.h +++ b/src/lib/colour_conversion.h @@ -45,6 +45,7 @@ public: ColourConversion (boost::shared_ptr); virtual void as_xml (xmlpp::Node *) const; + std::string identifier () const; boost::optional preset () const; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 8b0ec4c99..3f6e171a5 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -225,7 +225,8 @@ VideoContent::identifier () const << "_" << crop().left << "_" << crop().right << "_" << crop().top - << "_" << crop().bottom; + << "_" << crop().bottom + << "_" << colour_conversion().identifier (); if (ratio()) { s << "_" << ratio()->id (); diff --git a/test/colour_conversion_test.cc b/test/colour_conversion_test.cc new file mode 100644 index 000000000..3e90d542a --- /dev/null +++ b/test/colour_conversion_test.cc @@ -0,0 +1,34 @@ +/* + Copyright (C) 2013 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include +#include "lib/colour_conversion.h" + +using std::cout; + +/* Basic test of identifier() for ColourConversion (i.e. a hash of the numbers) */ +BOOST_AUTO_TEST_CASE (colour_conversion_test) +{ + ColourConversion A (2.4, true, libdcp::colour_matrix::srgb_to_xyz, 2.6); + ColourConversion B (2.4, false, libdcp::colour_matrix::srgb_to_xyz, 2.6); + + BOOST_CHECK_EQUAL (A.identifier(), "246ff9b7dc32c0488948a32a713924b3"); + BOOST_CHECK_EQUAL (B.identifier(), "a8d1da30f96a121d8db06a03409758b3"); +} diff --git a/test/wscript b/test/wscript index 8cc50a683..7c7aee733 100644 --- a/test/wscript +++ b/test/wscript @@ -16,6 +16,7 @@ def build(bld): obj.use = 'libdcpomatic' obj.source = """ test.cc + colour_conversion_test.cc audio_delay_test.cc silence_padding_test.cc audio_merger_test.cc @@ -40,5 +41,6 @@ def build(bld): image_test.cc 4k_test.cc """ + obj.target = 'unit-tests' obj.install_path = ''