Skip to content
Snippets Groups Projects
Commit da38667a authored by Karsten Suehring's avatar Karsten Suehring
Browse files

Add check whether writing to bistream succeeded

parent 3afe4046
No related branches found
No related tags found
1 merge request!2275Add check whether writing to bitstream succeeded
Pipeline #7587 passed
......@@ -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