From patchwork Sun Dec 11 16:39:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 1755 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp1280418vsa; Sun, 11 Dec 2016 08:40:12 -0800 (PST) X-Received: by 10.28.137.81 with SMTP id l78mr5797671wmd.36.1481474412895; Sun, 11 Dec 2016 08:40:12 -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 127si25416952wmv.35.2016.12.11.08.40.12; Sun, 11 Dec 2016 08:40:12 -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 63B996898C9; 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 B47B7680A9B for ; Sun, 11 Dec 2016 18:39:58 +0200 (EET) Received: from phare.normalesup.org (archicubes.ens.fr [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id uBBGe2qj015328 for ; Sun, 11 Dec 2016 17:40:03 +0100 (CET) Received: by phare.normalesup.org (Postfix, from userid 1001) id B5A90E0087; Sun, 11 Dec 2016 17:40:02 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Dec 2016 17:39:58 +0100 Message-Id: <20161211164000.2858-1-george@nsup.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161211162928.GA2110330@phare.normalesup.org> References: <20161211162928.GA2110330@phare.normalesup.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 1/3] Revert "avcodec: Add max_pixels options" 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 2f07830e69bd14eaba348eb739b9503e7eb7cd4b. It was rushed and not properly designed. Signed-off-by: Nicolas George --- doc/codecs.texi | 4 ---- libavcodec/avcodec.h | 8 -------- libavcodec/options_table.h | 1 - libavcodec/utils.c | 12 ++++++------ tests/ref/fate/api-mjpeg-codec-param | 2 -- tests/ref/fate/api-png-codec-param | 2 -- 6 files changed, 6 insertions(+), 23 deletions(-) Just to show that it is not just an idle proposal. FFmpeg have lived for years with this so-called issue, many libraries still do. We can take a few days properly designing things. I think these changes were introduced recently enough to allow just reverting them without introducing compability bloat. diff --git a/doc/codecs.texi b/doc/codecs.texi index 9a3a56d..ca7c523 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -1272,10 +1272,6 @@ ffprobe -dump_separator " " -i ~/videos/matrixbench_mpeg2.mpg @end example -@item max_pixels @var{integer} (@emph{decoding/encoding,video}) -Maximum number of pixels per image. This value can be used to avoid out of -memory failures due to large images. - @end table @c man end CODEC OPTIONS diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 02234ae..7ac2ada 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3570,14 +3570,6 @@ typedef struct AVCodecContext { */ int trailing_padding; - /** - * The number of pixels per image to maximally accept. - * - * - decoding: set by user - * - encoding: set by user - */ - int64_t max_pixels; - } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 3fe7925..ee79859 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -570,7 +570,6 @@ static const AVOption avcodec_options[] = { {"codec_whitelist", "List of decoders that are allowed to be used", OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, A|V|S|D }, {"pixel_format", "set pixel format", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64=AV_PIX_FMT_NONE}, -1, INT_MAX, 0 }, {"video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str=NULL}, 0, INT_MAX, 0 }, -{"max_pixels", "Maximum number of pixels", OFFSET(max_pixels), AV_OPT_TYPE_INT64, {.i64 = INT_MAX }, 0, INT_MAX, A|V|S|D|E }, {NULL}, }; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 44ecc09..89a12c6 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -209,7 +209,7 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height) int ff_set_dimensions(AVCodecContext *s, int width, int height) { - int ret = av_image_check_size2(width, height, s->max_pixels, AV_PIX_FMT_NONE, 0, s); + int ret = av_image_check_size(width, height, 0, s); if (ret < 0) width = height = 0; @@ -904,7 +904,7 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) int ret; if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { - if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { + if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0 || avctx->pix_fmt<0) { av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n"); return AVERROR(EINVAL); } @@ -1338,8 +1338,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height) - && ( av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0 - || av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)) { + && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0 + || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) { av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n"); ff_set_dimensions(avctx, 0, 0); } @@ -1982,7 +1982,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, return 0; } - if (av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) + if (av_image_check_size(avctx->width, avctx->height, 0, avctx)) return AVERROR(EINVAL); if (frame && frame->format == AV_PIX_FMT_NONE) @@ -2233,7 +2233,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi } *got_picture_ptr = 0; - if ((avctx->coded_width || avctx->coded_height) && av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) + if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx)) return AVERROR(EINVAL); avctx->internal->pkt = avpkt; diff --git a/tests/ref/fate/api-mjpeg-codec-param b/tests/ref/fate/api-mjpeg-codec-param index 08313ad..c67d1b1 100644 --- a/tests/ref/fate/api-mjpeg-codec-param +++ b/tests/ref/fate/api-mjpeg-codec-param @@ -155,7 +155,6 @@ stream=0, decode=0 codec_whitelist= pixel_format=yuvj422p video_size=400x225 - max_pixels=2147483647 stream=0, decode=1 b=0 ab=0 @@ -313,4 +312,3 @@ stream=0, decode=1 codec_whitelist= pixel_format=yuvj422p video_size=400x225 - max_pixels=2147483647 diff --git a/tests/ref/fate/api-png-codec-param b/tests/ref/fate/api-png-codec-param index 7a9a921..bd53441 100644 --- a/tests/ref/fate/api-png-codec-param +++ b/tests/ref/fate/api-png-codec-param @@ -155,7 +155,6 @@ stream=0, decode=0 codec_whitelist= pixel_format=rgba video_size=128x128 - max_pixels=2147483647 stream=0, decode=1 b=0 ab=0 @@ -313,4 +312,3 @@ stream=0, decode=1 codec_whitelist= pixel_format=rgba video_size=128x128 - max_pixels=2147483647