-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from ngageoint/compressedSiddByteProvider
Compressed sidd byte provider
- Loading branch information
Showing
9 changed files
with
1,511 additions
and
16 deletions.
There are no files selected for viewing
1,117 changes: 1,117 additions & 0 deletions
1,117
six/modules/c++/samples/test_create_sidd_with_compressed_byte_provider.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
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
93 changes: 93 additions & 0 deletions
93
six/modules/c++/six.sidd/include/six/sidd/CompressedSIDDByteProvider.h
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,93 @@ | ||
/* ========================================================================= | ||
* This file is part of six.sidd-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2004 - 2018, MDA Information Systems LLC | ||
* | ||
* six.sidd-c++ 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, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef __SIX_SIDD_COMPRESSED_SIDD_BYTE_PROVIDER_H__ | ||
#define __SIX_SIDD_COMPRESSED_SIDD_BYTE_PROVIDER_H__ | ||
|
||
#include <six/CompressedByteProvider.h> | ||
#include <six/sidd/DerivedData.h> | ||
|
||
namespace six | ||
{ | ||
namespace sidd | ||
{ | ||
/*! | ||
* \class CompressedSIDDByteProvider | ||
* \brief Used to provide corresponding compressed NITF bytes (including NITF headers) | ||
* when provided with some AOI of the pixel data. The idea is that if | ||
* getBytes() is called multiple times, eventually for the entire image, the | ||
* raw bytes provided back will be the entire NITF file. This abstraction is | ||
* useful if separate threads, processes, or even machines have only portions of | ||
* the SIDD pixel data and are all trying to write out a single file; in that | ||
* scenario, this class provides all the raw bytes corresponding to the caller's | ||
* AOI, including NITF headers if necessary. The caller does not need to | ||
* understand anything about the NITF file layout in order to write out the | ||
* file. The bytes are intentionally provided back as a series of pointers | ||
* rather than one contiguous block of memory in order to not perform any | ||
* copies. A single logical SIDD image which spans multiple NITF image segments | ||
* is supported; unrelated SIDD images in one NITF are not yet supported. | ||
*/ | ||
class CompressedSIDDByteProvider : public six::CompressedByteProvider | ||
{ | ||
public: | ||
/*! | ||
* Constructor | ||
* | ||
* \param data Representation of the derived data | ||
* \param schemPaths Directories or files of schema locations | ||
* \param bytesPerBlock A vector for each image segment. Each inner vector | ||
* contains the compressed size for each block in the segment, | ||
* in bytes. | ||
* \param numRowsPerBlock The number of rows per block. Defaults to no | ||
* blocking. | ||
* \param numColsPerBlock The number of columns per block. Defaults to no | ||
* blocking. | ||
* \param maxProductSize The max number of bytes in an image segment. | ||
* By default this is set automatically for you based on NITF file rules. | ||
*/ | ||
CompressedSIDDByteProvider(const DerivedData& data, | ||
const std::vector<std::string>& schemaPaths, | ||
const std::vector<std::vector<size_t> >& bytesPerBlock, | ||
size_t numRowsPerBlock = 0, | ||
size_t numColsPerBlock = 0, | ||
size_t maxProductSize = 0); | ||
|
||
/*! | ||
* Constructor | ||
* This option allows you to pass in an initialized writer, | ||
* in case you need something specific in the header | ||
* | ||
* \param writer Initialized NITFWriteControl. Must have all desired | ||
* product size and blocking values set. | ||
* \param schemaPaths Directories or files of schema locations | ||
* \param bytesPerBlock A vector for each image segment. Each inner vector | ||
* contains the compressed size for each block in the segment, | ||
* in bytes. | ||
*/ | ||
CompressedSIDDByteProvider(const NITFWriteControl& writer, | ||
const std::vector<std::string>& schemaPaths, | ||
const std::vector<std::vector<size_t> >& bytesPerBlock); | ||
}; | ||
} | ||
} | ||
|
||
#endif |
61 changes: 61 additions & 0 deletions
61
six/modules/c++/six.sidd/source/CompressedSIDDByteProvider.cpp
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,61 @@ | ||
/* ========================================================================= | ||
* This file is part of six.sidd-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2004 - 2018, MDA Information Systems LLC | ||
* | ||
* six.sidd-c++ 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, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include <six/sidd/DerivedXMLControl.h> | ||
#include <six/sidd/CompressedSIDDByteProvider.h> | ||
|
||
namespace six | ||
{ | ||
namespace sidd | ||
{ | ||
CompressedSIDDByteProvider::CompressedSIDDByteProvider( | ||
const DerivedData& data, | ||
const std::vector<std::string>& schemaPaths, | ||
const std::vector<std::vector<size_t> >& bytesPerBlock, | ||
size_t numRowsPerBlock, | ||
size_t numColsPerBlock, | ||
size_t maxProductSize) | ||
{ | ||
XMLControlRegistry xmlRegistry; | ||
xmlRegistry.addCreator(six::DataType::DERIVED, | ||
new six::XMLControlCreatorT<DerivedXMLControl>()); | ||
|
||
mem::SharedPtr<Container> container(new Container( | ||
DataType::DERIVED)); | ||
|
||
// The container wants to take ownership of the data | ||
// To avoid memory problems, we'll just clone it | ||
container->addData(data.clone()); | ||
|
||
initialize(container, xmlRegistry, schemaPaths, bytesPerBlock, | ||
maxProductSize, numRowsPerBlock, numColsPerBlock); | ||
} | ||
|
||
CompressedSIDDByteProvider::CompressedSIDDByteProvider( | ||
const NITFWriteControl& writer, | ||
const std::vector<std::string>& schemaPaths, | ||
const std::vector<std::vector<size_t> >& bytesPerBlock) | ||
{ | ||
initialize(writer, schemaPaths, bytesPerBlock); | ||
} | ||
} | ||
} |
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,96 @@ | ||
/* ========================================================================= | ||
* This file is part of six-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2004 - 2018, MDA Information Systems LLC | ||
* | ||
* six-c++ 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, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef __SIX_COMPRESSED_BYTE_PROVIDER_H__ | ||
#define __SIX_COMPRESSED_BYTE_PROVIDER_H__ | ||
|
||
#include <nitf/CompressedByteProvider.hpp> | ||
#include <mem/SharedPtr.h> | ||
#include <six/Container.h> | ||
#include <six/NITFWriteControl.h> | ||
#include <six/NITFSegmentInfo.h> | ||
#include <six/XMLControlFactory.h> | ||
|
||
namespace six | ||
{ | ||
/*! | ||
* \class CompressedByteProvider | ||
* \brief Used to provide corresponding compressed NITF bytes | ||
* (and uncompressed NITF headers) when provided with some AOI of the pixel data. | ||
* The idea is that if getBytes() is called multiple times, eventually for the | ||
* entire image, the raw bytes provided back will be the entire NITF file. | ||
* This abstraction is useful if separate threads, processes, or even machines | ||
* have only portions of the SICD/SIDD pixel data and are all trying to write | ||
* out a single file; in that scenario, this class provides all the raw bytes | ||
* corresponding to the caller's AOI, including NITF headers if necessary. | ||
* The caller does not need to understand anything about the NITF file layout | ||
* in order to write out the file. | ||
* The bytes are intentionally provided back as a series of pointers | ||
* rather than one contiguous block of memory in order to minimize the number of | ||
* copies. | ||
*/ | ||
class CompressedByteProvider : public nitf::CompressedByteProvider | ||
{ | ||
protected: | ||
/*! | ||
* Initialize the byte provider. Must be called in the constructor of | ||
* inheriting classes. | ||
* | ||
* \param container Container initialized with all associated data | ||
* \param xmlRegistry XML registry | ||
* \param schemaPaths Directories or files of schema locations | ||
* \param bytesPerBlock A vector for each image segment. Each inner vector | ||
* contains the compressed size for each block in the segment, | ||
* in bytes. | ||
* \param maxProductSize The max number of bytes in an image segment. | ||
* \param numRowsPerBlock The number of rows per block. Only applies for | ||
* SIDD. Defaults to no blocking. | ||
* \param numColsPerBlock The number of columns per block. Only applies | ||
* for SIDD. Defaults to no blocking. | ||
*/ | ||
void initialize(mem::SharedPtr<Container> container, | ||
const XMLControlRegistry& xmlRegistry, | ||
const std::vector<std::string>& schemaPaths, | ||
const std::vector<std::vector<size_t> >& bytesPerBlock, | ||
size_t maxProductSize, | ||
size_t numRowsPerBlock = 0, | ||
size_t numColsPerBlock = 0); | ||
|
||
/*! | ||
* Initialize the byte provider. Must be called in the constructor of | ||
* inheriting classes. | ||
* | ||
* \param writer Writer. Must be initialized via | ||
* NITFWriteControl::initialize() and have all desired product size and | ||
* blocking values set. | ||
* \param schemaPaths Directories or files of schema locations | ||
* \param bytesPerBlock A vector for each image segment. Each inner vector | ||
* contains the compressed size for each block in the segment, | ||
* in bytes. | ||
*/ | ||
void initialize(const NITFWriteControl& writer, | ||
const std::vector<std::string>& schemaPaths, | ||
const std::vector<std::vector<size_t> >& bytesPerBlock); | ||
}; | ||
} | ||
|
||
#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
Oops, something went wrong.