From patchwork Wed Dec 2 04:22:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24253 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 3C39544A4E3 for ; Wed, 2 Dec 2020 06:24:47 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A3B168A755; Wed, 2 Dec 2020 06:24:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EF02368A2BC for ; Wed, 2 Dec 2020 06:24:38 +0200 (EET) Received: by mail-ej1-f68.google.com with SMTP id pg6so674185ejb.6 for ; Tue, 01 Dec 2020 20:24:38 -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:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=QAtSCx8niP0ZzisUoeIrLoTiTkBT0ugpF1GG0f7TmeA=; b=ViPW1xPoAvDduk9cWxjgLQzyI5A8LCGO99ah2gyKonPK6lYZRHf5pIMB7EcfpX603m UYCZANTiWzhFljiou4+pZDb5GGDxzHB19yhLsNFZ7OpiuK7rdj0p7HFXCZwpOlUuNxV8 AdecMzHl5SlJDk8oVP/IfcB1Xxw4rIen1ARzPdBp5715XE4F91NiUur9mc660/kOp11s cmVvWlkUS2NNUexo5miJi0HpH/6XMiaVrekxcRk69I4uq+6zpd1u1bO7O1OC0xqxSMXb TGaS1hIdPo9coEKssoK2Re5xXMVDpHNbQ0jb9Q4NGKA/IXzmZhPLXYPIv0cNKI7B2zWH /XCA== 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:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=QAtSCx8niP0ZzisUoeIrLoTiTkBT0ugpF1GG0f7TmeA=; b=VcypMhyQa1mgL/x6B5jkrh2yLDSkT00PkOtN23D2GVes1rV2zRdWBGVHSpRpP4OQfo rqSIz2V+RWYDL0mtXaThzyS1h03ALT5poxodisKWOiAGD20T/dlnd+79KtHzxAXkA1FA BQiXcwfits15wOT1umB0V2azB6N9v+XEKo8qcVPdB4BgZs86gm4CHN+NKdGbzZdSGSCJ NEmG9nNu/RxuJ13sdYhfpgd0NgDX9+whx+7q7ueMIPz4AoAPX3gQ0NMkM6a9nQz4Y7xO OC/91dW5ePjrOzNWaC2vrsUGJD9JGEabq5fi1vIAPnFN1gmLGieTuz8WYBXbhqc0OC/L IlYg== X-Gm-Message-State: AOAM532bUaucGocKBstHDjOcxUUbTyTKVR7tbKUyGc0yZ7eUYlgXjZ4q 4MVJWo8IzL+TTfMNwRPHNtXB0JRIhsxUUg== X-Google-Smtp-Source: ABdhPJyYoParv7i467/01T7mwDBlBcFX56WfD6KjRl09DMNCEHDfUk4ZW6eNeZPzxCXTQsvkSWahng== X-Received: by 2002:a17:906:958e:: with SMTP id r14mr574592ejx.319.1606883078195; Tue, 01 Dec 2020 20:24:38 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id mc25sm265087ejb.58.2020.12.01.20.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 20:24:37 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Dec 2020 05:22:40 +0100 Message-Id: <20201202042244.519127-79-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201127010249.2724610-1-andreas.rheinhardt@gmail.com> References: <20201127010249.2724610-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 213/217] avcodec/me_cmp: Remove ff_check_alignment() 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" The usage of a static variable presents a potential for data races and means that this function can't be used in init functions of codecs with FF_CODEC_CAP_INIT_THREADSAFE (unless of course one presumes that everything is alright in which case the error is not triggered; but then the whole function is pointless...). This makes the Snow decoder init-threadsafe as it already claims. Notice that this function has been removed in 2014 by Libav in commit 9103185bd116930f90b847090e66a64fa9971ce2, because only some codepaths are checked this way and because it only affects legacy compilers. The latter is of course even more true today. Signed-off-by: Andreas Rheinhardt --- libavcodec/me_cmp.c | 23 ----------------------- libavcodec/me_cmp.h | 2 -- libavcodec/mpegvideo_enc.c | 6 ------ 3 files changed, 31 deletions(-) diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c index ae248c52f8..34ecea9bb4 100644 --- a/libavcodec/me_cmp.c +++ b/libavcodec/me_cmp.c @@ -1011,31 +1011,8 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) WRAPPER8_16_SQ(rd8x8_c, rd16_c) WRAPPER8_16_SQ(bit8x8_c, bit16_c) -int ff_check_alignment(void) -{ - static int did_fail = 0; - LOCAL_ALIGNED_16(int, aligned, [4]); - - if ((intptr_t)aligned & 15) { - if (!did_fail) { -#if HAVE_MMX || HAVE_ALTIVEC - av_log(NULL, AV_LOG_ERROR, - "Compiler did not align stack variables. Libavcodec has been miscompiled\n" - "and may be very slow or crash. This is not a bug in libavcodec,\n" - "but in the compiler. You may try recompiling using gcc >= 4.2.\n" - "Do not report crashes to FFmpeg developers.\n"); -#endif - did_fail=1; - } - return -1; - } - return 0; -} - av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx) { - ff_check_alignment(); - c->sum_abs_dctelem = sum_abs_dctelem_c; /* TODO [0] 16 [1] 8 */ diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h index 0a589e3c3d..e9b5161c9a 100644 --- a/libavcodec/me_cmp.h +++ b/libavcodec/me_cmp.h @@ -79,8 +79,6 @@ typedef struct MECmpContext { me_cmp_func median_sad[6]; } MECmpContext; -int ff_check_alignment(void); - void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx); void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx); void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 7afc789ec0..878f507b57 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2785,8 +2785,6 @@ static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ static int estimate_motion_thread(AVCodecContext *c, void *arg){ MpegEncContext *s= *(void**)arg; - ff_check_alignment(); - s->me.dia_size= s->avctx->dia_size; s->first_slice_line=1; for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { @@ -2813,8 +2811,6 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ MpegEncContext *s= *(void**)arg; int mb_x, mb_y; - ff_check_alignment(); - for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) { for(mb_x=0; mb_x < s->mb_width; mb_x++) { int xx = mb_x * 16; @@ -2943,8 +2939,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ uint8_t bit_buf_tex[2][MAX_MB_BYTES]; PutBitContext pb[2], pb2[2], tex_pb[2]; - ff_check_alignment(); - for(i=0; i<2; i++){ init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES); init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);