From patchwork Thu Jun 15 19:31:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 3991 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp949578vsw; Thu, 15 Jun 2017 12:31:40 -0700 (PDT) X-Received: by 10.28.169.87 with SMTP id s84mr4880945wme.62.1497555100549; Thu, 15 Jun 2017 12:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497555100; cv=none; d=google.com; s=arc-20160816; b=cbQk9ue8g2MwuFqrbYsVP+wT+gRKgdiAazbxpG9Ge6vYe0+nctiLunCXzSjxoWbg3X E5rbFGfJu5BWkJklVWQFdOjAVug1SQHZ/o2F5g2bFHt7m5PB12JVW+rw6aKfcmMDBXM0 qpZcTKZyRwYIMluXQOD65btiOQC3DGWEqsBQbTKC1++go9R4y8zc+Go8b9cgMt89Oq/Y RNm9VBd9zAsPd3Han+oiSdqVr83yGaIF7d7BhkOCtfWQ2MCGWPBpOEWuKyJWs+huGgzk 8Iamwth8pa4BMgBL0NdhfYyXKVv3TYiP337dxZTXoc11bOfsNI+64r9MJS/TdDCYKu7B 9Ycw== 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:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=rPvOOPxfVxMJFWA3H6gVkK7ATysoQaw2vMrymML/fh8=; b=IQSr5opC63OI8977Ut8c2oQNiMBy2PXnYe3adGQP0IO+LK3Rs3PZid1gp3pv9o5Zi4 ZT/ulN308aoiZT+i+DDN1ipltv/fmsQJDIGRp0DKDRqJ6+U5CsK0vsC/qGeIGJSBYdPF hbCjCWyznxvXd2WiSzRHn8PsTt3raFy+iyxv8J2QDBQFeJXz4dhN1C47v8MMtl8zb4uW XR65TvzDXdB5Xrvy2QlTddZ6a5HRiFYh2Gfvlx8aESisFmmXDYrvScddgshUfEcmpsmW /TTeGbZzHdnzSu0gVmCS6bk870DDO1sJOfL4rTXSK6z6oNVpYRbIQAMsPWynGkz46Ayd CYKQ== 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 n65si91272wmd.152.2017.06.15.12.31.40; Thu, 15 Jun 2017 12:31:40 -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 3BD9F68A3A4; Thu, 15 Jun 2017 22:31:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8EA9B68A381 for ; Thu, 15 Jun 2017 22:31:20 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dLaUF-0005Bx-3t for ffmpeg-devel@ffmpeg.org; Thu, 15 Jun 2017 21:31:23 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id Z7XN1v00D0S5wYM017XPDq; Thu, 15 Jun 2017 21:31:23 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 15 Jun 2017 21:31:20 +0200 Message-Id: <20170615193120.1513-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170615193120.1513-1-michael@niedermayer.cc> References: <20170615193120.1513-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/ffv1enc: Try to choose slice count so that slice packet sizes are within the supported size 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" Fixes assertion failure Signed-off-by: Michael Niedermayer --- libavcodec/ffv1enc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 7f31606775..e59d540737 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -848,10 +848,17 @@ FF_ENABLE_DEPRECATION_WARNINGS } if (s->version > 1) { + int plane_count = 1 + 2*s->chroma_planes + s->transparency; s->num_v_slices = (avctx->width > 352 || avctx->height > 288 || !avctx->slices) ? 2 : 1; - for (; s->num_v_slices < 9; s->num_v_slices++) { + for (; s->num_v_slices < 32; s->num_v_slices++) { for (s->num_h_slices = s->num_v_slices; s->num_h_slices < 2*s->num_v_slices; s->num_h_slices++) { - if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= 64 || !avctx->slices) + int maxw = (avctx->width + s->num_h_slices - 1) / s->num_h_slices; + int maxh = (avctx->height + s->num_v_slices - 1) / s->num_v_slices; + if (s->num_h_slices > avctx->width || s->num_v_slices > avctx->height) + continue; + if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24) + continue; + if (avctx->slices == s->num_h_slices * s->num_v_slices && avctx->slices <= MAX_SLICES || !avctx->slices) goto slices_ok; } }