diff mbox series

[FFmpeg-devel,1/2] fix the bug that AV_PKT_FLAG_CORRUPT flags lost after parse_packet()

Message ID HK0PR02MB3601CDA7444C0A2D5B504209C59E0@HK0PR02MB3601.apcprd02.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,1/2] fix the bug that AV_PKT_FLAG_CORRUPT flags lost after parse_packet() | expand

Checks

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

Commit Message

ZHAOYI YI June 13, 2020, 2:22 p.m. UTC
From: zhaoyi <levizhao@live.cn>

---
 libavformat/utils.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andreas Rheinhardt June 13, 2020, 5:13 p.m. UTC | #1
levizhao@live.cn:
> From: zhaoyi <levizhao@live.cn>
> 
> ---
>  libavformat/utils.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 667249362c..a74c0f74a2 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1516,6 +1516,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>          out_pkt.dts          = st->parser->dts;
>          out_pkt.pos          = st->parser->pos;
>          out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_DISCARD;
> +        out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_CORRUPT;
>  
>          if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
>              out_pkt.pos = st->parser->frame_offset;
> 
You can combine this with the line above via pkt->flags &
(AV_PKT_FLAG_DISCARD | AV_PKT_FLAG_CORRUPT).

- Andreas
Marton Balint June 28, 2020, 8:26 p.m. UTC | #2
On Sat, 13 Jun 2020, Andreas Rheinhardt wrote:

> levizhao@live.cn:
>> From: zhaoyi <levizhao@live.cn>
>> 
>> ---
>>  libavformat/utils.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 667249362c..a74c0f74a2 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -1516,6 +1516,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>>          out_pkt.dts          = st->parser->dts;
>>          out_pkt.pos          = st->parser->pos;
>>          out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_DISCARD;
>> +        out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_CORRUPT;
>>
>>          if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
>>              out_pkt.pos = st->parser->frame_offset;
>> 
> You can combine this with the line above via pkt->flags &
> (AV_PKT_FLAG_DISCARD | AV_PKT_FLAG_CORRUPT).

I sent a similar patch a while ago, but Michael was against it because 
a parser can repacketize packets, and it is not clear what should we 
do if part of a packet comes from a corrupt packet.

Nevertheless I still think it is better to propagate this flag as this 
patch does it, than removing all corrupt flags at parsing.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 667249362c..a74c0f74a2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1516,6 +1516,7 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         out_pkt.dts          = st->parser->dts;
         out_pkt.pos          = st->parser->pos;
         out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_DISCARD;
+        out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_CORRUPT;
 
         if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
             out_pkt.pos = st->parser->frame_offset;