mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/ituh263dec: Make initializing VLCs thread-safe
This automatically makes the FLV, H.263, H.263+, Intel H.263, MPEG-4, RealVideo 1.0 and RealVideo 2.0 decoders init-threadsafe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
6b39573547
commit
f326855947
|
@ -123,7 +123,8 @@ const AVCodec ff_flv_decoder = {
|
|||
.close = ff_h263_decode_end,
|
||||
.decode = ff_h263_decode_frame,
|
||||
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
|
||||
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
|
||||
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.max_lowres = 3,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NONE },
|
||||
|
|
|
@ -772,7 +772,8 @@ const AVCodec ff_h263_decoder = {
|
|||
AV_CODEC_CAP_TRUNCATED |
|
||||
#endif
|
||||
AV_CODEC_CAP_DELAY,
|
||||
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
|
||||
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.flush = ff_mpeg_flush,
|
||||
.max_lowres = 3,
|
||||
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
|
||||
|
@ -793,7 +794,8 @@ const AVCodec ff_h263p_decoder = {
|
|||
AV_CODEC_CAP_TRUNCATED |
|
||||
#endif
|
||||
AV_CODEC_CAP_DELAY,
|
||||
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
|
||||
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.flush = ff_mpeg_flush,
|
||||
.max_lowres = 3,
|
||||
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
|
||||
|
|
|
@ -139,7 +139,8 @@ const AVCodec ff_h263i_decoder = {
|
|||
.close = ff_h263_decode_end,
|
||||
.decode = ff_h263_decode_frame,
|
||||
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
|
||||
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
|
||||
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NONE
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "libavutil/internal.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/thread.h"
|
||||
#include "avcodec.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "h263.h"
|
||||
|
@ -103,12 +104,8 @@ static VLC cbpc_b_vlc;
|
|||
|
||||
/* init vlcs */
|
||||
|
||||
/* XXX: find a better solution to handle static init */
|
||||
av_cold void ff_h263_decode_init_vlc(void)
|
||||
static av_cold void h263_decode_init_vlc(void)
|
||||
{
|
||||
static volatile int done = 0;
|
||||
|
||||
if (!done) {
|
||||
INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
|
||||
ff_h263_intra_MCBPC_bits, 1, 1,
|
||||
ff_h263_intra_MCBPC_code, 1, 1, 72);
|
||||
|
@ -130,8 +127,12 @@ av_cold void ff_h263_decode_init_vlc(void)
|
|||
INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
|
||||
&ff_cbpc_b_tab[0][1], 2, 1,
|
||||
&ff_cbpc_b_tab[0][0], 2, 1, 8);
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
av_cold void ff_h263_decode_init_vlc(void)
|
||||
{
|
||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||
ff_thread_once(&init_static_once, h263_decode_init_vlc);
|
||||
}
|
||||
|
||||
int ff_h263_decode_mba(MpegEncContext *s)
|
||||
|
|
|
@ -3674,7 +3674,8 @@ const AVCodec ff_mpeg4_decoder = {
|
|||
AV_CODEC_CAP_TRUNCATED |
|
||||
#endif
|
||||
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS,
|
||||
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
|
||||
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
|
||||
FF_CODEC_CAP_ALLOCATE_PROGRESS,
|
||||
.flush = ff_mpeg_flush,
|
||||
.max_lowres = 3,
|
||||
|
|
|
@ -691,6 +691,7 @@ const AVCodec ff_rv10_decoder = {
|
|||
.close = rv10_decode_end,
|
||||
.decode = rv10_decode_frame,
|
||||
.capabilities = AV_CODEC_CAP_DR1,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
||||
.max_lowres = 3,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_YUV420P,
|
||||
|
@ -708,6 +709,7 @@ const AVCodec ff_rv20_decoder = {
|
|||
.close = rv10_decode_end,
|
||||
.decode = rv10_decode_frame,
|
||||
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
||||
.flush = ff_mpeg_flush,
|
||||
.max_lowres = 3,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
|
|
Loading…
Reference in New Issue