[vlc-commits] codec: dav1d: always pull all available pictures

Francois Cartegnie git at videolan.org
Thu Feb 13 22:41:41 CET 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Feb 13 17:38:11 2020 +0100| [4a3247306ae607eab8304862118a9c40d935c7f2] | committer: Francois Cartegnie

codec: dav1d: always pull all available pictures

otherwise introduces latency due to pacing, and
potentially an offset in frame output sequence

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a3247306ae607eab8304862118a9c40d935c7f2
---

 modules/codec/dav1d.c | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/modules/codec/dav1d.c b/modules/codec/dav1d.c
index b123a64db2..e802c77fdf 100644
--- a/modules/codec/dav1d.c
+++ b/modules/codec/dav1d.c
@@ -234,8 +234,6 @@ static int Decode(decoder_t *dec, block_t *block)
         b_eos = (block->i_flags & BLOCK_FLAG_END_OF_SEQUENCE);
     }
 
-    Dav1dPicture img = { 0 };
-
     bool b_draining = false;
     int i_ret = VLCDEC_SUCCESS;
     int res;
@@ -251,27 +249,37 @@ static int Decode(decoder_t *dec, block_t *block)
             }
         }
 
-        res = dav1d_get_picture(p_sys->c, &img);
-        if (res == 0)
+        bool b_output_error = false;
+        do
         {
-            picture_t *_pic = img.allocator_data;
-            picture_t *pic = picture_Clone(_pic);
-            if (unlikely(pic == NULL))
+            Dav1dPicture img = { 0 };
+            res = dav1d_get_picture(p_sys->c, &img);
+            if (res == 0)
             {
-                i_ret = VLC_EGENERIC;
-                picture_Release(_pic);
+                picture_t *_pic = img.allocator_data;
+                picture_t *pic = picture_Clone(_pic);
+                if (unlikely(pic == NULL))
+                {
+                    i_ret = VLC_EGENERIC;
+                    picture_Release(_pic);
+                    b_output_error = true;
+                    break;
+                }
+                pic->b_progressive = true; /* codec does not support interlacing */
+                pic->date = img.m.timestamp;
+                decoder_QueueVideo(dec, pic);
+                dav1d_picture_unref(&img);
+            }
+            else if (res != DAV1D_ERR(EAGAIN))
+            {
+                msg_Warn(dec, "Decoder error %d!", res);
+                b_output_error = true;
                 break;
             }
-            pic->b_progressive = true; /* codec does not support interlacing */
-            pic->date = img.m.timestamp;
-            decoder_QueueVideo(dec, pic);
-            dav1d_picture_unref(&img);
-        }
-        else if (res != DAV1D_ERR(EAGAIN))
-        {
-            msg_Warn(dec, "Decoder error %d!", res);
+        } while(res == 0);
+
+        if(b_output_error)
             break;
-        }
 
         /* on drain, we must ignore the 1st EAGAIN */
         if(!b_draining && (res == DAV1D_ERR(EAGAIN) || res == 0)



More information about the vlc-commits mailing list