summaryrefslogtreecommitdiff
path: root/libavcodec/frame_thread_encoder.c
diff options
context:
space:
mode:
authorlee ju <julee.vv@outlook.com>2018-08-04 10:19:45 +0000
committerMichael Niedermayer <michael@niedermayer.cc>2018-08-16 03:05:54 +0200
commit6a0feafebe0e74bf7ce2d12a8177c670ebf2379a (patch)
tree71f8cdc3e9eaa217ad8ed841684de5fa37313578 /libavcodec/frame_thread_encoder.c
parent3378194ce8e9a126a7cc6ed57bedde1221790469 (diff)
downloadffmpeg-6a0feafebe0e74bf7ce2d12a8177c670ebf2379a.tar.gz
avcodec/frame_thread_encoder: fix memory leak that occurs when close encoder without sending eof and receiving to end
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/frame_thread_encoder.c')
-rw-r--r--libavcodec/frame_thread_encoder.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index 5ff3f7863c..55756c4c54 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -251,6 +251,23 @@ void ff_frame_thread_encoder_free(AVCodecContext *avctx){
pthread_join(c->worker[i], NULL);
}
+ while (av_fifo_size(c->task_fifo) > 0) {
+ Task task;
+ AVFrame *frame;
+ av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL);
+ frame = task.indata;
+ av_frame_free(&frame);
+ task.indata = NULL;
+ }
+
+ for (i=0; i<BUFFER_SIZE; i++) {
+ if (c->finished_tasks[i].outdata != NULL) {
+ AVPacket *pkt = c->finished_tasks[i].outdata;
+ av_packet_free(&pkt);
+ c->finished_tasks[i].outdata = NULL;
+ }
+ }
+
pthread_mutex_destroy(&c->task_fifo_mutex);
pthread_mutex_destroy(&c->finished_task_mutex);
pthread_mutex_destroy(&c->buffer_mutex);