mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/vp9: Check initializing conditions/mutexes
Also don't destroy uninitialized conditions/mutexes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
a4f7fabc26
commit
0e09067261
|
@ -27,6 +27,8 @@
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "profiles.h"
|
#include "profiles.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include "pthread_internal.h"
|
||||||
|
|
||||||
#include "videodsp.h"
|
#include "videodsp.h"
|
||||||
#include "vp56.h"
|
#include "vp56.h"
|
||||||
#include "vp9.h"
|
#include "vp9.h"
|
||||||
|
@ -39,6 +41,10 @@
|
||||||
#define VP9_SYNCCODE 0x498342
|
#define VP9_SYNCCODE 0x498342
|
||||||
|
|
||||||
#if HAVE_THREADS
|
#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) {
|
static void vp9_free_entries(AVCodecContext *avctx) {
|
||||||
VP9Context *s = avctx->priv_data;
|
VP9Context *s = avctx->priv_data;
|
||||||
|
|
||||||
|
@ -1248,10 +1254,7 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx)
|
||||||
free_buffers(s);
|
free_buffers(s);
|
||||||
vp9_free_entries(avctx);
|
vp9_free_entries(avctx);
|
||||||
#if HAVE_THREADS
|
#if HAVE_THREADS
|
||||||
if (avctx->active_thread_type & FF_THREAD_SLICE) {
|
ff_pthread_free(s, vp9_context_offsets);
|
||||||
pthread_mutex_destroy(&s->progress_mutex);
|
|
||||||
pthread_cond_destroy(&s->progress_cond);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
av_freep(&s->td);
|
av_freep(&s->td);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1794,14 +1797,16 @@ static void vp9_decode_flush(AVCodecContext *avctx)
|
||||||
static av_cold int vp9_decode_init(AVCodecContext *avctx)
|
static av_cold int vp9_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
VP9Context *s = avctx->priv_data;
|
VP9Context *s = avctx->priv_data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
s->last_bpp = 0;
|
s->last_bpp = 0;
|
||||||
s->s.h.filter.sharpness = -1;
|
s->s.h.filter.sharpness = -1;
|
||||||
|
|
||||||
#if HAVE_THREADS
|
#if HAVE_THREADS
|
||||||
if (avctx->active_thread_type & FF_THREAD_SLICE) {
|
if (avctx->active_thread_type & FF_THREAD_SLICE) {
|
||||||
pthread_mutex_init(&s->progress_mutex, NULL);
|
ret = ff_pthread_init(s, vp9_context_offsets);
|
||||||
pthread_cond_init(&s->progress_cond, NULL);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ typedef struct VP9Context {
|
||||||
pthread_mutex_t progress_mutex;
|
pthread_mutex_t progress_mutex;
|
||||||
pthread_cond_t progress_cond;
|
pthread_cond_t progress_cond;
|
||||||
atomic_int *entries;
|
atomic_int *entries;
|
||||||
|
unsigned pthread_init_cnt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t ss_h, ss_v;
|
uint8_t ss_h, ss_v;
|
||||||
|
|
Loading…
Reference in New Issue