-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial merge of C core library * includes exrinfo, similar to exrheader (subject to removal before release) * introduces the idea of an encoding and decoding pipeline which should enable future gpu or other custom paths Signed-off-by: Kimball Thurston <kdt3rd@gmail.com> * Comments, testing, and small fixes Signed-off-by: Kimball Thurston <kdt3rd@gmail.com> Co-authored-by: Timothy Grant <tgrant@nvidia.com>
- Loading branch information
Showing
86 changed files
with
46,726 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright Contributors to the OpenEXR Project. | ||
|
||
add_executable(exrinfo main.c) | ||
target_link_libraries(exrinfo OpenEXR::OpenEXRCore) | ||
set_target_properties(exrinfo PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" | ||
) | ||
install(TARGETS exrinfo DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED)) | ||
target_compile_definitions(exrinfo PRIVATE OPENEXR_DLL) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
** SPDX-License-Identifier: BSD-3-Clause | ||
** Copyright Contributors to the OpenEXR Project. | ||
*/ | ||
|
||
#include <openexr.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#ifdef _WIN32 | ||
# include <fcntl.h> | ||
# include <io.h> | ||
# include <windows.h> | ||
#else | ||
# include <unistd.h> | ||
#endif | ||
|
||
#include <stdlib.h> | ||
|
||
static void | ||
usage (const char* argv0) | ||
{ | ||
fprintf ( | ||
stderr, | ||
"Usage: %s [-v|--verbose] <filename> [<filename> ...]\n\n", | ||
argv0); | ||
} | ||
|
||
static void | ||
error_handler_cb (exr_const_context_t f, int code, const char* msg) | ||
{ | ||
const char* fn; | ||
if (EXR_ERR_SUCCESS != exr_get_file_name (f, &fn)) fn = "<error>"; | ||
fprintf ( | ||
stderr, | ||
"ERROR '%s' (%s): %s\n", | ||
fn, | ||
exr_get_error_code_as_string (code), | ||
msg); | ||
} | ||
|
||
static int64_t | ||
stdin_reader ( | ||
exr_const_context_t file, | ||
void* userdata, | ||
void* buffer, | ||
uint64_t sz, | ||
uint64_t offset, | ||
exr_stream_error_func_ptr_t error_cb) | ||
{ | ||
static uint64_t lastoffset = 0; | ||
int64_t nread = 0; | ||
|
||
(void) userdata; | ||
|
||
if (offset != lastoffset) | ||
{ | ||
error_cb (file, EXR_ERR_READ_IO, "Unable to seek in stdin stream"); | ||
return -1; | ||
} | ||
#ifdef _WIN32 | ||
if (sz >= (size_t) (INT32_MAX)) | ||
{ | ||
error_cb ( | ||
file, EXR_ERR_READ_IO, "Read request too large for win32 API"); | ||
return -1; | ||
} | ||
nread = _read (_fileno (stdin), buffer, (unsigned) sz); | ||
#else | ||
nread = read (STDIN_FILENO, buffer, sz); | ||
#endif | ||
if (nread > 0) lastoffset = offset + (uint64_t) nread; | ||
return nread; | ||
} | ||
|
||
static int | ||
process_stdin (int verbose) | ||
{ | ||
int rv; | ||
exr_context_t e = NULL; | ||
exr_context_initializer_t cinit = EXR_DEFAULT_CONTEXT_INITIALIZER; | ||
cinit.error_handler_fn = &error_handler_cb; | ||
cinit.read_fn = &stdin_reader; | ||
|
||
#ifdef _WIN32 | ||
_setmode (_fileno (stdin), _O_BINARY); | ||
#endif | ||
rv = exr_start_read (&e, "<stdin>", &cinit); | ||
if (rv == EXR_ERR_SUCCESS) | ||
{ | ||
exr_print_context_info (e, verbose); | ||
exr_finish (&e); | ||
} | ||
return rv; | ||
} | ||
|
||
static int | ||
process_file (const char* filename, int verbose) | ||
{ | ||
int rv; | ||
exr_context_t e = NULL; | ||
exr_context_initializer_t cinit = EXR_DEFAULT_CONTEXT_INITIALIZER; | ||
cinit.error_handler_fn = &error_handler_cb; | ||
|
||
rv = exr_start_read (&e, filename, &cinit); | ||
if (rv == 0) | ||
{ | ||
exr_print_context_info (e, verbose); | ||
exr_finish (&e); | ||
} | ||
return rv; | ||
} | ||
|
||
int | ||
main (int argc, const char* argv[]) | ||
{ | ||
int rv = 0, nfiles = 0, verbose = 0; | ||
|
||
for (int a = 1; a < argc; ++a) | ||
{ | ||
if (!strcmp (argv[a], "-h") || !strcmp (argv[a], "-?") || | ||
!strcmp (argv[a], "--help")) | ||
{ | ||
usage (argv[0]); | ||
return 0; | ||
} | ||
else if (!strcmp (argv[a], "-v") || !strcmp (argv[a], "--verbose")) | ||
{ | ||
verbose = 1; | ||
} | ||
else if (!strcmp (argv[a], "-")) | ||
{ | ||
++nfiles; | ||
rv += process_stdin (verbose); | ||
} | ||
else if (argv[a][0] == '-') | ||
{ | ||
usage (argv[0]); | ||
return 1; | ||
} | ||
else | ||
{ | ||
++nfiles; | ||
rv += process_file (argv[a], verbose); | ||
} | ||
} | ||
|
||
return rv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright Contributors to the OpenEXR Project. | ||
|
||
openexr_define_library(OpenEXRCore | ||
PRIV_EXPORT OPENEXRCORE_EXPORTS | ||
CURDIR ${CMAKE_CURRENT_SOURCE_DIR} | ||
SOURCES | ||
#NB: If you make any of these public, make sure to update the | ||
# locking macros in the relative source files | ||
internal_attr.h | ||
internal_channel_list.h | ||
internal_coding.h | ||
internal_constants.h | ||
internal_compress.h | ||
internal_decompress.h | ||
internal_file.h | ||
internal_float_vector.h | ||
internal_memory.h | ||
internal_opaque.h | ||
internal_posix_file_impl.h | ||
internal_win32_file_impl.h | ||
internal_preview.h | ||
internal_string.h | ||
internal_string_vector.h | ||
internal_structs.h | ||
internal_xdr.h | ||
|
||
internal_rle.c | ||
internal_zip.c | ||
internal_pxr24.c | ||
internal_b44.c | ||
internal_b44_table.c | ||
internal_piz.c | ||
internal_dwa.c | ||
internal_huf.c | ||
|
||
attributes.c | ||
string.c | ||
string_vector.c | ||
float_vector.c | ||
channel_list.c | ||
opaque.c | ||
preview.c | ||
|
||
base.c | ||
context.c | ||
memory.c | ||
internal_structs.c | ||
|
||
part.c | ||
part_attr.c | ||
std_attr.c | ||
|
||
parse_header.c | ||
write_header.c | ||
|
||
chunk.c | ||
coding.c | ||
decoding.c | ||
encoding.c | ||
pack.c | ||
unpack.c | ||
validation.c | ||
|
||
debug.c | ||
|
||
HEADERS | ||
openexr.h | ||
|
||
openexr_attr.h | ||
openexr_base.h | ||
openexr_chunkio.h | ||
openexr_coding.h | ||
openexr_conf.h | ||
openexr_context.h | ||
openexr_decode.h | ||
openexr_debug.h | ||
openexr_encode.h | ||
openexr_errors.h | ||
openexr_part.h | ||
openexr_std_attr.h | ||
DEPENDENCIES | ||
ZLIB::ZLIB | ||
PRIVATE_DEPS | ||
${OPENEXR_EXTRA_MATH_LIB} | ||
) | ||
|
||
# when building with an internal imath, this isn't generated until | ||
# install time, so need to use private header only include path (we | ||
# aren't linking to imath or anything c++) | ||
if (TARGET Imath::ImathConfig) | ||
target_link_libraries(OpenEXRCore PRIVATE Imath::ImathConfig) | ||
else() | ||
target_include_directories(OpenEXRCore PRIVATE ${IMATH_HEADER_ONLY_INCLUDE_DIRS}) | ||
endif() |
Oops, something went wrong.