diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2014-12-23 00:42:49 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-12-23 01:36:13 +0100 |
commit | 1ffcf6ac9045c647ce27581a836f325118e40b03 (patch) | |
tree | a7d67ebb2cd528b005b9c32b0a640dedc339763c /libavcodec | |
parent | fe439c20698fc4992b9373cb068efb438fe1a098 (diff) | |
download | ffmpeg-1ffcf6ac9045c647ce27581a836f325118e40b03.tar.gz |
frame_thread_encoder: use ref-counting to avoid memcpy of all input frames
Apparently uneeded lock/unlock removed by commiter
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/frame_thread_encoder.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 6eae8b5733..9a49fea527 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -254,25 +254,17 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVF av_assert1(!*got_packet_ptr); if(frame){ - if(!(avctx->flags & CODEC_FLAG_INPUT_PRESERVED)){ - AVFrame *new = av_frame_alloc(); - if(!new) - return AVERROR(ENOMEM); - pthread_mutex_lock(&c->buffer_mutex); - ret = ff_get_buffer(c->parent_avctx, new, 0); - pthread_mutex_unlock(&c->buffer_mutex); - if(ret<0) - return ret; - new->pts = frame->pts; - new->quality = frame->quality; - new->pict_type = frame->pict_type; - av_image_copy(new->data, new->linesize, (const uint8_t **)frame->data, frame->linesize, - avctx->pix_fmt, avctx->width, avctx->height); - frame = new; + AVFrame *new = av_frame_alloc(); + if(!new) + return AVERROR(ENOMEM); + ret = av_frame_ref(new, frame); + if(ret < 0) { + av_frame_free(&new); + return ret; } task.index = c->task_index; - task.indata = (void*)frame; + task.indata = (void*)new; pthread_mutex_lock(&c->task_fifo_mutex); av_fifo_generic_write(c->task_fifo, &task, sizeof(task), NULL); pthread_cond_signal(&c->task_fifo_cond); |