summaryrefslogtreecommitdiff
path: root/libavcodec/vp9.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-02 13:33:46 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-04 08:03:19 +0200
commit0e0906726133519c59a2234162df66f53d755de0 (patch)
tree8d589ac57a7beab541b815dd6a2ac3867e99c886 /libavcodec/vp9.c
parenta4f7fabc2684890ea9fbcfaefb7503ab6633479f (diff)
downloadffmpeg-0e0906726133519c59a2234162df66f53d755de0.tar.gz
avcodec/vp9: Check initializing conditions/mutexes
Also don't destroy uninitialized conditions/mutexes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/vp9.c')
-rw-r--r--libavcodec/vp9.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 5c20a7ec5d..239475cdbe 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -27,6 +27,8 @@
#include "internal.h"
#include "profiles.h"
#include "thread.h"
+#include "pthread_internal.h"
+
#include "videodsp.h"
#include "vp56.h"
#include "vp9.h"
@@ -39,6 +41,10 @@
#define VP9_SYNCCODE 0x498342
#if HAVE_THREADS
+DEFINE_OFFSET_ARRAY(VP9Context, vp9_context, pthread_init_cnt,
+ (offsetof(VP9Context, progress_mutex)),
+ (offsetof(VP9Context, progress_cond)));
+
static void vp9_free_entries(AVCodecContext *avctx) {
VP9Context *s = avctx->priv_data;
@@ -1248,10 +1254,7 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx)
free_buffers(s);
vp9_free_entries(avctx);
#if HAVE_THREADS
- if (avctx->active_thread_type & FF_THREAD_SLICE) {
- pthread_mutex_destroy(&s->progress_mutex);
- pthread_cond_destroy(&s->progress_cond);
- }
+ ff_pthread_free(s, vp9_context_offsets);
#endif
av_freep(&s->td);
return 0;
@@ -1794,14 +1797,16 @@ static void vp9_decode_flush(AVCodecContext *avctx)
static av_cold int vp9_decode_init(AVCodecContext *avctx)
{
VP9Context *s = avctx->priv_data;
+ int ret;
s->last_bpp = 0;
s->s.h.filter.sharpness = -1;
#if HAVE_THREADS
if (avctx->active_thread_type & FF_THREAD_SLICE) {
- pthread_mutex_init(&s->progress_mutex, NULL);
- pthread_cond_init(&s->progress_cond, NULL);
+ ret = ff_pthread_init(s, vp9_context_offsets);
+ if (ret < 0)
+ return ret;
}
#endif