Browse code

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>

Hendrik Leppkes authored on 2014/12/23 08:42:49
Showing 1 changed files
... ...
@@ -254,25 +254,17 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVF
254 254
     av_assert1(!*got_packet_ptr);
255 255
 
256 256
     if(frame){
257
-        if(!(avctx->flags & CODEC_FLAG_INPUT_PRESERVED)){
258
-            AVFrame *new = av_frame_alloc();
259
-            if(!new)
260
-                return AVERROR(ENOMEM);
261
-            pthread_mutex_lock(&c->buffer_mutex);
262
-            ret = ff_get_buffer(c->parent_avctx, new, 0);
263
-            pthread_mutex_unlock(&c->buffer_mutex);
264
-            if(ret<0)
265
-                return ret;
266
-            new->pts = frame->pts;
267
-            new->quality = frame->quality;
268
-            new->pict_type = frame->pict_type;
269
-            av_image_copy(new->data, new->linesize, (const uint8_t **)frame->data, frame->linesize,
270
-                          avctx->pix_fmt, avctx->width, avctx->height);
271
-            frame = new;
257
+        AVFrame *new = av_frame_alloc();
258
+        if(!new)
259
+            return AVERROR(ENOMEM);
260
+        ret = av_frame_ref(new, frame);
261
+        if(ret < 0) {
262
+            av_frame_free(&new);
263
+            return ret;
272 264
         }
273 265
 
274 266
         task.index = c->task_index;
275
-        task.indata = (void*)frame;
267
+        task.indata = (void*)new;
276 268
         pthread_mutex_lock(&c->task_fifo_mutex);
277 269
         av_fifo_generic_write(c->task_fifo, &task, sizeof(task), NULL);
278 270
         pthread_cond_signal(&c->task_fifo_cond);