From patchwork Thu Dec 10 11:16:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24495 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7F8514495E8 for ; Thu, 10 Dec 2020 13:23:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B0C468A0EA; Thu, 10 Dec 2020 13:23:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A1DEA68A1C8 for ; Thu, 10 Dec 2020 13:23:03 +0200 (EET) Received: by mail-wm1-f43.google.com with SMTP id e25so4918571wme.0 for ; Thu, 10 Dec 2020 03:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; bh=rxRIS4mwhay+bY4sPMOpFOLKb6H+/VWYlGn6n24lgn8=; b=aqwy4iH9ClY2zUuFiOvQAr+FpDrENdPB7kZ6keXyCRxsTRvvYO2JV8WDqL5aqHr+C+ 9gfrqRd/nEjAtYJLTJYI3jIql+rX8jY1w10aZqbSqfX82/yoJhj7GlELEi9frbtHIvxE LcdlE/knbSmR3MkWyHXt4QUjqPRHZwyPcc1uokfzXV9utZoxTUEa7/oO7JnjRe4//taG 8Q6Fl3v2xPeLafIKXLMT/uEOx2Rnn/bSMxSK6/H9pY7dOHXEtjIWV97DFlPezeEHsBFj hv4ORMvTCwytd2Pzh9+1wlia24+GcrXRmDbaVBd5Ej+v+KeEP+44y6mW3nscw9OHWMxM OcGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :mime-version:content-transfer-encoding; bh=rxRIS4mwhay+bY4sPMOpFOLKb6H+/VWYlGn6n24lgn8=; b=ZmaBY6/lYZLSTgNhouIH+c+wuGD5UMoEbZAldRB+zVPR2Fj8206o8HppHQY9Yqyjuc shfyKbg30ACFuOFhpF4MX11X6eAjD1RWotnxLhYVE+/cY9DbszQAVaNRlH7Fag3Ti/rL tV1HjA20Fw24iV1WKJEyZKliE390bgwDJHKxV+RHCS9vNoX8Jxz17VtLYmYgylNnb2tn BL0SLdCHnIBJAyAXK2vGbIMZXLt1RGQr49mEcf1hO7m31mZi7atJFMdXhQBJ1KudTLFF 8L48sIUhMcS6fbmimgbCprAE3Z3YprqSZ1nyw8sHqpoktqN2qLzXq84rFLdhUqAECBqb dghQ== X-Gm-Message-State: AOAM533IGE950+u3dqcQ9skHRI6Xzk5KYGxa1ZyNplk2uhsVJ+63Wlob RvAeDFRVEksdN+neVFUJTY/r7BUpfMfduQ== X-Google-Smtp-Source: ABdhPJzllP3gjtYWQU13LR1n/9HXucbw34BduCPjjdIz6Wxh6kcebczBPTcIKeVNQYC2ivmOF4dYiA== X-Received: by 2002:a1c:2cc2:: with SMTP id s185mr7442562wms.111.1607599025989; Thu, 10 Dec 2020 03:17:05 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id s133sm8942330wmf.38.2020.12.10.03.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 03:17:05 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 12:16:18 +0100 Message-Id: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 00/39] Make mpegvideo encoders init-threadsafe X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This patchset makes all mpegvideo encoders (i.e. all those that use ff_mpv_encode_init()) init-threadsafe; some of the patches here supersede earlier patches (namely #214-216 from my earlier init-threadsafe patchset [1] as well as patches from the latter part of my init-vlc patchset (said part actually dealt with init-threadsafety), namely #181-183 [2]); also an error in [3] (which was not applied because of this) is corrected (the earlier patch ignored that the RLTables used by mpeg1/2 are initialized at two different places, so guarding one of them with an AVOnce is not enough). In order to make this patchset self-contained [4] from my earlier init-threadsafe patchset has been included here unchanged. Furthermore, there are also numerous fixes for RLTables interwoven in this patchset. Finally, the SpeedHQ encoder has also received attention. It called the wrong function, leading to potential segfaults. The mpegvideo decoders are my next target. [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-December/273287.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-November/272876.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-November/272873.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-December/273286.html Andreas Rheinhardt (39): avcodec/rl: Remove nonstatic storage of RL tables avcodec/mpeg12: Don't initialize encoder-only parts of RLTable avcodec/mpeg12: Make initializing VLCs thread-safe avcodec/mpeg12: Reindentation avcodec/mpeg12enc, speedhqenc: Avoid redundant copies of tables avcodec/speedhq: Remove cast avcodec/rl: Allow to create only a few VLC tables avcodec/h261dec: Don't initialize unused VLCs avcodec/msmpeg4dec: Don't initialize unused RL VLCs avcodec/mpeg4videodec: Don't initialize unused RL VLCs avcodec/ituh263dec: Don't initialize unused RL VLCs avcodec/msmpeg4dec: Reuse identical RL VLCs avcodec/msmpeg4dec: Reuse identical MV VLC avcodec/h261dec: Don't use too big max_depth in get_vlc2() avcodec/mpegvideo: Merge ff_mpv_decode_defaults into ff_mpv_decode_init avcodec/mpeg12dec: Remove redundant writes avcodec/me_cmp: Remove ff_check_alignment() avcodec/motion_est, mpegvideo: Make pointers to static storage const avcodec/mpegvideo_enc: Make mpv_encode_defaults thread-safe avcodec/h261dec: Don't initialize unused part of RLTable avcodec/h261dec: Make decoder init-threadsafe avcodec/h261dec: Reindentation avcodec/h261enc: Make encoder init-threadsafe avcodec/ituh263dec: Don't initialize unused parts of RLTable avcodec/ituh263enc: Remove unused function parameter avcodec/h263data, ituh263*: Make initializing RL inter table thread-safe avcodec/ituh263enc: Make static initializations thread-safe avcodec/mpeg4video: Making initializing RLTable thread-safe avcodec/mpeg4videoenc: Make encoder init-threadsafe avcodec/msmpeg4: Make ff_msmpeg4_common_init() thread-safe avcodec/msmpeg4: Reindentation avcodec/msmpeg4enc: Don't use code for static init that can fail avcodec/msmpeg4: Factor out common RLTable initialization code avcodec/msmpeg4enc: Make msmpeg4 encoders init-threadsafe avcodec/msmpeg4enc: Reindent after the last commit avcodec/speedhqenc: Call correct function avcodec/speedhq, speedhqenc: Make codecs init-threadsafe avcodec/speedhqenc: Hardcode table to save space configure, libavcodec/speedhq: Fix compiling SpeedHQ encoder configure | 1 + libavcodec/Makefile | 2 +- libavcodec/eamad.c | 1 + libavcodec/eatqi.c | 1 + libavcodec/flvenc.c | 2 +- libavcodec/h261.c | 13 ---- libavcodec/h261.h | 3 - libavcodec/h261dec.c | 45 ++++++------- libavcodec/h261enc.c | 16 +++-- libavcodec/h263.h | 2 + libavcodec/h263data.c | 16 ++++- libavcodec/h263data.h | 2 +- libavcodec/h263dec.c | 1 - libavcodec/ituh263dec.c | 12 ++-- libavcodec/ituh263enc.c | 39 +++++------ libavcodec/mdec.c | 1 + libavcodec/me_cmp.c | 23 ------- libavcodec/me_cmp.h | 2 - libavcodec/mjpegenc.c | 4 +- libavcodec/motion_est.c | 12 ++-- libavcodec/motion_est.h | 4 +- libavcodec/motion_est_template.c | 2 +- libavcodec/mpeg12.c | 67 +++++++++---------- libavcodec/mpeg12.h | 3 +- libavcodec/mpeg12dec.c | 17 ++--- libavcodec/mpeg12enc.c | 31 +++++---- libavcodec/mpeg4video.c | 14 +++- libavcodec/mpeg4video.h | 3 +- libavcodec/mpeg4videodec.c | 12 ++-- libavcodec/mpeg4videoenc.c | 26 ++++---- libavcodec/mpegvideo.c | 7 +- libavcodec/mpegvideo.h | 3 +- libavcodec/mpegvideo_enc.c | 34 +++++----- libavcodec/msmpeg4.c | 110 +++++++++++++++++-------------- libavcodec/msmpeg4.h | 2 +- libavcodec/msmpeg4data.c | 1 - libavcodec/msmpeg4data.h | 1 - libavcodec/msmpeg4dec.c | 23 +++---- libavcodec/msmpeg4enc.c | 63 ++++++++---------- libavcodec/rl.c | 53 ++++----------- libavcodec/rl.h | 19 +++--- libavcodec/rv10.c | 1 - libavcodec/rv10enc.c | 2 +- libavcodec/rv20enc.c | 2 +- libavcodec/rv34.c | 1 - libavcodec/speedhq.c | 9 +-- libavcodec/speedhqenc.c | 47 ++++--------- libavcodec/wmv2enc.c | 2 +- 48 files changed, 339 insertions(+), 418 deletions(-)