diff mbox series

[FFmpeg-devel] avformat/img2dec: Join branches

Message ID GV1P250MB073712158301160EA808A35D8FE52@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel] avformat/img2dec: Join branches | expand

Commit Message

Andreas Rheinhardt May 8, 2024, 10:13 a.m. UTC
Piped inputs don't support the ts_from_file option,
which allows to avoid a branch. Should also help
Coverity with issue #1500302.

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

Patch

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index a40675d434..5c2ff58f2e 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -502,7 +502,9 @@  int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
     }
     pkt->stream_index = 0;
     pkt->flags       |= AV_PKT_FLAG_KEY;
-    if (s->ts_from_file) {
+    if (s->is_pipe) {
+        pkt->pos = avio_tell(f[0]);
+    } else if (s->ts_from_file) {
         struct stat img_stat;
         if (stat(filename, &img_stat)) {
             res = AVERROR(EIO);
@@ -514,13 +516,10 @@  int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
             pkt->pts = 1000000000*pkt->pts + img_stat.st_mtim.tv_nsec;
 #endif
         av_add_index_entry(s1->streams[0], s->img_number, pkt->pts, 0, 0, AVINDEX_KEYFRAME);
-    } else if (!s->is_pipe) {
+    } else {
         pkt->pts      = s->pts;
     }
 
-    if (s->is_pipe)
-        pkt->pos = avio_tell(f[0]);
-
     /*
      * export_path_metadata must be explicitly enabled via
      * command line options for path metadata to be exported