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 2812C47479 for ; Fri, 8 Sep 2023 03:15:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CDA968C782; Fri, 8 Sep 2023 06:15:13 +0300 (EEST) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6CA168C77C for ; Fri, 8 Sep 2023 06:15:06 +0300 (EEST) Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2bb9a063f26so28160861fa.2 for ; Thu, 07 Sep 2023 20:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694142906; x=1694747706; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xemKjuk+Ewsg+7wjOHD4BplvKqXnZZceaRjYr37+dLQ=; b=P9tp1C/hITFXu0QXGItung960NumMj4w/BjNcafYWx2roLbS33RF31Az4Sr9Ok+4ya PIsKGEtGEupcsYrmjK/gEkJiFSmrisQVxFiDXmXGQlNM3FoCqTKCFUNMb2Jtf2KLi7/G 73N0t7YtdvYbmO+tbe4ZztB67hgOBNwu1Pa8EnUZVP+FqWYOG94ImOlNFLOa8C/itonF J0iASuf3CHEtVdFlTM3BWJUfMbqHhWfgF6wbE72PW9L/70WqUdQ+CXgl4UUcX2xGPNS9 6xDKfraDnlrtK2fqJVlARUICNU7Or9ArsDnQc3N1XOjAesHdulSrpQaLEpVvKPNUpHTf 6UJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694142906; x=1694747706; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xemKjuk+Ewsg+7wjOHD4BplvKqXnZZceaRjYr37+dLQ=; b=nu096WtUgeSNZPQqIKLAb9PQa9rIXy6OYuY8oJuadDRmua407OzrYlKv4wNNJIkyXt e5TeE+Nu9KNEMRV/34f3rmf2UuDhUKkYaEQvY1cyXKEAcYR6aMgtTYDXT45/Lr7VlLPf cGu7X1Fo1eE/hO412eWvKNrQvTk6Jy/oODUwNCY5hGwWFFNk37lLYXiZZI3Le1u9TT+C /mHjMMtecwdFoV9SD8DLytFvzzsM8XAEeWJX/EpFhFitbor0ikf9mPDssP+z5Ik7dDYm 0PeaNMldb7HZVFHWK8d2BZXFb1CaphOkaO1SdpWnKHdnvorIMu4cW9UkHXzzlXRJdTs2 GWkw== X-Gm-Message-State: AOJu0Yw5sV0iwQhKnQcc7qIOLISxijmF0EPHWMFabYYimdtyEIsGKUHT 74Wjy2wehjDVe61cfZNITkdZPm2QWUsmJw== X-Google-Smtp-Source: AGHT+IFA9SVbF18SMbIdO4QAduNLZQR8XINOlOHardl9sBJqkIBfQd6R0f2b/S2MM4J+3LSdg0oCLg== X-Received: by 2002:a19:655c:0:b0:501:c3cd:652c with SMTP id c28-20020a19655c000000b00501c3cd652cmr788488lfj.31.1694142905836; Thu, 07 Sep 2023 20:15:05 -0700 (PDT) Received: from [192.168.1.104] (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id lc18-20020a170906f91200b0099329b3ab67sm414085ejb.71.2023.09.07.20.15.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Sep 2023 20:15:05 -0700 (PDT) From: Marvin Scholz To: FFmpeg development discussions and patches Date: Fri, 08 Sep 2023 05:15:04 +0200 X-Mailer: MailMate (1.14r5964) Message-ID: <9532EE0B-2128-4418-8CD2-3B4FED7986D6@gmail.com> In-Reply-To: <20230908025546.3205524-2-mypopydev@gmail.com> References: <20230908025546.3205524-1-mypopydev@gmail.com> <20230908025546.3205524-2-mypopydev@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v3 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 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: On 8 Sep 2023, at 4:55, Jun Zhao wrote: > Get the encoder supported properties list, it will be used for > feature support checks. > > Signed-off-by: Jun Zhao > --- > libavcodec/videotoolboxenc.c | 70 ++++++++++++++++++++++++------------ > 1 file changed, 47 insertions(+), 23 deletions(-) > > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index 2e96990741..832147b6cd 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,20 @@ static int vtenc_create_encoder(AVCodecContext *avctx, > return AVERROR_EXTERNAL; > } > > + if (__builtin_available(macOS 10.13, iOS 11, tvOS 11, *)) { Thanks, though this needs the proper SDK guards as well too, to not break building with SDKs older than 10.13, unless FFmpeg does not care about this. See https://epir.at/2019/10/30/api-availability-and-target-conditionals/#checking-api-availability-at-compile-time > + 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; > @@ -1662,7 +1705,6 @@ static av_cold int vtenc_init(AVCodecContext *avctx) > // It can happen when user set avctx->profile directly. > if (vtctx->profile == AV_PROFILE_UNKNOWN) > vtctx->profile = avctx->profile; > - vtctx->session = NULL; > status = vtenc_configure_encoder(avctx); > if (status) return status; > > @@ -2431,8 +2473,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); > @@ -2688,10 +2730,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)); > @@ -2714,23 +2753,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". _______________________________________________ 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".