Skip to content
Snippets Groups Projects
Commit 17688908 authored by Xiang Li's avatar Xiang Li
Browse files

Merge branch 'check_stream_write' into 'master'

Add check whether writing to bitstream succeeded

See merge request jvet/VVCSoftware_VTM!2275
parents 3afe4046 da38667a
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,15 @@
//! \ingroup EncoderLib
//! \{
void checkWriteError(std::ostream& out)
{
if (out.fail())
{
printf ("Error writing bitstream file\n");
exit (EXIT_FAILURE);
}
}
uint32_t writeAnnexBNalUnit(std::ostream& out, const NALUnitEBSP& nalu, bool useLongStartcode)
{
uint32_t size = 0; /* size of annexB unit in bytes */
......@@ -51,14 +60,17 @@ uint32_t writeAnnexBNalUnit(std::ostream& out, const NALUnitEBSP& nalu, bool use
if (useLongStartcode)
{
out.write(reinterpret_cast<const char*>(startCodePrefix), 4);
checkWriteError(out);
size += 4;
}
else
{
out.write(reinterpret_cast<const char*>(startCodePrefix+1), 3);
checkWriteError(out);
size += 3;
}
out << nalu.m_nalUnitData.str();
checkWriteError(out);
size += uint32_t(nalu.m_nalUnitData.str().size());
return size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment