There can be valid files path sporting %-sequences or have
files ending with .V in the the same directory but not related.
---

Mainly an rfc and pro-memoria.

 libavformat/img2dec.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index b73554e..3a39e32 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -41,6 +41,7 @@ typedef struct {
     char *framerate;        /**< Set by a private option. */
     int loop;
     int start_number;
+    int verbatim;
 } VideoDemuxData;

 static const int sizes[][2] = {
@@ -188,7 +189,7 @@ static int img_read_header(AVFormatContext *s1)
         st->codec->height = height;
     }

-    if (!s->is_pipe) {
+    if (!s->is_pipe && !s->verbatim) {
         if (find_image_range(&first_index, &last_index, s->path,
                              FFMAX(s->start_number, 5)) < 0)
             return AVERROR(ENOENT);
@@ -226,7 +227,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket 
*pkt)
     AVIOContext *f[3]     = { NULL };
     AVCodecContext *codec = s1->streams[0]->codec;

-    if (!s->is_pipe) {
+    if (!s->is_pipe && !s->verbatim) {
         /* loop over input */
         if (s->loop && s->img_number > s->img_last) {
             s->img_number = s->img_first;
@@ -256,10 +257,17 @@ static int img_read_packet(AVFormatContext *s1, AVPacket 
*pkt)
         if (codec->codec_id == AV_CODEC_ID_RAWVIDEO && !codec->width)
             infer_size(&codec->width, &codec->height, size[0]);
     } else {
-        f[0] = s1->pb;
-        if (f[0]->eof_reached)
-            return AVERROR(EIO);
-        size[0] = 4096;
+        if (s->is_pipe) {
+            f[0] = s1->pb;
+            if (f[0]->eof_reached)
+                return AVERROR(EIO);
+            size[0] = 4096;
+        } else {
+            if ((res = avio_open2(&f[0], filename, AVIO_FLAG_READ,
+                           &s1->interrupt_callback, NULL)) < 0)
+                return res;
+            size[0] = avio_size(f[0]);
+        }
     }

     res = av_new_packet(pkt, size[0] + size[1] + size[2]);
@@ -295,6 +303,7 @@ static const AVOption options[] = {
     { "pixel_format", "",                             OFFSET(pixel_format), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0,       DEC },
     { "video_size",   "",                             OFFSET(video_size),   
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0,       DEC },
     { "framerate",    "",                             OFFSET(framerate),    
AV_OPT_TYPE_STRING, { .str = "25" }, 0, 0,       DEC },
+    { "verbatim",     "Disable %-expansion",          OFFSET(verbatim),     
AV_OPT_TYPE_INT,    { .i64 = 0    }, 0, 1,       DEC },
     { "loop",         "",                             OFFSET(loop),         
AV_OPT_TYPE_INT,    { .i64 = 0    }, 0, 1,       DEC },
     { "start_number", "first number in the sequence", OFFSET(start_number), 
AV_OPT_TYPE_INT,    { .i64 = 1    }, 1, INT_MAX, DEC },
     { NULL },
--
1.9.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to