aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pthread_frame.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-09 10:14:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-12-09 08:42:25 +0100
commitd351ef47d0e0ccb7de96b37f137c16b2885580ac (patch)
tree2add168bc25d55494e7abb6b853d9170ae05b8c8 /libavcodec/pthread_frame.c
parentb605b123ef1d3bac0e7c221d8d7fa74cd8c7253c (diff)
downloadffmpeg-d351ef47d0e0ccb7de96b37f137c16b2885580ac.tar.gz
pthread_frame: use the AVFrame API properly.
Remove the extended_data workaround, all decoders should now handle this properly.
Diffstat (limited to 'libavcodec/pthread_frame.c')
-rw-r--r--libavcodec/pthread_frame.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 626d4f724b..ece0e804b1 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -66,7 +66,7 @@ typedef struct PerThreadContext {
uint8_t *buf; ///< backup storage for packet data when the input packet is not refcounted
int allocated_buf_size; ///< Size allocated for buf
- AVFrame frame; ///< Output frame (for decoding) or input (for encoding).
+ AVFrame *frame; ///< Output frame (for decoding) or input (for encoding).
int got_frame; ///< The output of got_picture_ptr from the last avcodec_decode_video() call.
int result; ///< The result of the last codec decode/encode() call.
@@ -140,13 +140,9 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
ff_thread_finish_setup(avctx);
pthread_mutex_lock(&p->mutex);
- avcodec_get_frame_defaults(&p->frame);
+ av_frame_unref(p->frame);
p->got_frame = 0;
- p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt);
-
- /* many decoders assign whole AVFrames, thus overwriting extended_data;
- * make sure it's set correctly */
- p->frame.extended_data = p->frame.data;
+ p->result = codec->decode(avctx, p->frame, &p->got_frame, &p->avpkt);
if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx);
@@ -409,7 +405,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
pthread_mutex_unlock(&p->progress_mutex);
}
- av_frame_move_ref(picture, &p->frame);
+ av_frame_move_ref(picture, p->frame);
*got_picture_ptr = p->got_frame;
picture->pkt_dts = p->avpkt.dts;
@@ -527,7 +523,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
avctx->codec = NULL;
release_delayed_buffers(p);
- av_frame_unref(&p->frame);
+ av_frame_free(&p->frame);
}
for (i = 0; i < thread_count; i++) {
@@ -599,6 +595,12 @@ int ff_frame_thread_init(AVCodecContext *avctx)
pthread_cond_init(&p->progress_cond, NULL);
pthread_cond_init(&p->output_cond, NULL);
+ p->frame = av_frame_alloc();
+ if (!p->frame) {
+ err = AVERROR(ENOMEM);
+ goto error;
+ }
+
p->parent = fctx;
p->avctx = copy;
@@ -674,7 +676,7 @@ void ff_thread_flush(AVCodecContext *avctx)
PerThreadContext *p = &fctx->threads[i];
// Make sure decode flush calls with size=0 won't return old frames
p->got_frame = 0;
- av_frame_unref(&p->frame);
+ av_frame_unref(p->frame);
release_delayed_buffers(p);
}