From patchwork Wed Oct 4 09:17:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 5408 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.76 with SMTP id m12csp624184jah; Wed, 4 Oct 2017 02:17:39 -0700 (PDT) X-Received: by 10.28.230.216 with SMTP id e85mr15412832wmi.86.1507108659663; Wed, 04 Oct 2017 02:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507108659; cv=none; d=google.com; s=arc-20160816; b=SLFyJrkr6k+DvgjE5LYkVfwq80y/8QkMnQ2zMLdhUm8ogp29AcTVt3xW5MtM4TEaNm zctYxNXNsLwvOgCsLcAOREpBlYRLiA431AHXfebruHDBdptAxNAxY0gRv+suMY6DRLXm Ay6BdRVWAOq+i5lUdZjGgVSi5X7WWqVwnclNGw14WKE3U1Cedw48FAjqM/qCI33eq9oy LzBqmak0zoUi/vAmFip1iV4cFvQMzC/GgMZGIpkXKOu0qnNLOWpYI3MRuhY7xaIoXDsy +HlOr/RMnSicQ10nnnequWSag1za7ml/669zIoP9qwPoz52judVE7W0CYDDBQhAPVnho ZMfQ== 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=+60Rzpg7u5MT2CchYR/uhqtIqvSLbgUX/Jn/NPaBrjg=; b=0eYRYrJdpzzq/v5edl36newTAW27L5gBhY1K0na8MzoDQ0Aai7yjwa+DgyAVwCo85R MBg+NME6/EkDFCmn4W71O45JN5ZWoEQiYYa4qHvjMA/yoI/gJLA5Mwt90eSMb//LENA/ CZciXHPa3LgFNuwUvBn3OOw4NIlTKVPEWi/S0CxuqkoYDIRFoPkQcExsNHo3Z3qrfU+g ojGso84EJT20ARHY0VUPvBhXnmgEI3RLfvxCX7hlexN/m1LGrYwnlllu+Nrgs1sndDnu pICqPLm7/l3PpVteWcphkTHtWt3D/ry7xalTB7NDETkpvUufr+/cv/QmhKa+oicbZKJ3 N8Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aKr6+mXH; 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=linaro.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j25si13207971wrc.432.2017.10.04.02.17.38; Wed, 04 Oct 2017 02:17:39 -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=@linaro.org header.s=google header.b=aKr6+mXH; 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=linaro.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D998668A230; Wed, 4 Oct 2017 12:17:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 300E468A217 for ; Wed, 4 Oct 2017 12:17:14 +0300 (EEST) Received: by mail-wm0-f53.google.com with SMTP id k4so19630952wmc.1 for ; Wed, 04 Oct 2017 02:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=y8DGobwy9f5fo4+DFbBH+ENNhD1O5HAQY+Ewl0I0Sa0=; b=aKr6+mXHRs5Lz7B6cYB10+owQfuTuXyaP1wf1Rxs/8A6TYMlTijN8tun3ZJldvOd2T sd25b+ABs9o05YCof1b7pJf721bJksFZJLWlfNsHEqby8ldpMyRTcqgaio9uyz7L62Qm GPcLyVbQpot+fySrhKU/F+HYKuCFRE/VWBwPU= 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=y8DGobwy9f5fo4+DFbBH+ENNhD1O5HAQY+Ewl0I0Sa0=; b=LW9CbOewQS4LlSweSsVKOVWOJykrdY3A3l7wM65lj6B3qSwnDV6MA09sOrbnb8Bgpo a4jeulJBVXXYbW4/OZfC4DX1ZYsNn3P2ZUMTgDi9Zae2L+ayZCqahF7HVrmVlDCJ/fun 7NpJuZCK/tbRYlwbrIHSETJDxMQ1POIgkVyiFNZlonOFBXw/Om37+wujkvneECaHNK4g MWbXZJtSBAOLMpbkiRgkmLJBeH99y3lFTX9AP5XJZXWhp1pjudmSP4oI5PywwnH0hsn4 oKPOn1m0T6UK5XLipCLbS244WPNu66dzuhCOi0xc6RCvUT4LAdN0HLo3VoVlyATHSE+j ZlEA== X-Gm-Message-State: AMCzsaUIvtruiS4RZ2iWgU2cfQJjrXCenuc+25/G81fxYXNUfnm336a0 fdJT6fUbSo9WPxg35zCP4eDDnA== X-Google-Smtp-Source: AOwi7QAXbmNOiI9b3vOrB4f9KHnPyDOpLs5v53CW0mTpRCB64KTLzA3Aefm2iMXMTL64z5vxIzqDbg== X-Received: by 10.28.234.140 with SMTP id g12mr10078398wmi.73.1507108648938; Wed, 04 Oct 2017 02:17:28 -0700 (PDT) Received: from localhost.localdomain (51.red-88-3-176.dynamicip.rima-tde.net. [88.3.176.51]) by smtp.gmail.com with ESMTPSA id w82sm19485526wme.5.2017.10.04.02.17.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Oct 2017 02:17:28 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, ffmpeg-devel@ffmpeg.org Date: Wed, 4 Oct 2017 11:17:24 +0200 Message-Id: <1507108644-20466-1-git-send-email-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] avcodec/v4l2: set sizeimage param for non-raw buffers [fixes #6716] 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" Some V4L2 drivers fail to allocate buffers when sizeimage is not set to a max value. This is indeed the case for sp5-mfc [1] Most drivers should be able to calculate this value from the frame dimensions and format - or at least have their own default. However since this work around should not impact those drivers doing the "right thing" this commit just provides such a default. [1] linux.git/drivers/media/platform/s5p-mfc --- libavcodec/v4l2_context.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 297792f..2707ef5 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -92,6 +92,8 @@ static inline int v4l2_type_supported(V4L2Context *ctx) static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_update *fmt) { + const int MAX_SIZEIMAGE = 2 * 1024 * 1024; + ctx->format.type = ctx->type; if (fmt->update_avfmt) @@ -101,13 +103,21 @@ static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_upd /* update the sizes to handle the reconfiguration of the capture stream at runtime */ ctx->format.fmt.pix_mp.height = ctx->height; ctx->format.fmt.pix_mp.width = ctx->width; - if (fmt->update_v4l2) + if (fmt->update_v4l2) { ctx->format.fmt.pix_mp.pixelformat = fmt->v4l2_fmt; + + /* s5p-mfc requires the user to specify MAX buffer size */ + ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage = MAX_SIZEIMAGE; + } } else { ctx->format.fmt.pix.height = ctx->height; ctx->format.fmt.pix.width = ctx->width; - if (fmt->update_v4l2) + if (fmt->update_v4l2) { ctx->format.fmt.pix.pixelformat = fmt->v4l2_fmt; + + /* s5p-mfc requires the user to specify MAX buffer size */ + ctx->format.fmt.pix.sizeimage = MAX_SIZEIMAGE; + } } }