diff mbox series

[FFmpeg-devel,1/2] avcodec/mediacodecdec_common: ensure input buffer timestamp is positive

Message ID 20240612134729.150227-2-matthieu.bouron@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/mediacodecdec_common: ensure input buffer timestamp is positive | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Matthieu Bouron June 12, 2024, 1:42 p.m. UTC
Submitting a buffer with a negative timestamp seems to stall the Mediacodec audio
decoders.
---
 libavcodec/mediacodecdec_common.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index d6f91e6e89..4d22db8ecf 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -658,6 +658,8 @@  int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
         if (pts && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
             pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
         }
+        if (pts < 0)
+            pts = 0;
 
         if (need_draining) {
             uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);