Skip to content

Commit

Permalink
latest from "nitro"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Apr 18, 2022
1 parent 543bf38 commit 5296635
Show file tree
Hide file tree
Showing 128 changed files with 4,715 additions and 931 deletions.
6 changes: 6 additions & 0 deletions externals/nitro/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# NITRO (NITF i/o) Release Notes

## WIP: [Version 2.?.?](https://github.com/mdaus/nitro/releases/tag/NITRO-2.?.?); ??? ??, 2022
* the large unused **archive** directory has been removed; contents are in [archive/java](https://github.com/mdaus/nitro/tree/archive/java)
and [archive/mex](https://github.com/mdaus/nitro/tree/archive/mex).
* the large unused **docs** directory has been removed; contents are in [archive/docs](https://github.com/mdaus/nitro/tree/archive/docs).
* Copy the J2K wrappers from **coda**.

## [Version 2.10.8](https://github.com/mdaus/nitro/releases/tag/NITRO-2.10.8); February 22, 2022 (aka 2/22/22)
* [coda-oss](https://github.com/mdaus/coda-oss) release [2022-02-22](https://github.com/mdaus/coda-oss/releases/tag/2022-02-22)
* Show how to use [strongly typed TREs](https://github.com/mdaus/nitro/tree/feature/strongly-typed-TREs).
Expand Down
3 changes: 3 additions & 0 deletions externals/nitro/modules/c++/cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <time.h>
#include <stdint.h>
#include <stddef.h>
#include <inttypes.h>

#include <string>
#include <numeric>
Expand All @@ -35,9 +36,11 @@
#include <sstream>
#include <ostream>
#include <iostream>
#include <fstream>
#include <ios>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <utility>
#include <functional>
Expand Down
17 changes: 14 additions & 3 deletions externals/nitro/modules/c++/nitf-c++.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@
<ClCompile Include="nitf\source\IOStreamReader.cpp" />
<ClCompile Include="nitf\source\IOStreamWriter.cpp" />
<ClCompile Include="nitf\source\J2KComponent.cpp" />
<ClCompile Include="nitf\source\J2KCompressionParameters.cpp" />
<ClCompile Include="nitf\source\J2KCompressor.cpp" />
<ClCompile Include="nitf\source\J2KContainer.cpp" />
<ClCompile Include="nitf\source\J2KEncoder.cpp" />
<ClCompile Include="nitf\source\J2KImage.cpp" />
<ClCompile Include="nitf\source\J2KReader.cpp" />
<ClCompile Include="nitf\source\J2KStream.cpp" />
<ClCompile Include="nitf\source\J2KWriter.cpp" />
<ClCompile Include="nitf\source\LabelSegment.cpp" />
<ClCompile Include="nitf\source\LabelSubheader.cpp" />
Expand All @@ -71,6 +76,7 @@
<ClCompile Include="nitf\source\TextSegment.cpp" />
<ClCompile Include="nitf\source\TextSubheader.cpp" />
<ClCompile Include="nitf\source\TRE.cpp" />
<ClCompile Include="nitf\source\UnitTests.cpp" />
<ClCompile Include="nitf\source\Utils.cpp" />
<ClCompile Include="nitf\source\WriteHandler.cpp" />
<ClCompile Include="nitf\source\Writer.cpp" />
Expand Down Expand Up @@ -123,8 +129,13 @@
<ClInclude Include="nitf\include\nitf\IOStreamReader.hpp" />
<ClInclude Include="nitf\include\nitf\IOStreamWriter.hpp" />
<ClInclude Include="nitf\include\nitf\J2KComponent.hpp" />
<ClInclude Include="nitf\include\nitf\J2KCompressionParameters.hpp" />
<ClInclude Include="nitf\include\nitf\J2KCompressor.hpp" />
<ClInclude Include="nitf\include\nitf\J2KContainer.hpp" />
<ClInclude Include="nitf\include\nitf\J2KEncoder.hpp" />
<ClInclude Include="nitf\include\nitf\J2KImage.hpp" />
<ClInclude Include="nitf\include\nitf\J2KReader.hpp" />
<ClInclude Include="nitf\include\nitf\J2KStream.hpp" />
<ClInclude Include="nitf\include\nitf\J2KWriter.hpp" />
<ClInclude Include="nitf\include\nitf\LabelSegment.hpp" />
<ClInclude Include="nitf\include\nitf\LabelSubheader.hpp" />
Expand All @@ -151,6 +162,7 @@
<ClInclude Include="nitf\include\nitf\TextSubheader.hpp" />
<ClInclude Include="nitf\include\nitf\TRE.hpp" />
<ClInclude Include="nitf\include\nitf\TREField.hpp" />
<ClInclude Include="nitf\include\nitf\UnitTests.hpp" />
<ClInclude Include="nitf\include\nitf\Utils.hpp" />
<ClInclude Include="nitf\include\nitf\Version.hpp" />
<ClInclude Include="nitf\include\nitf\WriteHandler.hpp" />
Expand Down Expand Up @@ -215,12 +227,12 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<EnablePREfast>true</EnablePREfast>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
<TreatWarningAsError>true</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<SupportJustMyCode>true</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>
Expand All @@ -246,7 +258,6 @@
<ControlFlowGuard>Guard</ControlFlowGuard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
Expand Down
36 changes: 36 additions & 0 deletions externals/nitro/modules/c++/nitf-c++.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,24 @@
<ClCompile Include="nitf\source\J2KWriter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nitf\source\J2KCompressionParameters.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nitf\source\J2KStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nitf\source\J2KImage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nitf\source\J2KEncoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nitf\source\J2KCompressor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nitf\source\UnitTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand Down Expand Up @@ -428,5 +446,23 @@
<ClInclude Include="nitf\include\nitf\J2KWriter.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nitf\include\nitf\J2KCompressionParameters.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nitf\include\nitf\J2KStream.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nitf\include\nitf\J2KImage.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nitf\include\nitf\J2KEncoder.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nitf\include\nitf\J2KCompressor.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nitf\include\nitf\UnitTests.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
15 changes: 13 additions & 2 deletions externals/nitro/modules/c++/nitf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(MODULE_NAME nitf)
set(MODULE_DEPS nitf-c j2k-c except-c++ io-c++ mt-c++ sys-c++ str-c++ gsl-c++ std-c++)
set(MODULE_DEPS nitf-c j2k-c except-c++ sio.lite-c++ io-c++ mt-c++ sys-c++ str-c++ gsl-c++ std-c++)
if (MSVC)
list(APPEND MODULE_DEPS wsock32 ws2_32)
endif()
Expand Down Expand Up @@ -47,8 +47,13 @@ coda_add_module(
source/ImageSubheader.cpp
source/ImageWriter.cpp
source/J2KComponent.cpp
source/J2KCompressionParameters.cpp
source/J2KCompressor.cpp
source/J2KContainer.cpp
source/J2KEncoder.cpp
source/J2KImage.cpp
source/J2KReader.cpp
source/J2KStream.cpp
source/J2KWriter.cpp
source/LabelSegment.cpp
source/LabelSubheader.cpp
Expand All @@ -69,6 +74,7 @@ coda_add_module(
source/TestingTest.cpp
source/TextSegment.cpp
source/TextSubheader.cpp
source/UnitTests.cpp
source/Utils.cpp
source/WriteHandler.cpp
source/Writer.cpp
Expand Down Expand Up @@ -97,10 +103,15 @@ coda_add_tests(
test_image_blocker.cpp
test_image_segment_blank_nm_compression.cpp
test_image_segment_computer.cpp
test_image_writer.cpp
test_nitf_buffer_list.cpp
test_tre_mods++.cpp
test_tre_create++.cpp
test_j2k_read_tile.cpp)
test_j2k_loading++.cpp
test_j2k_read_tile.cpp
test_j2k_compress_tile.cpp
test_j2k_compressed_byte_provider.cpp
test_tre_read.cpp)

add_executable(show_nitf++ apps/show_nitf++.cpp)
target_link_libraries(show_nitf++ PRIVATE nitf-c++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<ControlFlowGuard>Guard</ControlFlowGuard>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
<TreatWarningAsError>true</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<SupportJustMyCode>true</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -83,7 +83,6 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
Expand Down
1 change: 1 addition & 0 deletions externals/nitro/modules/c++/nitf/include/nitf/BandInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ DECLARE_CLASS(BandInfo)
};

explicit BandInfo(Subcategory);
BandInfo(Representation, Subcategory, const std::string & imageFilterCondition, const std::string & imageFilterCode);

//! Get the subcategory
nitf::Field getSubcategory() const;
Expand Down
8 changes: 2 additions & 6 deletions externals/nitro/modules/c++/nitf/include/nitf/BandSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef DataSource BandSource;
* times during the case of memory mapping, although it may be used
* to sample down or cut the image into pieces).
*/
struct NITRO_NITFCPP_API MemorySource : public BandSource
struct NITRO_NITFCPP_API MemorySource final : public BandSource
{
/*!
* Constructor
Expand All @@ -74,10 +74,6 @@ struct NITRO_NITFCPP_API MemorySource : public BandSource

MemorySource(std::span<const std::byte> span, nitf::Off start, int numBytesPerPixel, int pixelSkip)
: MemorySource(span.data(), span.size(), start, numBytesPerPixel, pixelSkip) {}

template<typename TSpanLike>
MemorySource(const TSpanLike& span, nitf::Off start, int pixelSkip)
: MemorySource(span.data(), span.size() * sizeof(span[0]), start, sizeof(span[0]), pixelSkip) {}
};

/*!
Expand All @@ -90,7 +86,7 @@ struct NITRO_NITFCPP_API MemorySource : public BandSource
* we allow the creator to specify a start point, and a pixel skip
* (this would help you create a thumbnail as well).
*/
struct NITRO_NITFCPP_API FileSource : public BandSource
struct NITRO_NITFCPP_API FileSource final : public BandSource
{
FileSource(const std::string& fname,
nitf::Off start,
Expand Down
37 changes: 33 additions & 4 deletions externals/nitro/modules/c++/nitf/include/nitf/ByteProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __NITF_BYTE_PROVIDER_HPP__
#define __NITF_BYTE_PROVIDER_HPP__
#ifndef NITF_ByteProvider_hpp_INCLUDED_
#define NITF_ByteProvider_hpp_INCLUDED_
#pragma once

#include <vector>
#include <utility>
#include <memory>
#include <std/span>
#include <std/cstddef>

#include <nitf/coda-oss.hpp>
#include <nitf/System.hpp>
Expand Down Expand Up @@ -97,6 +99,7 @@ namespace nitf
struct NITRO_NITFCPP_API ByteProvider
{
typedef std::pair<const void*, size_t> PtrAndLength;
using PtrAndLength_t = std::span<const std::byte>;

/*!
* \param record Pre-populated NITF record. All TREs, image subheader, and
Expand All @@ -113,12 +116,16 @@ struct NITRO_NITFCPP_API ByteProvider
std::vector<PtrAndLength>(),
size_t numRowsPerBlock = 0,
size_t numColsPerBlock = 0);
ByteProvider(Record& record,
const std::vector<PtrAndLength_t>& desData,
size_t numRowsPerBlock = 0,
size_t numColsPerBlock = 0);

/*!
* Destructor. No virtual methods but this is virtual in case it's useful
* to inherit from this class and use it polymorphically.
*/
virtual ~ByteProvider();
virtual ~ByteProvider() = default;

//! \return The total number of bytes in the NITF
nitf::Off getFileNumBytes() const noexcept
Expand Down Expand Up @@ -261,6 +268,9 @@ struct NITRO_NITFCPP_API ByteProvider
std::vector<PtrAndLength>(),
size_t numRowsPerBlock = 0,
size_t numColsPerBlock = 0);
void initialize(const Record& record,
const std::vector<PtrAndLength_t>& desData,
size_t numRowsPerBlock = 0, size_t numColsPerBlock = 0);

static void copyFromStreamAndClear(io::ByteStream& stream,
std::vector<sys::byte>& rawBytes);
Expand Down Expand Up @@ -302,6 +312,8 @@ struct NITRO_NITFCPP_API ByteProvider

void getFileLayout(const nitf::Record& inRecord,
const std::vector<PtrAndLength>& desData);
void getFileLayout(const nitf::Record & inRecord,
const std::vector<PtrAndLength_t>&desData);

std::vector<size_t> mImageDataLengths;

Expand All @@ -314,6 +326,11 @@ struct NITRO_NITFCPP_API ByteProvider
const std::vector<PtrAndLength>& desData,
size_t numRowsPerBlock,
size_t numColsPerBlock);
void initializeImpl(
const Record & record,
const std::vector<PtrAndLength_t>&desData,
size_t numRowsPerBlock,
size_t numColsPerBlock);

// Represents the row information for a NITF image segment
struct SegmentInfo
Expand Down Expand Up @@ -358,7 +375,19 @@ struct NITRO_NITFCPP_API ByteProvider
std::vector<nitf::Off> mImageSubheaderFileOffsets; // Per segment
nitf::Off mDesSubheaderFileOffset = 0;
nitf::Off mFileNumBytes = 0;

private:
template<typename TPtrAndLength>
void getFileLayout_(const nitf::Record& inRecord,
const std::vector<TPtrAndLength>& desData);

template<typename TPtrAndLength>
void initializeImpl_(
const Record& record,
const std::vector<TPtrAndLength>& desData,
size_t numRowsPerBlock,
size_t numColsPerBlock);
};
}

#endif
#endif // NITF_ByteProvider_hpp_INCLUDED_
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ struct NITRO_NITFCPP_API CompressedByteProvider : public ByteProvider
std::vector<PtrAndLength>(),
size_t numRowsPerBlock = 0,
size_t numColsPerBlock = 0);
CompressedByteProvider(Record& record,
const std::vector<std::vector<size_t> >& bytesPerBlock,
const std::vector<PtrAndLength_t>& desData,
size_t numRowsPerBlock = 0, size_t numColsPerBlock = 0);

/*!
* Given a range of rows from [startRow, startRow + numRows), provide the
Expand Down Expand Up @@ -163,6 +167,10 @@ struct NITRO_NITFCPP_API CompressedByteProvider : public ByteProvider
std::vector<PtrAndLength>(),
size_t numRowsPerBlock = 0,
size_t numColsPerBlock = 0);
void initialize(const Record & record,
const std::vector<std::vector<size_t> >&bytesPerBlock,
const std::vector<PtrAndLength_t>&desData,
size_t numRowsPerBlock = 0, size_t numColsPerBlock = 0);

size_t countBytesForCompressedImageData(
size_t seg, size_t startRow, size_t numRowsToWrite) const;
Expand All @@ -187,6 +195,11 @@ struct NITRO_NITFCPP_API CompressedByteProvider : public ByteProvider
size_t numRowsToWrite) const;

private:
template<typename TPtrAndLength>
void initialize_(const Record & record,
const std::vector<std::vector<size_t> >&bytesPerBlock,
const std::vector<TPtrAndLength>&desData,
size_t numRowsPerBlock = 0, size_t numColsPerBlock = 0);
std::vector<std::vector<size_t> > mBytesInEachBlock;
};
}
Expand Down
Loading

0 comments on commit 5296635

Please sign in to comment.