Commit 31cc4b54 for libheif
commit 31cc4b5498e7694a382afe57271e04edd6fadefe
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Thu Dec 18 17:36:08 2025 +0100
[BSD3] support for short avcC boxes
diff --git a/libheif/codecs/avc_boxes.cc b/libheif/codecs/avc_boxes.cc
index 2dc5155e..ddd945f2 100644
--- a/libheif/codecs/avc_boxes.cc
+++ b/libheif/codecs/avc_boxes.cc
@@ -58,18 +58,20 @@ Error Box_avcC::parse(BitstreamRange& range, const heif_security_limits* limits)
}
// See ISO/IEC 14496-15 2017 Section 5.3.3.1.2
- if ((m_configuration.AVCProfileIndication != 66) &&
- (m_configuration.AVCProfileIndication != 77) &&
- (m_configuration.AVCProfileIndication != 88)) {
- m_configuration.chroma_format = (heif_chroma) (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);
+ if (range.get_remaining_bytes() > 0) {
+ if ((m_configuration.AVCProfileIndication != 66) &&
+ (m_configuration.AVCProfileIndication != 77) &&
+ (m_configuration.AVCProfileIndication != 88)) {
+ m_configuration.chroma_format = (heif_chroma) (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);
+ }
}
}