---
libavcodec/rv34.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index d27e9c1..8766e0d 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -703,7 +703,7 @@ static inline void rv34_mc(RV34DecContext *r, const int
block_type,
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
/* wait for the referenced mb row to be finished */
int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4);
- AVFrame *f = dir ? &s->next_picture_ptr->f : &s->last_picture_ptr->f;
+ ThreadFrame *f = dir ? &s->next_picture_ptr->tf :
&s->last_picture_ptr->tf;
ff_thread_await_progress(f, mb_row, 0);
}
@@ -864,7 +864,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type)
//surprisingly, it uses motion scheme from next reference frame
/* wait for the current mb row to be finished */
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
- ff_thread_await_progress(&s->next_picture_ptr->f, FFMAX(0,
s->mb_y-1), 0);
+ ff_thread_await_progress(&s->next_picture_ptr->tf, FFMAX(0,
s->mb_y-1), 0);
next_bt = s->next_picture_ptr->mb_type[s->mb_x + s->mb_y *
s->mb_stride];
if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){
@@ -1443,7 +1443,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end,
const uint8_t* buf, int
r->loop_filter(r, s->mb_y - 2);
if (HAVE_THREADS && (s->avctx->active_thread_type &
FF_THREAD_FRAME))
- ff_thread_report_progress(&s->current_picture_ptr->f,
+ ff_thread_report_progress(&s->current_picture_ptr->tf,
s->mb_y - 2, 0);
}
@@ -1502,6 +1502,8 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
+ avctx->internal->allocate_progress = 1;
+
return 0;
}
@@ -1519,6 +1521,9 @@ int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
if ((err = rv34_decoder_alloc(r)) < 0)
return err;
}
+
+ avctx->internal->allocate_progress = 1;
+
return 0;
}
@@ -1562,21 +1567,23 @@ static int finish_frame(AVCodecContext *avctx, AVFrame
*pict)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
- int got_picture = 0;
+ int got_picture = 0, ret;
ff_er_frame_end(&s->er);
ff_MPV_frame_end(s);
s->mb_num_left = 0;
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
+ ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
+ if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ return ret;
ff_print_debug_info(s, s->current_picture_ptr);
got_picture = 1;
} else if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
+ if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+ return ret;
ff_print_debug_info(s, s->last_picture_ptr);
got_picture = 1;
}
@@ -1594,7 +1601,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
MpegEncContext *s = &r->s;
AVFrame *pict = data;
SliceInfo si;
- int i;
+ int i, ret;
int slice_count;
const uint8_t *slices_hdr = NULL;
int last = 0;
@@ -1603,7 +1610,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
- *pict = s->next_picture_ptr->f;
+ if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
+ return ret;
s->next_picture_ptr = NULL;
*got_picture_ptr = 1;
@@ -1760,7 +1768,10 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
if(r->loop_filter)
r->loop_filter(r, s->mb_height - 1);
- *got_picture_ptr = finish_frame(avctx, pict);
+ ret = finish_frame(avctx, pict);
+ if (ret < 0)
+ return ret;
+ *got_picture_ptr = ret;
} else if (HAVE_THREADS &&
(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n");
@@ -1769,7 +1780,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
ff_er_frame_end(&s->er);
ff_MPV_frame_end(s);
s->mb_num_left = 0;
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
+ ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);
return AVERROR_INVALIDDATA;
}
}
--
1.7.10.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel