diff mbox series

[FFmpeg-devel,2/2] lavc/videotoolboxenc: explicitly set realtime=false

Message ID 20211218215319.84070-2-rcombs@rcombs.me
State Accepted
Commit 4778ab2b1fa993457bb3657de56a12dc9a55f3a0
Headers show
Series [FFmpeg-devel,1/2] libavcodec/videotoolboxenc: use the correct types for options | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Ridley Combs Dec. 18, 2021, 9:53 p.m. UTC
On some encoders, this defaults to true, which can result in encode speed
being _limited_ to only slightly above realtime (as a power-saving measure),
so we need a way to disable it.
---
 libavcodec/videotoolboxenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Aman Karmani Dec. 19, 2021, 4:37 p.m. UTC | #1
On Sat, Dec 18, 2021 at 1:53 PM rcombs <rcombs@rcombs.me> wrote:

> On some encoders, this defaults to true, which can result in encode speed
> being _limited_ to only slightly above realtime (as a power-saving
> measure),
> so we need a way to disable it.
> ---
>  libavcodec/videotoolboxenc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 5f1e3a9b9c..3599d730d8 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -1391,10 +1391,10 @@ static int vtenc_create_encoder(AVCodecContext
>  *avctx,
>          }
>      }
>
> -    if (vtctx->realtime) {
> +    if (vtctx->realtime >= 0) {
>          status = VTSessionSetProperty(vtctx->session,
>
>  compat_keys.kVTCompressionPropertyKey_RealTime,
> -                                      kCFBooleanTrue);
> +                                      vtctx->realtime ? kCFBooleanTrue :
> kCFBooleanFalse);



LGTM


>
>          if (status) {
>              av_log(avctx, AV_LOG_ERROR, "Error setting realtime property:
> %d\n", status);
> @@ -2676,7 +2676,7 @@ static const enum AVPixelFormat prores_pix_fmts[] = {
>      { "require_sw", "Require software encoding", OFFSET(require_sw),
> AV_OPT_TYPE_BOOL, \
>          { .i64 = 0 }, 0, 1, VE }, \
>      { "realtime", "Hint that encoding should happen in real-time if not
> faster (e.g. capturing from camera).", \
> -        OFFSET(realtime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
> +        OFFSET(realtime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, -1, 1, VE }, \
>      { "frames_before", "Other frames will come before the frames in this
> session. This helps smooth concatenation issues.", \
>          OFFSET(frames_before), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE
> }, \
>      { "frames_after", "Other frames will come after the frames in this
> session. This helps smooth concatenation issues.", \
> --
> 2.33.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".
>
diff mbox series

Patch

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 5f1e3a9b9c..3599d730d8 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1391,10 +1391,10 @@  static int vtenc_create_encoder(AVCodecContext   *avctx,
         }
     }
 
-    if (vtctx->realtime) {
+    if (vtctx->realtime >= 0) {
         status = VTSessionSetProperty(vtctx->session,
                                       compat_keys.kVTCompressionPropertyKey_RealTime,
-                                      kCFBooleanTrue);
+                                      vtctx->realtime ? kCFBooleanTrue : kCFBooleanFalse);
 
         if (status) {
             av_log(avctx, AV_LOG_ERROR, "Error setting realtime property: %d\n", status);
@@ -2676,7 +2676,7 @@  static const enum AVPixelFormat prores_pix_fmts[] = {
     { "require_sw", "Require software encoding", OFFSET(require_sw), AV_OPT_TYPE_BOOL, \
         { .i64 = 0 }, 0, 1, VE }, \
     { "realtime", "Hint that encoding should happen in real-time if not faster (e.g. capturing from camera).", \
-        OFFSET(realtime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
+        OFFSET(realtime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, -1, 1, VE }, \
     { "frames_before", "Other frames will come before the frames in this session. This helps smooth concatenation issues.", \
         OFFSET(frames_before), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
     { "frames_after", "Other frames will come after the frames in this session. This helps smooth concatenation issues.", \