[vlc-commits] codec: aom: flush decoder on seek

Francois Cartegnie git at videolan.org
Thu Oct 4 17:20:47 CEST 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jul 19 16:56:30 2018 +0200| [0a59986d1c56dbcd233da69a27aebe170bcca248] | committer: Tristan Matthews

codec: aom: flush decoder on seek

also drops flushed pics intead of sending them

(cherry picked from commit 7d721887512fd4a103215c8949268670c6030cda)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0a59986d1c56dbcd233da69a27aebe170bcca248
---

 modules/codec/aom.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/modules/codec/aom.c b/modules/codec/aom.c
index a56fad7d6c..37cfcbef7b 100644
--- a/modules/codec/aom.c
+++ b/modules/codec/aom.c
@@ -228,7 +228,8 @@ static void OutputFrame(decoder_t *dec, const struct aom_image *img)
     }
 }
 
-static int PopFrames(decoder_t *dec)
+static int PopFrames(decoder_t *dec,
+                     void(*pf_output)(decoder_t *, const struct aom_image *))
 {
     decoder_sys_t *p_sys = dec->p_sys;
     aom_codec_ctx_t *ctx = &p_sys->ctx;
@@ -245,12 +246,32 @@ static int PopFrames(decoder_t *dec)
             continue;
         }
 
-        OutputFrame(dec, img);
+        pf_output(dec, img);
     }
 
     return VLCDEC_SUCCESS;
 }
 
+/****************************************************************************
+ * Flush: clears decoder between seeks
+ ****************************************************************************/
+static void DropFrame(decoder_t *dec, const struct aom_image *img)
+{
+    VLC_UNUSED(dec);
+    VLC_UNUSED(img);
+    /* do nothing for now */
+}
+
+static void FlushDecoder(decoder_t *dec)
+{
+    decoder_sys_t *p_sys = dec->p_sys;
+    aom_codec_ctx_t *ctx = &p_sys->ctx;
+
+    if(PushFrame(dec, NULL) != VLCDEC_SUCCESS)
+        AOM_ERR(dec, ctx, "Failed to flush decoder");
+    else
+        PopFrames(dec, DropFrame);
+}
 
 /****************************************************************************
  * Decode: the whole thing
@@ -265,7 +286,7 @@ static int Decode(decoder_t *dec, block_t *block)
 
     int i_ret = PushFrame(dec, block);
 
-    PopFrames(dec);
+    PopFrames(dec, OutputFrame);
 
     return i_ret;
 }
@@ -307,6 +328,7 @@ static int OpenDecoder(vlc_object_t *p_this)
     }
 
     dec->pf_decode = Decode;
+    dec->pf_flush = FlushDecoder;
 
     dec->fmt_out.video.i_width = dec->fmt_in.video.i_width;
     dec->fmt_out.video.i_height = dec->fmt_in.video.i_height;
@@ -329,10 +351,7 @@ static void CloseDecoder(vlc_object_t *p_this)
     decoder_sys_t *sys = dec->p_sys;
 
     /* Flush decoder */
-    if(PushFrame(dec, NULL) != VLCDEC_SUCCESS)
-        AOM_ERR(p_this, &sys->ctx, "Failed to flush decoder");
-    else
-        PopFrames(dec);
+    FlushDecoder(dec);
 
     aom_codec_destroy(&sys->ctx);
 



More information about the vlc-commits mailing list