[FFmpeg-devel] [PATCH 28/39] avcodec/mpeg4video: Making initializing RLTable thread-safe

Anton Khirnov anton at khirnov.net
Sat Apr 17 16:53:27 EEST 2021


Quoting Andreas Rheinhardt (2020-12-10 12:16:46)
> Up until now the RLTable ff_mpeg4_rl_intra was initialized by both mpeg4
> decoder and encoder (except the VLCs that are only used by the decoder).
> This is an obstacle to making these codecs init-threadsafe, so move
> initializing this to a single function that is guarded by a dedicated
> AVOnce.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> Those ff_rl_init(&ff_rvlc_rl_inter/intra, ...) calls are actually
> superfluous: If these RLTables are in use, the parts initialized by
> ff_rl_init() are not used (see mpeg4_decode_block in mpeg4videodec.c).
> Yet I have no sample that actually triggers this codepath, so I haven't
> done it (rvlc stands for reversible VLC). It would be great if someone
> could provide me with samples for this.
> 
>  libavcodec/mpeg4video.c    | 14 +++++++++++++-
>  libavcodec/mpeg4video.h    |  3 +--
>  libavcodec/mpeg4videodec.c |  8 +++++---
>  libavcodec/mpeg4videoenc.c |  2 +-
>  4 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
> index e919db87a5..74470efb51 100644
> --- a/libavcodec/mpeg4video.h
> +++ b/libavcodec/mpeg4video.h
> @@ -129,6 +129,7 @@ extern const int8_t ff_mpeg4_intra_level[102];
>  extern const int8_t ff_mpeg4_intra_run[102];
>  
>  extern RLTable ff_mpeg4_rl_intra;
> +av_cold void ff_mpeg4_init_rl_intra(void);

Does it make sense to mark the prototype as av_cold?

Beyond that patch looks ok.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list