Skip to content

Commit

Permalink
VIDEO: Throw exceptions when libxvidcore returns errors
Browse files Browse the repository at this point in the history
  • Loading branch information
clone2727 committed Jun 13, 2017
1 parent 3cc915f commit 8118cd0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/video/codecs/h263.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ H263Codec::H263Codec(uint32 width, uint32 height, Common::SeekableReadStream &ex
xvid_dec_create.version = XVID_VERSION;
xvid_dec_create.width = width;
xvid_dec_create.height = height;
if (xvid_decore(0, XVID_DEC_CREATE, &xvid_dec_create, 0) != 0)
error("Could not initialize xvid decoder");

int result = xvid_decore(0, XVID_DEC_CREATE, &xvid_dec_create, 0);
if (result != 0)
throw Common::Exception("H263Codec::H263Codec(): Failed to create the decore context: %d", result);

_decHandle = xvid_dec_create.handle;

Expand Down Expand Up @@ -111,9 +113,9 @@ void H263Codec::decodeInternal(Common::SeekableReadStream &dataStream, Graphics:
std::memset(&xvid_dec_stats, 0, sizeof(xvid_dec_stats_t));
xvid_dec_stats.version = XVID_VERSION;

int c = xvid_decore(_decHandle, XVID_DEC_DECODE, &xvid_dec_frame, &xvid_dec_stats);
if ((dataSize - c) > 1)
warning("H263Codec::decodeFrame(): %u bytes left in frame", (uint)(dataSize - c));
int result = xvid_decore(_decHandle, XVID_DEC_DECODE, &xvid_dec_frame, &xvid_dec_stats);
if (result < 0)
throw Common::Exception("H263Codec::decodeFrame(): Failed to decode frame: %d", result);

if (surface &&
xvid_dec_frame.output.plane[0] &&
Expand Down

0 comments on commit 8118cd0

Please sign in to comment.