diff mbox series

[FFmpeg-devel,2/2] avformat/tty: add seeking support

Message ID 20200202130428.27689-2-onemda@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/tty: make probing strict for first 8 bytes | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Paul B Mahol Feb. 2, 2020, 1:04 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/tty.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andreas Rheinhardt Feb. 2, 2020, 1:16 p.m. UTC | #1
Paul B Mahol:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/tty.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/tty.c b/libavformat/tty.c
> index 61e9f3e95c..2065fc0a53 100644
> --- a/libavformat/tty.c
> +++ b/libavformat/tty.c
> @@ -150,6 +150,8 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
>              n = s->fsize - p;
>      }
>  
> +    pkt->stream_index = 0;
> +    pkt->pts = pkt->pos / n;
>      pkt->size = av_get_packet(avctx->pb, pkt, n);
>      if (pkt->size < 0)
>          return pkt->size;
> @@ -182,4 +184,5 @@ AVInputFormat ff_tty_demuxer = {
>      .read_packet    = read_packet,
>      .extensions     = tty_extensions,
>      .priv_class     = &tty_demuxer_class,
> +    .flags          = AVFMT_GENERIC_INDEX,
>  };
> 
The very first thing av_get_packet() does is initializing the packet
which resets every field except data and size. In particular, it
overwrites what you set in the code you intend to add (where pkt->pos
is btw still -1 from the initialization done before the read_packet
function is called). So if this is supposed to make sense, you'd need
to put this code after av_get_packet().
And I'm curious what happened when you tested seeking with your code.

- Andreas
Paul B Mahol Feb. 7, 2020, 9:22 a.m. UTC | #2
On 2/2/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Paul B Mahol:
>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> ---
>>  libavformat/tty.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/libavformat/tty.c b/libavformat/tty.c
>> index 61e9f3e95c..2065fc0a53 100644
>> --- a/libavformat/tty.c
>> +++ b/libavformat/tty.c
>> @@ -150,6 +150,8 @@ static int read_packet(AVFormatContext *avctx,
>> AVPacket *pkt)
>>              n = s->fsize - p;
>>      }
>>
>> +    pkt->stream_index = 0;
>> +    pkt->pts = pkt->pos / n;
>>      pkt->size = av_get_packet(avctx->pb, pkt, n);
>>      if (pkt->size < 0)
>>          return pkt->size;
>> @@ -182,4 +184,5 @@ AVInputFormat ff_tty_demuxer = {
>>      .read_packet    = read_packet,
>>      .extensions     = tty_extensions,
>>      .priv_class     = &tty_demuxer_class,
>> +    .flags          = AVFMT_GENERIC_INDEX,
>>  };
>>
> The very first thing av_get_packet() does is initializing the packet
> which resets every field except data and size. In particular, it
> overwrites what you set in the code you intend to add (where pkt->pos
> is btw still -1 from the initialization done before the read_packet
> function is called). So if this is supposed to make sense, you'd need
> to put this code after av_get_packet().
> And I'm curious what happened when you tested seeking with your code.

It worked somehow, locally fixed.

>
> - Andreas
> _______________________________________________
> 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/tty.c b/libavformat/tty.c
index 61e9f3e95c..2065fc0a53 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -150,6 +150,8 @@  static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
             n = s->fsize - p;
     }
 
+    pkt->stream_index = 0;
+    pkt->pts = pkt->pos / n;
     pkt->size = av_get_packet(avctx->pb, pkt, n);
     if (pkt->size < 0)
         return pkt->size;
@@ -182,4 +184,5 @@  AVInputFormat ff_tty_demuxer = {
     .read_packet    = read_packet,
     .extensions     = tty_extensions,
     .priv_class     = &tty_demuxer_class,
+    .flags          = AVFMT_GENERIC_INDEX,
 };