• Andreas Rheinhardt's avatar
    avcodec/hevc_filter: Pass HEVCLocalContext when slice-threading · 8c4f95e1
    Andreas Rheinhardt authored
    The HEVC decoder has both HEVCContext and HEVCLocalContext
    structures. The latter is supposed to be the structure
    containing the per-slicethread state.
    
    Yet that is not how it is handled in practice: Each HEVCLocalContext
    has a unique HEVCContext allocated for it and each of these
    coincides with the main HEVCContext except in exactly one field:
    The corresponding HEVCLocalContext.
    This makes it possible to pass the HEVCContext everywhere where
    logically a HEVCLocalContext should be used.
    
    This commit stops doing this for lavc/hevc_filter.c; it also constifies
    everything that is possible in order to ensure that no slice thread
    accidentally modifies the main HEVCContext state.
    
    There are places where this was not possible, namely with the SAOParams
    in sao_filter_CTB() or with sao_pixels_buffer_h in copy_CTB_to_hv().
    Both of these instances lead to data races, see
    https://fate.ffmpeg.org/report.cgi?time=20220629145651&slot=x86_64-archlinux-gcc-tsan-slicesSigned-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
    8c4f95e1
hevc_filter.c 39.1 KB