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

Matthieu Bouron matthieu.bouron at gmail.com
Wed Jun 12 16:42:09 EEST 2024


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 --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);
-- 
2.45.2



More information about the ffmpeg-devel mailing list