@@ -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
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(-)