Disabled external gits

This commit is contained in:
2022-04-07 18:46:57 +02:00
parent 88cb3426ad
commit 15e7120d6d
5316 changed files with 4563444 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
Makefile
Makefile.in
config.h.in
config.h
config.log
config.status
configure
libtool
stamp-h
aclocal.m4
OpenEXR.pc
autom4te.cache
ltmain.sh
stamp-h.in
depcomp
.deps

View File

@@ -0,0 +1,21 @@
# yue.nicholas@gmail.com
ADD_EXECUTABLE ( exrmakepreview
makePreview.cpp
main.cpp
)
TARGET_LINK_LIBRARIES ( exrmakepreview
IlmImf
IlmThread${ILMBASE_LIBSUFFIX}
Iex${ILMBASE_LIBSUFFIX}
Half
${PTHREAD_LIB}
${ZLIB_LIBRARIES}
)
INSTALL ( TARGETS
exrmakepreview
DESTINATION
${CMAKE_INSTALL_PREFIX}/bin
)

View File

@@ -0,0 +1,17 @@
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = exrmakepreview
INCLUDES = -I$(top_builddir) \
-I$(top_srcdir)/IlmImf -I$(top_srcdir)/config \
@ILMBASE_CXXFLAGS@
LDADD = @ILMBASE_LDFLAGS@ @ILMBASE_LIBS@\
$(top_builddir)/IlmImf/libIlmImf.la \
-lz
exrmakepreview_SOURCES = main.cpp makePreview.cpp makePreview.h
noinst_HEADERS = makePreview.h
EXTRA_DIST = main.cpp makePreview.cpp makePreview.h CMakeLists.txt

View File

@@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// exrmakepreview -- a program that inserts a
// preview image into an OpenEXR file's header.
//
//-----------------------------------------------------------------------------
#include "makePreview.h"
#include <iostream>
#include <exception>
#include <stdlib.h>
#include <string.h>
using namespace std;
void
usageMessage (const char argv0[], bool verbose = false)
{
cerr << "usage: " << argv0 << " [options] infile outfile" << endl;
if (verbose)
{
cerr << "\n"
"Reads an OpenEXR image from infile, generates a preview\n"
"image, adds it to the image's header, and saves the result\n"
"in outfile. Infile and outfile must not refer to the same\n"
"file (the program cannot edit an image file \"in place\").\n"
"\n"
"Options:\n"
"\n"
"-w x sets the width of the preview image to x pixels\n"
" (default is 100)\n"
"\n"
"-e s adjusts the preview image's exposure by s f-stops\n"
" (default is 0). Positive values make the image\n"
" brighter, negative values make it darker.\n"
"\n"
"-v verbose mode\n"
"\n"
"-h prints this message\n";
cerr << endl;
}
exit (1);
}
int
main(int argc, char **argv)
{
const char *inFile = 0;
const char *outFile = 0;
int previewWidth = 100;
float exposure = 0;
bool verbose = false;
//
// Parse the command line.
//
if (argc < 2)
usageMessage (argv[0], true);
int i = 1;
while (i < argc)
{
if (!strcmp (argv[i], "-w"))
{
//
// Set preview image width
//
if (i > argc - 2)
usageMessage (argv[0]);
previewWidth = strtol (argv[i + 1], 0, 0);
i += 2;
}
else if (!strcmp (argv[i], "-e"))
{
//
// Set preview image width
//
if (i > argc - 2)
usageMessage (argv[0]);
exposure = strtod (argv[i + 1], 0);
i += 2;
}
else if (!strcmp (argv[i], "-v"))
{
//
// Verbose mode
//
verbose = true;
i += 1;
}
else if (!strcmp (argv[i], "-h"))
{
//
// Print help message
//
usageMessage (argv[0], true);
}
else
{
//
// Image file name
//
if (inFile == 0)
inFile = argv[i];
else
outFile = argv[i];
i += 1;
}
}
if (inFile == 0 || outFile == 0)
usageMessage (argv[0]);
if (!strcmp (inFile, outFile))
{
cerr << "Input and output cannot be the same file." << endl;
return 1;
}
if (previewWidth <= 0)
{
cerr << "Preview image width must be greather than zero." << endl;
return 1;
}
//
// Load inFile, add a preview image, and save the result in outFile.
//
int exitStatus = 0;
try
{
makePreview (inFile, outFile, previewWidth, exposure, verbose);
}
catch (const exception &e)
{
cerr << e.what() << endl;
exitStatus = 1;
}
return exitStatus;
}

View File

@@ -0,0 +1,186 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Add a preview image to an OpenEXR file.
//
//----------------------------------------------------------------------------
#include "makePreview.h"
#include <ImfInputFile.h>
#include <ImfOutputFile.h>
#include <ImfTiledOutputFile.h>
#include <ImfRgbaFile.h>
#include <ImfPreviewImage.h>
#include <ImfArray.h>
#include <ImathMath.h>
#include <ImathFun.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <OpenEXRConfig.h>
using namespace OPENEXR_IMF_NAMESPACE;
using namespace IMATH_NAMESPACE;
using namespace std;
namespace {
float
knee (float x, float f)
{
return log (x * f + 1) / f;
}
unsigned char
gamma (half h, float m)
{
//
// Conversion from half to unsigned char pixel data,
// with gamma correction. The conversion is the same
// as in the exrdisplay program's ImageView class,
// except with defog, kneeLow, and kneeHigh fixed
// at 0.0, 0.0, and 5.0 respectively.
//
float x = max (0.f, h * m);
if (x > 1)
x = 1 + knee (x - 1, 0.184874f);
return (unsigned char) (clamp (Math<float>::pow (x, 0.4545f) * 84.66f,
0.f,
255.f));
}
void
generatePreview (const char inFileName[],
float exposure,
int previewWidth,
int &previewHeight,
Array2D <PreviewRgba> &previewPixels)
{
//
// Read the input file
//
RgbaInputFile in (inFileName);
Box2i dw = in.dataWindow();
float a = in.pixelAspectRatio();
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
Array2D <Rgba> pixels (h, w);
in.setFrameBuffer (&pixels[0][0] - dw.min.y * w - dw.min.x, 1, w);
in.readPixels (dw.min.y, dw.max.y);
//
// Make a preview image
//
previewHeight = max (int (h / (w * a) * previewWidth + .5f), 1);
previewPixels.resizeErase (previewHeight, previewWidth);
float fx = (previewWidth > 0)? (float (w - 1) / (previewWidth - 1)): 1;
float fy = (previewHeight > 0)? (float (h - 1) / (previewHeight - 1)): 1;
float m = Math<float>::pow (2.f, clamp (exposure + 2.47393f, -20.f, 20.f));
for (int y = 0; y < previewHeight; ++y)
{
for (int x = 0; x < previewWidth; ++x)
{
PreviewRgba &preview = previewPixels[y][x];
const Rgba &pixel = pixels[int (y * fy + .5f)][int (x * fx + .5f)];
preview.r = gamma (pixel.r, m);
preview.g = gamma (pixel.g, m);
preview.b = gamma (pixel.b, m);
preview.a = int (clamp (pixel.a * 255.f, 0.f, 255.f) + .5f);
}
}
}
} // namespace
void
makePreview (const char inFileName[],
const char outFileName[],
int previewWidth,
float exposure,
bool verbose)
{
if (verbose)
cout << "generating preview image" << endl;
Array2D <PreviewRgba> previewPixels;
int previewHeight;
generatePreview (inFileName,
exposure,
previewWidth,
previewHeight,
previewPixels);
InputFile in (inFileName);
Header header = in.header();
header.setPreviewImage
(PreviewImage (previewWidth, previewHeight, &previewPixels[0][0]));
if (verbose)
cout << "copying " << inFileName << " to " << outFileName << endl;
if (header.hasTileDescription())
{
TiledOutputFile out (outFileName, header);
out.copyPixels (in);
}
else
{
OutputFile out (outFileName, header);
out.copyPixels (in);
}
if (verbose)
cout << "done." << endl;
}

View File

@@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_MAKE_PREVIEW_H
#define INCLUDED_MAKE_PREVIEW_H
//----------------------------------------------------------------------------
//
// Add a preview image to an OpenEXR file.
//
//----------------------------------------------------------------------------
void makePreview (const char inFileName[],
const char outFileName[],
int previewWidth,
float exposure,
bool verbose);
#endif