Skip to content

Commit

Permalink
uncompressed: refactor and extend uncompressed decode
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh committed Dec 25, 2023
1 parent a37785a commit 52119a3
Show file tree
Hide file tree
Showing 106 changed files with 4,869 additions and 353 deletions.
2 changes: 1 addition & 1 deletion libheif/uncompressed.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ enum heif_uncompressed_sampling_mode
/**
* Maximum valid sampling mode identifier.
*/
sampling_type_max_valid = sampling_mode_411
sampling_mode_max_valid = sampling_mode_411
};


Expand Down
32 changes: 24 additions & 8 deletions libheif/uncompressed_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include "uncompressed_box.h"


/**
* Check for valid component format.
*
* @param format the format value to check
* @return true if the format is a valid value, or false otherwise
*/
bool is_valid_component_format(uint8_t format)
{
return format <= component_format_max_valid;
Expand All @@ -43,9 +49,15 @@ static std::map<heif_uncompressed_component_format, const char*> sNames_uncompre
};


bool is_valid_interleave_mode(uint8_t sampling)
/**
* Check for valid interleave mode.
*
* @param interleave the interleave value to check
* @return true if the interleave mode is valid, or false otherwise
*/
bool is_valid_interleave_mode(uint8_t interleave)
{
return sampling <= interleave_mode_max_valid;
return interleave <= interleave_mode_max_valid;
}

static std::map<heif_uncompressed_interleave_mode, const char*> sNames_uncompressed_interleave_mode{
Expand All @@ -58,9 +70,15 @@ static std::map<heif_uncompressed_interleave_mode, const char*> sNames_uncompres
};


/**
* Check for valid sampling mode.
*
* @param sampling the sampling value to check
* @return true if the sampling mode is valid, or false otherwise
*/
bool is_valid_sampling_mode(uint8_t sampling)
{
return sampling <= sampling_type_max_valid;
return sampling <= sampling_mode_max_valid;
}

static std::map<heif_uncompressed_sampling_mode, const char*> sNames_uncompressed_sampling_mode{
Expand Down Expand Up @@ -180,6 +198,9 @@ Error Box_uncC::parse(BitstreamRange& range)
{
parse_full_box_header(range);
m_profile = range.read32();
if (get_version() != 0) {
return Error{heif_error_Invalid_input, heif_suberror_Unsupported_data_version, "Unsupported version (only 0 is currently supported)"};
}

unsigned int component_count = range.read32();

Expand Down Expand Up @@ -272,11 +293,6 @@ std::string Box_uncC::dump(Indent& indent) const
return sstr.str();
}

bool Box_uncC::get_headers(std::vector<uint8_t>* dest) const
{
// TODO: component_bit_depth?
return true;
}

Error Box_uncC::write(StreamWriter& writer) const
{
Expand Down
23 changes: 19 additions & 4 deletions libheif/uncompressed_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "box.h"
#include "bitstream.h"
#include "libheif/uncompressed.h"

#include <cstdint>
#include <string>
Expand Down Expand Up @@ -69,19 +70,33 @@ class Box_cmpd : public Box
std::vector<Component> m_components;
};

/**
* Uncompressed Frame Configuration Box
*/
class Box_uncC : public FullBox
{
public:
Box_uncC()
Box_uncC() :
m_profile(0),
m_sampling_type(sampling_mode_no_subsampling),
m_interleave_type(interleave_mode_component),
m_block_size(0),
m_components_little_endian(false),
m_block_pad_lsb(false),
m_block_little_endian(false),
m_block_reversed(false),
m_pad_unknown(false),
m_pixel_size(0),
m_row_align_size(0),
m_tile_align_size(0),
m_num_tile_cols(1),
m_num_tile_rows(1)
{
m_profile = 0;
set_short_type(fourcc("uncC"));
}

std::string dump(Indent&) const override;

bool get_headers(std::vector<uint8_t>* dest) const;

Error write(StreamWriter& writer) const override;

struct Component
Expand Down
Loading

0 comments on commit 52119a3

Please sign in to comment.