Message ID | tencent_82D472A0D076F6490C36630EB84136429E06@qq.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avcodec/videotoolboxenc: add low-latency encoding | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
On 5/18/2023 7:15 AM, xufuji456 wrote: > Signed-off-by: xufuji456 <839789740@qq.com> > --- > libavcodec/videotoolboxenc.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index c6f22723d6..88334f1851 100644 > --- a/libavcodec/videotoolboxenc.c > +++ b/libavcodec/videotoolboxenc.c > @@ -251,6 +251,8 @@ typedef struct VTEncContext { > > /* can't be bool type since AVOption will access it as int */ > int a53_cc; > + > + int low_latency; > } VTEncContext; > > static int vtenc_populate_extradata(AVCodecContext *avctx, > @@ -1441,6 +1443,16 @@ static int vtenc_create_encoder(AVCodecContext *avctx, > } > } > > + if (vtctx->low_latency) { Nothing seems to set this? Also, you should check the existing AV_CODEC_FLAG_LOW_DELAY flag instead. > + status = VTSessionSetProperty(vtctx->session, > + kVTVideoEncoderSpecification_EnableLowLatencyRateControl, > + kCFBooleanTrue); > + > + if (status) { > + av_log(avctx, AV_LOG_ERROR, "Error setting low latency property: %d\n", status); > + } > + } > + > status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session); > if (status) { > av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index c6f22723d6..88334f1851 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -251,6 +251,8 @@ typedef struct VTEncContext { /* can't be bool type since AVOption will access it as int */ int a53_cc; + + int low_latency; } VTEncContext; static int vtenc_populate_extradata(AVCodecContext *avctx, @@ -1441,6 +1443,16 @@ static int vtenc_create_encoder(AVCodecContext *avctx, } } + if (vtctx->low_latency) { + status = VTSessionSetProperty(vtctx->session, + kVTVideoEncoderSpecification_EnableLowLatencyRateControl, + kCFBooleanTrue); + + if (status) { + av_log(avctx, AV_LOG_ERROR, "Error setting low latency property: %d\n", status); + } + } + status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session); if (status) { av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);
Signed-off-by: xufuji456 <839789740@qq.com> --- libavcodec/videotoolboxenc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)