Skip to content

Commit

Permalink
FFmpegReader: Throw correct exception
Browse files Browse the repository at this point in the history
The only reason an `AV_ALLOCATE_FRAME()` could fail is because
there wasn't enough memory to allocate the necessary buffers,
so if it returns a `nullptr` then throwing `OutOfMemory` makes
far more sense than throwing `OutOfBoundsFrame`.
  • Loading branch information
ferdnyc committed Mar 15, 2021
1 parent 691fc83 commit c1a4016
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/FFmpegReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,13 +1243,13 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
processing_video_frames[current_frame] = current_frame;

// Create variables for a RGB Frame (since most videos are not in RGB, we must convert it)
AVFrame *pFrameRGB = NULL;
uint8_t *buffer = NULL;
AVFrame *pFrameRGB = nullptr;
uint8_t *buffer = nullptr;

// Allocate an AVFrame structure
pFrameRGB = AV_ALLOCATE_FRAME();
if (pFrameRGB == NULL)
throw OutOfBoundsFrame("Convert Image Broke!", current_frame, video_length);
if (pFrameRGB == nullptr)
throw OutOfMemory("Failed to allocate frame buffer", path);

// Determine the max size of this source image (based on the timeline's size, the scaling mode,
// and the scaling keyframes). This is a performance improvement, to keep the images as small as possible,
Expand Down

0 comments on commit c1a4016

Please sign in to comment.