"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "srcs/api-cpp/H26xTools.cpp" between
heif-3.6.1.tar.gz and heif-3.6.2.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).

H26xTools.cpp  (heif-3.6.1):H26xTools.cpp  (heif-3.6.2)
/* /*
* This file is part of Nokia HEIF library * This file is part of Nokia HEIF library
* *
* Copyright (c) 2015-2020 Nokia Corporation and/or its subsidiary(-ies). All ri ghts reserved. * Copyright (c) 2015-2021 Nokia Corporation and/or its subsidiary(-ies). All ri ghts reserved.
* *
* Contact: heif@nokia.com * Contact: heif@nokia.com
* *
* This software, including documentation, is protected by copyright controlled by Nokia Corporation and/ or its * This software, including documentation, is protected by copyright controlled by Nokia Corporation and/ or its
* subsidiaries. All rights are reserved. Copying, including reproducing, storin g, adapting or translating, any or all * subsidiaries. All rights are reserved. Copying, including reproducing, storin g, adapting or translating, any or all
* of this material requires the prior written consent of Nokia. * of this material requires the prior written consent of Nokia.
*/ */
#include "H26xTools.h" #include "H26xTools.h"
skipping to change at line 68 skipping to change at line 68
return false; return false;
} }
bool NAL_State::parse_byte_stream(const std::uint8_t*& nal_unit, std::uint64_t& nal_unit_length) bool NAL_State::parse_byte_stream(const std::uint8_t*& nal_unit, std::uint64_t& nal_unit_length)
{ {
/* /*
The decoder then performs the following step-wise process repeatedly to extr act and decode each NAL unit syntax The decoder then performs the following step-wise process repeatedly to extr act and decode each NAL unit syntax
structure in the byte stream until the end of the byte stream has been encou ntered (as determined by unspecified structure in the byte stream until the end of the byte stream has been encou ntered (as determined by unspecified
means and the last NAL unit in the byte stream has been decoded: means and the last NAL unit in the byte stream has been decoded:
*/ */
/*1. When the next four bytes in the bitstream form the four-byte sequence 0 x00000001, /* 1. When the next four bytes in the bitstream form the four-byte sequence 0x00000001,
the next byte in the byte stream (which is a zero_byte syntax element) is ex tracted the next byte in the byte stream (which is a zero_byte syntax element) is ex tracted
and discarded and the current position in the byte stream is set equal to th e position and discarded and the current position in the byte stream is set equal to th e position
of the byte following this discarded byte. of the byte following this discarded byte.
*/ */
if ((mLength >= 4) && ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 0) && (mData[3] == 1))) if ((mLength >= 4) && ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 0) && (mData[3] == 1)))
{ {
// discard zero byte // discard zero byte
/* /*
When one or more of the following conditions are true, the zero_byte syn tax element shall be present: When one or more of the following conditions are true, the zero_byte syn tax element shall be present:
H265 H265
The nal_unit_type within the nal_unit( ) syntax structure is equal to - The nal_unit_type within the nal_unit( ) syntax structure is equal to
VPS_NUT, SPS_NUT or PPS_NUT. VPS_NUT, SPS_NUT or PPS_NUT.
The byte stream NAL unit syntax structure contains the first NAL unit - The byte stream NAL unit syntax structure contains the first NAL unit
of an access unit in decoding order, as of an access unit in decoding order, as
specified in clause 7.4.2.4.4. H264 The nal_unit_type within the nal_u specified in clause 7.4.2.4.4.
nit( ) is equal to 7 (sequence parameter H264
set) or 8 (picture parameter set), The byte stream NAL unit syntax str - The nal_unit_type within the nal_unit( ) is equal to 7 (sequence param
ucture contains the first NAL unit of an eter set) or 8 (picture parameter set),
access unit in decoding order, as specified in clause 7.4.1.2.3. - The byte stream NAL unit syntax structure contains the first NAL unit
of an access unit in decoding order, as
specified in clause 7.4.1.2.3.
*/ */
// Currently not validating that the nal unit is of type that CAN have t he zero byte. // Currently not validating that the nal unit is of type that CAN have t he zero byte.
mLength--; mLength--;
mData++; mData++;
} }
if (mLength < 3) if (mLength < 3)
{ {
// end of stream. // end of stream.
nal_unit = nullptr; nal_unit = nullptr;
nal_unit_length = 0; nal_unit_length = 0;
return false; return false;
} }
/*2. The next three-byte sequence in the byte stream (which is a start_code_ prefix_one_3bytes) /* 2. The next three-byte sequence in the byte stream (which is a start_code _prefix_one_3bytes)
is extracted and discarded and the current position in the byte stream is se t equal to is extracted and discarded and the current position in the byte stream is se t equal to
the position of the byte following this three-byte sequence. the position of the byte following this three-byte sequence.
*/ */
if ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 1)) if ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 1))
{ {
// skip start_code_prefix // skip start_code_prefix
mLength -= 3; mLength -= 3;
mData += 3; mData += 3;
} }
else else
{ {
// corrupted stream. // corrupted stream.
nal_unit = nullptr; nal_unit = nullptr;
nal_unit_length = 0; nal_unit_length = 0;
return false; return false;
} }
/*3. NumBytesInNalUnit is set equal to the number of bytes starting with the byte at the current /* 3. NumBytesInNalUnit is set equal to the number of bytes starting with th e byte at the current
position in the byte stream up to and including the last byte that precedes the location of position in the byte stream up to and including the last byte that precedes the location of
one or more of the following conditions: one or more of the following conditions:
A subsequent byte-aligned three-byte sequence equal to 0x000000, - A subsequent byte-aligned three-byte sequence equal to 0x000000,
A subsequent byte-aligned three-byte sequence equal to 0x000001, - A subsequent byte-aligned three-byte sequence equal to 0x000001,
The end of the byte stream, as determined by unspecified means. - The end of the byte stream, as determined by unspecified means.
*/ */
const std::uint8_t* src = mData; const std::uint8_t* src = mData;
std::uint64_t bytes_left = mLength; std::uint64_t bytes_left = mLength;
while (bytes_left) while (bytes_left)
{ {
if ((bytes_left >= 3) && ((src[0] == 0) && (src[1] == 0) && ((src[2] == 0) || (src[2] == 1)))) if ((bytes_left >= 3) && ((src[0] == 0) && (src[1] == 0) && ((src[2] == 0) || (src[2] == 1))))
{ {
break; break;
} }
src++; src++;
bytes_left--; bytes_left--;
} }
/*4. NumBytesInNalUnit bytes are removed from the bitstream and the current position in the byte /* 4. NumBytesInNalUnit bytes are removed from the bitstream and the current position in the byte
stream is advanced by NumBytesInNalUnit bytes. stream is advanced by NumBytesInNalUnit bytes.
This sequence of bytes is nal_unit( NumBytesInNalUnit ) and is decoded using the NAL unit decoding process. This sequence of bytes is nal_unit( NumBytesInNalUnit ) and is decoded using the NAL unit decoding process.
*/ */
nal_unit = mData; nal_unit = mData;
nal_unit_length = static_cast<uint64_t>(src - mData); nal_unit_length = static_cast<uint64_t>(src - mData);
mData += nal_unit_length; mData += nal_unit_length;
mLength -= nal_unit_length; mLength -= nal_unit_length;
/*5. When the current position in the byte stream is not at the end of the b /* 5. When the current position in the byte stream is not at the end of the
yte stream (as determined by unspecified byte stream (as determined by
means) and the next bytes in the byte stream do not start with a three-byte unspecified means) and the next bytes in the byte stream do not start with a
sequence equal to 0x000001 and the next three-byte sequence equal to 0x000001
bytes in the byte stream do not start with a four byte sequence equal to 0x0 and the next bytes in the byte stream do not start with a four byte sequence
0000001 ,the decoder extracts and equal to 0x00000001 ,the decoder
discards each trailing_zero_8bits syntax element, moving the current positio extracts and discards each trailing_zero_8bits syntax element, moving the cu
n in the byte stream forward one byte at rrent position in the byte stream
a time, until the current position in the byte stream is such that the next forward one byte at a time, until the current position in the byte stream is
bytes in the byte stream form the such that the next bytes in the byte
fourbyte sequence 0x00000001 or the end of the byte stream has been encounte stream form the fourbyte sequence 0x00000001 or the end of the byte stream h
red (as determined by unspecified as been encountered (as determined by
means). unspecified means).
*/ */
if ((mLength >= 3) && ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 1) )) if ((mLength >= 3) && ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 1) ))
{ {
return true; return true;
} }
if ((mLength >= 4) && ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 0) && (mData[3] == 1))) if ((mLength >= 4) && ((mData[0] == 0) && (mData[1] == 0) && (mData[2] == 0) && (mData[3] == 1)))
{ {
return true; return true;
} }
 End of changes. 8 change blocks. 
30 lines changed or deleted 32 lines changed or added

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