From patchwork Tue Sep 5 16:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 43560 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:299e:b0:13c:b4d8:6e34 with SMTP id f30csp1959146pzh; Tue, 5 Sep 2023 09:02:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOtNdVCO8oOWuvdM/vb/dRkV4GIbC3ywL1DqigTYv69QR5aDwyWsRnQPvNtfLfuPBHQO2p X-Received: by 2002:aa7:dd12:0:b0:522:27ea:58b with SMTP id i18-20020aa7dd12000000b0052227ea058bmr175813edv.39.1693929768410; Tue, 05 Sep 2023 09:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929768; cv=none; d=google.com; s=arc-20160816; b=rqy/m0E4x4EGYyIWnHXPKgdWePnXSdwG3cv5KmPdvq4RIXSBUshuidngRwunNpcve2 YYWqiyKmJn6rc/Wya3dCluv63wc9Eve5VWCy+o6tJ8pl5DwHFUO6qrEtWB91NMwoi9pF Q3waQO2dIiL4JDrcYH1fKpM079yugkj9GSOA1XTli3ckuEB74W8ZtvuoGZSu10oFZYt9 00VZk6Vu/UGWOb95cnEBJN4/fi09R9pEYnmcfu2xaDFHE6JlfiAZi5uXJ+ye59sqPy2t Z+y4iVovVNnEgoU/ZNnJ4PC/GBdAcdyvOIHBtHFjOnQRS0qOCgNOI+Syp2NCZGdJz3AP vHCw== 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=cODGU8Hd93CK4A/FnouxrPapLv8i6Xispr78mggyBIw=; fh=paNsSD/gLXCX8XaG2wP2EhSbyn4+hY3DzFJxc2Arm+k=; b=NwxuodxZiWgJ4sIM+690koIJulLfmnctHD2bvyz/panEsDqEh/KtTCXXoCDuajPBqf LOl1iz/zJZ9X62PC3iWZs3/YxyWVft3G1RkxVWcLKUfp7Z9dhIGXAoVHTqzvaL0BsqKn um5REPRMPCAsxu/v0cqkXogQtH3kYjqp0rF3CZpeDQyVJRnONihjuK8Kqd0vF9PNhhL6 Hd/8FPaGS+OlYDWuZFbQdtjvd9F4YdwR/ZVpwxCa6MtkH7eEmbuOeiztdaEPpyY2j2ZI OrwEVBYJVErdZTOxwSugvLjSBQrVS47Dd9QnBfyOldpiEQTahZVBA26ttRqt1SGj+9I3 Ecyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=VCwefOv+; 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 w9-20020aa7d289000000b0052a18a31b34si7634378edq.600.2023.09.05.09.02.38; Tue, 05 Sep 2023 09:02:48 -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=VCwefOv+; 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 93FDC68C264; Tue, 5 Sep 2023 19:02:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 79D8368C264 for ; Tue, 5 Sep 2023 19:02:27 +0300 (EEST) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-401f503b529so26816575e9.0 for ; Tue, 05 Sep 2023 09:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693929746; x=1694534546; 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=8FsYNNYBkGzvkdR7mWd+rFeQ1UXyf2auqviwpRwma6s=; b=VCwefOv+lDcrNyMPhUGKtz1CoaDtoPRCKtvsKnzUQYVNYyqM1R9q9TpNeIY530tVJw +RKfwuAaPAFQ2tMB4Y3bwWRJG7QT+340eDMfmhwMkr3as0ZqfjEY9/hjWxC/Xpu2IEFp zGhtab70gMWBxZaGVBourl0hMPTqqeY1xjCuZ5iKMGXI9jVhODx0iGIQW2XhQumkVO5H 0SaplkL730h8wWQJXMA7VCBUttThuwtvC2sw344dqGHfr8wQaScTCDVsfkzEEh9bmqj7 ALm6NRMGJSMkzTTCYM2JWNilTRlFwVVd2Wy7xdGvIbvm4HAvRNFYA0GlPJUBjCNHuk8f QPyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693929746; x=1694534546; 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=8FsYNNYBkGzvkdR7mWd+rFeQ1UXyf2auqviwpRwma6s=; b=AQIvCf2HryKYqFWPjTdQZm2W/36WthdTpN+GiItgl0BRG2EKu/qVLa6pNQxRd9yifb Lu6AEmC4ay4e38OBL5KsNHxtEn4n36fWAluPZ7CDY92sSbXzN3XEBX1pGFb1U7ITvuFN v+frLIBdYMV+jIe7lbOgYhdxnaadFZXF2csRYu9QtajitIsZ04ICCUEkTFI6H3Gm9yOW Yj6A6N/AAIPkfLAtCEiVgxBBKHa82SWDLw7fS4iGNGsN5YyMFz1m8KXgGRqqBLpT80rG o6bAaZghyAHNfohZRaPZLgJ3UgginOdvl3uSFg8HlbzM47O2UPJPUexZK1Rb8YXDT1vG tnHw== X-Gm-Message-State: AOJu0Yz96oB2TtuZaHqYiyDXKMuOnVxzNtubUQZrqYII3c2WMx/vpqEP Yb0YzAwuz6Ti7nVtUC1pb4Dg+e/99k6sZw== X-Received: by 2002:a1c:4b01:0:b0:401:dc7c:2488 with SMTP id y1-20020a1c4b01000000b00401dc7c2488mr161657wma.11.1693929746368; Tue, 05 Sep 2023 09:02:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 09:02:25 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Sep 2023 00:02:20 +0800 Message-Id: <20230905160221.2347008-1-mypopydev@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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: lFHO2XPCJhWJ Dump the encoder, it's will help debug some case Signed-off-by: Jun Zhao --- libavcodec/videotoolboxenc.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 8e493c4f7a..3512d35b73 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1110,6 +1110,32 @@ 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) { + CFIndex length = CFStringGetLength(encoderID); + CFIndex max_size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); + char *name = av_malloc(max_size); + if (!name) + return AVERROR(ENOMEM); + + CFStringGetCString(encoderID, + name, + max_size, + kCFStringEncodingUTF8); + av_log(avctx, AV_LOG_DEBUG, "Init the encoder: %s\n", name); + + av_freep(&name); + } + 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 Tue Sep 5 16:02:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 43561 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4f16:b0:149:dfde:5c0a with SMTP id gi22csp1947546pzb; Tue, 5 Sep 2023 09:03:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRsUBvuFjj235zy2dFd27Gf6uMKsP53RIfscoA/275lRmn3eJmcqZvf3ID3Whg+vSTiQOk X-Received: by 2002:a17:906:76c2:b0:99e:39d:4fa7 with SMTP id q2-20020a17090676c200b0099e039d4fa7mr245734ejn.22.1693929785351; Tue, 05 Sep 2023 09:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929785; cv=none; d=google.com; s=arc-20160816; b=0JwHkUDksfFPKX2K/lzwCp6PeUtc7zbFgeKKsy8oFq34+WNBuXhJVsAm7gHFaeA+6V hirWXofe1lV4mt+my7EBQpbsgxNu1bXel7lJ6+shcCElj137zZhIPjSBVowy+9S/A17/ oV4ZpFO0h0ZkHUB7RZ75hlH2oAfZZnw9UgmxX4i/uX2IMGawQh6d24jNnu/xDg152QSn 4FbMu/fV5uNAbcIXp/aioUH4YOEcIeUnbAOxK7+/keFbT+Ij6PpJwPy019re/yq5oB4H ZoeVIPUOKeBy9PmO26H055BkHH/TE5Hk0qA7xkcrfB/OfiumVV9XgVTmDrWhOepWvFdY /v8Q== 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=0eoEfJ4QtkzZzF39Pf3L1iWPL+ubZHUUWi92GJhC32k=; fh=paNsSD/gLXCX8XaG2wP2EhSbyn4+hY3DzFJxc2Arm+k=; b=o3GWnKuZafFQmgDq8+lnpFUtvvdw1e/8jUHyE8K/KiS4sDUEwnUQZebGvfv0HaP7Em S3hPEN/O9yBb5TksL3ilGO+CJBUb9+2cif94xzpEWJ6dZ7EW5LKGZ/1wBbIVLMkzkn/6 ZxWk0Ssq2jCnS+MlF3n9+t6zrcTNlYTQM8hEL8jfJP43N3KsHCZQYN8RrYjdAxFOB2x9 B7+AN+GQxqkxdUG9zwb5/DJ2NW786V3FjgB1tSn7UWM9W/4AbisrwgzUQovdnDT9b1pl uxYmzrmlYkrI3+5/4aO3J2LN4ef5fx9/0xZrf53ajrja/oVH2CHxB2680PY7lCT+0k25 IG6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=cI2Zk5I5; 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 ke25-20020a17090798f900b0099279b2cdd8si7839669ejc.831.2023.09.05.09.02.52; Tue, 05 Sep 2023 09:03: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=cI2Zk5I5; 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 BAE2C68C7F6; Tue, 5 Sep 2023 19:02:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MQX8ulI6M2uW 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; }