---
 drivers/media/video/uvc/uvc_video.c |   30 +++++++++++++++++++++---------
 drivers/media/video/uvc/uvcvideo.h  |    7 +++++--
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index feb585b..c8c5967 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -436,7 +436,9 @@ static void uvc_video_stats_decode(struct uvc_streaming *stream,
     /* Do the SCR.STC and SCR.SOF fields vary through the frame ? */
     if (has_scr && stream->stats.frame.nb_scr) {
         if (stream->stats.frame.scr_stc != scr_stc)
-            stream->stats.frame.nb_scr_diffs++;
+            stream->stats.frame.nb_scr_stc_diffs++;
+        if (stream->stats.frame.scr_sof != scr_sof)
+            stream->stats.frame.nb_scr_sof_diffs++;
     }

     if (has_scr) {
@@ -457,6 +459,13 @@ static void uvc_video_stats_decode(struct uvc_streaming *stream,
             stream->stats.stream.max_sof = scr_sof;
     }

+    if (has_pts) {
+        if (stream->stats.frame.nb_pts > 0 && stream->stats.stream.pts > 0)
+            stream->stats.stream.nb_pts_count +=
+            (pts - stream->stats.stream.pts);
+        stream->stats.stream.pts = pts;
+    }
+
     if (stream->stats.frame.size == 0 && len > header_size)
         stream->stats.frame.first_data = stream->stats.frame.nb_packets;

@@ -474,13 +483,15 @@ static void uvc_video_stats_update(struct uvc_streaming *stream)
     struct uvc_stats_frame *frame = &stream->stats.frame;

     uvc_trace(UVC_TRACE_TIMESTAMP, "frame %u stats: %u/%u/%u packets "
-          "%u/%u/%u pts (%searly %sinitial) %u/%u scr\n",
+          "%u/%u/%u pts (%searly %sinitial) %u/%u scr.stc "
+          "%u/%u scr.sof",
           stream->sequence, frame->first_data,
           frame->nb_non_empty_packets, frame->nb_packets,
           frame->nb_pts_diffs, frame->last_pts_diff, frame->nb_pts,
           frame->has_early_pts ? "" : "!",
           frame->has_initial_pts ? "" : "!",
-          frame->nb_scr_diffs, frame->nb_scr);
+          frame->nb_scr_stc_diffs, frame->nb_scr,
+          frame->nb_scr_sof_diffs, frame->nb_scr);

     stream->stats.stream.nb_frames++;

@@ -492,8 +503,8 @@ static void uvc_video_stats_update(struct uvc_streaming *stream)
         stream->stats.stream.nb_pts_constant++;
     if (frame->nb_scr >= frame->nb_non_empty_packets)
         stream->stats.stream.nb_scr_count_ok++;
-    if (frame->nb_scr_diffs + 1 == frame->nb_scr)
-        stream->stats.stream.nb_scr_diffs_ok++;
+    if (frame->nb_scr_stc_diffs + 1 == frame->nb_scr)
+        stream->stats.stream.nb_scr_stc_diffs_ok++;

     memset(&stream->stats.frame, 0, sizeof(stream->stats.frame));
 }
@@ -524,16 +535,17 @@ static void uvc_video_stats_dump(struct uvc_streaming *stream)
         scr_sof_freq = 0;

     uvc_trace(UVC_TRACE_TIMESTAMP, "stream stats: %u frames %u early pts "
-          "%u initial pts %u pts ok %u scr count ok %u scr diff ok, "
-          "%u <= sof <= %u, sof freq %u.%03u kHz\n",
+          "%u initial pts %u pts ok %u scr count ok %u scr.stc diff ok"
+          " %u <= sof <= %u, sof freq %u.%03u kHz, pts count = %llu",
           stream->stats.stream.nb_frames,
           stream->stats.stream.nb_pts_early,
           stream->stats.stream.nb_pts_initial,
           stream->stats.stream.nb_pts_constant,
           stream->stats.stream.nb_scr_count_ok,
-          stream->stats.stream.nb_scr_diffs_ok,
+          stream->stats.stream.nb_scr_stc_diffs_ok,
           stream->stats.stream.min_sof, stream->stats.stream.max_sof,
-          scr_sof_freq / 1000, scr_sof_freq % 1000);
+          scr_sof_freq / 1000, scr_sof_freq % 1000,
+          (unsigned long long)stream->stats.stream.nb_pts_count);
 }

 static void uvc_video_stats_init(struct uvc_streaming *stream)
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index 40f461c..6c823d7 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -471,11 +471,13 @@ struct uvc_streaming {
unsigned int nb_pts_early; /* Number of frames with early PTS */ unsigned int nb_pts_initial; /* Number of frames with initial PTS */ unsigned int nb_scr_count_ok; /* Number of frames with at least one SCR per non empty packet */ - unsigned int nb_scr_diffs_ok; /* Number of frames with varying SCR.STC */ + unsigned int nb_scr_stc_diffs_ok; /* Number of frames with varying SCR.STC */ unsigned int scr_sof_count; /* STC.SOF counter accumulated since stream start */
             unsigned int scr_sof;        /* STC.SOF of the last packet */
             unsigned int min_sof;        /* Minimum STC.SOF value */
             unsigned int max_sof;        /* Maximum STC.SOF value */
+            unsigned int pts;
+            u64 nb_pts_count;
         } stream;

         struct uvc_stats_frame {
@@ -495,7 +497,8 @@ struct uvc_streaming {
             u32 pts;            /* PTS of the last packet */

unsigned int nb_scr; /* Number of packets with a SCR timestamp */ - unsigned int nb_scr_diffs; /* Number of SCR.STC differences inside a frame */ + unsigned int nb_scr_stc_diffs; /* Number of SCR.STC differences inside a frame */ + unsigned int nb_scr_sof_diffs; /* Number of SCR.SOF differences inside a frame */
             u16 scr_sof;            /* SCR.SOF of the last packet */
             u32 scr_stc;            /* SCR.STC of the last packet */
         } frame;
--
1.7.4.1
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to