[FFmpeg-devel] [PATCH v2 3/3] avdevice/decklink: addition of absolute wallclock option for pts source

Vishwanath Dixit vdixit at akamai.com
Mon Jan 15 10:30:01 EET 2018



On 1/12/18 8:25 PM, Marton Balint wrote:
>
> On Wed, 10 Jan 2018, vdixit at akamai.com wrote:
>
>> From: Vishwanath Dixit <vdixit at akamai.com>
>>
>> ---
>> doc/indevs.texi                 | 6 ++++--
>> libavdevice/decklink_common_c.h | 1 +
>> libavdevice/decklink_dec.cpp    | 4 ++++
>> libavdevice/decklink_dec_c.c    | 1 +
>> 4 files changed, 10 insertions(+), 2 deletions(-)
>>
>> 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},
>> - at samp{reference} or @samp{wallclock}. Defaults to @samp{video}.
>> + at 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},
>> - at samp{reference} or @samp{wallclock}. Defaults to @samp{audio}.
>> + at 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 18097e2..08e9f9b 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,
>>     PTS_SRC_NB
>> } DecklinkPtsSource;
>>
>> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
>> index 1fd40ca..c6eea43 100644
>> --- a/libavdevice/decklink_dec.cpp
>> +++ b/libavdevice/decklink_dec.cpp
>> @@ -607,6 +607,8 @@ static int64_t 
>> get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
>>                 res = 
>> videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, 
>> &bmd_duration);
>>             break;
>>         case PTS_SRC_WALLCLOCK:
>> +            /* fall through */
>> +        case PTS_SRC_ABS_WALLCLOCK:
>>         {
>>             /* MSVC does not support compound literals like 
>> AV_TIME_BASE_Q
>>              * in C++ code (compiler error C4576) */
>> @@ -652,6 +654,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();
>
> This logic is not entirely correct, the user may request abs_wallclock 
> as video pts source, and wallclock as audio... So this "if" should be 
> on its own assigning a different variable, (e.g. abs_wallclock) and 
> you need to pass that to get_pkt_pts as well.
>
Thanks for the review inputs. I have made the suggested updates and 
submitted the revised patch set with version v3 
(https://patchwork.ffmpeg.org/patch/7288/)
>>
>>     // Handle Video Frame
>>     if (videoFrame) {
>> diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
>> index d52dde5..00fb3af 100644
>> --- a/libavdevice/decklink_dec_c.c
>> +++ b/libavdevice/decklink_dec_c.c
>> @@ -70,6 +70,7 @@ static const AVOption options[] = {
>>     { "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 },
>
> Regards,
> Marton
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



More information about the ffmpeg-devel mailing list