Skip to content

Commit

Permalink
uncompressed: (cleanup)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 3, 2024
1 parent ab2f694 commit 5ae88f6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 93 deletions.
2 changes: 0 additions & 2 deletions libheif/codecs/uncompressed/decoder_abstract.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdint>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>
#include <utility>
Expand Down
22 changes: 6 additions & 16 deletions libheif/codecs/uncompressed/decoder_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,9 @@ class AbstractDecoder
std::shared_ptr<HeifPixelImage>& img,
uint32_t out_x0, uint32_t out_y0,
uint32_t image_width, uint32_t image_height,
uint32_t tile_x, uint32_t tile_y)
{
assert(false);
return Error{heif_error_Unsupported_feature,
heif_suberror_Unsupported_image_type,
"unci tile decoding not supported for this image type"};
}
uint32_t tile_x, uint32_t tile_y) = 0;

void buildChannelList(std::shared_ptr<HeifPixelImage>& img);

protected:
AbstractDecoder(uint32_t width, uint32_t height,
Expand Down Expand Up @@ -178,10 +174,6 @@ class AbstractDecoder

std::vector<ChannelListEntry> channelList;

public:
void buildChannelList(std::shared_ptr<HeifPixelImage>& img);

protected:
void processComponentSample(UncompressedBitReader& srcBits, const ChannelListEntry& entry, uint64_t dst_row_offset, uint32_t tile_column, uint32_t tile_x);

// Handles the case where a row consists of a single component type
Expand All @@ -198,11 +190,6 @@ class AbstractDecoder
// Not valid for multi-Y pixel interleave
void processComponentTileRow(ChannelListEntry& entry, UncompressedBitReader& srcBits, uint64_t dst_offset);

private:
ChannelListEntry buildChannelListEntry(Box_uncC::Component component, std::shared_ptr<HeifPixelImage>& img);

protected:

// generic compression and uncompressed, per 23001-17
const Error get_compressed_image_data_uncompressed(const HeifContext* context, heif_item_id ID,
std::vector<uint8_t>* data,
Expand All @@ -213,6 +200,9 @@ class AbstractDecoder
const Error do_decompress_data(std::shared_ptr<const Box_cmpC>& cmpC_box,
std::vector<uint8_t> compressed_data,
std::vector<uint8_t>* data) const;

private:
ChannelListEntry buildChannelListEntry(Box_uncC::Component component, std::shared_ptr<HeifPixelImage>& img);
};

#endif
11 changes: 0 additions & 11 deletions libheif/codecs/uncompressed/decoder_component_interleave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdint>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>
#include <utility>

#include "common_utils.h"
#include "context.h"
#include "compression.h"
#include "error.h"
#include "libheif/heif.h"
#include "unc_types.h"
#include "unc_boxes.h"
#include "unc_codec.h"
#include "unc_dec.h"

#include "decoder_component_interleave.h"
Expand Down
10 changes: 0 additions & 10 deletions libheif/codecs/uncompressed/decoder_mixed_interleave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,12 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdint>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>
#include <utility>

#include "common_utils.h"
#include "context.h"
#include "compression.h"
#include "error.h"
#include "libheif/heif.h"
#include "unc_types.h"
#include "unc_boxes.h"
#include "unc_codec.h"
#include "unc_dec.h"

#include "decoder_mixed_interleave.h"
Expand Down
16 changes: 2 additions & 14 deletions libheif/codecs/uncompressed/decoder_pixel_interleave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,13 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdint>
#include <cstring>
#include "decoder_pixel_interleave.h"

#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>
#include <utility>

#include "common_utils.h"
#include "context.h"
#include "compression.h"
#include "error.h"
#include "libheif/heif.h"
#include "unc_types.h"
#include "unc_boxes.h"
#include "unc_codec.h"
#include "unc_dec.h"

#include "decoder_pixel_interleave.h"


Error PixelInterleaveDecoder::decode_tile(const HeifContext* context,
Expand Down
15 changes: 2 additions & 13 deletions libheif/codecs/uncompressed/decoder_row_interleave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,15 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdint>
#include <cstring>
#include "decoder_row_interleave.h"

#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>
#include <utility>

#include "common_utils.h"
#include "context.h"
#include "compression.h"
#include "error.h"
#include "libheif/heif.h"
#include "unc_types.h"
#include "unc_boxes.h"
#include "unc_codec.h"
#include "unc_dec.h"

#include "decoder_row_interleave.h"


Error RowInterleaveDecoder::decode_tile(const HeifContext* context,
heif_item_id image_id,
Expand Down
46 changes: 19 additions & 27 deletions libheif/codecs/uncompressed/unc_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdint>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>
#include <utility>
#include "unc_codec.h"

#include "common_utils.h"
#include "context.h"
#include "compression.h"
#include "error.h"
#include "libheif/heif.h"
#include "unc_types.h"
#include "unc_boxes.h"
#include "unc_codec.h"
#include "unc_dec.h"

#include "decoder_abstract.h"
#include "decoder_component_interleave.h"
Expand All @@ -43,6 +34,11 @@
#include "decoder_row_interleave.h"
#include "decoder_tile_component_interleave.h"

#include <algorithm>
#include <map>
#include <iostream>
#include <cassert>


bool isKnownUncompressedFrameConfigurationBoxProfile(const std::shared_ptr<const Box_uncC>& uncC)
{
Expand Down Expand Up @@ -401,23 +397,19 @@ bool map_uncompressed_component_to_channel(const std::shared_ptr<const Box_cmpd>

static AbstractDecoder* makeDecoder(uint32_t width, uint32_t height, const std::shared_ptr<Box_cmpd>& cmpd, const std::shared_ptr<Box_uncC>& uncC)
{
if (uncC->get_interleave_type() == interleave_mode_component) {
return new ComponentInterleaveDecoder(width, height, cmpd, uncC);
}
else if (uncC->get_interleave_type() == interleave_mode_pixel) {
return new PixelInterleaveDecoder(width, height, cmpd, uncC);
}
else if (uncC->get_interleave_type() == interleave_mode_mixed) {
return new MixedInterleaveDecoder(width, height, cmpd, uncC);
}
else if (uncC->get_interleave_type() == interleave_mode_row) {
return new RowInterleaveDecoder(width, height, cmpd, uncC);
}
else if (uncC->get_interleave_type() == interleave_mode_tile_component) {
return new TileComponentInterleaveDecoder(width, height, cmpd, uncC);
}
else {
return nullptr;
switch (uncC->get_interleave_type()) {
case interleave_mode_component:
return new ComponentInterleaveDecoder(width, height, cmpd, uncC);
case interleave_mode_pixel:
return new PixelInterleaveDecoder(width, height, cmpd, uncC);
case interleave_mode_mixed:
return new MixedInterleaveDecoder(width, height, cmpd, uncC);
case interleave_mode_row:
return new RowInterleaveDecoder(width, height, cmpd, uncC);
case interleave_mode_tile_component:
return new TileComponentInterleaveDecoder(width, height, cmpd, uncC);
default:
return nullptr;
}
}

Expand Down

0 comments on commit 5ae88f6

Please sign in to comment.