Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Jun Zhao <mypopydev@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Jun Zhao <barryjzhao@tencent.com>, Jun Zhao <mypopydev@gmail.com>
Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties
Date: Mon,  4 Sep 2023 11:53:40 +0800
Message-ID: <20230904035340.1819580-2-mypopydev@gmail.com> (raw)
In-Reply-To: <20230904035340.1819580-1-mypopydev@gmail.com>

Get the encoder supported properties list, it will be used for
feature support checks.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 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);
-- 
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".

  reply	other threads:[~2023-09-04  3:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  3:53 [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Jun Zhao
2023-09-04  3:53 ` Jun Zhao [this message]
2023-09-05  7:52   ` [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties Tomas Härdin
2023-09-05  9:36     ` mypopy
2023-09-05  9:49       ` "zhilizhao(赵志立)"
2023-09-05  7:46 ` [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Tomas Härdin
2023-09-05 10:43 ` Richard Kern
2023-09-05 10:47   ` "zhilizhao(赵志立)"

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230904035340.1819580-2-mypopydev@gmail.com \
    --to=mypopydev@gmail.com \
    --cc=barryjzhao@tencent.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git