[vlc-commits] codec: aom: handle drain

Francois Cartegnie git at videolan.org
Thu Jul 19 17:15:24 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jul 19 16:51:29 2018 +0200| [a0fe91a6bb6acd224ee86f5fa9fc2f5b770e1707] | committer: Francois Cartegnie

codec: aom: handle drain

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

 modules/codec/aom.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/modules/codec/aom.c b/modules/codec/aom.c
index ad291a436d..ec63abd76e 100644
--- a/modules/codec/aom.c
+++ b/modules/codec/aom.c
@@ -173,15 +173,29 @@ static int PushFrame(decoder_t *dec, block_t *block)
 {
     decoder_sys_t *p_sys = dec->p_sys;
     aom_codec_ctx_t *ctx = &p_sys->ctx;
+    const uint8_t *p_buffer;
+    size_t i_buffer;
 
     /* Associate packet PTS with decoded frame */
     struct frame_priv_s *priv = &p_sys->frame_priv[p_sys->i_next_frame_priv++ % AOM_MAX_FRAMES_DEPTH];
-    priv->pts = (block->i_pts != VLC_TICK_INVALID) ? block->i_pts : block->i_dts;
+
+    if(likely(block))
+    {
+        p_buffer = block->p_buffer;
+        i_buffer = block->i_buffer;
+        priv->pts = (block->i_pts != VLC_TICK_INVALID) ? block->i_pts : block->i_dts;
+    }
+    else
+    {
+        p_buffer = NULL;
+        i_buffer = 0;
+    }
 
     aom_codec_err_t err;
-    err = aom_codec_decode(ctx, block->p_buffer, block->i_buffer, priv);
+    err = aom_codec_decode(ctx, p_buffer, i_buffer, priv);
 
-    block_Release(block);
+    if(block)
+        block_Release(block);
 
     if (err != AOM_CODEC_OK) {
         AOM_ERR(dec, ctx, "Failed to decode frame");
@@ -277,10 +291,8 @@ static int PopFrames(decoder_t *dec)
  ****************************************************************************/
 static int Decode(decoder_t *dec, block_t *block)
 {
-    if (!block) /* No Drain */
-        return VLCDEC_SUCCESS;
-
-    if (block->i_flags & (BLOCK_FLAG_CORRUPTED)) {
+    if (block && block->i_flags & (BLOCK_FLAG_CORRUPTED))
+    {
         block_Release(block);
         return VLCDEC_SUCCESS;
     }
@@ -351,13 +363,10 @@ static void CloseDecoder(vlc_object_t *p_this)
     decoder_sys_t *sys = dec->p_sys;
 
     /* Flush decoder */
-    aom_codec_err_t err = aom_codec_decode(&sys->ctx, NULL, 0, NULL);
-    if (err != AOM_CODEC_OK)
-    {
+    if(PushFrame(dec, NULL) != VLCDEC_SUCCESS)
         AOM_ERR(p_this, &sys->ctx, "Failed to flush decoder");
-    }
-
-    PopFrames(dec);
+    else
+        PopFrames(dec);
 
     aom_codec_destroy(&sys->ctx);
 



More information about the vlc-commits mailing list