diff mbox series

[FFmpeg-devel,2/2] avformat/moflex: make seeking more useful

Message ID 20200910203904.17757-2-onemda@gmail.com
State Accepted
Commit cd67bf2a280fb3d2038756e523666b0bd1d1d6fc
Headers show
Series [FFmpeg-devel,1/2] avcodec/mobiclip: add missing flush
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Paul B Mahol Sept. 10, 2020, 8:39 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/moflex.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Andreas Rheinhardt Sept. 10, 2020, 8:41 p.m. UTC | #1
Paul B Mahol:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/moflex.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/moflex.c b/libavformat/moflex.c
> index 747e32f079..2111157408 100644
> --- a/libavformat/moflex.c
> +++ b/libavformat/moflex.c
> @@ -327,7 +327,13 @@ static int moflex_read_packet(AVFormatContext *s, AVPacket *pkt)
>                  av_packet_move_ref(pkt, packet);
>                  pkt->pos = m->pos;
>                  pkt->stream_index = stream_index;
> -                pkt->flags |= AV_PKT_FLAG_KEY;
> +                if (s->streams[stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
> +                    pkt->duration = 1;
> +                    if (pkt->data[0] & 0x80)
> +                        pkt->flags |= AV_PKT_FLAG_KEY;
> +                } else {
> +                    pkt->flags |= AV_PKT_FLAG_KEY;
> +                }
>                  return ret;
>              }
>          }
> @@ -341,6 +347,16 @@ static int moflex_read_packet(AVFormatContext *s, AVPacket *pkt)
>      return AVERROR_EOF;
>  }
>  
> +static int moflex_read_seek(AVFormatContext *s, int stream_index,
> +                            int64_t pts, int flags)
> +{
> +    MOFLEXDemuxContext *m = s->priv_data;
> +
> +    m->in_block = 0;
> +
> +    return -1;

A seek that always fails? Why?

> +}
> +
>  static int moflex_read_close(AVFormatContext *s)
>  {
>      for (int i = 0; i < s->nb_streams; i++) {
> @@ -360,6 +376,7 @@ AVInputFormat ff_moflex_demuxer = {
>      .read_probe     = moflex_probe,
>      .read_header    = moflex_read_header,
>      .read_packet    = moflex_read_packet,
> +    .read_seek      = moflex_read_seek,
>      .read_close     = moflex_read_close,
>      .extensions     = "moflex",
>      .flags          = AVFMT_GENERIC_INDEX,
>
Paul B Mahol Sept. 11, 2020, 9:07 a.m. UTC | #2
On Thu, Sep 10, 2020 at 10:41:09PM +0200, Andreas Rheinhardt wrote:
> Paul B Mahol:
> > Signed-off-by: Paul B Mahol <onemda@gmail.com>
> > ---
> >  libavformat/moflex.c | 19 ++++++++++++++++++-
> >  1 file changed, 18 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/moflex.c b/libavformat/moflex.c
> > index 747e32f079..2111157408 100644
> > --- a/libavformat/moflex.c
> > +++ b/libavformat/moflex.c
> > @@ -327,7 +327,13 @@ static int moflex_read_packet(AVFormatContext *s, AVPacket *pkt)
> >                  av_packet_move_ref(pkt, packet);
> >                  pkt->pos = m->pos;
> >                  pkt->stream_index = stream_index;
> > -                pkt->flags |= AV_PKT_FLAG_KEY;
> > +                if (s->streams[stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
> > +                    pkt->duration = 1;
> > +                    if (pkt->data[0] & 0x80)
> > +                        pkt->flags |= AV_PKT_FLAG_KEY;
> > +                } else {
> > +                    pkt->flags |= AV_PKT_FLAG_KEY;
> > +                }
> >                  return ret;
> >              }
> >          }
> > @@ -341,6 +347,16 @@ static int moflex_read_packet(AVFormatContext *s, AVPacket *pkt)
> >      return AVERROR_EOF;
> >  }
> >  
> > +static int moflex_read_seek(AVFormatContext *s, int stream_index,
> > +                            int64_t pts, int flags)
> > +{
> > +    MOFLEXDemuxContext *m = s->priv_data;
> > +
> > +    m->in_block = 0;
> > +
> > +    return -1;
> 
> A seek that always fails? Why?

Seek does not always fails, it succeeds with keyframes.
It switches to generic seek later.

> 
> > +}
> > +
> >  static int moflex_read_close(AVFormatContext *s)
> >  {
> >      for (int i = 0; i < s->nb_streams; i++) {
> > @@ -360,6 +376,7 @@ AVInputFormat ff_moflex_demuxer = {
> >      .read_probe     = moflex_probe,
> >      .read_header    = moflex_read_header,
> >      .read_packet    = moflex_read_packet,
> > +    .read_seek      = moflex_read_seek,
> >      .read_close     = moflex_read_close,
> >      .extensions     = "moflex",
> >      .flags          = AVFMT_GENERIC_INDEX,
> > 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/moflex.c b/libavformat/moflex.c
index 747e32f079..2111157408 100644
--- a/libavformat/moflex.c
+++ b/libavformat/moflex.c
@@ -327,7 +327,13 @@  static int moflex_read_packet(AVFormatContext *s, AVPacket *pkt)
                 av_packet_move_ref(pkt, packet);
                 pkt->pos = m->pos;
                 pkt->stream_index = stream_index;
-                pkt->flags |= AV_PKT_FLAG_KEY;
+                if (s->streams[stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+                    pkt->duration = 1;
+                    if (pkt->data[0] & 0x80)
+                        pkt->flags |= AV_PKT_FLAG_KEY;
+                } else {
+                    pkt->flags |= AV_PKT_FLAG_KEY;
+                }
                 return ret;
             }
         }
@@ -341,6 +347,16 @@  static int moflex_read_packet(AVFormatContext *s, AVPacket *pkt)
     return AVERROR_EOF;
 }
 
+static int moflex_read_seek(AVFormatContext *s, int stream_index,
+                            int64_t pts, int flags)
+{
+    MOFLEXDemuxContext *m = s->priv_data;
+
+    m->in_block = 0;
+
+    return -1;
+}
+
 static int moflex_read_close(AVFormatContext *s)
 {
     for (int i = 0; i < s->nb_streams; i++) {
@@ -360,6 +376,7 @@  AVInputFormat ff_moflex_demuxer = {
     .read_probe     = moflex_probe,
     .read_header    = moflex_read_header,
     .read_packet    = moflex_read_packet,
+    .read_seek      = moflex_read_seek,
     .read_close     = moflex_read_close,
     .extensions     = "moflex",
     .flags          = AVFMT_GENERIC_INDEX,