"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "srcs/common/hevcdecoderconfigrecord.cpp" between
heif-3.6.0.tar.gz and heif-3.6.1.tar.gz

About: HEIF (High Efficiency Image File Format) is a visual media container format for images and image sequences (MPEG-standard). This HEIF engine demonstrates its powerful features and capabilities (under Nokia HEIF license).

hevcdecoderconfigrecord.cpp  (heif-3.6.0):hevcdecoderconfigrecord.cpp  (heif-3.6.1)
skipping to change at line 47 skipping to change at line 47
, mBitDepthChromaMinus8(0) , mBitDepthChromaMinus8(0)
, mAvgFrameRate(0) , mAvgFrameRate(0)
, mConstantFrameRate(0) , mConstantFrameRate(0)
, mNumTemporalLayers(0) , mNumTemporalLayers(0)
, mTemporalIdNested(0) , mTemporalIdNested(0)
, mLengthSizeMinus1(0) , mLengthSizeMinus1(0)
, mNalArray() , mNalArray()
{ {
} }
void HevcDecoderConfigurationRecord::makeConfigFromSPS(const Vector<uint8_t> &sr cSps) bool HevcDecoderConfigurationRecord::makeConfigFromSPS(const Vector<uint8_t>& sr cSps)
{ {
unsigned int maxNumSubLayersMinus1; unsigned int maxNumSubLayersMinus1;
Vector<bool> subLayerProfilePresentFlag(8, false); Vector<bool> subLayerProfilePresentFlag(8, false);
Vector<bool> subLayerLevelPresentFlag(8, false); Vector<bool> subLayerLevelPresentFlag(8, false);
Vector<uint8_t> sps = convertByteStreamToRBSP(srcSps); Vector<uint8_t> sps;
if (convertByteStreamToRBSP(srcSps, sps) == false)
{
return false;
}
mAvgFrameRate = 0; // Unspecified average frame rate. mAvgFrameRate = 0; // Unspecified average frame rate.
mConstantFrameRate = 0; mConstantFrameRate = 0;
mLengthSizeMinus1 = 3; // NAL length fields are 4 bytes long (3+1) mLengthSizeMinus1 = 3; // NAL length fields are 4 bytes long (3+1)
BitStream bitstr(sps); BitStream bitstr(sps);
// NALU header // NALU header
bitstr.readBits(1); // forbidden_zero_bit bitstr.readBits(1); // forbidden_zero_bit
bitstr.readBits(6); // nal_unit_type bitstr.readBits(6); // nal_unit_type
skipping to change at line 132 skipping to change at line 136
} }
// end profile_tier_level parsing // end profile_tier_level parsing
bitstr.readExpGolombCode(); // sps_se q_parameter_set_id bitstr.readExpGolombCode(); // sps_se q_parameter_set_id
mChromaFormat = static_cast<uint8_t>(bitstr.readExpGolombCode()); // chroma _format_idc mChromaFormat = static_cast<uint8_t>(bitstr.readExpGolombCode()); // chroma _format_idc
if (mChromaFormat == 3) if (mChromaFormat == 3)
{ {
bitstr.readBits(1); // separate_colour_plane_flag bitstr.readBits(1); // separate_colour_plane_flag
} }
else if (mChromaFormat > 3)
{
return false;
}
mPicWidthInLumaSamples = static_cast<uint16_t>(bitstr.readExpGolombCode()); // pic_width_in_luma_samples mPicWidthInLumaSamples = static_cast<uint16_t>(bitstr.readExpGolombCode()); // pic_width_in_luma_samples
mPicHeightInLumaSamples = static_cast<uint16_t>(bitstr.readExpGolombCode()); // pic_height_in_luma_samples mPicHeightInLumaSamples = static_cast<uint16_t>(bitstr.readExpGolombCode()); // pic_height_in_luma_samples
if (bitstr.readBits(1)) // conformance_window_flag if (bitstr.readBits(1)) // conformance_window_flag
{ {
mConfWinLeftOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_left_offset mConfWinLeftOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_left_offset
mConfWinRightOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_right_offset mConfWinRightOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_right_offset
mConfWinTopOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_top_offset mConfWinTopOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_top_offset
mConfWinBottomOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_bottom_offset mConfWinBottomOffset = static_cast<uint16_t>(bitstr.readExpGolombCode()) ; // conf_win_bottom_offset
} }
skipping to change at line 156 skipping to change at line 165
mConfWinTopOffset = 0; mConfWinTopOffset = 0;
mConfWinBottomOffset = 0; mConfWinBottomOffset = 0;
} }
mBitDepthLumaMinus8 = static_cast<uint8_t>(bitstr.readExpGolombCode()); / / bit_depth_luma_minus8 mBitDepthLumaMinus8 = static_cast<uint8_t>(bitstr.readExpGolombCode()); / / bit_depth_luma_minus8
mBitDepthChromaMinus8 = static_cast<uint8_t>(bitstr.readExpGolombCode()); / / bit_depth_chroma_minus8 mBitDepthChromaMinus8 = static_cast<uint8_t>(bitstr.readExpGolombCode()); / / bit_depth_chroma_minus8
bitstr.readExpGolombCode(); / / log2_max_pic_order_cnt_lsb_minus4 bitstr.readExpGolombCode(); / / log2_max_pic_order_cnt_lsb_minus4
mMinSpatialSegmentationIdc = 0; mMinSpatialSegmentationIdc = 0;
mParallelismType = 0; mParallelismType = 0;
return true;
} }
void HevcDecoderConfigurationRecord::addNalUnit(const Vector<uint8_t> &nalUnit, void HevcDecoderConfigurationRecord::addNalUnit(const Vector<uint8_t>& nalUnit,
const HevcNalUnitType nalUnitTyp e, const HevcNalUnitType nalUnitTyp e,
const bool arrayCompleteness) const bool arrayCompleteness)
{ {
NALArray *nalArray = nullptr; NALArray* nalArray = nullptr;
Vector<uint8_t> tmpNalUnit; Vector<uint8_t> tmpNalUnit;
unsigned int startCodeLen; unsigned int startCodeLen;
// find array for the given NAL unit type // find array for the given NAL unit type
for (auto &i : mNalArray) for (auto& i : mNalArray)
{ {
if (static_cast<uint8_t>(nalUnitType) == static_cast<uint8_t>(i.nalUnitT ype)) if (static_cast<uint8_t>(nalUnitType) == static_cast<uint8_t>(i.nalUnitT ype))
{ {
nalArray = &i; nalArray = &i;
break; break;
} }
} }
// if an array is not present for the NAL unit type, create one // if an array is not present for the NAL unit type, create one
if (nalArray == nullptr) if (nalArray == nullptr)
skipping to change at line 194 skipping to change at line 205
} }
startCodeLen = findStartCodeLen(nalUnit); startCodeLen = findStartCodeLen(nalUnit);
tmpNalUnit.insert(tmpNalUnit.begin(), nalUnit.cbegin() + static_cast<int>(st artCodeLen), tmpNalUnit.insert(tmpNalUnit.begin(), nalUnit.cbegin() + static_cast<int>(st artCodeLen),
nalUnit.cend()); // copy NAL data excluding potential sta rt code nalUnit.cend()); // copy NAL data excluding potential sta rt code
// add NAL unit to the NAL unit array // add NAL unit to the NAL unit array
nalArray->nalList.push_back(tmpNalUnit); nalArray->nalList.push_back(tmpNalUnit);
} }
void HevcDecoderConfigurationRecord::writeDecConfigRecord(ISOBMFF::BitStream &bi tstr) const void HevcDecoderConfigurationRecord::writeDecConfigRecord(ISOBMFF::BitStream& bi tstr) const
{ {
bitstr.writeBits(mConfigurationVersion, 8); bitstr.writeBits(mConfigurationVersion, 8);
bitstr.writeBits(mGeneralProfileSpace, 2); bitstr.writeBits(mGeneralProfileSpace, 2);
bitstr.writeBits(mGeneralTierFlag, 1); bitstr.writeBits(mGeneralTierFlag, 1);
bitstr.writeBits(mGeneralProfileIdc, 5); bitstr.writeBits(mGeneralProfileIdc, 5);
bitstr.writeBits(mGeneralProfileCompatibilityFlags, 32); bitstr.writeBits(mGeneralProfileCompatibilityFlags, 32);
for (unsigned int i = 0; i < 6; i++) for (unsigned int i = 0; i < 6; i++)
{ {
bitstr.writeBits(mGeneralConstraintIndicatorFlags.at(i), 8); bitstr.writeBits(mGeneralConstraintIndicatorFlags.at(i), 8);
} }
skipping to change at line 223 skipping to change at line 234
bitstr.writeBits(mBitDepthLumaMinus8, 3); bitstr.writeBits(mBitDepthLumaMinus8, 3);
bitstr.writeBits(0x1f, 5); // reserved = '11111'b bitstr.writeBits(0x1f, 5); // reserved = '11111'b
bitstr.writeBits(mBitDepthChromaMinus8, 3); bitstr.writeBits(mBitDepthChromaMinus8, 3);
bitstr.writeBits(mAvgFrameRate, 16); bitstr.writeBits(mAvgFrameRate, 16);
bitstr.writeBits(mConstantFrameRate, 2); bitstr.writeBits(mConstantFrameRate, 2);
bitstr.writeBits(mNumTemporalLayers, 3); bitstr.writeBits(mNumTemporalLayers, 3);
bitstr.writeBits(mTemporalIdNested, 1); bitstr.writeBits(mTemporalIdNested, 1);
bitstr.writeBits(mLengthSizeMinus1, 2); bitstr.writeBits(mLengthSizeMinus1, 2);
bitstr.writeBits(mNalArray.size(), 8); bitstr.writeBits(mNalArray.size(), 8);
for (const auto &i : mNalArray) for (const auto& i : mNalArray)
{ {
bitstr.writeBits(i.arrayCompleteness, 1); bitstr.writeBits(i.arrayCompleteness, 1);
bitstr.writeBits(0, 1); // reserved = 0 bitstr.writeBits(0, 1); // reserved = 0
bitstr.writeBits(static_cast<uint8_t>(i.nalUnitType), 6); bitstr.writeBits(static_cast<uint8_t>(i.nalUnitType), 6);
bitstr.writeBits(static_cast<unsigned int>(i.nalList.size()), 16); bitstr.writeBits(static_cast<unsigned int>(i.nalList.size()), 16);
for (const auto &j : i.nalList) for (const auto& j : i.nalList)
{ {
bitstr.writeBits(static_cast<unsigned int>(j.size()), 16); bitstr.writeBits(static_cast<unsigned int>(j.size()), 16);
bitstr.write8BitsArray(j, j.size()); // write parameter set NAL uni t bitstr.write8BitsArray(j, j.size()); // write parameter set NAL uni t
} }
} }
} }
void HevcDecoderConfigurationRecord::parseConfig(ISOBMFF::BitStream &bitstr) void HevcDecoderConfigurationRecord::parseConfig(ISOBMFF::BitStream& bitstr)
{ {
unsigned int numOfArrays; unsigned int numOfArrays;
mConfigurationVersion = static_cast<uint8_t>(bitstr.readBits(8)) ; mConfigurationVersion = static_cast<uint8_t>(bitstr.readBits(8)) ;
mGeneralProfileSpace = static_cast<uint8_t>(bitstr.readBits(2)) ; mGeneralProfileSpace = static_cast<uint8_t>(bitstr.readBits(2)) ;
mGeneralTierFlag = static_cast<uint8_t>(bitstr.readBits(1)) ; mGeneralTierFlag = static_cast<uint8_t>(bitstr.readBits(1)) ;
mGeneralProfileIdc = static_cast<uint8_t>(bitstr.readBits(5)) ; mGeneralProfileIdc = static_cast<uint8_t>(bitstr.readBits(5)) ;
mGeneralProfileCompatibilityFlags = bitstr.readBits(32); mGeneralProfileCompatibilityFlags = bitstr.readBits(32);
for (unsigned int i = 0; i < 6; i++) for (unsigned int i = 0; i < 6; i++)
{ {
skipping to change at line 291 skipping to change at line 302
unsigned int nalSize; unsigned int nalSize;
nalSize = bitstr.readBits(16); nalSize = bitstr.readBits(16);
nalData.clear(); nalData.clear();
bitstr.read8BitsArray(nalData, nalSize); // read parameter set NAL unit bitstr.read8BitsArray(nalData, nalSize); // read parameter set NAL unit
addNalUnit(nalData, nalUnitType, arrayCompleteness); addNalUnit(nalData, nalUnitType, arrayCompleteness);
} }
} }
} }
void HevcDecoderConfigurationRecord::getOneParameterSet(Vector<uint8_t> &byteStr eam, void HevcDecoderConfigurationRecord::getOneParameterSet(Vector<uint8_t>& byteStr eam,
const HevcNalUnitType na lUnitType) const const HevcNalUnitType na lUnitType) const
{ {
for (const auto &array : mNalArray) for (const auto& array : mNalArray)
{ {
if (array.nalUnitType == nalUnitType && array.nalList.size() > 0) if (array.nalUnitType == nalUnitType && array.nalList.size() > 0)
{ {
// add start code (0x00000001) before the NAL unit // add start code (0x00000001) before the NAL unit
byteStream.push_back(0); byteStream.push_back(0);
byteStream.push_back(0); byteStream.push_back(0);
byteStream.push_back(0); byteStream.push_back(0);
byteStream.push_back(1); byteStream.push_back(1);
byteStream.insert(byteStream.end(), array.nalList.at(0).cbegin(), ar ray.nalList.at(0).cend()); byteStream.insert(byteStream.end(), array.nalList.at(0).cbegin(), ar ray.nalList.at(0).cend());
} }
} }
} }
uint16_t HevcDecoderConfigurationRecord::getPicWidth() const uint16_t HevcDecoderConfigurationRecord::getPicWidth() const
{ {
const uint16_t subWidthC[4] = {1, 2, 2, 1}; const Vector<uint16_t> subWidthC = {1, 2, 2, 1};
return mPicWidthInLumaSamples - subWidthC[mChromaFormat] * (mConfWinLeftOffs return mPicWidthInLumaSamples - subWidthC.at(mChromaFormat) * (mConfWinLeftO
et + mConfWinRightOffset); ffset + mConfWinRightOffset);
} }
uint16_t HevcDecoderConfigurationRecord::getPicHeight() const uint16_t HevcDecoderConfigurationRecord::getPicHeight() const
{ {
const uint16_t subHeightC[4] = {1, 2, 1, 1}; const Vector<uint16_t> subHeightC = {1, 2, 1, 1};
return mPicHeightInLumaSamples - subHeightC[mChromaFormat] * (mConfWinTopOff return mPicHeightInLumaSamples - subHeightC.at(mChromaFormat) * (mConfWinTop
set + mConfWinBottomOffset); Offset + mConfWinBottomOffset);
} }
uint16_t HevcDecoderConfigurationRecord::getAvgFrameRate() const uint16_t HevcDecoderConfigurationRecord::getAvgFrameRate() const
{ {
return mAvgFrameRate; return mAvgFrameRate;
} }
std::uint8_t HevcDecoderConfigurationRecord::getChromaFormat() const std::uint8_t HevcDecoderConfigurationRecord::getChromaFormat() const
{ {
return mChromaFormat; return mChromaFormat;
skipping to change at line 350 skipping to change at line 361
std::uint32_t HevcDecoderConfigurationRecord::getGeneralProfileCompatibilityFlag s() const std::uint32_t HevcDecoderConfigurationRecord::getGeneralProfileCompatibilityFlag s() const
{ {
return mGeneralProfileCompatibilityFlags; return mGeneralProfileCompatibilityFlags;
} }
std::uint8_t HevcDecoderConfigurationRecord::getGeneralLevelIdc() const std::uint8_t HevcDecoderConfigurationRecord::getGeneralLevelIdc() const
{ {
return mGeneralLevelIdc; return mGeneralLevelIdc;
} }
void HevcDecoderConfigurationRecord::getConfigurationMap(ConfigurationMap &aMap) const void HevcDecoderConfigurationRecord::getConfigurationMap(ConfigurationMap& aMap) const
{ {
Vector<std::uint8_t> sps; Vector<std::uint8_t> sps;
Vector<std::uint8_t> pps; Vector<std::uint8_t> pps;
Vector<std::uint8_t> vps; Vector<std::uint8_t> vps;
getOneParameterSet(sps, HevcNalUnitType::SPS); getOneParameterSet(sps, HevcNalUnitType::SPS);
getOneParameterSet(pps, HevcNalUnitType::PPS); getOneParameterSet(pps, HevcNalUnitType::PPS);
getOneParameterSet(vps, HevcNalUnitType::VPS); getOneParameterSet(vps, HevcNalUnitType::VPS);
aMap.insert({DecoderParameterType::HEVC_SPS, move(sps)}); aMap.insert({DecoderParameterType::HEVC_SPS, move(sps)});
aMap.insert({DecoderParameterType::HEVC_PPS, move(pps)}); aMap.insert({DecoderParameterType::HEVC_PPS, move(pps)});
 End of changes. 16 change blocks. 
18 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)