[FFmpeg-devel,2/3] libavcodec/v4l2_buffers: check for valid pts value

Submitted by Lukas Rusak on Jan. 8, 2018, 11:27 p.m.

Details

Message ID 20180108232739.24962-3-lorusak@gmail.com
State New
Headers show

Commit Message

Lukas Rusak Jan. 8, 2018, 11:27 p.m.
we check for a valid pts in v4l2_set_pts so we should do the same here

---
 libavcodec/v4l2_buffers.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

wm4 Jan. 8, 2018, 11:46 p.m.
On Mon,  8 Jan 2018 15:27:38 -0800
Lukas Rusak <lorusak@gmail.com> wrote:

> we check for a valid pts in v4l2_set_pts so we should do the same here
> 
> ---
>  libavcodec/v4l2_buffers.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
> index fdafe7edca..5337f6f287 100644
> --- a/libavcodec/v4l2_buffers.c
> +++ b/libavcodec/v4l2_buffers.c
> @@ -71,7 +71,10 @@ static inline int64_t v4l2_get_pts(V4L2Buffer *avbuf)
>      /* convert pts back to encoder timebase */
>      v4l2_pts = avbuf->buf.timestamp.tv_sec * USEC_PER_SEC + avbuf->buf.timestamp.tv_usec;
>  
> -    return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base);
> +    if (v4l2_pts == 0)
> +        return AV_NOPTS_VALUE;
> +    else
> +        return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base);
>  }
>  
>  static enum AVColorPrimaries v4l2_get_color_primaries(V4L2Buffer *buf)

So, what about pts=0, which is valid? You shouldn't just turn 0 into
AV_NOPTS_VALUE.
Lukas Rusak Jan. 9, 2018, midnight
Hmm ok, disregard then.
On Mon, Jan 8, 2018 at 3:53 PM wm4 <nfxjfg@googlemail.com> wrote:

> On Mon,  8 Jan 2018 15:27:38 -0800
> Lukas Rusak <lorusak@gmail.com> wrote:
>
> > we check for a valid pts in v4l2_set_pts so we should do the same here
> >
> > ---
> >  libavcodec/v4l2_buffers.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
> > index fdafe7edca..5337f6f287 100644
> > --- a/libavcodec/v4l2_buffers.c
> > +++ b/libavcodec/v4l2_buffers.c
> > @@ -71,7 +71,10 @@ static inline int64_t v4l2_get_pts(V4L2Buffer *avbuf)
> >      /* convert pts back to encoder timebase */
> >      v4l2_pts = avbuf->buf.timestamp.tv_sec * USEC_PER_SEC +
> avbuf->buf.timestamp.tv_usec;
> >
> > -    return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base);
> > +    if (v4l2_pts == 0)
> > +        return AV_NOPTS_VALUE;
> > +    else
> > +        return av_rescale_q(v4l2_pts, v4l2_timebase,
> s->avctx->time_base);
> >  }
> >
> >  static enum AVColorPrimaries v4l2_get_color_primaries(V4L2Buffer *buf)
>
> So, what about pts=0, which is valid? You shouldn't just turn 0 into
> AV_NOPTS_VALUE.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Patch hide | download patch | download mbox

diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index fdafe7edca..5337f6f287 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -71,7 +71,10 @@  static inline int64_t v4l2_get_pts(V4L2Buffer *avbuf)
     /* convert pts back to encoder timebase */
     v4l2_pts = avbuf->buf.timestamp.tv_sec * USEC_PER_SEC + avbuf->buf.timestamp.tv_usec;
 
-    return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base);
+    if (v4l2_pts == 0)
+        return AV_NOPTS_VALUE;
+    else
+        return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base);
 }
 
 static enum AVColorPrimaries v4l2_get_color_primaries(V4L2Buffer *buf)