From patchwork Mon Nov 27 04:30:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rostislav Pehlivanov X-Patchwork-Id: 6392 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1213261jah; Sun, 26 Nov 2017 20:30:40 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDwPxEzYVE1Pnf5JljU2VTUWWj32Z7FB0OpN72t5JUswvsvULiJHiUao5bCGbwTYTeiqpp X-Received: by 10.223.159.15 with SMTP id l15mr24254349wrf.155.1511757040684; Sun, 26 Nov 2017 20:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511757040; cv=none; d=google.com; s=arc-20160816; b=deKXle11Kwz0oNXavOBCZi24NV+8Csr/k4E9B79ZNpXe0CSORlTtFvZldNAICG+jek I2gx8YcA0DhRAXE8qRyUryBYHpBWhGNYmiHLH2QPTjTt9x1rNLGyAVIteZ4Ir0tObZoh jmfXwrYws2kBxbvZbA2g7wpENhDQ3A7BeA0w9mZzkl/qi1ieIL2HrvNElEUgIcdphiLZ evuDUfbqikKRPmYcFZOy2KcDMzbV8r+ZHI1cSZ7Ya67sfvxVIuEe1M7HNHn1UZcnEVvO dZBfUMq1LAM94FQsI2TSG8B/WOlY3KK/H+s1rAnKxYZK+0mmSrs4zw3rATXvEwzalUld 8xFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=dslXC1uDASsHKzKvDljGU2efezMA/0t6XYAMe4cSUOk=; b=SLytb5y3snPaLEUbOw5QnjUy9nFn6qTxrH7eSB79hwruI0w5tRGbEXCDAPiv4OwJKd D9YIMZ7plt7KjAOWLm/pVWVnCWJ/jnYpmfhirp5tZuQfSWHSUiI/NphcNhvHF/svTALK 2wPd6CEoYmuqQ7OMmTqJ/LufYNJOtYUN+Re6HBQHF0S4y6ebQRUPmgtAMi47BozH714K ZoqTEo09JGagxQrsRy1Y3fZyvZGs+O2W+J+5Tg27Pp5HYbJAhwTCo8ucQP/x6P209qmP 5Ige9Ft+IjuiUa/Ku0U8BQrhcNlXcB0vK9EDonbtwRY7ZSFjvfnKu5M1QL/6E6c1qHAb 0IRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=SJpl4fcm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f57si22213786wra.422.2017.11.26.20.30.40; Sun, 26 Nov 2017 20:30:40 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=SJpl4fcm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1ACEB689D60; Mon, 27 Nov 2017 06:30:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7CD9A688290 for ; Mon, 27 Nov 2017 06:30:24 +0200 (EET) Received: by mail-wr0-f195.google.com with SMTP id r2so18685704wra.13 for ; Sun, 26 Nov 2017 20:30:26 -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; bh=c8EJ+ig3eEVGYoqR7w+J9thRQrexiFFDqjH6KMkGUho=; b=SJpl4fcmR8rA3cf8awSbexbQ0lSTJVz86QuvoADpziegECsI/g6zvrwB0MbUOlMnRE GqoiX/+wmexs1ik09Vit8RonLaxf/ZhcH8mlVn3Mfof+3b6+++pI7COmHuMcx0xTkNPi cb4YC5yFLDi/GgZaM+6MQN/tnRNZzO1RJMGMRb7R42MOM0RPp8XNtutakHcbPquSukCM AyPETzgm6GwXehurYu6c+do6aK5LHbeDQhvPcq/9pFYt86E8ddcI+jxa0PKaleo6zHYl VvqGNi4EtMHE9VsvgriDcsHZOB9plX3aIj5causuO6Xqqyah9PiyZDM8ll2ztN9tMMRk Ytww== 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; bh=c8EJ+ig3eEVGYoqR7w+J9thRQrexiFFDqjH6KMkGUho=; b=JVFZj/i72NTMSWmx6IXhRoquRL8EEeunFB9DQO7ibNw0YVCKlM80r1N81cw/LAMEL6 YDwHq0d6KT14S7hMe4Rjq4uN24DQ111J0lnF2sqUgw4NfyYqu1LpSR9NQOdIrnnD2LPb 9fQe46MgvkQ5vO6Nm0ewKc+DB1ztIM58bNi8vVvDkifYKOjURgq4mq9rbmgx3H/umlpP vJ5eXUqOGcAuE1SMrzpua4i4ADbeTUi4sKknAJb8YF2Cu3oZ3pMTROtCfRPNl/qA2rDC /dop6iy3U9/qP9RWfvbCC1tpyWETXM/A/liQrIHc5dsfqBjQslY44tSTBazIB0Ekbrq2 FD+A== X-Gm-Message-State: AJaThX4LokbP9Cylmg0EzTYuXvnC+109ZAAoL1kLvO9uf5pRkr0TXwMe t/OjbPvXPjgQdML04JwIlZmrAb6e X-Received: by 10.223.135.179 with SMTP id b48mr34368584wrb.24.1511757025915; Sun, 26 Nov 2017 20:30:25 -0800 (PST) Received: from moonbase.pars.ee ([2a00:23c4:7c83:f700:5813:5124:6fa1:dad9]) by smtp.gmail.com with ESMTPSA id 68sm20151547wmh.2.2017.11.26.20.30.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Nov 2017 20:30:24 -0800 (PST) From: Rostislav Pehlivanov To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Nov 2017 04:30:20 +0000 Message-Id: <20171127043021.20321-3-atomnuker@gmail.com> X-Mailer: git-send-email 2.15.0.417.g466bffb3ac In-Reply-To: <20171127043021.20321-1-atomnuker@gmail.com> References: <20171127043021.20321-1-atomnuker@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/4] lavf/format: simplify I/O registration 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: Rostislav Pehlivanov MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Same as previous commit, unneded use of atomics. Signed-off-by: Rostislav Pehlivanov --- libavformat/format.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavformat/format.c b/libavformat/format.c index 38ca2a3465..6ac7349ec5 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/atomic.h" #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/opt.h" @@ -62,9 +61,11 @@ void av_register_input_format(AVInputFormat *format) { AVInputFormat **p = last_iformat; - // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL - while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) - p = &(*p)->next; + /* Iterate through the list until the last entry has been reached */ + while (p != &format->next && !format->next) { + *p = format; + p = &(format)->next; + } if (!format->next) last_iformat = &format->next; @@ -74,9 +75,11 @@ void av_register_output_format(AVOutputFormat *format) { AVOutputFormat **p = last_oformat; - // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL - while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) - p = &(*p)->next; + /* Iterate through the list until the last entry has been reached */ + while (p != &format->next && !format->next) { + *p = format; + p = &(format)->next; + } if (!format->next) last_oformat = &format->next;