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 539CD47352 for ; Tue, 5 Sep 2023 16:13:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 59EE368C7E9; Tue, 5 Sep 2023 19:13:07 +0300 (EEST) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9764568C60F for ; Tue, 5 Sep 2023 19:13:00 +0300 (EEST) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2bcbfb3705dso42259841fa.1 for ; Tue, 05 Sep 2023 09:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693930380; x=1694535180; 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=7RDJiWuZoHNj5MEzsDA0UO00B1995rxgApnMlGK8Uto=; b=oWJICDymw61pecKStjJheeAi3vJCQP2g6/46l+Cuv5TB9fT44RYFuDkr1ggP9At5hE wJv1HMiHiprBWbq10RGK0XmgidQSI8Mv0A/GEkmmp6XbzRZHb4u/f9astA3gZER1ubXM tfpyZtjUwA/BOcXzB7YVSC3JuHiORGrSKYlcFcbb4MIGqalp///KD4P3wjg0v14ATtZf LW9QmLaXlxLGGcxs3rqa2E+897YF4RFOI0OlaUqw1D+ZBOI/MS4Q5fmfjC8RUagDmDMh w0y1msxeUsz0j0R3gojz6YU0ve3jbZp9wVMmxm40lFqlkEP9EcI99/1wioKaeqMCHmO5 0zgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693930380; x=1694535180; 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=7RDJiWuZoHNj5MEzsDA0UO00B1995rxgApnMlGK8Uto=; b=KvKMZQi905/IeTIxrl5VK8WrVVMj6MbA0VoyltnNIrXFmAKo9k+tNMDXYBS9kjDVtn FCZ2pVj0isxzHG3oKUp/guErMwS62NVw8NQ1SE5qReO2m+YlzDj2XLDyAghC8+iCWLUR dC9rWY3f2Ax3Tx7X2iWsyJEJCCQq1XesCWxFnaMPdBNclc+iWh7P9N2elMjCc9Yw2ppz Aw3HiKKv44e09rUe/B47YPtj7pqdn0od5cCK8xllR2RJGUpTPVSQ1IkLHxxYvGvhvPAl P8ivBGfdX+O0ILIGt5jHQdz2NKCaAUOl6KXCT1pt+lI27mrJd6hZEkqJlUVip3ueVijF t7Fg== X-Gm-Message-State: AOJu0YxIEPQ9Tqao9Wr2STtl8VMHwt5k3WnqTuYzMKILvy3AE+7+Nib6 pVq01r1NvHnTdO9R3IRljW/VYa2fXBs= X-Google-Smtp-Source: AGHT+IH7+o86s5UMtTgrfvH18xkNF2i6/4y03QB9vHTKLl5w3yZ5sH9jUijU3sWfxWBgE3MeVL3pag== X-Received: by 2002:a2e:3a0f:0:b0:2bc:fac8:309c with SMTP id h15-20020a2e3a0f000000b002bcfac8309cmr129186lja.16.1693930379410; Tue, 05 Sep 2023 09:12:59 -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 gf16-20020a170906e21000b0098669cc16b2sm7743099ejb.83.2023.09.05.09.12.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2023 09:12:58 -0700 (PDT) From: Marvin Scholz To: FFmpeg development discussions and patches Date: Tue, 05 Sep 2023 18:12:57 +0200 X-Mailer: MailMate (1.14r5964) Message-ID: In-Reply-To: <20230905160221.2347008-2-mypopydev@gmail.com> References: <20230905160221.2347008-1-mypopydev@gmail.com> <20230905160221.2347008-2-mypopydev@gmail.com> MIME-Version: 1.0 Subject: Re: [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 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 5 Sep 2023, at 18:02, 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 | 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); Only available starting macOS 10.13+, needs to be handled accordingly, I think. > + > + 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". _______________________________________________ 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".