From patchwork Fri May 19 03:17:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5b6Q56aP6ZqG?= <839789740@qq.com> X-Patchwork-Id: 41718 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp983340pzb; Thu, 18 May 2023 20:17:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40wXJs3ehIIrzhJSvsAMb6ypD98KxyY7PDmJ0NWPdTk/p+mb/4Z6Xe3lOvyTq7kAJb1aa+ X-Received: by 2002:a17:907:3f13:b0:94a:57d1:5539 with SMTP id hq19-20020a1709073f1300b0094a57d15539mr374900ejc.5.1684466257055; Thu, 18 May 2023 20:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684466257; cv=none; d=google.com; s=arc-20160816; b=oY25MyK1sBybxXwQX7AF6GJtx2AU4Jz3G1heFmvVF6vv1tfRunXdlv0rPKjLDGHWN8 2/QPeVEQPuYCIfN8pH7KDeE36HUo7avMQsNmZ04bDQkMaEBi6EKyISm96/XgPFurF6Ff MlHhLC96kKnclE9TdUhL2GoW36AIs93yLdZvEbF0SZSbMHSfJRLXJRxnynZYTUrCfqBL +dNOa/PBkc9BYsdI9MozlkY1Ppvec4aUgxxKFQc59F5o3vGkEVOEMNxMr2WzQr7O4R4t Qo3IXiLomZaq1dQd37MgrqWuD5oSpsM7j/GyFg/+TzjU2B1Ln/GmtH0KXTEOwVs8UoWY WzEQ== 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:date:to:from:message-id :dkim-signature:delivered-to; bh=JQG4+DQvML7ifBsLNZeFq1AWh3MrdnenLsLi6pI0mgY=; b=skpmJlj61hNGVcKMatSmueh+bzdLZv2lvymC/Mlaocwz1x84lcXpHhMWvsAOAG8wGS HvtBOZruf0hr5UcN9umjQ3ttyqaPKBMfZgi0tyT6FiNPbXXwR+bfwjbRu+KAlw5IYnoD hHWiN6aTJ1+Y3zy+zPpe0Jm/7KMm/2IF3xIvq3g/ZlkDDVDvcfTVEmRLj8pjFbLfqfnJ 15dCGcDYgts9361dcX/8dkAbDd6zdEUAVJw6Vcq0LUmQnqfox1BMnCA7MnrKdZZEVspF 3WVL664D1lYzcfML5D3+C+cGTubbmKX6FEusSWRglvo/oz0aXrhdSfjsac9oGcBB6LZH Dvww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@qq.com header.s=s201512 header.b=A6ZtjJSB; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b5-20020a1709065e4500b00965e2dbb4fesi2553909eju.299.2023.05.18.20.17.36; Thu, 18 May 2023 20:17:37 -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=@qq.com header.s=s201512 header.b=A6ZtjJSB; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 141ED68BF7D; Fri, 19 May 2023 06:17:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-205.mail.qq.com (out203-205-221-205.mail.qq.com [203.205.221.205]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3B3E68C136 for ; Fri, 19 May 2023 06:17:24 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1684466242; bh=OpYF7eGHBJVH/6u7d+kKFsKzoJJ42GYYTz012R/Kai8=; h=From:To:Cc:Subject:Date; b=A6ZtjJSBldPiv3alh8F4OLby2TsSIwmTfLNZVj8ps0YJ2REfe92i9zQ4ZBKsRenQi t3KiofIMaGwpSGg5UxEyhHzbdj8+wdZLSlvButOyLhqPUDOCGhBBBB9h5SVXKEXt1u B7zP3D71F1/gyC80mHRYcRTBpkL+tr7dtpA6fiqI= Received: from localhost.localdomain ([113.66.217.3]) by newxmesmtplogicsvrsza12-0.qq.com (NewEsmtp) with SMTP id 44626806; Fri, 19 May 2023 11:17:06 +0800 X-QQ-mid: xmsmtpt1684466226t4vfcbxkk Message-ID: X-QQ-XMAILINFO: NvKyM24IHTKSaYjPUcn4li2Yu76irA8FUtrxfmW0XOvSw1i/fqNKYwdAAr4L8Q MGSEcnBN1+fz4hL4mu02oTxz9HjCdaQPL8krl3ceWpza4at+wOlWWHddzW+tZOR5zF1xsWp9qTM5 SvaillrRkFh7s9SVnNxPcV9SacJNUAqeIWkMngfYfVtY2g0jRNp9l9lUbZdWKMOj6pksVwIkcTG7 DSqTMpsO7AXAXhjNyipTWya6Q7V099ALn7SbuKJoH/mXGUMBZlr/4qGAHUrrj37m7c6kUvqSes8O iwKLf09WpyvoX+ONsSw6omOOuoG51UP5C1mtrYnKuLxqFhbOkYWMQKlOLoPKR8UHzpvGWKcxnPuE 9eAChDv8UHTSUzq6hlzReOE070oXY25qqdSaHF59pYE8S57tA6GTfE9mUMm0lIv04yFG0wCgGw41 5L1Lp+Ml676Eb4Yj/0fFdp7ZBsbROKxjNROoxip3MZswVhhH/lzt1sQnL8uTEqRoWj8TukcQZ5OS NQCQmvhS9VA0Z5ZxPht7pi4UvK8rKeys6rtiidHonoxjovHlmlZ4xsS2qHh1JOXMKwmjfLqJKRlK fbbLbQRGl25bPjJ5kX9hpLsG30F2tEv6fP+2b5/6f+Z1m1zMr73irJeH4IQ7dsufjj5JRjaf6A5Z 8IWVFW6DNjEyzuneiSfa32sIypd4nvX8QSZrZoKzcSmt8vD4E7pgMXnApxY8t2fNfvSHE4LsBvvy cZAnQJYjaY80Jd6CoeBtwSVa8Y4OlRqkrKZqpFc0p2ZYFITK0dIG41LJ5DEtkUPsKa8QzMNLDx8T CcEwalI8iyvuOLgrapg/Mbm7zPgMlNMZG4/Mvp0DDFplBMFLHFmXEZSJ1/gy7cPPLN96dlFNil+V 1SSPGAhGLqnFcfQYLvs2xqHrYuvR9Zthpr4bwr9RhO9ra6FXvKLyB0WGFsfVDPWHuO0MCRunrMJ7 Jj5vbgaumzfoqdZwh/N8uxguB4tqzjUPgmgoN3OdMFFomOBBe1IcdcxPImZV8d From: xufuji456 <839789740@qq.com> To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 May 2023 11:17:03 +0800 X-OQ-MSGID: <20230519031703.21046-1-839789740@qq.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: add low-latency 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: xufuji456 <839789740@qq.com> Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: lEwBrsdZdvD2 When using low-latency mode, it eliminates frame reordering and follows a one-in-one-out encoding mode Signed-off-by: xufuji456 <839789740@qq.com> --- libavcodec/videotoolboxenc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index c6f22723d6..ae1ef32b2d 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1441,6 +1441,17 @@ static int vtenc_create_encoder(AVCodecContext *avctx, } } + // low-latency mode: eliminate frame reordering, follow a one-in-one-out encoding mode + if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == AV_CODEC_ID_H264) { + status = VTSessionSetProperty(vtctx->session, + kVTVideoEncoderSpecification_EnableLowLatencyRateControl, + kCFBooleanTrue); + + if (status) { + av_log(avctx, AV_LOG_ERROR, "Error setting low latency property: %d\n", status); + } + } + status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session); if (status) { av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);