Simplify ff_await_decode_progress.
Always set and allocate the progress pointer, so
ff_await_decode_progress doesn't have to check for threading to be on.
---
libavcodec/framethread.c | 28 ++++++++++------------------
1 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/libavcodec/framethread.c b/libavcodec/framethread.c
index f707cf3..3cd83d2 100644
--- a/libavcodec/framethread.c
+++ b/libavcodec/framethread.c
@@ -172,13 +172,10 @@ int ff_decode_frame_threaded(AVCodecContext *avctx,
}
void ff_report_decode_progress(AVFrame *f, int n) {
- PerThreadContext *p;
- int *progress;
-
- if (!f->avctx->thread_opaque) return;
+ PerThreadContext *p = f->avctx->thread_opaque;
+ int *progress = f->thread_opaque;
- p = f->avctx->thread_opaque;
- progress = f->thread_opaque;
+ if (!p) {*progress = n; return;}
pthread_mutex_lock(&p->progress_mutex);
*progress = n;
@@ -187,13 +184,8 @@ void ff_report_decode_progress(AVFrame *f, int n) {
}
void ff_await_decode_progress(AVFrame *f, int n) {
- PerThreadContext *p;
- int * volatile progress;
-
- if (!f->avctx->thread_opaque) return;
-
- p = f->avctx->thread_opaque;
- progress = f->thread_opaque;
+ PerThreadContext *p = f->avctx->thread_opaque;
+ int * volatile progress = f->thread_opaque;
if (*progress >= n) return;
@@ -311,6 +303,9 @@ int ff_mt_get_buffer(AVCodecContext *avctx, AVFrame *f)
f->avctx = avctx;
+ f->thread_opaque = progress = av_malloc(sizeof(int));
+ *progress = -1;
+
if (!p) {
return avctx->get_buffer(avctx, f);
}
@@ -319,9 +314,6 @@ int ff_mt_get_buffer(AVCodecContext *avctx, AVFrame *f)
ret = avctx->get_buffer(avctx, f);
pthread_mutex_unlock(&p->buffer_mutex);
- f->thread_opaque = progress = av_malloc(sizeof(int));
- *progress = -1;
-
return ret;
}
@@ -329,6 +321,8 @@ void ff_mt_release_buffer(AVFrame *f)
{
PerThreadContext *p = f->avctx->thread_opaque;
+ av_freep(&f->thread_opaque);
+
if (!p) {
f->avctx->release_buffer(f->avctx, f);
return;
@@ -337,6 +331,4 @@ void ff_mt_release_buffer(AVFrame *f)
pthread_mutex_lock(&p->buffer_mutex);
f->avctx->release_buffer(f->avctx, f);
pthread_mutex_unlock(&p->buffer_mutex);
-
- av_freep(&f->thread_opaque);
}
--
1.5.5.1
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc