mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/svq1dec: Make decoder init-threadsafe
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
5baee59301
commit
da860802ad
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include "libavutil/crc.h"
|
||||
#include "libavutil/thread.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
|
@ -762,22 +763,8 @@ err:
|
|||
return result;
|
||||
}
|
||||
|
||||
static av_cold int svq1_decode_init(AVCodecContext *avctx)
|
||||
static av_cold void svq1_static_init(void)
|
||||
{
|
||||
SVQ1Context *s = avctx->priv_data;
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
s->prev = av_frame_alloc();
|
||||
if (!s->prev)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
s->width = avctx->width + 3 & ~3;
|
||||
s->height = avctx->height + 3 & ~3;
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
|
||||
|
||||
ff_hpeldsp_init(&s->hdsp, avctx->flags);
|
||||
|
||||
INIT_VLC_STATIC(&svq1_block_type, 2, 4,
|
||||
&ff_svq1_block_type_vlc[0][1], 2, 1,
|
||||
&ff_svq1_block_type_vlc[0][0], 2, 1, 6);
|
||||
|
@ -786,7 +773,7 @@ static av_cold int svq1_decode_init(AVCodecContext *avctx)
|
|||
&ff_mvtab[0][1], 2, 1,
|
||||
&ff_mvtab[0][0], 2, 1, 176);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (int i = 0, offset = 0; i < 6; i++) {
|
||||
static const uint8_t sizes[2][6] = { { 14, 10, 14, 18, 16, 18 },
|
||||
{ 10, 10, 14, 14, 14, 16 } };
|
||||
static VLC_TYPE table[168][2];
|
||||
|
@ -813,6 +800,24 @@ static av_cold int svq1_decode_init(AVCodecContext *avctx)
|
|||
INIT_VLC_STATIC(&svq1_inter_mean, 9, 512,
|
||||
&ff_svq1_inter_mean_vlc[0][1], 4, 2,
|
||||
&ff_svq1_inter_mean_vlc[0][0], 4, 2, 1434);
|
||||
}
|
||||
|
||||
static av_cold int svq1_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||
SVQ1Context *s = avctx->priv_data;
|
||||
|
||||
s->prev = av_frame_alloc();
|
||||
if (!s->prev)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
s->width = avctx->width + 3 & ~3;
|
||||
s->height = avctx->height + 3 & ~3;
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
|
||||
|
||||
ff_hpeldsp_init(&s->hdsp, avctx->flags);
|
||||
|
||||
ff_thread_once(&init_static_once, svq1_static_init);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -848,4 +853,5 @@ AVCodec ff_svq1_decoder = {
|
|||
.flush = svq1_flush,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P,
|
||||
AV_PIX_FMT_NONE },
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue