Skip to content

Commit

Permalink
fix(amfenc): stop busy waiting for encoder output (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman authored Sep 2, 2024
1 parent 8cd3656 commit a65a35b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ jobs:
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/04-mfenc-lowlatency.patch
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/05-amfenc-new-av1-usages.patch
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/06-vaapi-customized-surface-alignment.patch
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/07-amfenc-query-timeout.patch
- name: Setup cross compilation
id: cross
Expand Down
53 changes: 53 additions & 0 deletions ffmpeg_patches/ffmpeg/07-amfenc-query-timeout.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From df5d0203200337f9472b729dfb9a1eb9442971c3 Mon Sep 17 00:00:00 2001
From: Cameron Gutman <aicommander@gmail.com>
Date: Mon, 2 Sep 2024 16:57:36 -0500
Subject: [PATCH] amfenc: Use QUERY_TIMEOUT feature to avoid busy looping

---
libavcodec/amfenc_av1.c | 2 ++
libavcodec/amfenc_h264.c | 2 ++
libavcodec/amfenc_hevc.c | 2 ++
3 files changed, 6 insertions(+)

diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c
index c4e9f45e87..5102db2068 100644
--- a/libavcodec/amfenc_av1.c
+++ b/libavcodec/amfenc_av1.c
@@ -196,6 +196,8 @@ FF_ENABLE_DEPRECATION_WARNINGS

AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_FRAMERATE, framerate);

+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_QUERY_TIMEOUT, 50);
+
switch (avctx->profile) {
case AV_PROFILE_AV1_MAIN:
profile = AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN;
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index d3c6f6a10b..d94644bd85 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -225,6 +225,8 @@ FF_ENABLE_DEPRECATION_WARNINGS

AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_FRAMERATE, framerate);

+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QUERY_TIMEOUT, 50);
+
switch (avctx->profile) {
case AV_PROFILE_H264_BASELINE:
profile = AMF_VIDEO_ENCODER_PROFILE_BASELINE;
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index c0da0f08b2..4b9e419b74 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -187,6 +187,8 @@ FF_ENABLE_DEPRECATION_WARNINGS

AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMERATE, framerate);

+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QUERY_TIMEOUT, 50);
+
color_depth = AMF_COLOR_BIT_DEPTH_8;
switch (avctx->profile) {
case AV_PROFILE_HEVC_MAIN:
--
2.43.0.windows.1

0 comments on commit a65a35b

Please sign in to comment.