diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-27 22:21:16 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-11 20:16:49 +0200 |
commit | 69cfe63a43f43207f72fd677c47eafcf58fcfd13 (patch) | |
tree | 856cf4fabbfdf18c75bf67470fe01c5566172feb /libavcodec/ffv1dec.c | |
parent | 44f69c0df8c1d12b450c01ac151d850bf6a8a5b6 (diff) | |
download | ffmpeg-69cfe63a43f43207f72fd677c47eafcf58fcfd13.tar.gz |
ffv1: Switch to ThreadFrame
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ffv1dec.c')
-rw-r--r-- | libavcodec/ffv1dec.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index d73c2e04e6..d623233ea8 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -38,7 +38,6 @@ #include "golomb.h" #include "mathops.h" #include "ffv1.h" -#include "thread.h" static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed) @@ -734,14 +733,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac int buf_size = avpkt->size; FFV1Context *f = avctx->priv_data; RangeCoder *const c = &f->slice_context[0]->c; - ThreadFrame frame = { .f = data }; int i, ret; uint8_t keystate = 128; const uint8_t *buf_p; - AVFrame *const p = data; + AVFrame *p; - f->cur = p; - f->avctx = avctx; + if (f->last_picture.f) + ff_thread_release_buffer(avctx, &f->last_picture); + FFSWAP(ThreadFrame, f->picture, f->last_picture); + + f->cur = p = f->picture.f; ff_init_range_decoder(c, buf, buf_size); ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8); @@ -762,7 +763,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac p->key_frame = 0; } - if ((ret = ff_thread_get_buffer(avctx, &frame, AV_GET_BUFFER_FLAG_REF)) < 0) + if ((ret = ff_thread_get_buffer(avctx, &f->picture, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; if (avctx->debug & FF_DEBUG_PICT_INFO) @@ -818,7 +819,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac for (i = f->slice_count - 1; i >= 0; i--) { FFV1Context *fs = f->slice_context[i]; int j; - if (fs->slice_damaged && f->last_picture.data[0]) { + if (fs->slice_damaged && f->last_picture.f->data[0]) { const uint8_t *src[4]; uint8_t *dst[4]; for (j = 0; j < 4; j++) { @@ -826,11 +827,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac int sv = (j==1 || j==2) ? f->chroma_v_shift : 0; dst[j] = p->data[j] + p->linesize[j]* (fs->slice_y>>sv) + (fs->slice_x>>sh); - src[j] = f->last_picture.data[j] + f->last_picture.linesize[j]* + src[j] = f->last_picture.f->data[j] + f->last_picture.f->linesize[j]* (fs->slice_y>>sv) + (fs->slice_x>>sh); } av_image_copy(dst, p->linesize, (const uint8_t **)src, - f->last_picture.linesize, + f->last_picture.f->linesize, avctx->pix_fmt, fs->slice_width, fs->slice_height); @@ -839,10 +840,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac f->picture_number++; - av_frame_unref(&f->last_picture); - if ((ret = av_frame_ref(&f->last_picture, p)) < 0) - return ret; + if (f->last_picture.f) + ff_thread_release_buffer(avctx, &f->last_picture); f->cur = NULL; + if ((ret = av_frame_ref(data, f->picture.f)) < 0) + return ret; *got_frame = 1; |