diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-14 23:06:06 +0200 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-14 23:06:06 +0200 |
commit | 15db457ea8f76cd03a371dee548b7dbc60efcb86 (patch) | |
tree | a9e15a657bac4ccfbc3a4dd433883944dbdfc4e7 | |
parent | f05021f3f49a45b36411ec9de3cd7522dc9f9110 (diff) | |
parent | d15368ee3926152a3a301c13cc638fbf7a062ddf (diff) | |
download | ffmpeg-15db457ea8f76cd03a371dee548b7dbc60efcb86.tar.gz |
Merge commit 'd15368ee3926152a3a301c13cc638fbf7a062ddf'
* commit 'd15368ee3926152a3a301c13cc638fbf7a062ddf':
h264: Run VLC init under pthread_once
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
-rw-r--r-- | libavcodec/h264.c | 9 | ||||
-rw-r--r-- | libavcodec/h264.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 3209c9c4a7..fff65bc670 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -644,6 +644,8 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h) return 0; } +static AVOnce h264_vlc_init = AV_ONCE_INIT; + av_cold int ff_h264_decode_init(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; @@ -657,7 +659,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) if (!avctx->has_b_frames) h->low_delay = 1; - ff_h264_decode_init_vlc(); + ret = ff_thread_once(&h264_vlc_init, ff_h264_decode_init_vlc); + if (ret != 0) { + av_log(avctx, AV_LOG_ERROR, "pthread_once has failed."); + return AVERROR_UNKNOWN; + } if (avctx->codec_id == AV_CODEC_ID_H264) { if (avctx->ticks_per_frame == 1) { @@ -1993,6 +1999,7 @@ AVCodec ff_h264_decoder = { .capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .flush = flush_dpb, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context), diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 769abdad4b..b3d08c3d11 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -29,6 +29,7 @@ #define AVCODEC_H264_H #include "libavutil/intreadwrite.h" +#include "libavutil/thread.h" #include "cabac.h" #include "error_resilience.h" #include "get_bits.h" |