Skip to content

Commit

Permalink
[what][bugfix][h264] 修复若干问题
Browse files Browse the repository at this point in the history
[how]
1. 修复可能存在的越界问题
2. 修复 chroma_format_idc 缺省赋值错误
  • Loading branch information
HR1025 committed Jul 29, 2024
1 parent 509c6c7 commit e8cf43e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions H264Deserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@ bool H264Deserialize::DeserializeSpsSyntax(H26xBinaryReader::ptr br, H264SpsSynt
}
}
}
else
{
// Hint : When chroma_format_idc is not present, it shall be inferred to be equal to 1 (4:2:0 chroma format).
sps->chroma_format_idc = 1;
}
br->UE(sps->log2_max_frame_num_minus4);
{
// Hint : The value of log2_max_frame_num_minus4 shall be in the range of 0 to 12, inclusive.
Expand Down Expand Up @@ -779,7 +784,10 @@ bool H264Deserialize::DeserializeSpsSyntax(H26xBinaryReader::ptr br, H264SpsSynt
return false;
}
}
br->rbsp_trailing_bits();
if (!br->Eof())
{
br->rbsp_trailing_bits();
}
FillH264SpsContext(sps);
_contex->spsSet[sps->seq_parameter_set_id] = sps;
_contex->sps = sps;
Expand Down Expand Up @@ -1345,7 +1353,10 @@ bool H264Deserialize::DeserializePpsSyntax(H26xBinaryReader::ptr br, H264PpsSynt
pps->ScalingList4x4 = sps->ScalingList4x4;
pps->ScalingList8x8 = sps->ScalingList8x8;
}
br->rbsp_trailing_bits();
if (!br->Eof())
{
br->rbsp_trailing_bits();
}
_contex->ppsSet[pps->pic_parameter_set_id] = pps;
_contex->pps = pps;
return true;
Expand Down
4 changes: 2 additions & 2 deletions H26xBinaryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void H26xBinaryReader::MoveNextByte()

bool H26xBinaryReader::Eof()
{
return _reader->Eof();
return _reader->Eof() && _curBitPos == 8;
}

void H26xBinaryReader::BeginNalUnit()
Expand Down Expand Up @@ -386,7 +386,7 @@ bool H26xBinaryReader::more_data_in_byte_stream()
// specified as follows:
// - If more data follow in the byte stream, the return value of more_data_in_byte_stream( ) is equal to TRUE.
// - Otherwise, the return value of more_data_in_byte_stream( ) is equal to FALSE.
return !_reader->Eof();
return !(_reader->Eof() && _curBitPos == 8);
}

void H26xBinaryReader::byte_alignment()
Expand Down

0 comments on commit e8cf43e

Please sign in to comment.