diff mbox series

[FFmpeg-devel] avformat/mpegts: make sure mpegts_read_header always stops at the first pmt

Message ID 20201114233941.22783-1-cus@passwd.hu
State Accepted
Commit bf19833ae26b054a111de79b5ab1681c00cd8d0a
Headers show
Series [FFmpeg-devel] avformat/mpegts: make sure mpegts_read_header always stops at the first pmt
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Marton Balint Nov. 14, 2020, 11:39 p.m. UTC
mpegts_read_header stops parsing the file at the first PMT. However the check
that ensured this was wrong because streams can also be added before the first
PMT is received (e.g. EIT).

So let's make sure we are in the header reading phase by checking if ts->pkt is
unset instead of checking if the number of streams found so far is 0.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mpegts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ross Nicholson Nov. 15, 2020, 9:39 a.m. UTC | #1
On Sat, 14 Nov 2020 at 23:40, Marton Balint <cus@passwd.hu> wrote:

> mpegts_read_header stops parsing the file at the first PMT. However the
> check
> that ensured this was wrong because streams can also be added before the
> first
> PMT is received (e.g. EIT).
>
> So let's make sure we are in the header reading phase by checking if
> ts->pkt is
> unset instead of checking if the number of streams found so far is 0.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mpegts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 80d010db6c..a2003c6632 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2355,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const
> uint8_t *section, int section_len
>          goto out;
>
>      // stop parsing after pmt, we found header
> -    if (!ts->stream->nb_streams)
> +    if (!ts->pkt)
>          ts->stop_parse = 2;
>
>      set_pmt_found(ts, h->id);
> --
> 2.26.2
>
> _______________________________________________
> 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".


Thanks for this. With this fix streams with embedded EIT data open in
approx 1-1.5 seconds as opposed to 10-15 seconds without the fix. If
possible also having this fix in the 4.3 branch as well as master would be
great.
Marton Balint Nov. 18, 2020, 8:10 p.m. UTC | #2
On Sun, 15 Nov 2020, Ross Nicholson wrote:

> On Sat, 14 Nov 2020 at 23:40, Marton Balint <cus@passwd.hu> wrote:
>
>> mpegts_read_header stops parsing the file at the first PMT. However the
>> check
>> that ensured this was wrong because streams can also be added before the
>> first
>> PMT is received (e.g. EIT).
>>
>> So let's make sure we are in the header reading phase by checking if
>> ts->pkt is
>> unset instead of checking if the number of streams found so far is 0.
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  libavformat/mpegts.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> index 80d010db6c..a2003c6632 100644
>> --- a/libavformat/mpegts.c
>> +++ b/libavformat/mpegts.c
>> @@ -2355,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const
>> uint8_t *section, int section_len
>>          goto out;
>>
>>      // stop parsing after pmt, we found header
>> -    if (!ts->stream->nb_streams)
>> +    if (!ts->pkt)
>>          ts->stop_parse = 2;
>>
>>      set_pmt_found(ts, h->id);
>> --
>> 2.26.2
>>
>> _______________________________________________
>> 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".
>
>
> Thanks for this. With this fix streams with embedded EIT data open in
> approx 1-1.5 seconds as opposed to 10-15 seconds without the fix. If
> possible also having this fix in the 4.3 branch as well as master would be
> great.

Ok, will apply and backport.

Regards,
Marton
Ross Nicholson Nov. 19, 2020, 10:14 p.m. UTC | #3
On Wed, 18 Nov 2020 at 20:11, Marton Balint <cus@passwd.hu> wrote:

>
>
> On Sun, 15 Nov 2020, Ross Nicholson wrote:
>
> > On Sat, 14 Nov 2020 at 23:40, Marton Balint <cus@passwd.hu> wrote:
> >
> >> mpegts_read_header stops parsing the file at the first PMT. However the
> >> check
> >> that ensured this was wrong because streams can also be added before the
> >> first
> >> PMT is received (e.g. EIT).
> >>
> >> So let's make sure we are in the header reading phase by checking if
> >> ts->pkt is
> >> unset instead of checking if the number of streams found so far is 0.
> >>
> >> Signed-off-by: Marton Balint <cus@passwd.hu>
> >> ---
> >>  libavformat/mpegts.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> >> index 80d010db6c..a2003c6632 100644
> >> --- a/libavformat/mpegts.c
> >> +++ b/libavformat/mpegts.c
> >> @@ -2355,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const
> >> uint8_t *section, int section_len
> >>          goto out;
> >>
> >>      // stop parsing after pmt, we found header
> >> -    if (!ts->stream->nb_streams)
> >> +    if (!ts->pkt)
> >>          ts->stop_parse = 2;
> >>
> >>      set_pmt_found(ts, h->id);
> >> --
> >> 2.26.2
> >>
> >> _______________________________________________
> >> 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".
> >
> >
> > Thanks for this. With this fix streams with embedded EIT data open in
> > approx 1-1.5 seconds as opposed to 10-15 seconds without the fix. If
> > possible also having this fix in the 4.3 branch as well as master would
> be
> > great.
>
> Ok, will apply and backport.
>
> Regards,
> Marton
> _______________________________________________
> 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".



Thanks!
diff mbox series

Patch

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 80d010db6c..a2003c6632 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2355,7 +2355,7 @@  static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
         goto out;
 
     // stop parsing after pmt, we found header
-    if (!ts->stream->nb_streams)
+    if (!ts->pkt)
         ts->stop_parse = 2;
 
     set_pmt_found(ts, h->id);