[FFmpeg-devel] [PATCH] avformat/utils: Preserve AV_PKT_FLAG_CORRUPT

Pavel Koshevoy pkoshevoy at gmail.com
Fri Mar 19 17:02:44 EET 2021


On Fri, Mar 19, 2021 at 7:58 AM Michael Niedermayer <michael at niedermayer.cc>
wrote:

> On Wed, Mar 17, 2021 at 06:19:26PM -0600, Pavel Koshevoy wrote:
> > Preserve AV_PKT_FLAG_CORRUPT so the caller can decide whether to drop
> > the packet.
> > ---
> >  libavformat/utils.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index a73f944e6e..0dc978e3d2 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -1494,7 +1494,8 @@ static int parse_packet(AVFormatContext *s,
> AVPacket *pkt,
> >          out_pkt->pts          = st->parser->pts;
> >          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 |
> > +                                              AV_PKT_FLAG_DISCARD);
>
> 1. assume the parsers input are a stream of 4kb packets, the output is
> lets say 101kb
> packets. Assumingh one input packet is corrupted which output packet if any
> gets the flag set and why is that the correct one ?
>
> 2. assume the parsers input are a stream of 128kb packets, the output is
> lets say 3kb
> packets. Assuming one input packet is corrupted which output packet if any
> gets the flag set and why is that the correct one ?
>


In both cases -- any output packet that may contain any part of the
corrupted input packet should be marked corrupted as well.
How likely is the 2nd case?  In my case the source is a UDP mpegts stream,
so input packets are small (188 bytes), much smaller than the typical
output packet size.

Pavel.


More information about the ffmpeg-devel mailing list