Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From f92587c6152843fed2ac3d7d8fee000efc0d0c03 Mon Sep 17 00:00:00 2001
- From: Hendrik Leppkes <h.leppkes@gmail.com>
- Date: Tue, 23 Dec 2014 00:42:49 +0100
- Subject: [PATCH] frame_thread_encoder: use ref-counting to avoid memcpy of all
- input frames
- ---
- libavcodec/frame_thread_encoder.c | 26 +++++++++-----------------
- 1 file changed, 9 insertions(+), 17 deletions(-)
- diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
- index 6eae8b5..f840d6e 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);
- + pthread_mutex_lock(&c->buffer_mutex);
- + ret = av_frame_ref(new, frame);
- + pthread_mutex_unlock(&c->buffer_mutex);
- + if(ret<0)
- + 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);
- --
- 1.9.5.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement