[vlc-devel] [PATCH] sout: sdi: use macros and helpers instead of direct access to CLOCK_FREQ
Steve Lhomme
robux4 at ycbcr.xyz
Tue Nov 5 08:15:50 CET 2019
And use vlc_tick_t where appropriate.
---
modules/stream_out/sdi/DBMSDIOutput.cpp | 27 +++++++++++++------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/modules/stream_out/sdi/DBMSDIOutput.cpp b/modules/stream_out/sdi/DBMSDIOutput.cpp
index 19de3288e1b..523f33f2499 100644
--- a/modules/stream_out/sdi/DBMSDIOutput.cpp
+++ b/modules/stream_out/sdi/DBMSDIOutput.cpp
@@ -47,9 +47,9 @@
#include <arpa/inet.h>
-#define DECKLINK_CARD_BUFFER (CLOCK_FREQ)
-#define DECKLINK_PREROLL (CLOCK_FREQ*3/4)
-#define DECKLINK_SCHED_OFFSET (CLOCK_FREQ/20)
+#define DECKLINK_CARD_BUFFER VLC_TICK_FROM_SEC(1)
+#define DECKLINK_PREROLL VLC_TICK_FROM_MS(750)
+#define DECKLINK_SCHED_OFFSET VLC_TICK_FROM_MS(50)
static_assert(DECKLINK_CARD_BUFFER > DECKLINK_PREROLL + DECKLINK_SCHED_OFFSET, "not in card buffer limits");
@@ -74,7 +74,7 @@ DBMSDIOutput::~DBMSDIOutput()
if(p_output)
{
while(!isDrained())
- vlc_tick_wait(vlc_tick_now() + CLOCK_FREQ/60);
+ vlc_tick_wait(vlc_tick_now() + vlc_tick_from_samples(1,60));
vlc_cancel(feeder.thread);
vlc_join(feeder.thread, NULL);
}
@@ -557,7 +557,7 @@ void * DBMSDIOutput::feederThreadCallback(void *me)
void DBMSDIOutput::feederThread()
{
- vlc_tick_t maxdelay = CLOCK_FREQ/60;
+ vlc_tick_t maxdelay = vlc_tick_from_samples(1,60);
for(;;)
{
vlc_mutex_lock(&feeder.lock);
@@ -567,7 +567,7 @@ void DBMSDIOutput::feederThread()
int cancel = vlc_savecancel();
doSchedule();
if(timescale)
- maxdelay = CLOCK_FREQ * frameduration / timescale;
+ maxdelay = vlc_tick_from_samples(frameduration, timescale);
vlc_restorecancel(cancel);
vlc_mutex_unlock(&feeder.lock);
}
@@ -590,7 +590,7 @@ int DBMSDIOutput::doSchedule()
const vlc_tick_t preroll = DECKLINK_PREROLL;
vlc_tick_t next = videoBuffer.NextPictureTime();
if(next == VLC_TICK_INVALID ||
- (!b_running && !ReachedPlaybackTime(next + preroll + SAMPLES_PER_FRAME*CLOCK_FREQ/48000)))
+ (!b_running && !ReachedPlaybackTime(next + preroll + vlc_tick_from_samples(SAMPLES_PER_FRAME,48000)))
return VLC_SUCCESS;
if(FAKE_DRIVER)
@@ -606,7 +606,7 @@ int DBMSDIOutput::doSchedule()
if(S_OK != p_output->GetBufferedVideoFrameCount(&bufferedFramesCount))
return VLC_EGENERIC;
- uint32_t bufferedFramesTarget = (uint64_t)timescale*preroll/frameduration/CLOCK_FREQ;
+ uint32_t bufferedFramesTarget = samples_from_vlc_tick(preroll,timescale)/frameduration;
if( bufferedFramesTarget > bufferedFramesCount )
{
for(size_t i=0; i<bufferedFramesTarget - bufferedFramesCount; i++)
@@ -631,11 +631,11 @@ int DBMSDIOutput::doSchedule()
if(S_OK != p_output->GetBufferedAudioSampleFrameCount(&bufferedAudioCount))
return VLC_EGENERIC;
- uint32_t bufferedAudioTarget = 48000*preroll/CLOCK_FREQ;
+ uint32_t bufferedAudioTarget = samples_from_vlc_tick(preroll, 48000);
if(bufferedAudioCount < bufferedAudioTarget)
{
- vlc_tick_t audioSamplesDuration = (bufferedAudioTarget - bufferedAudioCount)
- * CLOCK_FREQ / 48000;
+ vlc_tick_t audioSamplesDuration = vlc_tick_from_samples(bufferedAudioTarget - bufferedAudioCount,
+ 48000);
if(b_running)
FeedAudio(next, audioSamplesDuration, false);
else
@@ -721,7 +721,8 @@ int DBMSDIOutput::ProcessVideo(picture_t *picture, block_t *p_cc)
int DBMSDIOutput::doProcessVideo(picture_t *picture, block_t *p_cc)
{
HRESULT result;
- int w, h, stride, length, ret = VLC_EGENERIC;
+ int w, h, stride, ret = VLC_EGENERIC;
+ vlc_tick_t length;
BMDTimeValue scheduleTime;
IDeckLinkMutableVideoFrame *pDLVideoFrame = NULL;
w = video.configuredfmt.video.i_visible_width;
@@ -791,7 +792,7 @@ int DBMSDIOutput::doProcessVideo(picture_t *picture, block_t *p_cc)
// compute frame duration in CLOCK_FREQ units
- length = (frameduration * CLOCK_FREQ) / timescale;
+ length = vlc_tick_from_samples(frameduration, timescale);
picture->date -= clock.offset;
scheduleTime = picture->date + DECKLINK_SCHED_OFFSET;
result = p_output->ScheduleVideoFrame(pDLVideoFrame, scheduleTime, length, CLOCK_FREQ);
--
2.17.1
More information about the vlc-devel
mailing list