From patchwork Tue May 9 13:19:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 3629 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp1331517vsd; Tue, 9 May 2017 06:20:08 -0700 (PDT) X-Received: by 10.28.23.5 with SMTP id 5mr1163813wmx.100.1494336008736; Tue, 09 May 2017 06:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494336008; cv=none; d=google.com; s=arc-20160816; b=tPqGTts+ue+BFYfDRwCFgaFUc8bj3Dvcp301BicCN+xqWhFwMM1Pas7w7JMVdA22kw H1+bUzknbnMFeEPuf3x4TezSV2lDyNDHXPZYY6RuvNiPs6VpAGhbdhGhoZmC1BKHaTyY VcbCdujdG3ZzlJlGxl/uIXdPuavHPEZrIhhtf3BrS0TBIwHygh5Z6o3LtGEgSc9LXpr7 ke6ZoBx+aqu9ZObMwsN5uit0GasIK2QyNlAajcewLFtduNFLKAKndoIgHY26Q13bD2gM JQ84TKF3ZusO88pc46R/UB4dRN+gZL9hyCQtbSEiEl5ot8p38TW6O96QrKt5Y6RN9ckC vlPQ== 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:delivered-to :arc-authentication-results; bh=eRetWM9b9ynt8fKue7yZBXwfmedtZSuPXxiwQe3IL24=; b=j5KAukG/hZ6hVMO9Gwni8QVtEB0OeJb3nyjPJrLsgbod23JSLkRLkxmDAtESricj3A 2Danscs9YvkMbKK9IGeUR5fHTPK6uxpyxAeJQ8/PwkM3bCat5fm711A7k8pLWderHReR J7bs/G+UyiC/oDodvgW+CHzM0mjt2PCDt5IkwSuL4JDr+sscrSowk8We9bgutfbmIejD wkKE387x9hPozn5phRBlu9X7NcABn7uIyIiHh09arCa0Lg6gL7i8gJNpW40qUpwp9vDK uY2g0FIVXsUQuyCtWhB6t6p5/SYs+cUNQeQpSXzrFCThBYvmGw1OoZM1mUGzVOF8F15N JtvA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 88si17320404wrf.233.2017.05.09.06.20.07; Tue, 09 May 2017 06:20:08 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D57BC688380; Tue, 9 May 2017 16:19:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A046F680A7F for ; Tue, 9 May 2017 16:19:50 +0300 (EEST) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v49DJqOA066710 for ; Tue, 9 May 2017 15:19:53 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id D112AE00FB; Tue, 9 May 2017 15:19:52 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 May 2017 15:19:42 +0200 Message-Id: <20170509131944.27166-1-george@nsup.org> X-Mailer: git-send-email 2.11.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Tue, 09 May 2017 15:19:53 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 1/3] lavu/frame: add av_frame_check_align(). 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" Signed-off-by: Nicolas George --- doc/APIchanges | 3 +++ libavutil/frame.c | 18 ++++++++++++++++++ libavutil/frame.h | 8 ++++++++ libavutil/version.h | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) Added "const" and the version bump. diff --git a/doc/APIchanges b/doc/APIchanges index 09b1a49798..939d7d5f69 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-xx-xx - xxxxxxxxxx - lavu 55.63.100 - frame.h + Add av_frame_check_align(). + 2017-xx-xx - xxxxxxx - lavc 57.95.100 / 57.31.0 - avcodec.h Add AVCodecContext.apply_cropping to control whether cropping is handled by libavcodec or the caller. diff --git a/libavutil/frame.c b/libavutil/frame.c index 24d5d5f184..e8467a1cd6 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -781,3 +781,21 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) } return NULL; } + +int av_frame_check_align(const AVFrame *frame, unsigned align) +{ + unsigned mask = (1 << align) - 1; + unsigned i; + int ret; + + av_assert1(align < 16); + for (i = 0; i < AV_NUM_DATA_POINTERS; i++) + if (((intptr_t)frame->data[i] & mask)) + return 0; + if (!frame->extended_data || frame->extended_data == frame->data) + return 1; + for (i = AV_NUM_DATA_POINTERS; i < frame->channels; i++) + if (((intptr_t)frame->extended_data[i] & mask)) + return 0; + return 1; +} diff --git a/libavutil/frame.h b/libavutil/frame.h index 26261d7e40..196d311e29 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -772,6 +772,14 @@ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); const char *av_frame_side_data_name(enum AVFrameSideDataType type); /** + * Check if the data pointers of a frame are aligned enough. + * Test if all frame data pointers have the alignment lower bits cleared, + * i.e. are a multiple of 1<0 if aligned, 0 if not + */ +int av_frame_check_align(const AVFrame *frame, unsigned align); + +/** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index 6762bf300a..fb61dcc666 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 62 +#define LIBAVUTIL_VERSION_MINOR 63 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \