diff --git a/libheif/codecs/avc.cc b/libheif/codecs/avc.cc index 18218e979e..82cdcc8afb 100644 --- a/libheif/codecs/avc.cc +++ b/libheif/codecs/avc.cc @@ -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 sps_ext(sequenceParameterSetExtLength); + range.read(sps_ext.data(), sps_ext.size()); + m_sps_ext.push_back(sps_ext); + } } return range.get_error(); @@ -279,7 +288,7 @@ int ImageItem_AVC::get_luma_bits_per_pixel() const { auto avcC_box = get_file()->get_property(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; @@ -290,7 +299,7 @@ int ImageItem_AVC::get_chroma_bits_per_pixel() const { auto avcC_box = get_file()->get_property(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; diff --git a/libheif/codecs/avc.h b/libheif/codecs/avc.h index 0233e7efe6..59e2fb6369 100644 --- a/libheif/codecs/avc.h +++ b/libheif/codecs/avc.h @@ -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) @@ -63,6 +66,11 @@ class Box_avcC : public Box { return m_pps; } + const std::vector< std::vector > getSequenceParameterSetExt() const + { + return m_sps_ext; + } + void get_header_nals(std::vector& data) const; std::string dump(Indent &) const override; @@ -78,6 +86,7 @@ class Box_avcC : public Box { configuration m_configuration; std::vector< std::vector > m_sps; std::vector< std::vector > m_pps; + std::vector< std::vector > m_sps_ext; };