aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-05 13:18:13 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-11-05 13:30:08 +0100
commitf4aaf987a588fcf5978e636edf2193df35b3e83b (patch)
tree46d89b3a7d7b731df564b6a04dd4ee1a898e140b
parent17e67c532100024e1fe8fef69b3d99c82f393b9a (diff)
downloadffmpeg-f4aaf987a588fcf5978e636edf2193df35b3e83b.tar.gz
frame_thread_encoder: fix handling of case where the encoder does not output a packet.
This case could cause a deadlock Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/frame_thread_encoder.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index 664526a303..208874c483 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -95,9 +95,11 @@ static void * attribute_align_arg worker(void *v){
c->parent_avctx->release_buffer(c->parent_avctx, frame);
pthread_mutex_unlock(&c->buffer_mutex);
av_freep(&frame);
- if(!got_packet)
- continue;
- av_dup_packet(pkt);
+ if(got_packet) {
+ av_dup_packet(pkt);
+ } else {
+ pkt->data = pkt->size = 0;
+ }
pthread_mutex_lock(&c->finished_task_mutex);
c->finished_tasks[task.index].outdata = pkt; pkt = NULL;
c->finished_tasks[task.index].return_code = ret;
@@ -257,11 +259,11 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVF
}
task = c->finished_tasks[c->finished_task_index];
*pkt = *(AVPacket*)(task.outdata);
+ if(pkt->data)
+ *got_packet_ptr = 1;
av_freep(&c->finished_tasks[c->finished_task_index].outdata);
c->finished_task_index = (c->finished_task_index+1) % BUFFER_SIZE;
pthread_mutex_unlock(&c->finished_task_mutex);
- *got_packet_ptr = 1;
-
return task.return_code;
}