From patchwork Sun Dec 11 16:39:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 1756 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp1280465vsa; Sun, 11 Dec 2016 08:40:23 -0800 (PST) X-Received: by 10.28.18.194 with SMTP id 185mr5760483wms.124.1481474422973; Sun, 11 Dec 2016 08:40:22 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l203si25420020wmf.46.2016.12.11.08.40.22; Sun, 11 Dec 2016 08:40:22 -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; 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 BE57168995A; Sun, 11 Dec 2016 18:40:05 +0200 (EET) 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 D620D689204 for ; Sun, 11 Dec 2016 18:39:58 +0200 (EET) 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 uBBGe2Ds015330 for ; Sun, 11 Dec 2016 17:40:03 +0100 (CET) Received: by phare.normalesup.org (Postfix, from userid 1001) id DF631E00D0; Sun, 11 Dec 2016 17:40:02 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Dec 2016 17:39:59 +0100 Message-Id: <20161211164000.2858-2-george@nsup.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161211164000.2858-1-george@nsup.org> References: <20161211162928.GA2110330@phare.normalesup.org> <20161211164000.2858-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Sun, 11 Dec 2016 17:40:03 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 2/3] Revert "avutil: Add av_image_check_size2()" 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" This reverts commit f542b152aa2086b30d1089162d79f5c136905c0c. Signed-off-by: Nicolas George --- doc/APIchanges | 3 --- libavutil/imgutils.c | 29 +++++------------------------ libavutil/imgutils.h | 14 -------------- libavutil/version.h | 2 +- 4 files changed, 6 insertions(+), 42 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index fbeae7a..0cdb4cf 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,9 +15,6 @@ libavutil: 2015-08-28 API changes, most recent first: -2016-12-10 - xxxxxxx - lavu xx.xx.100- imgutils.h - Add av_image_check_size2() - 2016-xx-xx - xxxxxxx - lavc 57.67.100 / 57.29.0 - avcodec.h Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping information from containers. diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index cc410ab..37808e5 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -248,38 +248,19 @@ static const AVClass imgutils_class = { .parent_log_context_offset = offsetof(ImgUtils, log_ctx), }; -int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx) +int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) { ImgUtils imgutils = { .class = &imgutils_class, .log_offset = log_offset, .log_ctx = log_ctx, }; - int64_t stride = av_image_get_linesize(pix_fmt, w, 0); - if (stride <= 0) - stride = 8LL*w; - stride += 128*8; - - if ((int)w<=0 || (int)h<=0 || stride >= INT_MAX || stride*(uint64_t)(h+128) >= INT_MAX) { - av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); - return AVERROR(EINVAL); - } - - if (max_pixels < INT64_MAX) { - if (w*(int64_t)h > max_pixels) { - av_log(&imgutils, AV_LOG_ERROR, - "Picture size %ux%u exceeds specified max pixel count %"PRId64", see the documentation if you wish to increase it\n", - w, h, max_pixels); - return AVERROR(EINVAL); - } - } - return 0; -} + if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) + return 0; -int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) -{ - return av_image_check_size2(w, h, INT64_MAX, AV_PIX_FMT_NONE, log_offset, log_ctx); + av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); + return AVERROR(EINVAL); } int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar) diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 19f34de..23282a3 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -192,20 +192,6 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size, int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); /** - * Check if the given dimension of an image is valid, meaning that all - * bytes of the image can be addressed with a signed int. - * - * @param w the width of the picture - * @param h the height of the picture - * @param max_pixels the maximum number of pixels the user wants to accept - * @param pix_fmt the pixel format, can be AV_PIX_FMT_NONE if unknown. - * @param log_offset the offset to sum to the log level for logging with log_ctx - * @param log_ctx the parent logging context, it may be NULL - * @return >= 0 if valid, a negative error code otherwise - */ -int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx); - -/** * Check if the given sample aspect ratio of an image is valid. * * It is considered invalid if the denominator is 0 or if applying the ratio diff --git a/libavutil/version.h b/libavutil/version.h index 9f8c4c2..301c11b 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 43 +#define LIBAVUTIL_VERSION_MINOR 42 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \