[vlc-devel] [PATCH 6/7] video_output: drop reused pictures if they are late

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 20 11:04:37 CEST 2020


The reused picture happens when the decoding+display starts or after a flush.

In the former case it's possible the decoder took some time and we have fresher
pictures available.

In the latter case the kept decoded picture may be very old and we shouldn't be
reusing if it's late.

In both cases, there will be fresher ones coming if the one left was too late.
---
 src/video_output/video_output.c | 36 ++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index d9e6d5ff690..836dbe5a7aa 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1122,30 +1122,28 @@ static picture_t *ThreadGetPrerenderedLocked(vout_thread_sys_t *vout, bool reuse
             decoded = picture_Hold(sys->displayed.decoded);
         } else {
             decoded = picture_fifo_Pop(sys->decoder_fifo);
+            if (!decoded)
+                break;
 
-            if (decoded) {
-                if (DropLate(vout, decoded, can_drop_late, paused))
-                    continue;
-                vlc_video_context *pic_vctx = picture_GetVideoContext(decoded);
-                if (!VideoFormatIsCropArEqual(&decoded->format, &sys->filter.src_fmt))
-                {
-                    // we received an aspect ratio change
-                    // Update the filters with the filter source format with the new aspect ratio
-                    video_format_Clean(&sys->filter.src_fmt);
-                    video_format_Copy(&sys->filter.src_fmt, &decoded->format);
-                    if (sys->filter.src_vctx)
-                        vlc_video_context_Release(sys->filter.src_vctx);
-                    sys->filter.src_vctx = pic_vctx ? vlc_video_context_Hold(pic_vctx) : NULL;
-
-                    ThreadChangeFilters(vout);
-                }
+            vlc_video_context *pic_vctx = picture_GetVideoContext(decoded);
+            if (!VideoFormatIsCropArEqual(&decoded->format, &sys->filter.src_fmt))
+            {
+                // we received an aspect ratio change
+                // Update the filters with the filter source format with the new aspect ratio
+                video_format_Clean(&sys->filter.src_fmt);
+                video_format_Copy(&sys->filter.src_fmt, &decoded->format);
+                if (sys->filter.src_vctx)
+                    vlc_video_context_Release(sys->filter.src_vctx);
+                sys->filter.src_vctx = pic_vctx ? vlc_video_context_Hold(pic_vctx) : NULL;
+
+                ThreadChangeFilters(vout);
             }
         }
-
-        if (!decoded)
-            break;
         reuse_decoded = false;
 
+        if (DropLate(vout, decoded, can_drop_late, paused))
+            continue;
+
         if (sys->displayed.decoded)
             picture_Release(sys->displayed.decoded);
 
-- 
2.26.2



More information about the vlc-devel mailing list