diff mbox series

[FFmpeg-devel] avformat/mpegtsenc: correct bitstream check

Message ID 20240316044116.1319-1-ffmpeg@gyani.pro
State Accepted
Commit f5441e441f9b0d235e49bdccc69e141ccd92e854
Headers show
Series [FFmpeg-devel] avformat/mpegtsenc: correct bitstream check | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Gyan Doshi March 16, 2024, 4:41 a.m. UTC
8559cce3c3 made the bitstream check generic using a LUT.
However, one of the comparisons which involves a bitwise AND
and equality check is faulty due to operator precedence.

First reported and analysed at
https://github.com/streamlink/streamlink/issues/5876

Fixes #10908
---
 libavformat/mpegtsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marton Balint March 16, 2024, 8:32 a.m. UTC | #1
On Sat, 16 Mar 2024, Gyan Doshi wrote:

> 8559cce3c3 made the bitstream check generic using a LUT.
> However, one of the comparisons which involves a bitwise AND
> and equality check is faulty due to operator precedence.
>
> First reported and analysed at
> https://github.com/streamlink/streamlink/issues/5876
>
> Fixes #10908
> ---
> libavformat/mpegtsenc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 06e88e9879..b8efc535a7 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
>                 pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
>                 (AV_RB24(pkt->data) != 0x000001 ||
>                     (st->codecpar->extradata_size > 0 &&
> -                        (st->codecpar->extradata[0] & e->mask == e->value))))
> +                        ((st->codecpar->extradata[0] & e->mask) == e->value))))
>             return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
>     }
>     return 1;
> --

LGTM, thanks.

Marton
Gyan Doshi March 16, 2024, 9:01 a.m. UTC | #2
On 2024-03-16 02:02 pm, Marton Balint wrote:
>
>
> On Sat, 16 Mar 2024, Gyan Doshi wrote:
>
>> 8559cce3c3 made the bitstream check generic using a LUT.
>> However, one of the comparisons which involves a bitwise AND
>> and equality check is faulty due to operator precedence.
>>
>> First reported and analysed at
>> https://github.com/streamlink/streamlink/issues/5876
>>
>> Fixes #10908
>> ---
>> libavformat/mpegtsenc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index 06e88e9879..b8efc535a7 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -2319,7 +2319,7 @@ static int 
>> mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
>>                 pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
>>                 (AV_RB24(pkt->data) != 0x000001 ||
>>                     (st->codecpar->extradata_size > 0 &&
>> -                        (st->codecpar->extradata[0] & e->mask == 
>> e->value))))
>> +                        ((st->codecpar->extradata[0] & e->mask) == 
>> e->value))))
>>             return ff_stream_add_bitstream_filter(st, e->bsf_name, 
>> NULL);
>>     }
>>     return 1;
>> -- 
>
> LGTM, thanks.

Thanks. Pushed as f5441e441f9b0d235e49bdccc69e141ccd92e854

Regards,
Gyan
diff mbox series

Patch

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@  static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
                 pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
                 (AV_RB24(pkt->data) != 0x000001 ||
                     (st->codecpar->extradata_size > 0 &&
-                        (st->codecpar->extradata[0] & e->mask == e->value))))
+                        ((st->codecpar->extradata[0] & e->mask) == e->value))))
             return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
     }
     return 1;