Skip to content

Commit dbcfed4

Browse files
author
Clement Champetier
committed
Video/AudioEncoder: fixed size of encoded data allocated within avcodec
The AVPacket data attribut should be set to NULL: the encoder will allocate it.
1 parent 14164d6 commit dbcfed4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ bool AudioEncoder::encodeFrame(const Frame& sourceFrame, CodedData& codedFrame)
9696
AVCodecContext& avCodecContext = _codec.getAVCodecContext();
9797

9898
AVPacket& packet = codedFrame.getAVPacket();
99+
packet.data = NULL;
99100
packet.stream_index = 0;
100101

101102
if((avCodecContext.coded_frame) && (avCodecContext.coded_frame->pts != (int)AV_NOPTS_VALUE))
@@ -136,6 +137,7 @@ bool AudioEncoder::encodeFrame(CodedData& codedFrame)
136137
AVCodecContext& avCodecContext = _codec.getAVCodecContext();
137138

138139
AVPacket& packet = codedFrame.getAVPacket();
140+
packet.data = NULL;
139141
packet.stream_index = 0;
140142

141143
#if LIBAVCODEC_VERSION_MAJOR > 53

src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ bool VideoEncoder::encodeFrame(const Frame& sourceFrame, CodedData& codedFrame)
109109
AVCodecContext& avCodecContext = _codec.getAVCodecContext();
110110

111111
AVPacket& packet = codedFrame.getAVPacket();
112+
packet.data = NULL;
112113
packet.stream_index = 0;
113114

114115
if((avCodecContext.coded_frame) && (avCodecContext.coded_frame->pts != (int)AV_NOPTS_VALUE))
@@ -149,6 +150,7 @@ bool VideoEncoder::encodeFrame(CodedData& codedFrame)
149150
AVCodecContext& avCodecContext = _codec.getAVCodecContext();
150151

151152
AVPacket& packet = codedFrame.getAVPacket();
153+
packet.data = NULL;
152154
packet.stream_index = 0;
153155

154156
#if LIBAVCODEC_VERSION_MAJOR > 53

0 commit comments

Comments
 (0)