Skip to content

Commit 6e4d7d7

Browse files
author
Clement Champetier
committed
Frame: add freeAVFrame private method
To keep symmetry with allocateAVFrame private method.
1 parent 58cfca0 commit 6e4d7d7

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/AvTranscoder/data/decoded/Frame.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,7 @@ void Frame::operator=(const Frame& otherFrame)
3434

3535
Frame::~Frame()
3636
{
37-
if(_frame != NULL)
38-
{
39-
#if LIBAVCODEC_VERSION_MAJOR > 54
40-
av_frame_free(&_frame);
41-
#else
42-
#if LIBAVCODEC_VERSION_MAJOR > 53
43-
avcodec_free_frame(&_frame);
44-
#else
45-
av_free(_frame);
46-
#endif
47-
#endif
48-
_frame = NULL;
49-
}
37+
freeAVFrame();
5038
}
5139

5240
int Frame::getEncodedSize() const
@@ -100,6 +88,23 @@ void Frame::allocateAVFrame()
10088
}
10189
}
10290

91+
void Frame::freeAVFrame()
92+
{
93+
if(_frame != NULL)
94+
{
95+
#if LIBAVCODEC_VERSION_MAJOR > 54
96+
av_frame_free(&_frame);
97+
#else
98+
#if LIBAVCODEC_VERSION_MAJOR > 53
99+
avcodec_free_frame(&_frame);
100+
#else
101+
av_free(_frame);
102+
#endif
103+
#endif
104+
_frame = NULL;
105+
}
106+
}
107+
103108
bool Frame::isAudioFrame() const
104109
{
105110
if(_frame->sample_rate && _frame->channels && _frame->channel_layout && _frame->format != -1)

src/AvTranscoder/data/decoded/Frame.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class AvExport Frame
101101

102102
private:
103103
void allocateAVFrame();
104+
void freeAVFrame();
104105

105106
protected:
106107
AVFrame* _frame;

0 commit comments

Comments
 (0)