From patchwork Sun Sep 26 12:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NoHalfBits X-Patchwork-Id: 30591 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a10:ed07:0:0:0:0 with SMTP id jg7csp3475471pxb; Sun, 26 Sep 2021 05:48:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHT3CZRBNW1Dny7HufantohbDz1hoMmllt0hCdg3J/bVCPNSwe6seA4D83G570P9dwF6Ux X-Received: by 2002:a17:907:7755:: with SMTP id kx21mr21631356ejc.463.1632660488776; Sun, 26 Sep 2021 05:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632660488; cv=none; d=google.com; s=arc-20160816; b=JMGfb3x38+0Cy0SFP7iMge2TxJ2YcdtmfwWGe3o7osuEWF4UshY8GOjYm2ceSjK3a8 MtAl+MKWjx+EUqeZk1wp/caaFe9jwtRukmh7zeoNJTnFJjwjCf47pq7UfhkGINU45J/F b3xWtAjuy8xw2I4I4nB9nLu1XBIu7yYW1mpbo4iwE3Jba9r2cdVs/0rs1aCxDoXpmMPN fee1JN5uRfq+sb9Heq2KOcIAHZc5C/lWmyRHQrV8haomOWXf3uRy9CEp7kOZ5R7JTu77 g2XNgILC3RDie8hWLA8FGAwyrYg+kfTlsJnCAydfZGonxbDu2nUm0X5w/E6cBWO7Em4j iYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=a3bEvsnVBVOmtRZjPNBcHvPespKsgue44CqIgT5t310=; b=mPyF0gzsQ/L0/n4iJdVAbkR3laYVruGRm4U/kRA8d/cx2nNfdF5ywluOlIdPvO3xqu JWJbCCErMAH9X4/e7JGCx3Bh33k/1kkFnGgJ300ekSa8XRo32qrYEIJqDyGCmh3+pU2E swqWY221XJsu81CEuWJ55tpXnSj6eYn6996vuJe/7ZUQkXFOXnMc00lBgKiQeYjrFg9a Mk4LNlKXcOPkpuGxrnFmjm03fZoiBafYGhBg+6UTJ/0uVh1OD5pQ9ybbxMvip9X0mYKM yB1y4O3hzRJ20CHOZwG8n3w/yW1WmaIF2LXymRmNAWsOXj4LSLb53mV4VTZtVfZqjLCa BxGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@fluthaus.com header.s=key2 header.b=Z9VUAeS9; 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 r16si2179860edy.214.2021.09.26.05.48.08; Sun, 26 Sep 2021 05:48: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; dkim=neutral (body hash did not verify) header.i=@fluthaus.com header.s=key2 header.b=Z9VUAeS9; 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 543F668A98D; Sun, 26 Sep 2021 15:48:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.61.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6CD068A866 for ; Sun, 26 Sep 2021 15:47:58 +0300 (EEST) Received: from mors-relay-8405.netcup.net (localhost [127.0.0.1]) by mors-relay-8405.netcup.net (Postfix) with ESMTPS id 4HHQXt0Rn0z6xFG for ; Sun, 26 Sep 2021 14:47:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fluthaus.com; s=key2; t=1632660478; bh=zenA+uMfmr3W9rFuqhEd/bJlG+DsvoZ/LeDjOZlfUy4=; h=From:To:Cc:Subject:Date:From; b=Z9VUAeS9gHrN4n2eraIwwTfTN6sVwGxo13I3CkWQ22pZE2od5dtOONnRgbqtRB6ub AeMp4qOiFJg8/y31wysveGTaOztmZKIhibkYDwZUyPlnh5F2INCvMPH6kb9dKkyxzQ KntFiIQRuZNBWhuE+uBsh7ZLodiEhKV5Lz4a9oPVKxiTW9uYyDSisUYSB/DpM4vH7z GfQNYrOYLf84bS6GPcftr6nLyPe1dqhqtoGJ6Kf9767BOKhB6Q8niUUL3twd4LH5xE okkrDjOGqjeG/S6/30Gt3zZ5wLVy9SHAcASrVGds7jhq65RTXJZH0i3BCdQK/H2Tqd 5Ri5YnIQ/fi9w== Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-8405.netcup.net (Postfix) with ESMTPS id 4HHQXt05yvz6xFB for ; Sun, 26 Sep 2021 14:47:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at policy02-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from mx2efc.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy02-mors.netcup.net (Postfix) with ESMTPS id 4HHQXr0nTqz8shD for ; Sun, 26 Sep 2021 14:47:56 +0200 (CEST) Received: from localhost.localdomain (dynamic-077-013-197-054.77.13.pool.telefonica.de [77.13.197.54]) by mx2efc.netcup.net (Postfix) with ESMTPSA id 7A0421A0045; Sun, 26 Sep 2021 14:47:55 +0200 (CEST) Authentication-Results: mx2efc; spf=pass (sender IP is 77.13.197.54) smtp.mailfrom=ffmpeg-devel@fluthaus.com smtp.helo=localhost.localdomain Received-SPF: pass (mx2efc: connection is authenticated) From: NoHalfBits To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Sep 2021 14:47:52 +0200 Message-Id: <20210926124752.14573-1-ffmpeg-devel@fluthaus.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 X-PPP-Message-ID: <163266047584.21315.17793875376794111904@mx2efc.netcup.net> X-PPP-Vhost: fluthaus.com X-NC-CID: 97T+W7sc+qCAqU9kHXE7GwzTqF//+3kU+rGWe0BNPFH6SUw= Subject: [FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: Fixes non-B-Frame encoding X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: NoHalfBits Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4bWoeHmX0O2o Sets vtctx->has_b_frames to 0 if the VideoToolbox compression session will not emit B-frames (and, in consequence, no valid DTSs). Required for the handling of invalid DTSs in 'vtenc_cm_to_avpacket' (line 2018ff) to work correctly and not abort encoding with "DTS is invalid." when no B-frames are generated. Signed-off-by: NoHalfBits --- libavcodec/videotoolboxenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 8dfd6e3d0c..93c3898fb5 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1516,7 +1516,10 @@ static av_cold int vtenc_init(AVCodecContext *avctx) if (!status && has_b_frames_cfbool) { //Some devices don't output B-frames for main profile, even if requested. // HEVC has b-pyramid - vtctx->has_b_frames = (CFBooleanGetValue(has_b_frames_cfbool) && avctx->codec_id == AV_CODEC_ID_HEVC) ? 2 : 1; + if (CFBooleanGetValue(has_b_frames_cfbool)) + vtctx->has_b_frames = avctx->codec_id == AV_CODEC_ID_HEVC ? 2 : 1; + else + vtctx->has_b_frames = 0; CFRelease(has_b_frames_cfbool); } avctx->has_b_frames = vtctx->has_b_frames;