From: "mypopy@gmail.com" <mypopy@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Zhao Zhili <zhilizhao@tencent.com>
Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: refactor dump encoder name
Date: Sun, 26 Nov 2023 16:38:04 +0800
Message-ID: <CACYjbn3o1TfLM9K6Wqyy2a2tv6MQTOVNxo98whxTrw2AgBcDLQ@mail.gmail.com> (raw)
In-Reply-To: <tencent_9313ABBD4E0770182DA99AA340869A589F08@qq.com>
On Sat, Nov 25, 2023 at 12:06 PM Zhao Zhili <quinkblack@foxmail.com> wrote:
>
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> ---
> libavcodec/videotoolboxenc.c | 65 +++++++++++++++++++++---------------
> 1 file changed, 38 insertions(+), 27 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index b8a07e4e44..fbd33fd3f9 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -280,6 +280,41 @@ typedef struct VTEncContext {
> int max_ref_frames;
> } VTEncContext;
>
> +static int vt_dump_encoder(AVCodecContext *avctx)
> +{
> + VTEncContext *vtctx = avctx->priv_data;
> + CFStringRef encoder_id = NULL;
> + int status;
> + CFIndex length, max_size;
> + char *name;
> +
> + status = VTSessionCopyProperty(vtctx->session,
> + compat_keys.kVTCompressionPropertyKey_EncoderID,
> + kCFAllocatorDefault,
> + &encoder_id);
> + // OK if not supported
> + if (status != noErr)
> + return 0;
> +
> + length = CFStringGetLength(encoder_id);
> + max_size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
> + name = av_malloc(max_size);
> + if (!name) {
> + CFRelease(encoder_id);
> + return AVERROR(ENOMEM);
> + }
> +
> + CFStringGetCString(encoder_id,
> + name,
> + max_size,
> + kCFStringEncodingUTF8);
> + av_log(avctx, AV_LOG_DEBUG, "Init the encoder: %s\n", name);
> + av_freep(&name);
> + CFRelease(encoder_id);
> +
> + return 0;
> +}
> +
> static int vtenc_populate_extradata(AVCodecContext *avctx,
> CMVideoCodecType codec_type,
> CFStringRef profile_level,
> @@ -1176,33 +1211,9 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
> }
> #endif
>
> - // Dump the init encoder
> - {
> - CFStringRef encoderID = NULL;
> - status = VTSessionCopyProperty(vtctx->session,
> - compat_keys.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) {
> - CFRelease(encoderID);
> - 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);
> - }
> + status = vt_dump_encoder(avctx);
> + if (status < 0)
> + return status;
>
> 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");
> --
> 2.42.0
>
Patchset looks good for if pass the build
_______________________________________________
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".
prev parent reply other threads:[~2023-11-26 8:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231125040602.64250-1-quinkblack@foxmail.com>
2023-11-25 4:06 ` Zhao Zhili
2023-11-26 8:38 ` mypopy [this message]
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=CACYjbn3o1TfLM9K6Wqyy2a2tv6MQTOVNxo98whxTrw2AgBcDLQ@mail.gmail.com \
--to=mypopy@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=zhilizhao@tencent.com \
/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