[FFmpeg-cvslog] avfilter/vsrc_ddagrab: account for mouse-only frames during probing

Timo Rothenpieler git at videolan.org
Sat Jul 15 20:06:50 EEST 2023


ffmpeg | branch: release/6.0 | Timo Rothenpieler <timo at rothenpieler.org> | Fri Jul 14 20:29:22 2023 +0200| [c433ad89a018e89deed63432c03ebbc87cacbaaa] | committer: Timo Rothenpieler

avfilter/vsrc_ddagrab: account for mouse-only frames during probing

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c433ad89a018e89deed63432c03ebbc87cacbaaa
---

 libavfilter/vsrc_ddagrab.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 00c72187ea..abe8f84916 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -585,7 +585,7 @@ static int update_mouse_pointer(AVFilterContext *avctx, DXGI_OUTDUPL_FRAME_INFO
     return 0;
 }
 
-static int next_frame_internal(AVFilterContext *avctx, ID3D11Texture2D **desktop_texture)
+static int next_frame_internal(AVFilterContext *avctx, ID3D11Texture2D **desktop_texture, int need_frame)
 {
     DXGI_OUTDUPL_FRAME_INFO frame_info;
     DdagrabContext *dda = avctx->priv;
@@ -608,18 +608,32 @@ static int next_frame_internal(AVFilterContext *avctx, ID3D11Texture2D **desktop
     if (dda->draw_mouse) {
         ret = update_mouse_pointer(avctx, &frame_info);
         if (ret < 0)
-            return ret;
+            goto error;
+    }
+
+    if (need_frame && (!frame_info.LastPresentTime.QuadPart || !frame_info.AccumulatedFrames)) {
+        ret = AVERROR(EAGAIN);
+        goto error;
     }
 
     hr = IDXGIResource_QueryInterface(desktop_resource, &IID_ID3D11Texture2D, (void**)desktop_texture);
-    IDXGIResource_Release(desktop_resource);
-    desktop_resource = NULL;
+    release_resource(&desktop_resource);
     if (FAILED(hr)) {
         av_log(avctx, AV_LOG_ERROR, "DXGIResource QueryInterface failed\n");
-        return AVERROR_EXTERNAL;
+        ret = AVERROR_EXTERNAL;
+        goto error;
     }
 
     return 0;
+
+error:
+    release_resource(&desktop_resource);
+
+    hr = IDXGIOutputDuplication_ReleaseFrame(dda->dxgi_outdupl);
+    if (FAILED(hr))
+        av_log(avctx, AV_LOG_ERROR, "DDA error ReleaseFrame failed!\n");
+
+    return ret;
 }
 
 static int probe_output_format(AVFilterContext *avctx)
@@ -631,7 +645,7 @@ static int probe_output_format(AVFilterContext *avctx)
     av_assert1(!dda->probed_texture);
 
     do {
-        ret = next_frame_internal(avctx, &dda->probed_texture);
+        ret = next_frame_internal(avctx, &dda->probed_texture, 1);
     } while(ret == AVERROR(EAGAIN));
     if (ret < 0)
         return ret;
@@ -918,7 +932,7 @@ static int ddagrab_request_frame(AVFilterLink *outlink)
     now -= dda->first_pts;
 
     if (!dda->probed_texture) {
-        ret = next_frame_internal(avctx, &cur_texture);
+        ret = next_frame_internal(avctx, &cur_texture, 0);
     } else {
         cur_texture = dda->probed_texture;
         dda->probed_texture = NULL;



More information about the ffmpeg-cvslog mailing list