This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: qvidcap: add --from-frame option
Author:  Hans Verkuil <hverk...@xs4all.nl>
Date:    Thu Jan 30 13:31:22 2025 +0100

With the --from-frame option you can skip the first N frames
when reading from a file.

Also report the frame number if --verbose is given.

Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>

 utils/qvidcap/capture.cpp | 19 ++++++++++++++-----
 utils/qvidcap/capture.h   |  2 ++
 utils/qvidcap/qvidcap.cpp | 14 +++++++++-----
 3 files changed, 25 insertions(+), 10 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=9e6e7470bab30c81f032976b7e84b6030259ea78
diff --git a/utils/qvidcap/capture.cpp b/utils/qvidcap/capture.cpp
index 85973418c95a..15ad14f2feb8 100644
--- a/utils/qvidcap/capture.cpp
+++ b/utils/qvidcap/capture.cpp
@@ -219,6 +219,7 @@ CaptureWin::CaptureWin(QScrollArea *sa, QWidget *parent) :
        m_frame(0),
        m_verbose(false),
        m_no_loop(false),
+       m_fromFrame(0),
        m_ctx(0),
        m_origPixelFormat(0),
        m_fps(0),
@@ -1416,12 +1417,14 @@ void CaptureWin::startTimer()
        for (unsigned p = 0; p < m_v4l_fmt.g_num_planes(); p++)
                m_imageSize += m_v4l_fmt.g_sizeimage(p);
 
-       if (m_file.isOpen())
-               m_file.seek(0);
-
-       if (m_file.isOpen() && m_imageSize > m_file.size()) {
+       if (m_file.isOpen() && (m_fromFrame + 1) * m_imageSize > m_file.size()) 
{
                fprintf(stderr, "the file size is too small (expect at least 
%u, got %llu)\n",
-                       m_imageSize, m_file.size());
+                       (m_fromFrame + 1) * m_imageSize, m_file.size());
+       }
+
+       if (m_file.isOpen()) {
+               m_file.seek(m_fromFrame * m_imageSize);
+               m_frame = m_fromFrame;
        }
 
        for (unsigned p = 0; p < m_v4l_fmt.g_num_planes(); p++) {
@@ -1463,6 +1466,9 @@ void CaptureWin::startTimer()
                                
ycbcr_enc2s(ycbcr_encs[m_testState.ycbcr_enc_idx]).c_str(),
                                
quantization2s(quantizations[m_testState.quant_idx]).c_str());
        }
+       m_frame++;
+       if (m_verbose)
+               printf("frame %d\n", m_frame - 1);
 }
 
 void CaptureWin::tpgUpdateFrame()
@@ -1484,6 +1490,7 @@ void CaptureWin::tpgUpdateFrame()
                if (m_verbose)
                        printf("loop\n");
                m_file.seek(0);
+               m_frame = 0;
        }
 
        if (m_mode != AppModeFile && is_alt) {
@@ -1500,6 +1507,8 @@ void CaptureWin::tpgUpdateFrame()
                        tpg_fillbuffer(&m_tpg, 0, p, m_curData[p]);
        }
        m_frame++;
+       if (m_verbose)
+               printf("frame %d\n", m_frame - 1);
        update();
        if (m_cnt != 1)
                tpg_update_mv_count(&m_tpg, is_alt);
diff --git a/utils/qvidcap/capture.h b/utils/qvidcap/capture.h
index cf3380463fdd..19320d06b2da 100644
--- a/utils/qvidcap/capture.h
+++ b/utils/qvidcap/capture.h
@@ -91,6 +91,7 @@ public:
        void setReportTimings(bool report) { m_reportTimings = report; }
        void setVerbose(bool verbose) { m_verbose = verbose; }
        void setNoLoop(bool no_loop) { m_no_loop = no_loop; }
+       void setFromFrame(unsigned from_frame) { m_fromFrame = from_frame; }
        void setOverridePixelFormat(__u32 fmt) { m_overridePixelFormat = fmt; }
        void setOverrideField(__u32 field) { m_overrideField = field; }
        void setOverrideColorspace(__u32 colsp) { m_overrideColorspace = colsp; 
}
@@ -182,6 +183,7 @@ private:
        unsigned m_imageSize;
        bool m_verbose;
        bool m_no_loop;
+       unsigned m_fromFrame;
        bool m_reportTimings;
        bool m_is_sdtv;
        v4l2_std_id m_std;
diff --git a/utils/qvidcap/qvidcap.cpp b/utils/qvidcap/qvidcap.cpp
index f81b376e9335..0c614976214d 100644
--- a/utils/qvidcap/qvidcap.cpp
+++ b/utils/qvidcap/qvidcap.cpp
@@ -36,7 +36,7 @@ static void usage()
               "  -c, --count=<cnt>        stop after <cnt> captured frames\n"
               "  -b, --buffers=<bufs>     request <bufs> buffers (default 4) 
when streaming\n"
               "                           from a video device\n"
-              "  -s, --single-step[=<frm>] starting with frame <frm> (default 
1), pause after\n"
+              "  -s, --single-step[=<frm>] starting with frame <frm> (default 
0), pause after\n"
               "                           displaying each frame until Space is 
pressed.\n"
               "  -C, --colorspace=<c>     override colorspace\n"
               "                           <c> can be one of the following 
colorspaces:\n"
@@ -65,6 +65,7 @@ static void usage()
               "  -v, --verbose            be more verbose\n"
               "  -R, --raw                open device in raw mode\n"
               "  --no-loop                stop at the end of the file, don't 
loop back to the beginning\n"
+              "  --from-frame=<frame>     start playing back the file at the 
given frame number (starts at 0)\n"
               "\n"
               "  --opengl                 force openGL to display the video\n"
               "  --opengles               force openGL ES to display the 
video\n"
@@ -441,12 +442,13 @@ int main(int argc, char **argv)
        unsigned cnt = 0;
        unsigned v4l2_bufs = 4;
        bool single_step = false;
-       unsigned single_step_start = 1;
+       unsigned single_step_start = 0;
        int port = 0;
        bool info_option = false;
        bool report_timings = false;
        bool verbose = false;
        bool no_loop = false;
+       unsigned from_frame = 0;
        __u32 overridePixelFormat = 0;
        __u32 overrideWidth = 0;
        __u32 overrideHeight = 0;
@@ -652,6 +654,9 @@ int main(int argc, char **argv)
                        verbose = true;
                } else if (isOption(args[i], "--no-loop")) {
                        no_loop = true;
+               } else if (isOptArg(args[i], "--from-frame")) {
+                       if (!processOption(args, i, from_frame))
+                               return 0;
                } else if (isOption(args[i], "--raw", "-R")) {
                        fd.s_direct(true);
                } else if (isOptArg(args[i], "--count", "-c")) {
@@ -662,7 +667,7 @@ int main(int argc, char **argv)
                                return 0;
                } else if (isOption(args[i], "--single-step", "-s")) {
                        single_step = true;
-                       single_step_start = 1;
+                       single_step_start = 0;
                } else if (isOptArg(args[i], "--single-step", "-s")) {
                        if (!processOption(args, i, single_step_start))
                                return 0;
@@ -749,10 +754,9 @@ int main(int argc, char **argv)
        CaptureWin win(sa);
        win.setVerbose(verbose);
        win.setNoLoop(no_loop);
+       win.setFromFrame(from_frame);
        if (mode == AppModeFile) {
                win.setModeFile(filename);
-               if (single_step_start)
-                       single_step_start--;
        } else if (mode == AppModeV4L2) {
                win.setModeV4L2(&fd);
        } else if (mode == AppModeTPG) {

Reply via email to