Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v5 2/2] lavf/mpegenc: fix termination on error conditions
Date: Fri, 1 Apr 2022 01:14:11 +0200
Message-ID: <AS1PR01MB95646D33080BBB40B9F27DCA8FE19@AS1PR01MB9564.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <20220325225452.47-3-nicolas.gaullier@cji.paris>

Nicolas Gaullier:
> Avoid an infinite 'retry' loop in output_packet when flushing.
> 
> Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
> ---
>  libavformat/mpegenc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
> index e0955a7d33..e113a42867 100644
> --- a/libavformat/mpegenc.c
> +++ b/libavformat/mpegenc.c
> @@ -1002,7 +1002,7 @@ static int output_packet(AVFormatContext *ctx, int flush)
>      MpegMuxContext *s = ctx->priv_data;
>      AVStream *st;
>      StreamInfo *stream;
> -    int i, avail_space = 0, es_size, trailer_size;
> +    int i, has_avail_data = 0, avail_space = 0, es_size, trailer_size;
>      int best_i = -1;
>      int best_score = INT_MIN;
>      int ignore_constraints = 0;
> @@ -1028,6 +1028,7 @@ retry:
>          if (avail_data == 0)
>              continue;
>          av_assert0(avail_data > 0);
> +        has_avail_data = 1;
>  
>          if (space < s->packet_size && !ignore_constraints)
>              continue;
> @@ -1048,6 +1049,8 @@ retry:
>          int64_t best_dts = INT64_MAX;
>          int has_premux = 0;
>  
> +        if (!has_avail_data)
> +            return 0;
>          for (i = 0; i < ctx->nb_streams; i++) {
>              AVStream *st = ctx->streams[i];
>              StreamInfo *stream = st->priv_data;

in case of errors, the context is left in an inconsistent state: The
PacketDesc linked-list claims that there is data in the FIFO although
this is wrong. I always prefer avoiding such scenarios over fixing them
lateron. In this case, fixing them would mean growing the FIFO before
allocating the new PacketDesc (if the FIFO needs growing at all). Shall
I do this or do you want to?
(In any case, thanks for reporting this issue.)

- Andreas
_______________________________________________
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".

  reply	other threads:[~2022-03-31 23:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 22:54 [FFmpeg-devel] [PATCH v5 0/2] lavf/mpegenc: fixes Nicolas Gaullier
2022-03-25 22:54 ` [FFmpeg-devel] [PATCH v5 1/2] lavf/mpegenc: fix ever-growing fifo size since the new API Nicolas Gaullier
2022-03-25 22:54 ` [FFmpeg-devel] [PATCH v5 2/2] lavf/mpegenc: fix termination on error conditions Nicolas Gaullier
2022-03-31 23:14   ` Andreas Rheinhardt [this message]
2022-04-01  7:05     ` Nicolas Gaullier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS1PR01MB95646D33080BBB40B9F27DCA8FE19@AS1PR01MB9564.eurprd01.prod.exchangelabs.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git