From patchwork Mon Sep 4 03:53:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 43503 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4f16:b0:149:dfde:5c0a with SMTP id gi22csp971696pzb; Sun, 3 Sep 2023 20:53:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFulJWeSzRuHxyYcvMZbUpGkH6IUaSXWNycuVs9B8IBIIX1MatI6FCNQrigOD1fthj3rUmj X-Received: by 2002:a05:6402:1348:b0:52b:daff:f6f2 with SMTP id y8-20020a056402134800b0052bdafff6f2mr6365668edw.3.1693799636436; Sun, 03 Sep 2023 20:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693799636; cv=none; d=google.com; s=arc-20160816; b=RjlGNXb7Pe7l1K+tcsHwTuneLu0ycrExM7MvO77OHX+xSo9/EGQBs4THC9RThFmW4d YO/5kUBNzEdzRtz6ybLHaSMoAjxdue6bHDfjSY8H5FlvLBR/Y6Liv1RWuDatHaBFS2Ur XMkK4ad0w71S1Qr+rRdE0tPsbdV7YMUa8e1JMNN3si9K+LqhTdJEpcZf6ZwL+RQ8nBQn C+/6ddNbAQvIG1OdvzxGv9ir3YIYbLwQuhp4BEbYMVB01nxCdwoeIsZ0utRVvt3IxA5B pvICObpWQ5qbqkU+I4qKhXOaMBorplBLb1OwvZ/mnWwuRW2VqR9odiUhDFTEHbDpx20T mIVw== 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=I4ebs5R1sVQ7SqljCH7p/VaUDePd95SZWj9KIlUv0qI=; fh=paNsSD/gLXCX8XaG2wP2EhSbyn4+hY3DzFJxc2Arm+k=; b=rAMBmHeOtZ1ODaC4Hscb8emamHCsC5WXR6MYc05EjFg3FXfbMkt5pp1dFbwUIaWbUY BThsKSqMtUWmwooPH1iu5sg6M/kbhxoZSl34ZKHWbAwyfVbOgkrK+HcvP1FiyRiv9Unn mcWl767xZ1j7e9bpzYLwDCMgirXutH+I5XwxUM977AEXcmEUfrmEnH9EUarMM6j++fhM LtEz/P+zX+DvB5wc86d5VXI5pqubtOSnNKY5OyO1CIHqSym3l7b27fl4c6+H4aRlDpGI Td+xUW2AFmpf7v6ZFIG+mHefJ+P6wb3c3lVC+XnbGcgXCjZDHMUmRxu+hTynmbguwvFw eZng== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=punB0zw4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v6-20020aa7d646000000b005257f2c057esi5803268edr.127.2023.09.03.20.53.55; Sun, 03 Sep 2023 20:53:56 -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=@gmail.com header.s=20221208 header.b=punB0zw4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D599468C775; Mon, 4 Sep 2023 06:53:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 11E0E68BD6B for ; Mon, 4 Sep 2023 06:53:46 +0300 (EEST) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-3fef56f7248so10468865e9.3 for ; Sun, 03 Sep 2023 20:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693799624; x=1694404424; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UHIc2Unue+6w+m7JC9mpCiShMnBWGRWpXNu/dnM8eVY=; b=punB0zw4Bw6Ocn04xkJ39PHY5NQHEGDEoMJbmlujl0TaYzeaCLY/VHIugNJApzEgqM BnibvFglVrSjqQpGUKWflIfxuuowCB6o8oaHHoySnc9voujuMNaQHrcvlkgQyAvOqpR5 98hsYrZz7Byb4dTP3HM2lru2U4KuSGfVlzNwA5XXBpDkjZ9yLHacwRYnXLgBVC04LSi1 kzYwASR7kfoRepR3R2kDnybRhKhUpAJef7AdnKu/xlMSDNz/e2tYyDqs9ELXTvn2uCyx r4Z3gZZHPpYFv+aUWhmHFW33VIvvfjmyYPOKphchpkqZmZhrjcW0ayz/F8CxT/QDOB90 ee/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693799624; x=1694404424; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UHIc2Unue+6w+m7JC9mpCiShMnBWGRWpXNu/dnM8eVY=; b=cFBOgXwZnEfWkXyAlC/I/NBSr3tcTLkXFcSjMt0FYTiHRaX5SxtvshtfL/bfZC+fNn /g7v8zYGn8TAPRbx2PeHlwsJRaEqgkXNPeGLrOkMIDeNiDvBgebk95sU+ywuwyr8ofrq 3VTo/DcbAeHxWHIWi4s41G5qOrPv7NlBmQAlHeGEFC5P4zuJYXl+SOvVxgA3lHhUxetL s2X0dzw9/DbTbNbwX/YwebstCFOX4v0x4GBJOkOVTjCqx6Zh90f703i9FqsYRVO0E3iA YyuxTBpLH1+PEFdom0Q0Ly+Yw1gayBfKe/4Alf3gMeosKW2KtCkBG6jMPWSvhAvq1dz4 wR4A== X-Gm-Message-State: AOJu0YxhYJEqNalbWkfeVA3hZDTsL72kfMq6PyDVJfLliKpi+ruC2VAj /lQ8+at5BTczBKCsFf81DpF3GeABWL6DXQ== X-Received: by 2002:a5d:6310:0:b0:319:7abf:d8e2 with SMTP id i16-20020a5d6310000000b003197abfd8e2mr5335917wru.24.1693799624310; Sun, 03 Sep 2023 20:53:44 -0700 (PDT) Received: from localhost.localdomain ([49.51.162.193]) by smtp.gmail.com with ESMTPSA id l21-20020a7bc455000000b003fe195cecb3sm15966716wmi.38.2023.09.03.20.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 20:53:43 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Sep 2023 11:53:39 +0800 Message-Id: <20230904035340.1819580-1-mypopydev@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder 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: Jun Zhao , Jun Zhao Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FXW/W3ZxsDJQ Dump the encoder, it's will help debug some case Signed-off-by: Jun Zhao --- libavcodec/videotoolboxenc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index bfc03787a0..5633640a30 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1110,6 +1110,26 @@ static int vtenc_create_encoder(AVCodecContext *avctx, return AVERROR_EXTERNAL; } + // Dump the init encoder + { + CFStringRef encoderID = NULL; + status = VTSessionCopyProperty(vtctx->session, + kVTCompressionPropertyKey_EncoderID, + kCFAllocatorDefault, + &encoderID); + if (status == noErr) { + char names[256] = { 0 }; + + CFStringGetCString(encoderID, + names, + 255, + kCFStringEncodingUTF8); + av_log(avctx, AV_LOG_INFO, "Init the encoder: %s\n", names); + } + if (encoderID != NULL) + CFRelease(encoderID); + } + if (avctx->flags & AV_CODEC_FLAG_QSCALE && !vtenc_qscale_enabled()) { av_log(avctx, AV_LOG_ERROR, "Error: -q:v qscale not available for encoder. Use -b:v bitrate instead.\n"); return AVERROR_EXTERNAL; From patchwork Mon Sep 4 03:53:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 43504 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4f16:b0:149:dfde:5c0a with SMTP id gi22csp971730pzb; Sun, 3 Sep 2023 20:54:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCtUyLCFBPXHb3MlGANM8Oh7ojPRbkCIS9aQ2/7GZ8N9XKAFtsTJEq93xPGG2WjZopPaw1 X-Received: by 2002:ac2:43d2:0:b0:500:771f:4887 with SMTP id u18-20020ac243d2000000b00500771f4887mr5215321lfl.55.1693799646031; Sun, 03 Sep 2023 20:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693799646; cv=none; d=google.com; s=arc-20160816; b=UsZ9Y/FL26cw0qzBOPCyR0DaLpjH1EkQ910luB5tTbKewJXgopV/ULeSQV0m4i3/lt HRkQUtvjQqHi1Xjw8wx1La0QL9kQr0rjbmTEGYHS5eQFcpjvEQGAUqofho1yyixTbcmW ypeSoCobXFIvOl63haxw4jcfY+3pgDjbI7GY7pIvA4LEsXFt5Hh/25F1/uhaa3NNncvF z7e5La7g5dq6iGNZ44vSFL+tYMfEh5U5vIJn6xs8XHKQpLYWwnApDKOfB0p+oc2eQshe S9yT1SNFSBfAE2C6AQD6InFP/FIJitLUPIhVqjE1E3O2FSm5t49bhj+bGoSXNCC0Yfla CPFA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Mkgk24xV5YTT5sNbU2ubK3Xg8gdgvWCVIfhP+cuZBMs=; fh=paNsSD/gLXCX8XaG2wP2EhSbyn4+hY3DzFJxc2Arm+k=; b=Plefy9a/laUOcr7IFhujfkn/d6aapbE1sX98q9mV62Nd10nwUUOZb8rSa0MTqnUf6W vS3cDUbbalPuCbUBEgwQ7M53ymwrYl30xHzD7jOKEUrOU/7DrNqIhmCxOdEv82TkAvpo /zUmPrwK+HHF/B95ce7SCx3GXOhp5u+Nz8qtlxPA7Ypq0PhMqFpFIX1QxtWvQffw7yy8 FM9Lkt6u2vmeBRVpweflZO+lrNm3WPy8SPtn3pVgMWTFQNAroKQF652YOtDKnX/ol8kc 7vpiVOBKtcvfid2WUnGmRPDPnJoTI4LHBrEQJtNteIFKPr47uh+qDQ4g4biL8eoDl9V3 IW4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b="UnlFqYA/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w12-20020a50fa8c000000b00529fc23f034si5608856edr.368.2023.09.03.20.54.05; Sun, 03 Sep 2023 20:54:05 -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=@gmail.com header.s=20221208 header.b="UnlFqYA/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0408568C7A2; Mon, 4 Sep 2023 06:53:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 382C768BD6B for ; Mon, 4 Sep 2023 06:53:48 +0300 (EEST) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-31f4a286ae1so169906f8f.3 for ; Sun, 03 Sep 2023 20:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693799627; x=1694404427; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YUIuW5uAT4pKqWSajsxc/TAjVprg3onwAb2ghhXXHFc=; b=UnlFqYA/7K6w7wzA3D++Wq8v9xVjqIBLPFnjLBI/tI28bAME4mrF9P9+Scld9KylZK g6yfFaRyPjy5GbB60Au6MvO5eEa/XO/u/GeDJrnM/58VvCnCIap4vF4Tq3bOZaNWoeFo /onKaOXsKNJ2JaoKQ0uTRvggbcsCQPdFezKrNm73QQnuHHGp5D3PW0WSndKZVsPId23F Fo+mqWbBj0bM03C0KWOoSCeFxUp5UAaTjWxcnmeALDflvceXS3BdAUVolSkWz47ZRumh QTa8EavJqxlx5IRZbhe2V9DWdgS1h15NcA026Ur2TDZ72Tey8HjHe9K0DsJ5SpqpuO/F U13w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693799627; x=1694404427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YUIuW5uAT4pKqWSajsxc/TAjVprg3onwAb2ghhXXHFc=; b=IdZiSpE3jqnS/xxmf3As8ODdAaqN3GT65yPjwaXf1Qr2dv2gjKLPMhRrVBSXtnHeO/ 0ADW1AonmJPqKkMVtyt09OF5cA37RWxZw8f4AGQ4eZBvDl2fVxNWX/iUOTsEzhRgDCdi xVGQxtcQLnGXJ3qzvbybh2YhVdV5WagtZ8OvC35gkbG/+xfQBSebQVpXoqw5+SkETaPn Dd8e2M5dI3NJOcNUXuIOZakRpOmCQ60fecVXrPrg0X40SwZTzees1sWhPeVC7/e/NQjT GwaXBuC1Ec4kKrrhXivZPh59draRQ1O0luWurcGIAcDPwe/AeyPu0nKKh2S7Kp3EpdiO LFgg== X-Gm-Message-State: AOJu0YyljdlwnDm9bHlY8ViQNN4Q0xG6Wc+TakW5MZ1Z94MG0wwkPWlo kwLHuxMgdKJeofsWsi2uicbLoWsiW5bAWgXu X-Received: by 2002:a5d:61cd:0:b0:31c:488e:ff33 with SMTP id q13-20020a5d61cd000000b0031c488eff33mr6501875wrv.58.1693799627073; Sun, 03 Sep 2023 20:53:47 -0700 (PDT) Received: from localhost.localdomain ([49.51.162.193]) by smtp.gmail.com with ESMTPSA id l21-20020a7bc455000000b003fe195cecb3sm15966716wmi.38.2023.09.03.20.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 20:53:46 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Sep 2023 11:53:40 +0800 Message-Id: <20230904035340.1819580-2-mypopydev@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230904035340.1819580-1-mypopydev@gmail.com> References: <20230904035340.1819580-1-mypopydev@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties 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: Jun Zhao , Jun Zhao Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: iYbPAk5jrTZ3 Get the encoder supported properties list, it will be used for feature support checks. Signed-off-by: Jun Zhao --- libavcodec/videotoolboxenc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 5633640a30..8e70915225 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -232,6 +232,7 @@ typedef struct VTEncContext { AVClass *class; enum AVCodecID codec_id; VTCompressionSessionRef session; + CFDictionaryRef supported_props; CFStringRef ycbcr_matrix; CFStringRef color_primaries; CFStringRef transfer_function; @@ -1110,6 +1111,18 @@ static int vtenc_create_encoder(AVCodecContext *avctx, return AVERROR_EXTERNAL; } + status = VTCopySupportedPropertyDictionaryForEncoder(avctx->width, + avctx->height, + codec_type, + enc_info, + NULL, + &vtctx->supported_props); + + if (status != noErr) { + av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported property dictionary err=%"PRId64"", (int64_t)status); + return AVERROR_EXTERNAL; + } + // Dump the init encoder { CFStringRef encoderID = NULL; @@ -1656,6 +1669,7 @@ static av_cold int vtenc_init(AVCodecContext *avctx) if (vtctx->profile == FF_PROFILE_UNKNOWN) vtctx->profile = avctx->profile; vtctx->session = NULL; + vtctx->supported_props = NULL; status = vtenc_configure_encoder(avctx); if (status) return status; @@ -2426,6 +2440,11 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx, if (vtstatus == kVTInvalidSessionErr) { CFRelease(vtctx->session); vtctx->session = NULL; + if (vtctx->supported_props) { + CFRelease(vtctx->supported_props); + vtctx->supported_props = NULL; + } + status = vtenc_configure_encoder(avctx); if (status == 0) pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session); @@ -2685,6 +2704,10 @@ pe_cleanup: CFRelease(vtctx->session); vtctx->session = NULL; + if (vtctx->supported_props) { + CFRelease(vtctx->supported_props); + vtctx->supported_props = NULL; + } vtctx->frame_ct_out = 0; av_assert0(status != 0 || (avctx->extradata && avctx->extradata_size > 0)); @@ -2709,6 +2732,10 @@ static av_cold int vtenc_close(AVCodecContext *avctx) pthread_mutex_destroy(&vtctx->lock); CFRelease(vtctx->session); vtctx->session = NULL; + if (vtctx->supported_props) { + CFRelease(vtctx->supported_props); + vtctx->supported_props = NULL; + } if (vtctx->color_primaries) { CFRelease(vtctx->color_primaries);