diff mbox

[FFmpeg-devel,3/3] libavcodec/v4l2_m2m_dec: set default time base

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

Commit Message

Lukas Rusak Jan. 8, 2018, 11:27 p.m. UTC
This default time base should be set in order for ffmpeg to rescale the timebase in v4l2_get_pts and v4l2_set_pts

---
 libavcodec/v4l2_m2m_dec.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

wm4 Jan. 8, 2018, 11:45 p.m. UTC | #1
On Mon,  8 Jan 2018 15:27:39 -0800
Lukas Rusak <lorusak@gmail.com> wrote:

> This default time base should be set in order for ffmpeg to rescale the timebase in v4l2_get_pts and v4l2_set_pts
> 
> ---
>  libavcodec/v4l2_m2m_dec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index 8308613978..4de091a011 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -177,6 +177,8 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
>      capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;
>      capture->av_pix_fmt = avctx->pix_fmt;
>  
> +    avctx->time_base = AV_TIME_BASE_Q;
> +
>      ret = ff_v4l2_m2m_codec_init(avctx);
>      if (ret) {
>          av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");

Decoders in FFmpeg don't really have a concept of a timebase. If they
do, they should not use avctx->time_base, but avctx->pkt_timebase.

(I don't think avctx->pkt_timebase even needs to be set - API users
normally expect that the decoder simply passes through timestamps,
regardless of timebase. But if pkt_timebase is set, it should be the
same timebase that AVPacket uses, and the output AVFrames must use the
same timebase.

avctx->time_base doesn't really mean anything for decoding. There is an
obscure "other" use of it that has been deprecated, and the replacement
has the same obscure use (see doxygen).
Lukas Rusak Jan. 9, 2018, 12:03 a.m. UTC | #2
I'm not really sure what to do then.

Should I just replace time_base with pkt_timebase instead?

Or

Should I just remove the time base rescaling completely in v4l2_set_pts and
v4l2_get_pts as it seems to be 1:1 anyways.
On Mon, Jan 8, 2018 at 3:45 PM wm4 <nfxjfg@googlemail.com> wrote:

> On Mon,  8 Jan 2018 15:27:39 -0800
> Lukas Rusak <lorusak@gmail.com> wrote:
>
> > This default time base should be set in order for ffmpeg to rescale the
> timebase in v4l2_get_pts and v4l2_set_pts
> >
> > ---
> >  libavcodec/v4l2_m2m_dec.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> > index 8308613978..4de091a011 100644
> > --- a/libavcodec/v4l2_m2m_dec.c
> > +++ b/libavcodec/v4l2_m2m_dec.c
> > @@ -177,6 +177,8 @@ static av_cold int v4l2_decode_init(AVCodecContext
> *avctx)
> >      capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;
> >      capture->av_pix_fmt = avctx->pix_fmt;
> >
> > +    avctx->time_base = AV_TIME_BASE_Q;
> > +
> >      ret = ff_v4l2_m2m_codec_init(avctx);
> >      if (ret) {
> >          av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
>
> Decoders in FFmpeg don't really have a concept of a timebase. If they
> do, they should not use avctx->time_base, but avctx->pkt_timebase.
>
> (I don't think avctx->pkt_timebase even needs to be set - API users
> normally expect that the decoder simply passes through timestamps,
> regardless of timebase. But if pkt_timebase is set, it should be the
> same timebase that AVPacket uses, and the output AVFrames must use the
> same timebase.
>
> avctx->time_base doesn't really mean anything for decoding. There is an
> obscure "other" use of it that has been deprecated, and the replacement
> has the same obscure use (see doxygen).
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
wm4 Jan. 9, 2018, 12:14 a.m. UTC | #3
On Tue, 09 Jan 2018 00:03:15 +0000
Lukas Rusak <lorusak@gmail.com> wrote:

> I'm not really sure what to do then.
> 
> Should I just replace time_base with pkt_timebase instead?
> 
> Or
> 
> Should I just remove the time base rescaling completely in v4l2_set_pts and
> v4l2_get_pts as it seems to be 1:1 anyways.

The encoder needs to use time_base, the decoder pkt_timebase.

If the decoder can simply pass through timestamps, you don't need to do
any rescaling in the decoder. But I doubt v4l can do that.
diff mbox

Patch

diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 8308613978..4de091a011 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -177,6 +177,8 @@  static av_cold int v4l2_decode_init(AVCodecContext *avctx)
     capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;
     capture->av_pix_fmt = avctx->pix_fmt;
 
+    avctx->time_base = AV_TIME_BASE_Q;
+
     ret = ff_v4l2_m2m_codec_init(avctx);
     if (ret) {
         av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");