[FFmpeg-devel,2/2] avdevice/decklink: addition of absolute wallclock option for pts source

Submitted by Dixit, Vishwanath on Jan. 8, 2018, 5:26 a.m.

Details

Message ID 1515389216-31035-1-git-send-email-vdixit@akamai.com
State New
Headers show

Commit Message

Dixit, Vishwanath Jan. 8, 2018, 5:26 a.m.
From: Vishwanath Dixit <vdixit@akamai.com>

---
 doc/indevs.texi                 | 6 ++++--
 libavdevice/decklink_common_c.h | 1 +
 libavdevice/decklink_dec.cpp    | 3 +++
 libavdevice/decklink_dec_c.c    | 5 +++--
 4 files changed, 11 insertions(+), 4 deletions(-)

Comments

Moritz Barsnick Jan. 8, 2018, 9:52 p.m.
On Mon, Jan 08, 2018 at 10:56:56 +0530, vdixit@akamai.com wrote:

> -    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, 4, DEC, "pts_source"},
> -    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, 4, DEC, "pts_source"},
> +    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, 5, DEC, "pts_source"},
> +    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, 5, DEC, "pts_source"},

This cries for a max macro:

     PTS_SRC_VIDEO     = 2,
     PTS_SRC_REFERENCE = 3,
     PTS_SRC_WALLCLOCK = 4,
+    PTS_SRC_ABS_WALLCLOCK = 5,
+    PTS_SRC_NB
 } DecklinkPtsSource;

and then

+    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, PTS_SRC_NB-1, DEC, "pts_source"},
+    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, PTS_SRC_NB-1, DEC, "pts_source"},

>              break;
>          case PTS_SRC_WALLCLOCK:
> +        case PTS_SRC_ABS_WALLCLOCK:

Coverty and similar tools like fall-throughs to be marked as such to
avoid false warnings.

> +    else if(ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK)

"else if ("

Moritz
Dixit, Vishwanath Jan. 10, 2018, 4:58 a.m.
On 1/9/18 3:22 AM, Moritz Barsnick wrote:
> On Mon, Jan 08, 2018 at 10:56:56 +0530, vdixit@akamai.com wrote:

>

>> -    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, 4, DEC, "pts_source"},

>> -    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, 4, DEC, "pts_source"},

>> +    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, 5, DEC, "pts_source"},

>> +    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, 5, DEC, "pts_source"},

>

> This cries for a max macro:

>

>      PTS_SRC_VIDEO     = 2,

>      PTS_SRC_REFERENCE = 3,

>      PTS_SRC_WALLCLOCK = 4,

> +    PTS_SRC_ABS_WALLCLOCK = 5,

> +    PTS_SRC_NB

>  } DecklinkPtsSource;

>

> and then

>

> +    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, PTS_SRC_NB-1, DEC, "pts_source"},

> +    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, PTS_SRC_NB-1, DEC, "pts_source"},

>

>>              break;

>>          case PTS_SRC_WALLCLOCK:

>> +        case PTS_SRC_ABS_WALLCLOCK:

>

> Coverty and similar tools like fall-throughs to be marked as such to

> avoid false warnings.

>

>> +    else if(ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK)

>

> "else if ("

>

> Moritz

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Thanks for your review comments. I have made the suggested changes and have submitted the revised patch set with version v2. https://patchwork.ffmpeg.org/patch/7243/, https://patchwork.ffmpeg.org/patch/7242/, https://patchwork.ffmpeg.org/patch/7244/

Patch hide | download patch | download mbox

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 36aef49..0bc8e6a 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -298,11 +298,13 @@  Sets the audio input source. Must be @samp{unset}, @samp{embedded},
 
 @item video_pts
 Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},
-@samp{reference} or @samp{wallclock}. Defaults to @samp{video}.
+@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
+Defaults to @samp{video}.
 
 @item audio_pts
 Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
-@samp{reference} or @samp{wallclock}. Defaults to @samp{audio}.
+@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
+Defaults to @samp{audio}.
 
 @item draw_bars
 If set to @samp{true}, color bars are drawn in the event of a signal loss.
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index ac6563a..d726190 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -28,6 +28,7 @@  typedef enum DecklinkPtsSource {
     PTS_SRC_VIDEO     = 2,
     PTS_SRC_REFERENCE = 3,
     PTS_SRC_WALLCLOCK = 4,
+    PTS_SRC_ABS_WALLCLOCK = 5,
 } DecklinkPtsSource;
 
 struct decklink_cctx {
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 1fd40ca..6bbfe62 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -607,6 +607,7 @@  static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
                 res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration);
             break;
         case PTS_SRC_WALLCLOCK:
+        case PTS_SRC_ABS_WALLCLOCK:
         {
             /* MSVC does not support compound literals like AV_TIME_BASE_Q
              * in C++ code (compiler error C4576) */
@@ -652,6 +653,8 @@  HRESULT decklink_input_callback::VideoInputFrameArrived(
     ctx->frameCount++;
     if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK)
         wallclock = av_gettime_relative();
+    else if(ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK)
+        wallclock = av_gettime();
 
     // Handle Video Frame
     if (videoFrame) {
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 6fb5ffe..c8f6f35 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -64,12 +64,13 @@  static const AVOption options[] = {
     { "analog_xlr",    NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = 4}, 0, 0,    DEC, "audio_input"},
     { "analog_rca",    NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = 5}, 0, 0,    DEC, "audio_input"},
     { "microphone",    NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = 6}, 0, 0,    DEC, "audio_input"},
-    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, 4, DEC, "pts_source"},
-    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, 4, DEC, "pts_source"},
+    { "audio_pts",     "audio pts source",   OFFSET(audio_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO    }, 1, 5, DEC, "pts_source"},
+    { "video_pts",     "video pts source",   OFFSET(video_pts_source),    AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO    }, 1, 5, DEC, "pts_source"},
     { "audio",         NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_AUDIO    }, 0, 0, DEC, "pts_source"},
     { "video",         NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_VIDEO    }, 0, 0, DEC, "pts_source"},
     { "reference",     NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, "pts_source"},
     { "wallclock",     NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"},
+    { "abs_wallclock", NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_ABS_WALLCLOCK}, 0, 0, DEC, "pts_source"},
     { "draw_bars",     "draw bars on signal loss" , OFFSET(draw_bars),    AV_OPT_TYPE_BOOL,  { .i64 = 1}, 0, 1, DEC },
     { "queue_size",    "input queue buffer size",   OFFSET(queue_size),   AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
     { "audio_depth",   "audio bitdepth (16 or 32)", OFFSET(audio_depth),  AV_OPT_TYPE_INT,   { .i64 = 16}, 16, 32, DEC },