* [FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: refactor dump encoder name [not found] <20231125040602.64250-1-quinkblack@foxmail.com> @ 2023-11-25 4:06 ` Zhao Zhili 2023-11-26 8:38 ` mypopy 0 siblings, 1 reply; 2+ messages in thread From: Zhao Zhili @ 2023-11-25 4:06 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Zhao Zhili 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 _______________________________________________ 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". ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: refactor dump encoder name 2023-11-25 4:06 ` [FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: refactor dump encoder name Zhao Zhili @ 2023-11-26 8:38 ` mypopy 0 siblings, 0 replies; 2+ messages in thread From: mypopy @ 2023-11-26 8:38 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Zhao Zhili 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". ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-26 8:38 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20231125040602.64250-1-quinkblack@foxmail.com> 2023-11-25 4:06 ` [FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: refactor dump encoder name Zhao Zhili 2023-11-26 8:38 ` mypopy
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