diff mbox series

[FFmpeg-devel,20/21] avformat/mpeg: Simplify cleanup after reading vobsub header fails

Message ID 20200322034756.29907-20-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,01/21] avformat/nsvdec: Use av_packet_move_ref() for packet ownership transfer | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt March 22, 2020, 3:47 a.m. UTC
by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Furthermore, also
remove an unnecessary check for NULL before avformat_close_input().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/mpeg.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index eba5852266..f21507dc63 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -720,8 +720,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;
 }
 
@@ -765,17 +764,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));
@@ -908,8 +907,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;
 }
@@ -1045,5 +1042,6 @@  AVInputFormat ff_vobsub_demuxer = {
     .flags          = AVFMT_SHOW_IDS,
     .extensions     = "idx",
     .priv_class     = &vobsub_demuxer_class,
+    .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP,
 };
 #endif