Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest from "nitro" and "coda-oss" #462

Merged
merged 254 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
254 commits
Select commit Hold shift + click to select a range
447f29a
Create CMakeSettings.json
Aug 11, 2020
89b7807
new/updated "docs" directory
Aug 11, 2020
f0e51d4
update externals/nitro with latest from nitro repo
Aug 11, 2020
a1d4038
use in32_t, etc. instead of nitf::Int32_t
Aug 11, 2020
aac9d2c
Merge branch 'feature/use_standard_C_types' into develop/jdsmith
Aug 11, 2020
52001ee
Merge branch 'feature/update_nitro' into develop/jdsmith
Aug 11, 2020
c36469f
Revert "Merge branch 'feature/update_nitro' into develop/jdsmith"
Aug 11, 2020
b42f93e
Revert "Merge branch 'feature/use_standard_C_types' into develop/jdsm…
Aug 11, 2020
e212252
use in32_t, etc. instead of nitf::Int32_t
Aug 11, 2020
7eb2813
update externals/nitro with latest from nitro repo
Aug 11, 2020
0a75cff
Revert "update externals/nitro with latest from nitro repo"
Aug 11, 2020
66e7669
update nitro/nrt
Aug 11, 2020
554c974
update "nitro"
Aug 11, 2020
60a45b8
nitf::Int8 -> int8_t
Aug 11, 2020
ce6044b
updates from coda-oss and nitro
Aug 31, 2020
acc353e
update externals/nitro with latest from "main"
Sep 16, 2020
b36a809
update externals/coda-oss with latest from "main"
Sep 16, 2020
e6fe2f1
Merge branch 'develop/master' into develop/main
Sep 16, 2020
cbb9b90
don't want "docs" directory in externals/nitro
Sep 16, 2020
130e3cd
fix bad merge
Sep 16, 2020
f121bad
ignore CMake-generated files
Sep 16, 2020
ce51201
std::auto_ptr -> std::unique_ptr
Sep 16, 2020
c95e858
need std::auto_ptr<> overloads for pre-generated Python wrapper code
Sep 16, 2020
914710c
provide std::auto_ptr "overloads" so that existing Python wrapper cod…
Sep 19, 2020
916f62a
impelement std::auto_ptr "overrides"
Sep 19, 2020
8cd8a70
latest from nitro:main
Sep 22, 2020
533878c
Merge pull request #349 from ngageoint/develop/main
Sep 22, 2020
d0d9f24
update externals/nitro
Oct 5, 2020
a85c00b
update coda-oss
Oct 5, 2020
75868bb
Merge pull request #354 from ngageoint/develop/main
Oct 5, 2020
4388277
Create codeql-analysis.yml
Oct 6, 2020
3f13025
Merge commit 'd216783a2d5ae168a34bc41da70c5c0004648c4a' into main
Oct 6, 2020
d13fd97
update coda-oss with latest from "main"
Oct 13, 2020
7b79bdf
Merge branch 'main' into develop/jdsmith
Oct 13, 2020
1fc1444
update nitro with latest from "main"
Oct 13, 2020
b6617ec
Merge pull request #356 from ngageoint/develop/jdsmith
Oct 13, 2020
571196e
Revert "Create codeql-analysis.yml"
Oct 13, 2020
8730781
fix nitf::Field to get rid of compiler errors
Oct 13, 2020
790ab26
build externals/coda-oss by itself
Oct 13, 2020
7e99996
Merge pull request #357 from ngageoint/develop/jdsmith
Oct 13, 2020
54b2d6f
build with Visual Studio 2019 (#358)
Oct 14, 2020
165fb1d
use c++11 (#359)
Oct 17, 2020
67ee284
get rid of hard-coded paths with <filesystem> (#360)
Oct 17, 2020
bb1dbe6
can't have "check_valid_six" as a directory for *ix build
Oct 17, 2020
e8636f4
build crop_sicd
Oct 17, 2020
52207d7
build crop_sicd in Visual Studio (#361)
Oct 17, 2020
d16b60d
Merge branch 'main' of github.com:ngageoint/six-library into main
Oct 20, 2020
495d74a
update coda-oss with latest from "main"
Oct 20, 2020
92af349
update coda-oss with latest from "main" (#362)
Oct 20, 2020
c7ff931
coda-oss updates to make TextEncoding part of the OutputStream
Oct 21, 2020
2be4824
updates from coda-oss to make TextEncoding part of the OutputStream
Oct 21, 2020
97ecde9
fix StringStream() .ctor()
Oct 21, 2020
39344b1
Merge branch 'main' into develop/update_externals
Oct 21, 2020
cdb0893
one more coda-oss update
Oct 21, 2020
fe9dfff
latest from coda-oss "main" (#364)
Oct 21, 2020
1edffff
latest from "main" on coda-oss: xml.lite updates for UTF-8
Oct 26, 2020
f996fa8
Merge branch 'main' into develop/update_externals
Oct 26, 2020
8ff2451
restore changes lost in merge
Oct 26, 2020
21a550c
update coda-oss (#365)
Oct 26, 2020
18613b5
Merge branch 'main' into develop/update_externals
Oct 26, 2020
d3423b3
latest from coda-oss
Oct 26, 2020
404dadc
another update to coda-oss (#366)
Oct 26, 2020
f71c7ed
Merge branch 'main' into develop/update_externals
Oct 26, 2020
313a601
latest from coda-oss
Oct 26, 2020
5c48090
Develop/update externals (#367)
Oct 26, 2020
f332607
latest from coda-oss
Nov 2, 2020
3a042b6
latest from coda-oss (#368)
Nov 2, 2020
70d253c
Merge branch 'main' into develop/update_externals
Nov 3, 2020
29d743f
latest from "main" on coda-oss
Nov 3, 2020
950668d
latest from coda-oss (#369)
Nov 3, 2020
f014cf4
use Filesystem.h from coda-oss instead of <filesystem>
Nov 3, 2020
90e42da
use sys::Filesystem
Nov 4, 2020
5c4bfb6
Merge branch 'develop/update_externals' into main
Nov 4, 2020
3c07e72
update "nitro" and "coda-oss" (#370)
Nov 9, 2020
f9283e8
preserve utf8 in XML text (#363)
Nov 9, 2020
ce28071
use .tar, not .tar.gz
Nov 9, 2020
79aa44f
add another unit-test (#371)
Nov 30, 2020
4538574
remove some compiler warnings (#372)
Dec 1, 2020
f1b6d22
update externals (#373)
Dec 1, 2020
b03c979
use c++11 features (#374)
Dec 2, 2020
48deaeb
latest "nitro" (#375)
Dec 5, 2020
10df67a
latest from "coda-oss" (#376)
Dec 5, 2020
d038e0e
more use of C++11 (#377)
Dec 5, 2020
ef45d66
fix build errors from recent changes (#378)
Dec 5, 2020
37f1620
NULL -> nullptr (#379)
Dec 5, 2020
e2084e8
latest from coda-oss (#381)
Dec 5, 2020
12f6f27
latest from develop/jdsmith (#382)
Dec 5, 2020
a2d5396
latest from "nitro" (#383)
Dec 5, 2020
514403d
latest from develop/jdsmith (#385)
Dec 8, 2020
f990e77
latest from "nitro" (#387)
Dec 19, 2020
6ba3ffd
latest changes from develop/jdsmith (#386)
Dec 19, 2020
f217f23
update externals (#388)
Dec 19, 2020
433e819
reduce use of toString() (#389)
Dec 22, 2020
21e2b67
latest from coda-oss (#390)
Dec 29, 2020
825a667
latest from coda-oss and nitro (#391)
Dec 30, 2020
f283be3
update coda-oss with latest from https://github.com/mdaus/coda-oss
Jan 9, 2021
ae630e6
update externals/nitro/docs
Jan 9, 2021
0b99300
latest from "nitro"
Jan 9, 2021
db45e1e
Revert "latest from "nitro""
Jan 11, 2021
e89da71
latest from nitro/master
Jan 11, 2021
3adb502
ignore build/ directory
Jan 11, 2021
89522fe
Revert "latest from nitro/master"
Jan 11, 2021
e82f28c
update externals/nitro/docs
Jan 11, 2021
8fe3028
update "c", "java", "mex", and "python" directories -- but not "c++"
Jan 11, 2021
b3c1dbd
update other nitro top-level files ... everything except modules/c++
Jan 11, 2021
a398eef
VCXPROJ files from nitro
Jan 11, 2021
7a9b240
several changes from nitro/c++ ... hoping this builds.
Jan 11, 2021
a688092
fix build error on Linux
Jan 11, 2021
84db123
more changes from nitro/modules/c++
Jan 11, 2021
7aba3b8
fix IOStreamWriter ctor
Jan 11, 2021
d9a5c2f
more changes from nitro/modules/c++
Jan 11, 2021
5e5870f
paths are wrong when in "externals"
Jan 11, 2021
7b8ca70
remove externals/nitro/docs
Jan 11, 2021
92d5bb5
Merge branch 'develop/update_externals' of github.com:ngageoint/six-l…
Jan 11, 2021
e6a58a2
slam in "main"
Jan 12, 2021
65026c2
latest from coda-oss/main
Jan 12, 2021
99a0a01
adjust coda-oss for our usage
Jan 12, 2021
4e6a752
latest from nitro/main
Jan 12, 2021
1bd0cb3
std::span removed from "nitro"
Jan 12, 2021
fa19905
need to redo C++17
Jan 12, 2021
120ee00
fix missing #include file
Jan 13, 2021
da30b96
remove "nitro" files not needed in externals/nitro
Jan 13, 2021
dd710d5
paths are wrong in "externals"
Jan 13, 2021
e69391b
Revert "remove "nitro" files not needed in externals/nitro"
Jan 13, 2021
436986f
Revert "Revert "remove "nitro" files not needed in externals/nitro""
Jan 13, 2021
ebe9550
slam in externals as merging creates too many conflicts
Jan 13, 2021
4e23991
Merge branch 'develop/update_externals' into main
Jan 13, 2021
6de2fa0
merge brought back a deleted #include
Jan 13, 2021
1073b39
add back "java" and "mex"
Jan 16, 2021
6fca258
lates from coda-oss/main
Jan 16, 2021
1083ac1
latest from "nitro"
Jan 16, 2021
e21d4fc
paths are wrong in "externals"
Jan 16, 2021
9e21803
need to redo C++17 support
Jan 16, 2021
c10f233
std::span -> gsl::span
Jan 16, 2021
f897082
Merge branch 'master' into develop/update_externals
Jan 19, 2021
fa0a138
Revert "std::span -> gsl::span"
Jan 19, 2021
b856b54
latest from coda-oss and nitro
Jan 19, 2021
70a3e72
these are the correct files from "master"
Jan 19, 2021
8242847
gsl::span -> std::span
Jan 19, 2021
0ec8633
get #includes right for PCH
Jan 19, 2021
460a96b
didn't want this change
Jan 19, 2021
671a89a
trigger build on GitHub
Jan 19, 2021
0ecff95
remove files that shouldn't have been committed
Jan 19, 2021
f99597a
Merge branch 'master' into develop/update_externals
Jan 26, 2021
4b40305
latest from coda-oss:master
Jan 27, 2021
f204751
latest from nitro::master
Jan 27, 2021
bc1744e
adjust to API changes in coda-oss/xml.lite
Jan 27, 2021
9dd7e36
Merge branch 'master' into develop/update_externals
Jan 27, 2021
6a3859f
latest from coda-oss
Jan 27, 2021
f13785c
latest from coda-oss
Jan 30, 2021
96918da
std::filesystem::path doesn't implicitly convert to std::string
Jan 30, 2021
6ba97c6
more place where an explicit std::filesystem::path::string() call is …
Jan 30, 2021
42c63d0
Merge branch 'master' into develop/update_externals
Feb 1, 2021
f616a8e
latest from "coda-oss" and "nitro"
Feb 1, 2021
805b4fd
Merge branch 'master' into develop/update_externals
Feb 2, 2021
a181f34
Merge branch 'master' into develop/update_externals
Feb 9, 2021
ee7b563
latest from coda-oss
Feb 9, 2021
92ab24a
one more change from coda-oss
Feb 9, 2021
9ef79c0
Merge branch 'master' into develop/update_externals
Feb 9, 2021
98df1ed
"nitro" changes to build with C90 instead of C99
Feb 9, 2021
c2a9909
old C++11 compilers don't like template<template>
Feb 9, 2021
00b6e23
new TREs from "nitro"
Feb 9, 2021
969cd6f
std::shared_ptr<> doesn't have [] versions, only std::unique_ptr
Feb 9, 2021
5d113a4
build with older compilers
Feb 10, 2021
67b5666
Merge branch 'master' into develop/update_externals
Feb 15, 2021
0c8be8e
latest coda-oss changes
Feb 15, 2021
e846b94
Update .gitignore from "nitro"
Feb 15, 2021
93d6814
Merge branch 'develop/update_externals' of github.com:ngageoint/six-l…
Feb 15, 2021
9bc5b4c
Merge branch 'master' into develop/update_externals
Feb 23, 2021
f64bd71
SWIG doesn't like "final"
Feb 23, 2021
6dfeb85
SWIG doesn't like "final"
Feb 23, 2021
241b4f5
Merge branch 'master' into develop/update_externals
Feb 23, 2021
af2417e
Merge branch 'master' into develop/update_externals
Mar 2, 2021
07ba711
latest from coda_oss
Mar 2, 2021
5dcd930
latest from "nitro"
Mar 2, 2021
9f26eed
Merge branch 'master' into develop/update_externals
Mar 6, 2021
cb99d69
add a version number to externals/coda-oss
Mar 6, 2021
a675370
add a version number to externals/nitro
Mar 6, 2021
25cd85e
restore "build" and "cmake"
Mar 6, 2021
2b4e00a
Gsl_.h got lost ... ?
Mar 6, 2021
f4e67de
Merge branch 'master' into develop/update_externals
Mar 6, 2021
abe6a56
update CMS to 3.0.3.3 (https://github.com/ngageoint/six-library/issue…
Mar 6, 2021
5283b31
remove version numbers (for now); we've went a very long time w/o them
Mar 8, 2021
b69e63a
finish rename
Mar 8, 2021
f84a172
version number is in too many places ...
Mar 8, 2021
9825b7d
missing .cmake files
Mar 8, 2021
2d5f38d
missing "build" files
Mar 8, 2021
a0206cf
Merge branch 'master' into develop/update_externals
Mar 8, 2021
a22422a
latest from coda-oss
Mar 16, 2021
cc369cc
Merge branch 'master' into develop/update_externals
Mar 22, 2021
4db1a4b
latest from "master" on coda-oss
Mar 22, 2021
5aa2efb
latest from "master" at nitro
Mar 22, 2021
cdb74ed
Merge branch 'master' into develop/update_externals
Mar 22, 2021
77b0b65
remove CA diagnostics from coda-oss
Mar 22, 2021
77276c1
Merge branch 'master' into develop/update_externals
Mar 22, 2021
eeba5b8
CODA_OSS_AUGMENT_std_namespace got clobbered again
Mar 24, 2021
c1f2b32
update coda-oss and nitro
Mar 24, 2021
fd1485f
be sure coda-oss "std" files are copied
Mar 24, 2021
30afeea
use new coda-oss "std" headers
Mar 24, 2021
dfff3e6
more coda-oss changes
Mar 24, 2021
b00fab7
updates from coda-oss and nitro
Mar 24, 2021
a9d7356
latest from coda-oss
Mar 24, 2021
a22f195
fix coda-oss unittest dependencies
Mar 24, 2021
3d28513
WAF dependencies for "scene"
Mar 24, 2021
899e615
sys/Filesystem.h -> std/filesystem
Mar 27, 2021
1005fb0
build using C++17 features
Mar 27, 2021
ab1348f
account for removed coda-oss overloads
Mar 27, 2021
f819681
Merge branch 'master' into develop/update_externals
Mar 27, 2021
f105c98
add back coda_oss;;filesystem::path
Mar 27, 2021
78ec6f6
Merge branch 'master' into develop/update_externals
Mar 27, 2021
1dfc034
forgot to add new "coda_oss" directory
Mar 27, 2021
0319e70
Merge branch 'master' into develop/update_externals
Mar 27, 2021
7cd31db
Merge branch 'master' into develop/update_externals
Apr 3, 2021
c773661
latest from "coda-oss" and "nitro"
Apr 5, 2021
6c8bb00
Merge branch 'master' into develop/update_externals
Apr 6, 2021
89898de
tweaks to python wrappers from coda-oss
Apr 6, 2021
582f71a
updates from coda-oss to remove compiler warnings
Apr 13, 2021
37b4a36
another update to coda-oss to get rid of code-analysis diagnostics
Apr 13, 2021
74491f1
Merge branch 'master' into develop/update_externals
Apr 14, 2021
d30e0ab
latest from coda-oss
Apr 14, 2021
e70e257
coda-oss updates to reduce compiler warnings/code-analysis diagnostics
Apr 14, 2021
445cf74
latest from coda-oss to reduce compiler warnings
Apr 14, 2021
8e15275
more code-analysis diagnostics fixes from coda-oss
Apr 17, 2021
24e1ee5
latest from coda-oss
Apr 17, 2021
09ffddb
updates from "nitro"
Apr 19, 2021
fc46c9f
lost sys/Conf.h #include
Apr 19, 2021
0b2b871
latest from coda-oss and nitro
Apr 20, 2021
733a255
latest from nitro
Apr 20, 2021
dc070a1
latest from coda-oss
Apr 26, 2021
5df9163
updates from "nitro"
Apr 26, 2021
f20557a
Merge branch 'master' into develop/update_externals
May 3, 2021
9faad06
latest from "nitro" to support nitf-c++ as a DLL/shared-library
May 3, 2021
f273b6d
build w/o errors when nitf-c++ is a DLL
May 3, 2021
5ace9f9
explicitly list SegmentMemorySource() overloads
May 3, 2021
0591d37
latest from coda-oss to get rid of more compiler warnings/code-analys…
May 4, 2021
2bb3a4e
Merge branch 'master' into develop/update_externals
May 8, 2021
a4f624b
be sure NITRO validation changes don't break SIX unittests
May 8, 2021
ef2d1fe
build NITRO @ /W4
May 11, 2021
0314b79
Merge branch 'master' into develop/update_externals
May 17, 2021
df166d5
latest from "nitro" and "coda-oss"
May 17, 2021
6a294c9
Merge branch 'master' into develop/update_externals
May 19, 2021
433aa81
reduce use of .c_str() in "nitro"
May 19, 2021
dfb69ca
changes from coda-oss to reduce code-analysis diagnostics
May 24, 2021
cc2d054
Merge branch 'master' into develop/update_externals
May 24, 2021
9c99881
Merge branch 'master' into develop/update_externals
May 24, 2021
4b89b4f
tweaks for VS2019 16.10
May 26, 2021
5a8c6a5
latest from nitro and coda-oss
May 27, 2021
10015fe
Merge branch 'master' into develop/update_externals
May 27, 2021
aef4a22
latest from coda-oss
Jun 10, 2021
f4c89c4
latest from NITRO
Jun 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
struct _Name##Exception : public _Base \
{ \
_Name##Exception() = default; virtual ~_Name##Exception() = default; \
_Name##Exception(const _Name##Exception&) = default; _Name##Exception& operator=(const _Name##Exception&) = default; \
_Name##Exception(_Name##Exception&&) = default; _Name##Exception& operator=(_Name##Exception&&) = default; \
_Name##Exception(const except::Context& c) : _Base(c){} \
_Name##Exception(const std::string& msg) : _Base(msg){} \
_Name##Exception(const except::Throwable& t, const except::Context& c) : _Base(t, c){} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Throwable
* Get the trace
* \return The trace (const)
*/
const Trace& getTrace() const
const Trace& getTrace() const noexcept
{
return mTrace;
}
Expand All @@ -118,7 +118,7 @@ class Throwable
* Get the trace
* \return The trace (non-const)
*/
Trace& getTrace()
Trace& getTrace() noexcept
{
return mTrace;
}
Expand All @@ -143,7 +143,7 @@ class Throwable
return s.str();
}

const std::vector<std::string>& getBacktrace() const
const std::vector<std::string>& getBacktrace() const noexcept
{
return mBacktrace;
}
Expand Down
8 changes: 4 additions & 4 deletions externals/coda-oss/modules/c++/except/include/except/Trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ struct Trace final
/*!
* Pops Context off the stack
*/
void popContext()
void popContext() noexcept
{
mStack.pop_front();
}

/*!
* Gets first Context on stack
*/
const Context& getContext() const
const Context& getContext() const noexcept
{
return mStack.front();
}
Expand All @@ -80,7 +80,7 @@ struct Trace final
* Get the stack
* \return The stack (const)
*/
const std::list<Context>& getStack() const
const std::list<Context>& getStack() const noexcept
{
return mStack;
}
Expand All @@ -89,7 +89,7 @@ struct Trace final
* Get the stack
* \return The stack (non-const)
*/
std::list<Context>& getStack()
std::list<Context>& getStack() noexcept
{
return mStack;
}
Expand Down
27 changes: 23 additions & 4 deletions externals/nitro/modules/c++/nitf/include/nitf/ImageReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
#pragma once

#include <assert.h>
#include <stdio.h>

#include <vector>
#include <string>
#include <memory>

#include <std/span>
#include <std/cstddef> // std::byte

#include "nitf/coda-oss.hpp"
#include "nitf/ImageReader.h"
Expand All @@ -49,7 +50,7 @@ namespace nitf
class BufferList /*final*/ // no "final", SWIG doesn't like it
{
std::vector<T*> buffer;
std::vector<std::unique_ptr<T[]>> buffer_;
std::vector<std::vector<T>> buffer_;

public:
BufferList(size_t nBands)
Expand All @@ -61,8 +62,8 @@ namespace nitf
{
for (size_t i = 0; i < size(); i++)
{
buffer_[i].reset(new T[subWindowSize]);
buffer[i] = buffer_[i].get();
buffer_[i].resize(subWindowSize);
buffer[i] = buffer_[i].data();
}
}

Expand All @@ -81,7 +82,24 @@ namespace nitf
{
return buffer[i];
}

int padded = 0;

using iterator = typename std::vector<std::vector<T>>::iterator;
iterator begin() { return buffer_.begin(); }
iterator end() { return buffer_.end(); }

using const_iterator = typename std::vector<std::vector<T>>::const_iterator;
const_iterator begin() const { return buffer_.begin(); }
const_iterator end() const { return buffer_.end(); }
const_iterator cbegin() const { return buffer_.cbegin(); }
const_iterator cend() const { return buffer_.cend(); }
};
template<typename T>
inline size_t write(FILE* f, const std::vector<T>& buffer)
{
return fwrite(buffer.data(), sizeof(T), buffer.size() / sizeof(T), f);
}

/*!
* \class ImageReader
Expand Down Expand Up @@ -121,6 +139,7 @@ DECLARE_CLASS(ImageReader)
void* user_ = user;
read(subWindow, static_cast<uint8_t**>(user_), padded);
}
BufferList<std::byte> read(const nitf::SubWindow& subWindow, size_t nbpp);

/*!
* Read a block directly from file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ DECLARE_CLASS(ImageSubheader)

//! Get the actualBitsPerPixel
nitf::Field getActualBitsPerPixel() const;
size_t actualBitsPerPixel() const
{
return getActualBitsPerPixel();
}

//! Get the pixelJustification
nitf::Field getPixelJustification() const;
Expand Down
9 changes: 7 additions & 2 deletions externals/nitro/modules/c++/nitf/include/nitf/SubWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <string>
#include <vector>

#include <std/optional>

#include "nitf/SubWindow.h"
#include "nitf/DownSampler.hpp"
#include "nitf/Object.hpp"
Expand Down Expand Up @@ -87,9 +89,9 @@ DECLARE_CLASS(SubWindow)
void setStartCol(uint32_t value);
void setNumCols(uint32_t value);
void setBandList(uint32_t * value);
void setBandList(std::vector<uint32_t>&&);
void setNumBands(uint32_t value);


/*!
* Reference a DownSampler within the SubWindow
* The SubWindow does NOT own the DownSampler
Expand All @@ -103,13 +105,16 @@ DECLARE_CLASS(SubWindow)

/*!
* Return the DownSampler that is referenced by this SubWindow.
* If no DownSampler is referenced, a NITFException is thrown.
*/
nitf::DownSampler* getDownSampler() noexcept;
const nitf::DownSampler* getDownSampler() const noexcept;

private:
nitf::DownSampler* mDownSampler = nullptr;
nitf_Error error{};

void updateBandList();
std::optional<std::vector<uint32_t>> bandList;
};

#if CODA_OSS_cpp14
Expand Down
26 changes: 26 additions & 0 deletions externals/nitro/modules/c++/nitf/source/ImageReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#include "nitf/ImageReader.hpp"

#undef min
#undef max

using namespace nitf;

ImageReader::ImageReader(const ImageReader & x)
Expand Down Expand Up @@ -76,6 +79,29 @@ void ImageReader::setReadCaching()
nitf_ImageReader_setReadCaching(getNativeOrThrow());
}

BufferList<std::byte> ImageReader::read(const nitf::SubWindow& window, size_t nbpp)
{
// see py_ImageReader_read() and doRead() in test_buffered_read.cpp

const auto numBitsPerPixel = nbpp;
const size_t numBytesPerPixel = NITF_NBPP_TO_BYTES(numBitsPerPixel);
const auto numBytesPerBand = static_cast<size_t>(window.getNumRows()) * static_cast<size_t>(window.getNumCols()) * numBytesPerPixel;

auto downsampler = window.getDownSampler();
const uint32_t rowSkip = downsampler ? downsampler->getRowSkip() : 1;
const uint32_t colSkip = downsampler ? downsampler->getColSkip() : 1;

auto imageDeblocker = getNativeOrThrow()->imageDeblocker;
const auto subimageSize = static_cast<size_t>(window.getNumRows() / rowSkip) *
(window.getNumCols() / colSkip) * nitf_ImageIO_pixelSize(imageDeblocker);

BufferList<std::byte> retval(window.getNumBands());
retval.initialize(subimageSize);
read(window, retval.data(), &retval.padded);

return std::move(retval);
}

extern "C" {
NITF_BOOL nitf_ImageIO_getMaskInfo(nitf_ImageIO* nitf,
uint32_t* imageDataOffset, uint32_t* blockRecordLength,
Expand Down
25 changes: 25 additions & 0 deletions externals/nitro/modules/c++/nitf/source/SubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,25 @@ SubWindow::SubWindow(const SubWindow & x)
*this = x;
}

void SubWindow::updateBandList()
{
assert(bandList.has_value());
setBandList(bandList->data());
setNumBands(gsl::narrow<uint32_t>(bandList->size()));
}

SubWindow & SubWindow::operator=(const SubWindow & x)
{
if (&x != this)
{
setNative(x.getNative());

bandList = x.bandList;
if (bandList.has_value())
{
updateBandList();
}
}
return *this;
}

Expand Down Expand Up @@ -109,6 +124,12 @@ void SubWindow::setBandList(uint32_t * value)
{
getNativeOrThrow()->bandList = value;
}
void SubWindow::setBandList(std::vector<uint32_t>&& value)
{
bandList = std::move(value);
updateBandList();
}


uint32_t SubWindow::getNumBands() const
{
Expand Down Expand Up @@ -143,3 +164,7 @@ nitf::DownSampler* SubWindow::getDownSampler() noexcept
{
return mDownSampler;
}
const nitf::DownSampler* SubWindow::getDownSampler() const noexcept
{
return mDownSampler;
}
117 changes: 117 additions & 0 deletions externals/nitro/modules/c++/nitf/tests/test_extract.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* =========================================================================
* This file is part of NITRO
* =========================================================================
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* NITRO is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, If not,
* see <http://www.gnu.org/licenses/>.
*
*/

// modeled after nitf_extract.py

#include <stdio.h>

#include <string>
#include <vector>
#include <numeric> // std::iota

#include <import/str.h>
#include <import/sys.h>

#include <import/nitf.hpp>

template<typename T>
inline std::vector<T> iota(size_t count, T value)
{
std::vector<T> retval(count);
std::iota(retval.begin(), retval.end(), value);
return retval;
}

static std::vector<std::string> extract_image(const nitf::ImageSubheader& subheader, uint32_t index, nitf::ImageReader& imageReader,
const std::string& outDir="", const std::string& baseName="")
{
nitf::SubWindow window;
window.setNumRows(subheader.numRows());
window.setNumCols(subheader.numCols());
window.setBandList(iota(subheader.getBandCount(), static_cast<uint32_t>(0))); // window.bandList = list(range(subheader.getBandCount()))
const auto nbpp = subheader.actualBitsPerPixel(); //const auto nbpp = subheader.numBitsPerPixel();
const auto bandData = imageReader.read(window, nbpp);

std::vector<std::string> outNames;
size_t band = 0;
for (const auto& data : bandData) // for band, data in enumerate(bandData):
{
auto outName = str::format("%s_%d__%d_x_%d_%d_band_%d.out",
baseName.c_str(), index, window.getNumRows(), window.getNumCols(), static_cast<int>(nbpp), static_cast<int>(band));
outName = sys::Path::joinPaths(outDir, outName);
auto f = fopen(outName.c_str(), "wb"); // f = open(outName, "wb");
nitf::write(f, data); // fwrite(data.data(), sizeof(data[0]), data.size() / sizeof(data[0]), f);
fclose(f); // f.close();
outNames.push_back(outName);
band++;
}

return outNames;
}

static void extract_images(const std::string& fileName, const std::string& outDir = "")
{
nitf::IOHandle handle(fileName);
nitf::Reader reader;
nitf::Record record = reader.read(handle);

uint32_t i = 0;
for (nitf::ImageSegment segment : record.getImages())
{
auto imReader = reader.newImageReader(i);
extract_image(segment.getSubheader(), i, imReader, outDir, sys::Path::basename(fileName));

i++;
}

handle.close();
}

int main(int argc, char **argv)
{
try
{
// Check argv and make sure we are happy
if (argc != 3)
{
std::cout << "Usage: %s <input-file> <output-file> \n" << argv[0]
<< std::endl;
exit( EXIT_FAILURE);
}

// Check that wew have a valid NITF
if (nitf::Reader::getNITFVersion(argv[1]) == nitf::Version::NITF_VER_UNKNOWN)
{
std::cout << "Invalid NITF: " << argv[1] << std::endl;
exit( EXIT_FAILURE);
}

extract_images(argv[1]);
return 0;
}
catch (const std::exception& ex)
{
std::cerr << "ERROR!: " << ex.what() << "\n";
return 1;
}
}