[vlc-commits] mediacodec: drain before restart
Thomas Guillem
git at videolan.org
Wed Mar 29 15:49:46 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Mar 27 17:59:07 2017 +0200| [8106fb6b7d31347b088e106ab7793aa1c41bdb47] | committer: Thomas Guillem
mediacodec: drain before restart
This avoid to loose some frames when SPS/PPS change.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8106fb6b7d31347b088e106ab7793aa1c41bdb47
---
modules/codec/omxil/mediacodec.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index af20d6f..2f7fb19 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -50,7 +50,7 @@
#define BLOCK_FLAG_CSD (0x01 << BLOCK_FLAG_PRIVATE_SHIFT)
#define DECODE_FLAG_RESTART (0x01)
-#define DECODE_FLASH_FLUSH (0x02)
+#define DECODE_FLAG_DRAIN (0x02)
/**
* Callback called when a new block is processed from DecodeBlock.
* It returns -1 in case of error, 0 if block should be dropped, 1 otherwise.
@@ -1404,6 +1404,8 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_in_block)
if (p_in_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED))
{
+ if (p_sys->b_output_ready)
+ QueueBlockLocked(p_dec, NULL, true);
DecodeFlushLocked(p_dec);
if (p_sys->b_aborted)
goto end;
@@ -1432,13 +1434,15 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_in_block)
}
goto end;
}
- if (p_sys->i_decode_flags & (DECODE_FLASH_FLUSH|DECODE_FLAG_RESTART))
+ if (p_sys->i_decode_flags & (DECODE_FLAG_DRAIN|DECODE_FLAG_RESTART))
{
- msg_Warn(p_dec, "Flushing from DecodeBlock");
+ msg_Warn(p_dec, "Draining from DecodeBlock");
const bool b_restart = p_sys->i_decode_flags & DECODE_FLAG_RESTART;
p_sys->i_decode_flags = 0;
- /* Flush before restart to unblock OutThread */
+ /* Drain and flush before restart to unblock OutThread */
+ if (p_sys->b_output_ready)
+ QueueBlockLocked(p_dec, NULL, true);
DecodeFlushLocked(p_dec);
if (p_sys->b_aborted)
goto end;
@@ -1539,8 +1543,8 @@ static int VideoHXXX_OnNewBlock(decoder_t *p_dec, block_t **pp_block)
p_sys->i_decode_flags |= DECODE_FLAG_RESTART;
} else
{
- msg_Err(p_dec, "SPS/PPS changed during playback. Flush it");
- p_sys->i_decode_flags |= DECODE_FLASH_FLUSH;
+ msg_Err(p_dec, "SPS/PPS changed during playback. Drain it");
+ p_sys->i_decode_flags |= DECODE_FLAG_DRAIN;
}
}
More information about the vlc-commits
mailing list