[FFmpeg-cvslog] avformat/mpeg: Simplify cleanup after reading vobsub header fails
Andreas Rheinhardt
git at videolan.org
Thu Jul 8 16:44:47 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Mar 21 21:03:44 2020 +0100| [bcdc1d106062677c17e721875b77f8dcae3b2a1a] | committer: Andreas Rheinhardt
avformat/mpeg: Simplify cleanup after reading vobsub header fails
by setting the FF_FMT_INIT_CLEANUP flag. Furthermore, also remove
an unnecessary check for NULL before avformat_close_input().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bcdc1d106062677c17e721875b77f8dcae3b2a1a
---
libavformat/mpeg.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 178e71d891..4b7493395d 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -723,8 +723,7 @@ static int vobsub_read_close(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++)
ff_subtitles_queue_clean(&vobsub->q[i]);
- if (vobsub->sub_ctx)
- avformat_close_input(&vobsub->sub_ctx);
+ avformat_close_input(&vobsub->sub_ctx);
return 0;
}
@@ -768,17 +767,17 @@ static int vobsub_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
}
- av_bprint_init(&header, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
-
if ((ret = ff_copy_whiteblacklists(vobsub->sub_ctx, s)) < 0)
- goto end;
+ return ret;
ret = avformat_open_input(&vobsub->sub_ctx, vobsub->sub_name, iformat, NULL);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Unable to open %s as MPEG subtitles\n", vobsub->sub_name);
- goto end;
+ return ret;
}
+ av_bprint_init(&header, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
+
while (!avio_feof(s->pb)) {
char line[MAX_LINE_SIZE];
int len = ff_get_line(s->pb, line, sizeof(line));
@@ -911,8 +910,6 @@ static int vobsub_read_header(AVFormatContext *s)
memcpy(par->extradata, header.str, header.len);
}
end:
- if (ret < 0)
- vobsub_read_close(s);
av_bprint_finalize(&header, NULL);
return ret;
}
@@ -1044,6 +1041,7 @@ const AVInputFormat ff_vobsub_demuxer = {
.name = "vobsub",
.long_name = NULL_IF_CONFIG_SMALL("VobSub subtitle format"),
.priv_data_size = sizeof(VobSubDemuxContext),
+ .flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = vobsub_probe,
.read_header = vobsub_read_header,
.read_packet = vobsub_read_packet,
More information about the ffmpeg-cvslog
mailing list