From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A6CE347349 for ; Tue, 5 Sep 2023 16:02:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 86C6C68C7F4; Tue, 5 Sep 2023 19:02:36 +0300 (EEST) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E80AC68C635 for ; Tue, 5 Sep 2023 19:02:30 +0300 (EEST) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-401d67434daso27032415e9.2 for ; Tue, 05 Sep 2023 09:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693929750; x=1694534550; 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=7sWkb8mLFZ5h8jGEUZb7mu93eXMxfxxD846zdfI8OQg=; b=cI2Zk5I5aUSn08yMD0nXmq4UywUNkxCXIaxKFO6sSHXHq1T1ymJEc/hzKmJzkhFXRn LfQ1LcOwC4u/KjRBhorwC1eAlKVIk5vHdk4INGn6bA1uOLflCB8maE5OMXk51DX5H0yk jtPoJKB/0RFu/Suv6foexKbuvZ0aZ1FHNCjJthaSC0ZJeO/+KhHVRpUPUma8ue/Df7vP TF/kEy6KyjOq7/9wRW+qgHE1I2SQl9nLdn4226EN6dzAxsHgGFJfppxko0W4T6j+mmz2 8BCegnjDd7+p/bcQIHW821zL4GIY5/T8DCN5/WM5itFJBEdM0zhDys/2NES2FElKsD8E UluA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693929750; x=1694534550; 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=7sWkb8mLFZ5h8jGEUZb7mu93eXMxfxxD846zdfI8OQg=; b=jS9LitrcyP4BveOkuGjjfiNuINfYZOC9VX3GjmLVFtYgEVSQioOfQHn316XsjbCSPp z/zukvM6amMQ5+uANO4Ztbe1XqMLzUD3uTDcoyQXR0QLH84FgaN4CtoDbt/mT/JcFrYG sTPk+79kgpANSyUsc8XgvS2QWBArULDBw9YAbrM3CzLBICmTYzx1uwo3IEnHOiOVBf5D sGImsYJQvJK5DnJyLUQp2hNOrioBgsiGcWtzL/c/1dqAsfoybBzXT+RRKMw6z2mFGBHo 52ehVEXj6SrCLhtAmTBkvWCUUu3Y5igNv8SA+n2JczZoA5mK8y1QupLLYzNgPBZCMbVG gxEg== X-Gm-Message-State: AOJu0YylqICsdLiYcGhqAbaBGnfCDY6ILZ0CgpdP9WzuIngODlFFfl6Z MyWF+43xNSd5XOj8CobaaHOVEZV5KeXwJbjG X-Google-Smtp-Source: AGHT+IGxVGhgjViP4gkRBThRouNDb6EBOot8o8rVviX4XlBVmwVrzhVtBirFB3OwRRK8jGKSxRu7Uw== X-Received: by 2002:a7b:c414:0:b0:3fe:f74c:b4f6 with SMTP id k20-20020a7bc414000000b003fef74cb4f6mr146543wmi.17.1693929749740; Tue, 05 Sep 2023 09:02:29 -0700 (PDT) Received: from localhost.localdomain ([49.51.162.193]) by smtp.gmail.com with ESMTPSA id v19-20020a05600c215300b003fef3180e7asm20537834wml.44.2023.09.05.09.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 09:02:29 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Sep 2023 00:02:21 +0800 Message-Id: <20230905160221.2347008-2-mypopydev@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230905160221.2347008-1-mypopydev@gmail.com> References: <20230905160221.2347008-1-mypopydev@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Get the encoder supported properties list, it will be used for feature support checks. Signed-off-by: Jun Zhao --- libavcodec/videotoolboxenc.c | 68 ++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 3512d35b73..0142342c58 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; @@ -321,6 +322,34 @@ static void clear_frame_queue(VTEncContext *vtctx) set_async_error(vtctx, 0); } +static void vtenc_reset(VTEncContext *vtctx) +{ + if (vtctx->session) { + 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); + vtctx->color_primaries = NULL; + } + + if (vtctx->transfer_function) { + CFRelease(vtctx->transfer_function); + vtctx->transfer_function = NULL; + } + + if (vtctx->ycbcr_matrix) { + CFRelease(vtctx->ycbcr_matrix); + vtctx->ycbcr_matrix = NULL; + } +} + static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, ExtraSEI **sei) { BufNode *info; @@ -1110,6 +1139,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"\n", (int64_t)status); + return AVERROR_EXTERNAL; + } + // Dump the init encoder { CFStringRef encoderID = NULL; @@ -1660,7 +1701,6 @@ static av_cold int vtenc_init(AVCodecContext *avctx) // It can happen when user set avctx->profile directly. if (vtctx->profile == FF_PROFILE_UNKNOWN) vtctx->profile = avctx->profile; - vtctx->session = NULL; status = vtenc_configure_encoder(avctx); if (status) return status; @@ -2429,8 +2469,8 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx, vtstatus = VTCompressionSessionPrepareToEncodeFrames(vtctx->session); if (vtstatus == kVTInvalidSessionErr) { - CFRelease(vtctx->session); - vtctx->session = NULL; + vtenc_reset(vtctx); + status = vtenc_configure_encoder(avctx); if (status == 0) pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session); @@ -2686,10 +2726,7 @@ static int vtenc_populate_extradata(AVCodecContext *avctx, pe_cleanup: CVPixelBufferRelease(pix_buf); - if(vtctx->session) - CFRelease(vtctx->session); - - vtctx->session = NULL; + vtenc_reset(vtctx); vtctx->frame_ct_out = 0; av_assert0(status != 0 || (avctx->extradata && avctx->extradata_size > 0)); @@ -2712,23 +2749,8 @@ static av_cold int vtenc_close(AVCodecContext *avctx) clear_frame_queue(vtctx); pthread_cond_destroy(&vtctx->cv_sample_sent); pthread_mutex_destroy(&vtctx->lock); - CFRelease(vtctx->session); - vtctx->session = NULL; - if (vtctx->color_primaries) { - CFRelease(vtctx->color_primaries); - vtctx->color_primaries = NULL; - } - - if (vtctx->transfer_function) { - CFRelease(vtctx->transfer_function); - vtctx->transfer_function = NULL; - } - - if (vtctx->ycbcr_matrix) { - CFRelease(vtctx->ycbcr_matrix); - vtctx->ycbcr_matrix = NULL; - } + vtenc_reset(vtctx); return 0; } -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".