Skip to content

Commit

Permalink
avc: additional avcC box parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh committed Sep 3, 2024
1 parent 50b4370 commit ec2bb0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 12 additions & 3 deletions libheif/codecs/avc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ Error Box_avcC::parse(BitstreamRange &range) {
if ((m_configuration.AVCProfileIndication != 66) &&
(m_configuration.AVCProfileIndication != 77) &&
(m_configuration.AVCProfileIndication != 88)) {
// TODO: we don't support this yet
m_configuration.chroma_format = range.read8() & 0b00000011;
m_configuration.bit_depth_luma = 8 + (range.read8() & 0b00000111);
m_configuration.bit_depth_chroma = 8 + (range.read8() & 0b00000111);
uint8_t numOfSequenceParameterSetExt = range.read8();
for (int i = 0; i < numOfSequenceParameterSetExt; i++) {
uint16_t sequenceParameterSetExtLength = range.read16();
std::vector<uint8_t> sps_ext(sequenceParameterSetExtLength);
range.read(sps_ext.data(), sps_ext.size());
m_sps_ext.push_back(sps_ext);
}
}

return range.get_error();
Expand Down Expand Up @@ -279,7 +288,7 @@ int ImageItem_AVC::get_luma_bits_per_pixel() const
{
auto avcC_box = get_file()->get_property<Box_avcC>(get_id());
if (avcC_box) {
return 8; // TODO avcC_box->get_configuration().bit_depth_luma;
return avcC_box->get_configuration().bit_depth_luma;
}

return -1;
Expand All @@ -290,7 +299,7 @@ int ImageItem_AVC::get_chroma_bits_per_pixel() const
{
auto avcC_box = get_file()->get_property<Box_avcC>(get_id());
if (avcC_box) {
return 8; // TODO avcC_box->get_configuration().bit_depth_chroma;
return avcC_box->get_configuration().bit_depth_chroma;
}

return -1;
Expand Down
9 changes: 9 additions & 0 deletions libheif/codecs/avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Box_avcC : public Box {
uint8_t profile_compatibility; // constraint set flags
uint8_t AVCLevelIndication; // level_idc
uint8_t lengthSize;
uint8_t chroma_format;
uint8_t bit_depth_luma = 8;
uint8_t bit_depth_chroma = 8;
};

void set_configuration(const configuration& config)
Expand All @@ -63,6 +66,11 @@ class Box_avcC : public Box {
return m_pps;
}

const std::vector< std::vector<uint8_t> > getSequenceParameterSetExt() const
{
return m_sps_ext;
}

void get_header_nals(std::vector<uint8_t>& data) const;

std::string dump(Indent &) const override;
Expand All @@ -78,6 +86,7 @@ class Box_avcC : public Box {
configuration m_configuration;
std::vector< std::vector<uint8_t> > m_sps;
std::vector< std::vector<uint8_t> > m_pps;
std::vector< std::vector<uint8_t> > m_sps_ext;
};


Expand Down

0 comments on commit ec2bb0b

Please sign in to comment.