[FFmpeg-devel,3/6] avcodec/mediacodecdec_common: warn when PTS is missing

Submitted by Aman Gupta on Sept. 5, 2019, 6:27 p.m.

Details

Message ID 20190905182735.65987-3-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Gupta Sept. 5, 2019, 6:27 p.m.
From: Aman Gupta <aman@tmm1.net>

MediaCodec decoders require PTS for proper operation.

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavcodec/mediacodecdec_common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Matthieu Bouron Sept. 6, 2019, 7:44 a.m.
On Thu, Sep 05, 2019 at 11:27:32AM -0700, Aman Gupta wrote:
> From: Aman Gupta <aman@tmm1.net>
> 
> MediaCodec decoders require PTS for proper operation.
> 
> Signed-off-by: Aman Gupta <aman@tmm1.net>
> ---
>  libavcodec/mediacodecdec_common.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
> index 1656cd6664..eae9c28d42 100644
> --- a/libavcodec/mediacodecdec_common.c
> +++ b/libavcodec/mediacodecdec_common.c
> @@ -612,7 +612,11 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
>          }
>  
>          pts = pkt->pts;
> -        if (pts != AV_NOPTS_VALUE && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
> +        if (pts == AV_NOPTS_VALUE) {
> +            av_log(avctx, AV_LOG_WARNING, "Packet is missing PTS!\n");

Maybe reword to "Input packet is missing PTS" ? (without the !)

> +            pts = 0;
> +        }
> +        if (pts && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
>              pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
>          }
>  
> -- 
> 2.20.1
> 

Except from my comment, LGTM.

Patch hide | download patch | download mbox

diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index 1656cd6664..eae9c28d42 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -612,7 +612,11 @@  int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
         }
 
         pts = pkt->pts;
-        if (pts != AV_NOPTS_VALUE && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
+        if (pts == AV_NOPTS_VALUE) {
+            av_log(avctx, AV_LOG_WARNING, "Packet is missing PTS!\n");
+            pts = 0;
+        }
+        if (pts && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
             pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
         }