History

avdevice/decklink: addition of absolute wallclock option for pts source

Vishwanath Dixit committed 8 years ago

Commit fc93eca1 parent dfa25235 files · +19 −7Browse files

Unified · Split

5 files
  1. doc/indevs.texi +4 −2
  2. libavdevice/decklink_common_c.h +1 −0
  3. libavdevice/decklink_dec.cpp +12 −4
  4. libavdevice/decklink_dec_c.c +1 −0
  5. libavdevice/version.h +1 −1
doc/indevs.texi+4−2
@@ -298,11 +298,13 @@ Sets the audio input source. Must be @samp{unset}, @samp{embedded}, · 297 unmodified lines
298298
299299 @item video_pts
300300 Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},
301−@samp{reference} or @samp{wallclock}. Defaults to @samp{video}.
301+@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
302+Defaults to @samp{video}.
302303
303304 @item audio_pts
304305 Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
305−@samp{reference} or @samp{wallclock}. Defaults to @samp{audio}.
306+@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
307+Defaults to @samp{audio}.
306308
307309 @item draw_bars
308310 If set to @samp{true}, color bars are drawn in the event of a signal loss.
libavdevice/decklink_common_c.h+1−0
@@ -28,6 +28,7 @@ typedef enum DecklinkPtsSource { · 27 unmodified lines
2828 PTS_SRC_VIDEO = 2,
2929 PTS_SRC_REFERENCE = 3,
3030 PTS_SRC_WALLCLOCK = 4,
31+ PTS_SRC_ABS_WALLCLOCK = 5,
3132 PTS_SRC_NB
3233 } DecklinkPtsSource;
3334
libavdevice/decklink_dec.cpp+12−4
@@ -585,6 +585,7 @@ ULONG decklink_input_callback::Release(void) · 584 unmodified lines
585585 static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
586586 IDeckLinkAudioInputPacket *audioFrame,
587587 int64_t wallclock,
588+ int64_t abs_wallclock,
588589 DecklinkPtsSource pts_src,
589590 AVRational time_base, int64_t *initial_pts,
590591 int copyts)
@@ -607,13 +608,18 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, · 16 unmodified lines
607608 res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration);
608609 break;
609610 case PTS_SRC_WALLCLOCK:
611+ /* fall through */
612+ case PTS_SRC_ABS_WALLCLOCK:
610613 {
611614 /* MSVC does not support compound literals like AV_TIME_BASE_Q
612615 * in C++ code (compiler error C4576) */
613616 AVRational timebase;
614617 timebase.num = 1;
615618 timebase.den = AV_TIME_BASE;
616− pts = av_rescale_q(wallclock, timebase, time_base);
619+ if (pts_src == PTS_SRC_WALLCLOCK)
620+ pts = av_rescale_q(wallclock, timebase, time_base);
621+ else
622+ pts = av_rescale_q(abs_wallclock, timebase, time_base);
617623 break;
618624 }
619625 }
@@ -637,7 +643,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 17 unmodified lines
637643 void *audioFrameBytes;
638644 BMDTimeValue frameTime;
639645 BMDTimeValue frameDuration;
640− int64_t wallclock = 0;
646+ int64_t wallclock = 0, abs_wallclock = 0;
641647 struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
642648
643649 if (ctx->autodetect) {
@@ -652,6 +658,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 8 unmodified lines
652658 ctx->frameCount++;
653659 if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK)
654660 wallclock = av_gettime_relative();
661+ if (ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK)
662+ abs_wallclock = av_gettime();
655663
656664 // Handle Video Frame
657665 if (videoFrame) {
@@ -698,7 +706,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 40 unmodified lines
698706 no_video = 0;
699707 }
700708
701− pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->video_pts_source, ctx->video_st->time_base, &initial_video_pts, cctx->copyts);
709+ pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, abs_wallclock, ctx->video_pts_source, ctx->video_st->time_base, &initial_video_pts, cctx->copyts);
702710 pkt.dts = pkt.pts;
703711
704712 pkt.duration = frameDuration;
@@ -789,7 +797,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 84 unmodified lines
789797 pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8);
790798 audioFrame->GetBytes(&audioFrameBytes);
791799 audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
792− pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts, cctx->copyts);
800+ pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, abs_wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts, cctx->copyts);
793801 pkt.dts = pkt.pts;
794802
795803 //fprintf(stderr,"Audio Frame size %d ts %d\n", pkt.size, pkt.pts);
libavdevice/decklink_dec_c.c+1−0
@@ -70,6 +70,7 @@ static const AVOption options[] = { · 69 unmodified lines
7070 { "video", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_VIDEO }, 0, 0, DEC, "pts_source"},
7171 { "reference", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, "pts_source"},
7272 { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"},
73+ { "abs_wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_ABS_WALLCLOCK}, 0, 0, DEC, "pts_source"},
7374 { "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC },
7475 { "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
7576 { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC },
libavdevice/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVDEVICE_VERSION_MAJOR 58
3131 #define LIBAVDEVICE_VERSION_MINOR 0
32−#define LIBAVDEVICE_VERSION_MICRO 100
32+#define LIBAVDEVICE_VERSION_MICRO 101
3333
3434 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
3535 LIBAVDEVICE_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t