Skip to content

Commit 1222dad

Browse files
authored
Merge pull request #559 from cchampet/dev_oiioAddSubSamplingParameter
oiio: up to v1.4 * writer : add sub sampling parameter * add reader/writer tests
2 parents d9d1f3a + 766e188 commit 1222dad

File tree

8 files changed

+61
-7
lines changed

8 files changed

+61
-7
lines changed

INSTALL.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ git clone https://github.com/tuttleofx/TuttleOFX-data.git
8080
Tests of host ( __libraries/tuttle/tests__ ) and plugins ( __tests__ directory in each plugin, with test files prefixed by "plugin_") with Boost Unit Test Framework.
8181
After compiling the project, executables are in __testBin__ directory.
8282

83+
The tests of the IO plugins need images which can be found in the [TuttleOFX-data](https://github.com/tuttleofx/TuttleOFX-data) repository. To indicate the path to these images:
84+
```
85+
export TUTTLE_TEST_DATA=/path/to/TuttleOFX-data
86+
```
87+
8388
- Python tests
8489

8590
Test of host ( __libraries/tuttle/pyTest__ ) with nosetests tool.

plugins/image/io/OpenImageIO/src/mainEntry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define OFXPLUGIN_VERSION_MAJOR 1
2-
#define OFXPLUGIN_VERSION_MINOR 3
2+
#define OFXPLUGIN_VERSION_MINOR 4
33

44
#include <tuttle/plugin/Plugin.hpp>
55
#include "reader/OpenImageIOReaderPluginFactory.hpp"

plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ enum ETuttlePluginComponents
3636
static const std::string kParamOutputQuality = "quality";
3737
static const std::string kParamOutputQualityLabel = "Quality";
3838

39+
enum ETuttlePluginSubsampling
40+
{
41+
eETuttlePluginSubsampling420 = 0,
42+
eETuttlePluginSubsampling422,
43+
eETuttlePluginSubsampling411,
44+
eETuttlePluginSubsampling444
45+
};
46+
47+
static const std::string kParamOutputSubsampling = "subsampling";
48+
static const std::string kParamOutputSubsamplingLabel = "Subsampling";
49+
static const std::string kParamOutputSubsamplingHint = "Controlling chroma-subsampling of output JPEG files:\n"
50+
"4:2:0 : one chrominance component for every 2x2 block of pixels.\n"
51+
"4:2:2 : one chrominance component for every 2x1 block of pixels.\n"
52+
"4:1:1 : one chrominance component for every 4x1 block of pixels.\n"
53+
"4:4:4 : one chrominance component for every pixel (no subsampling)\n";
54+
55+
static const std::string kParamOutputSubsampling420 = "420";
56+
static const std::string kParamOutputSubsampling422 = "422";
57+
static const std::string kParamOutputSubsampling411 = "411";
58+
static const std::string kParamOutputSubsampling444 = "444";
59+
3960
static const std::string kParamOutputOrientation = "orientation";
4061
static const std::string kParamOutputOrientationLabel = "Orientation";
4162

plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ OpenImageIOWriterPlugin::OpenImageIOWriterPlugin(OfxImageEffectHandle handle)
1919
_components = fetchChoiceParam(kTuttlePluginChannel);
2020
_orientation = fetchChoiceParam(kParamOutputOrientation);
2121
_quality = fetchIntParam(kParamOutputQuality);
22+
_paramSubsampling = fetchChoiceParam(kParamOutputSubsampling);
2223
}
2324

2425
OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const OfxTime time)
@@ -29,6 +30,7 @@ OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const O
2930
params._filepath = getAbsoluteFilenameAt(time);
3031
params._components = static_cast<ETuttlePluginComponents>(this->_components->getValue());
3132
params._bitDepth = static_cast<ETuttlePluginBitDepth>(this->_paramBitDepth->getValue());
33+
params._subsampling = static_cast<ETuttlePluginSubsampling>(_paramSubsampling->getValue());
3234
params._quality = _quality->getValue();
3335
params._orientation = static_cast<int>(_orientation->getValue());
3436
params._premultiply = this->_paramPremult->getValue();

plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct OpenImageIOWriterProcessParams
2121
std::string _filepath; ///< filepath
2222
ETuttlePluginComponents _components; ///< Force RGB
2323
ETuttlePluginBitDepth _bitDepth; ///< Output bit depth (real bit depth, not the buffer passed to OpenImageIO)
24+
ETuttlePluginSubsampling _subsampling; ///< Output subsampling
2425

2526
bool _premultiply; ///< Output premultiply
2627
int _quality; ///< Output quality
@@ -42,6 +43,7 @@ class OpenImageIOWriterPlugin : public WriterPlugin
4243
public:
4344
OFX::ChoiceParam* _components; ///< Choose components RGBA/RGB
4445
OFX::IntParam* _quality;
46+
OFX::ChoiceParam* _paramSubsampling;
4547
OFX::ChoiceParam* _orientation;
4648
};
4749
}

plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto
105105
quality->setDisplayRange(0, 100);
106106
quality->setDefault(80);
107107

108+
OFX::ChoiceParamDescriptor* subsampling = desc.defineChoiceParam(kParamOutputSubsampling);
109+
subsampling->setLabel(kParamOutputSubsamplingLabel);
110+
subsampling->setHint(kParamOutputSubsamplingHint);
111+
subsampling->appendOption(kParamOutputSubsampling420);
112+
subsampling->appendOption(kParamOutputSubsampling422);
113+
subsampling->appendOption(kParamOutputSubsampling411);
114+
subsampling->appendOption(kParamOutputSubsampling444);
115+
subsampling->setDefault(0);
116+
108117
OFX::ChoiceParamDescriptor* orientation = desc.defineChoiceParam(kParamOutputOrientation);
109118
orientation->setLabel(kParamOutputOrientationLabel);
110119
orientation->appendOption(kParamOutputOrientationNormal);

plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,24 @@ void OpenImageIOWriterProcess<View>::writeImage(View& src, const std::string& fi
547547
spec.attribute("CompressionQuality", params._quality);
548548
spec.attribute("Orientation", params._orientation);
549549

550+
// controlling chroma-subsampling of jpeg
551+
// Other formats don't have this attribute and ignore it.
552+
switch(params._subsampling)
553+
{
554+
case eETuttlePluginSubsampling420:
555+
spec.attribute("jpeg:subsampling", "4:2:0");
556+
break;
557+
case eETuttlePluginSubsampling422:
558+
spec.attribute("jpeg:subsampling", "4:2:2");
559+
break;
560+
case eETuttlePluginSubsampling411:
561+
spec.attribute("jpeg:subsampling", "4:1:1");
562+
break;
563+
case eETuttlePluginSubsampling444:
564+
spec.attribute("jpeg:subsampling", "4:4:4");
565+
break;
566+
}
567+
550568
// write par, xdensity and ydensity to the output
551569
// Some formats (ie. TIF, JPEG...) make the difference between those attributes.
552570
// Some others (ie. DPX...) don't have density attributes and ignore them.

plugins/image/io/OpenImageIO/tests/plugin_io_openImageIO.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ std::string pluginName = "tuttle.oiioreader";
3434
std::string filename = "jpeg/BLU.JPG";
3535
#include <tuttle/test/io/reader.hpp>
3636
BOOST_AUTO_TEST_SUITE_END()
37-
/*
37+
3838
BOOST_AUTO_TEST_SUITE( plugin_OpenImageIO_j2k_reader )
3939
std::string pluginName = "tuttle.oiioreader";
4040
std::string filename = "j2k/Bretagne1.j2k";
@@ -46,7 +46,7 @@ std::string pluginName = "tuttle.oiioreader";
4646
std::string filename = "jp2/relax.jp2";
4747
#include <tuttle/test/io/reader.hpp>
4848
BOOST_AUTO_TEST_SUITE_END()
49-
*/
49+
5050

5151
BOOST_AUTO_TEST_SUITE(plugin_OpenImageIO_png_reader)
5252
std::string pluginName = "tuttle.oiioreader";
@@ -61,13 +61,12 @@ std::string filename = "tif/test-ramp.tif";
6161
BOOST_AUTO_TEST_SUITE_END()
6262

6363
//// WRITER ////
64-
/*
64+
6565
BOOST_AUTO_TEST_SUITE( plugin_OpenImageIO_dpx_writer )
6666
std::string pluginName = "tuttle.oiiowriter";
6767
std::string filename = "test-oiio.dpx";
6868
#include <tuttle/test/io/writer.hpp>
6969
BOOST_AUTO_TEST_SUITE_END()
70-
*/
7170

7271
BOOST_AUTO_TEST_SUITE(plugin_OpenImageIO_exr_writer)
7372
std::string pluginName = "tuttle.oiiowriter";
@@ -81,7 +80,6 @@ std::string filename = "test-oiio.jpg";
8180
#include <tuttle/test/io/writer.hpp>
8281
BOOST_AUTO_TEST_SUITE_END()
8382

84-
/*
8583
BOOST_AUTO_TEST_SUITE( plugin_OpenImageIO_j2k_writer )
8684
std::string pluginName = "tuttle.oiiowriter";
8785
std::string filename = "test-oiio.j2k";
@@ -93,7 +91,6 @@ std::string pluginName = "tuttle.oiiowriter";
9391
std::string filename = "test-oiio.jp2";
9492
#include <tuttle/test/io/writer.hpp>
9593
BOOST_AUTO_TEST_SUITE_END()
96-
*/
9794

9895
BOOST_AUTO_TEST_SUITE(plugin_OpenImageIO_png_writer)
9996
std::string pluginName = "tuttle.oiiowriter";

0 commit comments

Comments
 (0)