From patchwork Sat Sep 2 17:07:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 4948 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp1650876jao; Sat, 2 Sep 2017 10:07:23 -0700 (PDT) X-Received: by 10.223.157.13 with SMTP id k13mr3328787wre.252.1504372043816; Sat, 02 Sep 2017 10:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504372043; cv=none; d=google.com; s=arc-20160816; b=PYCxrvVe9+d1p9QG0Y6NnXTcQIXxPJcix6ay+H6Rfpq6Ydsh4lnWode8simejzZXhx zkYepXpTOoKMW/FiLeRkWATrGpZ8M35VJfitFr6l5pgF90ukqjdKgtJ59NfDCV1lir1j E1F7I4dQhvFcgZ5iy+TX3DEG5W43PEsbk3BMmasP/FZWFqafxEA8n6OcbLOcHsPeuNih nfJ6SWCKBud9gMqFIrp4wbkg434tdeddgynkNr0NjXuKJNeT2we0BOG0vZqRW92jLtEA pwBtpopfuhYgQ7ofp8ihLtQULHVTvTmb1Si2CEiQNE2XZpf03aCHwONQqTZZetdTQPIj j3wQ== 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:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=SwpL4snE7Uii8/f/IPtnPyXTXGVoT5xCROQmDMckflQ=; b=OCAjGfkXbhCzdl2l/kRPVHyI9HI7iB/eSG4kMCcsoZ3eUw9ATN2KpXqJea/oNRqS9C UzC6tLKfeoyaOWFiuoJht/Z20BF8/fgI6dAm59A+keQE80tIYXpS89YFOHd1s/vKNK8M 1syb859oR7q+7mP4he4khy0VJKShiFepRT9rtK9EnWW0jIAFu2b4iTsfc7EjtYt1lD8J mea/wLG36roHOwl9CU7U5VCOS/OOQbcTOy2D6QpAec97IbQdgomk0RtqrzcBx7OOXg2t UogfZMUDVL1HS3B03odqGTOq2IbCswPlJfVv+5fBUkjx1WVArqmDhcTTzGNcniUI2ayt QExg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=XLpjHhG4; 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 e25si2116853wra.469.2017.09.02.10.07.22; Sat, 02 Sep 2017 10:07:23 -0700 (PDT) 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=XLpjHhG4; 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 402F0689D04; Sat, 2 Sep 2017 20:07:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5716B689A62 for ; Sat, 2 Sep 2017 20:07:13 +0300 (EEST) Received: by mail-qk0-f196.google.com with SMTP id l65so2060424qkc.3 for ; Sat, 02 Sep 2017 10:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=PpsFMB0DQMozh9kxsk2Z0hPD2gDowhkULFa/x9w2Sro=; b=XLpjHhG4x+L+DngsslikhuunCMASR/qI2Tm64S5ce+fEPbZBGUixM6ctkkXqPx1wd4 nnwGeCskWSp+7jqt8NgZ4uOh1UJqSs4b8YDDO+wx1W1K0hbaicbHGMH0KX/X57ZODW3P mpCeCXZb981R9UF43iXNAQ6BR4VBbXWL83gIyYdX6hAV5xsMRPD8sRSCmTN7LXEkoDJ3 i/kb3qR32hnbKqFFtdyQl+4WG9bylEpDIMh3HFr6O2GL9t8geyyl1stmPKhNd+7+TZF8 V/zFmnjOE+aus4h2fpe6WV/80BH8wxEykRXjQqFMcggV+/FhNPrpW1sqR+QyMgLp0OZ6 vXiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=PpsFMB0DQMozh9kxsk2Z0hPD2gDowhkULFa/x9w2Sro=; b=N/FL02dnyvnifFbfO96pv+WD3REWNuE0yFAxfeKCxhWcFKLg5d9/cz3W1H2HBWMmcA XJ7f7DEsg/s04PQATC+Hd6ixd+V0mL/HNNmvez8HjhhqF/lpZTk7iotHUfSW6qhutrlC oqnath2lNtbQ4+mxYmljl5vscBaYg4gFNePHFcfGsZe+3kyI/Rudlct5FWlltDaOE26l WBPbFEveqIVcfgBEWX22rMpdQNLZIR3SDoDkPzm2m+7C3WPtcY4VEAsB8PhuxrRnkCQM gToNq0ZStdbs3OCkCAAyS9fOLJniRiTqzEUj51A3S8ooeQ/pOYa6dPW78H51iuCHysok KL4A== X-Gm-Message-State: AHPjjUgnZg01T3fxhKO9AUid5J/FLqPM0S6LjwpMeT4rUrKUTliClRTl 7BGS2Efv/EgMVYFG X-Google-Smtp-Source: ADKCNb5ze0VbJVhbtCbsGoL20O6kHIpodrbW11mf4sTrZ4c/QK2MSX3j5PNnTdGbXkyKw8kh6F/Iww== X-Received: by 10.55.31.133 with SMTP id n5mr7297066qkh.340.1504372033419; Sat, 02 Sep 2017 10:07:13 -0700 (PDT) Received: from localhost.localdomain ([181.231.116.134]) by smtp.gmail.com with ESMTPSA id f189sm1094598qkj.10.2017.09.02.10.07.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 02 Sep 2017 10:07:12 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 2 Sep 2017 14:07:01 -0300 Message-Id: <20170902170701.9144-1-jamrial@gmail.com> X-Mailer: git-send-email 2.13.3 Subject: [FFmpeg-devel] [PATCH] cpu: add a function for querying maximum required data 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Anton Khirnov (cherry picked from commit e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e) Signed-off-by: James Almer --- This is (afaics) the last API introduced to libav before the major bump. doc/APIchanges | 3 +++ libavutil/cpu.c | 22 ++++++++++++++++++++++ libavutil/cpu.h | 13 +++++++++++++ libavutil/version.h | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4effbf9364..6a57c210a9 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-09-xx - xxxxxxx - lavu 55.75.100 / lavu 55.31.0 - cpu.h + Add av_cpu_max_align() for querying maximum required data alignment. + 2017-09-01 - xxxxxxx - lavf 57.81.100 - avio.h Add avio_read_partial(). diff --git a/libavutil/cpu.c b/libavutil/cpu.c index a22da0fa8c..c89f4e0b5f 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -16,9 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include +#include "attributes.h" #include "cpu.h" #include "cpu_internal.h" #include "config.h" @@ -299,3 +301,23 @@ int av_cpu_count(void) return nb_cpus; } + +size_t av_cpu_max_align(void) +{ + int av_unused flags = av_get_cpu_flags(); + +#if ARCH_ARM || ARCH_AARCH64 + if (flags & AV_CPU_FLAG_NEON) + return 16; +#elif ARCH_PPC + if (flags & AV_CPU_FLAG_ALTIVEC) + return 16; +#elif ARCH_X86 + if (flags & AV_CPU_FLAG_AVX) + return 32; + if (flags & AV_CPU_FLAG_SSE) + return 16; +#endif + + return 8; +} diff --git a/libavutil/cpu.h b/libavutil/cpu.h index de05593446..9e5d40affe 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -21,6 +21,8 @@ #ifndef AVUTIL_CPU_H #define AVUTIL_CPU_H +#include + #include "attributes.h" #define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */ @@ -113,4 +115,15 @@ int av_parse_cpu_caps(unsigned *flags, const char *s); */ int av_cpu_count(void); +/** + * Get the maximum data alignment that may be required by FFmpeg. + * + * Note that this is affected by the build configuration and the CPU flags mask, + * so e.g. if the CPU supports AVX, but libavutil has been built with + * --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through + * av_set_cpu_flags_mask(), then this function will behave as if AVX is not + * present. + */ +size_t av_cpu_max_align(void); + #endif /* AVUTIL_CPU_H */ diff --git a/libavutil/version.h b/libavutil/version.h index 6e25b4690c..d99eff5d15 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 74 +#define LIBAVUTIL_VERSION_MINOR 75 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \