diff mbox

[FFmpeg-devel] avformat: remove request_probe assert from ff_read_packet

Message ID 82ade2e1-0155-3d3d-d094-0cfea447f125@googlemail.com
State Accepted
Headers show

Commit Message

Andreas Cadhalpun Oct. 19, 2016, 5:27 p.m. UTC
On 19.10.2016 05:29, Michael Niedermayer wrote:
> hmm, i guess the patch is then ok
> alternatively you could use i think:
> @@ -803,7 +803,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>                  return ret;
>              for (i = 0; i < s->nb_streams; i++) {
>                  st = s->streams[i];
> -                if (st->probe_packets)
> +                if (st->probe_packets || st->request_probe > 0)
>                      if ((err = probe_codec(s, st, NULL)) < 0)
>                          return err;
>                  av_assert0(st->request_probe <= 0);

Yes, this works fine and should guarantee that the assert can't be triggered.
Patch doing it that way is attached.

Best regards,
Andreas

Comments

Michael Niedermayer Oct. 19, 2016, 8:45 p.m. UTC | #1
On Wed, Oct 19, 2016 at 07:27:59PM +0200, Andreas Cadhalpun wrote:
> On 19.10.2016 05:29, Michael Niedermayer wrote:
> > hmm, i guess the patch is then ok
> > alternatively you could use i think:
> > @@ -803,7 +803,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
> >                  return ret;
> >              for (i = 0; i < s->nb_streams; i++) {
> >                  st = s->streams[i];
> > -                if (st->probe_packets)
> > +                if (st->probe_packets || st->request_probe > 0)
> >                      if ((err = probe_codec(s, st, NULL)) < 0)
> >                          return err;
> >                  av_assert0(st->request_probe <= 0);
> 
> Yes, this works fine and should guarantee that the assert can't be triggered.
> Patch doing it that way is attached.
> 
> Best regards,
> Andreas
> 

>  utils.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> f1f2b8b10efdab27848eeb2e2bac646eda08a175  0001-avformat-prevent-triggering-request_probe-assert-in-.patch
> From 7912c6f200a37130844221a73941a7971afa6455 Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> Date: Wed, 19 Oct 2016 19:23:49 +0200
> Subject: [PATCH] avformat: prevent triggering request_probe assert in
>  ff_read_packet
> 
> If probe_codec is called with pkt == NULL, it sets probe_packets to 0
> and request_probe to -1.
> However, request_probe can change when calling s->iformat->read_packet
> and thus a probe_packets value of 0 doesn't guarantee a request_probe
> value of -1.
> In that case calling probe_codec again is necessary to prevent
> triggering the assert.
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavformat/utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

thx

[...]
Andreas Cadhalpun Oct. 19, 2016, 9:15 p.m. UTC | #2
On 19.10.2016 22:45, Michael Niedermayer wrote:
> On Wed, Oct 19, 2016 at 07:27:59PM +0200, Andreas Cadhalpun wrote:
>> f1f2b8b10efdab27848eeb2e2bac646eda08a175  0001-avformat-prevent-triggering-request_probe-assert-in-.patch
>> From 7912c6f200a37130844221a73941a7971afa6455 Mon Sep 17 00:00:00 2001
>> From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
>> Date: Wed, 19 Oct 2016 19:23:49 +0200
>> Subject: [PATCH] avformat: prevent triggering request_probe assert in
>>  ff_read_packet
>>
>> If probe_codec is called with pkt == NULL, it sets probe_packets to 0
>> and request_probe to -1.
>> However, request_probe can change when calling s->iformat->read_packet
>> and thus a probe_packets value of 0 doesn't guarantee a request_probe
>> value of -1.
>> In that case calling probe_codec again is necessary to prevent
>> triggering the assert.
>>
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
>> ---
>>  libavformat/utils.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> LGTM

Pushed.

Best regards,
Andreas
diff mbox

Patch

From 7912c6f200a37130844221a73941a7971afa6455 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Date: Wed, 19 Oct 2016 19:23:49 +0200
Subject: [PATCH] avformat: prevent triggering request_probe assert in
 ff_read_packet

If probe_codec is called with pkt == NULL, it sets probe_packets to 0
and request_probe to -1.
However, request_probe can change when calling s->iformat->read_packet
and thus a probe_packets value of 0 doesn't guarantee a request_probe
value of -1.
In that case calling probe_codec again is necessary to prevent
triggering the assert.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavformat/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8a51aea..70dbfa1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -803,7 +803,7 @@  int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
                 return ret;
             for (i = 0; i < s->nb_streams; i++) {
                 st = s->streams[i];
-                if (st->probe_packets)
+                if (st->probe_packets || st->request_probe > 0)
                     if ((err = probe_codec(s, st, NULL)) < 0)
                         return err;
                 av_assert0(st->request_probe <= 0);
-- 
2.9.3