diff mbox series

[FFmpeg-devel,2/8] avcodec/h264_cavlc: Remove redundant check

Message ID 20210310010601.1142819-2-andreas.rheinhardt@gmail.com
State Accepted
Commit b41e4f6187a10e729288fcf9ff5584f47a6a34e9
Headers show
Series [FFmpeg-devel,1/8] avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 10, 2021, 1:05 a.m. UTC
The only caller to ff_h264_decode_init_vlc() already uses
ff_thread_once() for the call; ergo the check via a simple int with
static storage duration in ff_h264_decode_init_vlc() is redundant.
And if it were not redundant, it would be a potential for data races.
So remove it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/h264_cavlc.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Andreas Rheinhardt March 12, 2021, 11:03 p.m. UTC | #1
Andreas Rheinhardt:
> The only caller to ff_h264_decode_init_vlc() already uses
> ff_thread_once() for the call; ergo the check via a simple int with
> static storage duration in ff_h264_decode_init_vlc() is redundant.
> And if it were not redundant, it would be a potential for data races.
> So remove it.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/h264_cavlc.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
> index 6481992e58..d0548d84f6 100644
> --- a/libavcodec/h264_cavlc.c
> +++ b/libavcodec/h264_cavlc.c
> @@ -325,12 +325,8 @@ static av_cold void init_cavlc_level_tab(void){
>  }
>  
>  av_cold void ff_h264_decode_init_vlc(void){
> -    static int done = 0;
> -
> -    if (!done) {
>          int i;
>          int offset;
> -        done = 1;
>  
>          chroma_dc_coeff_token_vlc.table = chroma_dc_coeff_token_vlc_table;
>          chroma_dc_coeff_token_vlc.table_allocated = chroma_dc_coeff_token_vlc_table_size;
> @@ -410,7 +406,6 @@ av_cold void ff_h264_decode_init_vlc(void){
>                   INIT_VLC_USE_NEW_STATIC);
>  
>          init_cavlc_level_tab();
> -    }
>  }
>  
>  static inline int get_level_prefix(GetBitContext *gb){
> 
Will apply patches 2-5 of this patchset tomorrow unless there are
objections.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 6481992e58..d0548d84f6 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -325,12 +325,8 @@  static av_cold void init_cavlc_level_tab(void){
 }
 
 av_cold void ff_h264_decode_init_vlc(void){
-    static int done = 0;
-
-    if (!done) {
         int i;
         int offset;
-        done = 1;
 
         chroma_dc_coeff_token_vlc.table = chroma_dc_coeff_token_vlc_table;
         chroma_dc_coeff_token_vlc.table_allocated = chroma_dc_coeff_token_vlc_table_size;
@@ -410,7 +406,6 @@  av_cold void ff_h264_decode_init_vlc(void){
                  INIT_VLC_USE_NEW_STATIC);
 
         init_cavlc_level_tab();
-    }
 }
 
 static inline int get_level_prefix(GetBitContext *gb){