Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avc: additional avcC box parsing #1297

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading