diff mbox series

[FFmpeg-devel,v3,13/17] avformat/dvdvideodec: open subdemuxer after initializing IFO headers

Message ID 20241007230505.27623-14-marth64@proxyid.net
State New
Headers show
Series avformat/dvdvideodec: bugfixes and menu chapter markers | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed

Commit Message

Marth64 Oct. 7, 2024, 11:05 p.m. UTC
It is wasteful to open the subdemuxer if an error occurs while
initializing streams or reading IFO headers.

Signed-off-by: Marth64 <marth64@proxyid.net>
---
 libavformat/dvdvideodec.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c
index 9983d34ec9..72565ee125 100644
--- a/libavformat/dvdvideodec.c
+++ b/libavformat/dvdvideodec.c
@@ -1565,9 +1565,9 @@  static int dvdvideo_read_header(AVFormatContext *s)
         if ((ret = dvdvideo_ifo_open(s)) < 0                                         ||
             (c->opt_preindex && (ret = dvdvideo_chapters_setup_preindex(s)) < 0)     ||
             (ret = dvdvideo_menu_open(s, &c->play_state)) < 0                        ||
-            (ret = dvdvideo_subdemux_open(s)) < 0                                    ||
             (ret = dvdvideo_video_stream_setup(s)) < 0                               ||
-            (ret = dvdvideo_audio_stream_add_all(s)) < 0)
+            (ret = dvdvideo_audio_stream_add_all(s)) < 0                             ||
+            (ret = dvdvideo_subdemux_open(s)) < 0)
         return ret;
 
         return 0;
@@ -1599,16 +1599,14 @@  static int dvdvideo_read_header(AVFormatContext *s)
     if (!c->opt_pgc && c->opt_preindex && (ret = dvdvideo_chapters_setup_preindex(s)) < 0)
         return ret;
 
-    if ((ret = dvdvideo_play_open(s, &c->play_state)) < 0   ||
-        (ret = dvdvideo_subdemux_open(s)) < 0               ||
-        (ret = dvdvideo_video_stream_setup(s)) < 0          ||
-        (ret = dvdvideo_audio_stream_add_all(s)) < 0        ||
-        (ret = dvdvideo_subp_stream_add_all(s)) < 0)
+    if ((ret = dvdvideo_play_open(s, &c->play_state)) < 0                                  ||
+        (!c->opt_pgc && !c->opt_preindex && (ret = dvdvideo_chapters_setup_simple(s)) < 0) ||
+        (ret = dvdvideo_video_stream_setup(s)) < 0                                         ||
+        (ret = dvdvideo_audio_stream_add_all(s)) < 0                                       ||
+        (ret = dvdvideo_subp_stream_add_all(s)) < 0                                        ||
+        (ret = dvdvideo_subdemux_open(s)) < 0)
         return ret;
 
-    if (!c->opt_pgc && !c->opt_preindex)
-        return dvdvideo_chapters_setup_simple(s);
-
     return 0;
 }