Skip to content

Commit 64afc62

Browse files
author
Clement Champetier
committed
VideoGenerator: fixed decoding if the given frame is not valid
1 parent 7419075 commit 64afc62

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/AvTranscoder/data/decoded/VideoFrame.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class AvExport VideoFrame : public Frame
7070
* @brief Allocate the image buffer of the frame.
7171
*/
7272
void allocateAVPicture(const VideoFrameDesc& desc);
73+
74+
/**
75+
* @note To allocate new image buffer if needed.
76+
* @see allocateAVPicture
77+
*/
78+
friend class VideoGenerator;
7379
};
7480
}
7581

src/AvTranscoder/decoder/VideoGenerator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ VideoGenerator::~VideoGenerator()
3737

3838
bool VideoGenerator::decodeNextFrame(Frame& frameBuffer)
3939
{
40+
// check the given frame
41+
if(!frameBuffer.isVideoFrame())
42+
{
43+
LOG_WARN("The given frame is not a valid video frame: allocate a new AVPicture to put generated data into it.");
44+
frameBuffer.clear();
45+
static_cast<VideoFrame&>(frameBuffer).allocateAVPicture(_frameDesc);
46+
}
47+
4048
// Generate black image
4149
if(!_inputFrame)
4250
{

0 commit comments

Comments
 (0)