diff mbox series

[FFmpeg-devel,48/54] avformat/tiertexseq: Simplify cleanup after read_header failure

Message ID HE1PR0301MB2154C0FBC857AA85AA00D2038F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 24e4127cb4e0ded3052907540b944b0df564a6ba
Headers show
Series [FFmpeg-devel,01/54] avformat: Add internal flags for AV(In|Out)putFormat | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt June 15, 2021, 11:32 p.m. UTC
by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/tiertexseq.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c
index 164a75bd53..ecc15e4039 100644
--- a/libavformat/tiertexseq.c
+++ b/libavformat/tiertexseq.c
@@ -202,20 +202,16 @@  static int seq_read_header(AVFormatContext *s)
 
     /* init internal buffers */
     rc = seq_init_frame_buffers(seq, pb);
-    if (rc) {
-        seq_read_close(s);
+    if (rc < 0)
         return rc;
-    }
 
     seq->current_frame_offs = 0;
 
     /* preload (no audio data, just buffer operations related data) */
     for (i = 1; i <= 100; i++) {
         rc = seq_parse_frame_data(seq, pb);
-        if (rc) {
-            seq_read_close(s);
+        if (rc < 0)
             return rc;
-        }
     }
 
     seq->current_frame_pts = 0;
@@ -224,10 +220,8 @@  static int seq_read_header(AVFormatContext *s)
 
     /* initialize the video decoder stream */
     st = avformat_new_stream(s, NULL);
-    if (!st) {
-        seq_read_close(s);
+    if (!st)
         return AVERROR(ENOMEM);
-    }
 
     avpriv_set_pts_info(st, 32, 1, SEQ_FRAME_RATE);
     seq->video_stream_index = st->index;
@@ -239,10 +233,8 @@  static int seq_read_header(AVFormatContext *s)
 
     /* initialize the audio decoder stream */
     st = avformat_new_stream(s, NULL);
-    if (!st) {
-        seq_read_close(s);
+    if (!st)
         return AVERROR(ENOMEM);
-    }
 
     st->start_time = 0;
     avpriv_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE);
@@ -320,6 +312,7 @@  const AVInputFormat ff_tiertexseq_demuxer = {
     .name           = "tiertexseq",
     .long_name      = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ"),
     .priv_data_size = sizeof(SeqDemuxContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = seq_probe,
     .read_header    = seq_read_header,
     .read_packet    = seq_read_packet,