mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/speedhq, speedhqenc: Make codecs init-threadsafe
The SpeedHQ decoder uses and initializes a RLTable's VLC, yet it also initializes other parts of the RLTable that it does not use. This has downsides besides being wasteful: Because the SpeedHQ encoder also initializes these additional fields, there is a potential for data races (and therefore undefined behaviour). In fact, removing the superfluous initializations from the decoder automatically makes both the decoder and the encoder init-threadsafe. This commit does so. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
8ab2bb81b2
commit
b05631f7b9
@ -155,8 +155,6 @@ static const uint8_t unscaled_quant_matrix[64] = {
|
|||||||
27, 29, 35, 38, 46, 56, 69, 83
|
27, 29, 35, 38, 46, 56, 69, 83
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t speedhq_static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
|
|
||||||
|
|
||||||
static VLC dc_lum_vlc_le;
|
static VLC dc_lum_vlc_le;
|
||||||
static VLC dc_chroma_vlc_le;
|
static VLC dc_chroma_vlc_le;
|
||||||
static VLC dc_alpha_run_vlc_le;
|
static VLC dc_alpha_run_vlc_le;
|
||||||
@ -648,7 +646,6 @@ static av_cold void speedhq_static_init(void)
|
|||||||
ff_mpeg12_vlc_dc_chroma_code, 2, 2,
|
ff_mpeg12_vlc_dc_chroma_code, 2, 2,
|
||||||
INIT_VLC_OUTPUT_LE, 514);
|
INIT_VLC_OUTPUT_LE, 514);
|
||||||
|
|
||||||
ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store);
|
|
||||||
INIT_2D_VLC_RL(ff_rl_speedhq, 674, INIT_VLC_LE);
|
INIT_2D_VLC_RL(ff_rl_speedhq, 674, INIT_VLC_LE);
|
||||||
|
|
||||||
compute_alpha_vlcs();
|
compute_alpha_vlcs();
|
||||||
@ -733,5 +730,6 @@ const AVCodec ff_speedhq_decoder = {
|
|||||||
.init = speedhq_decode_init,
|
.init = speedhq_decode_init,
|
||||||
.decode = speedhq_decode_frame,
|
.decode = speedhq_decode_frame,
|
||||||
.capabilities = AV_CODEC_CAP_DR1,
|
.capabilities = AV_CODEC_CAP_DR1,
|
||||||
|
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_SPEEDHQ_DECODER */
|
#endif /* CONFIG_SPEEDHQ_DECODER */
|
||||||
|
@ -298,7 +298,7 @@ const AVCodec ff_speedhq_encoder = {
|
|||||||
.init = ff_mpv_encode_init,
|
.init = ff_mpv_encode_init,
|
||||||
.encode2 = ff_mpv_encode_picture,
|
.encode2 = ff_mpv_encode_picture,
|
||||||
.close = ff_mpv_encode_end,
|
.close = ff_mpv_encode_end,
|
||||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||||
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
|
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
|
||||||
AV_PIX_FMT_NONE
|
AV_PIX_FMT_NONE
|
||||||
|
Loading…
Reference in New Issue
Block a user