mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-04-13 11:10:31 -04:00
clang-format: Increase column limit from 80 to 120
This commit is contained in:
@@ -24,8 +24,7 @@ template<typename T> RenderDelegate<T>::RenderDelegate(T *pOwner)
|
||||
|
||||
template<typename T> RenderDelegate<T>::~RenderDelegate() {}
|
||||
|
||||
template<typename T>
|
||||
HRESULT RenderDelegate<T>::QueryInterface(REFIID, LPVOID *ppv)
|
||||
template<typename T> HRESULT RenderDelegate<T>::QueryInterface(REFIID, LPVOID *ppv)
|
||||
{
|
||||
*ppv = NULL;
|
||||
return E_NOINTERFACE;
|
||||
@@ -48,9 +47,7 @@ template<typename T> ULONG RenderDelegate<T>::Release()
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
HRESULT
|
||||
RenderDelegate<T>::ScheduledFrameCompleted(IDeckLinkVideoFrame *completedFrame,
|
||||
BMDOutputFrameCompletionResult)
|
||||
HRESULT RenderDelegate<T>::ScheduledFrameCompleted(IDeckLinkVideoFrame *completedFrame, BMDOutputFrameCompletionResult)
|
||||
{
|
||||
m_pOwner->ScheduleVideoFrame(completedFrame);
|
||||
return S_OK;
|
||||
@@ -92,8 +89,7 @@ static inline int ConvertChannelFormat(speaker_layout format)
|
||||
}
|
||||
}
|
||||
|
||||
static inline audio_repack_mode_t ConvertRepackFormat(speaker_layout format,
|
||||
bool swap)
|
||||
static inline audio_repack_mode_t ConvertRepackFormat(speaker_layout format, bool swap)
|
||||
{
|
||||
switch (format) {
|
||||
case SPEAKERS_2POINT1:
|
||||
@@ -112,8 +108,7 @@ static inline audio_repack_mode_t ConvertRepackFormat(speaker_layout format,
|
||||
}
|
||||
}
|
||||
|
||||
DeckLinkDeviceInstance::DeckLinkDeviceInstance(DecklinkBase *decklink_,
|
||||
DeckLinkDevice *device_)
|
||||
DeckLinkDeviceInstance::DeckLinkDeviceInstance(DecklinkBase *decklink_, DeckLinkDevice *device_)
|
||||
: currentFrame(),
|
||||
currentPacket(),
|
||||
currentCaptions(),
|
||||
@@ -132,8 +127,7 @@ DeckLinkDeviceInstance::~DeckLinkDeviceInstance()
|
||||
}
|
||||
}
|
||||
|
||||
void DeckLinkDeviceInstance::HandleAudioPacket(
|
||||
IDeckLinkAudioInputPacket *audioPacket, const uint64_t timestamp)
|
||||
void DeckLinkDeviceInstance::HandleAudioPacket(IDeckLinkAudioInputPacket *audioPacket, const uint64_t timestamp)
|
||||
{
|
||||
if (audioPacket == nullptr)
|
||||
return;
|
||||
@@ -144,25 +138,19 @@ void DeckLinkDeviceInstance::HandleAudioPacket(
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t frameCount =
|
||||
(uint32_t)audioPacket->GetSampleFrameCount();
|
||||
const uint32_t frameCount = (uint32_t)audioPacket->GetSampleFrameCount();
|
||||
currentPacket.frames = frameCount;
|
||||
currentPacket.timestamp = timestamp;
|
||||
|
||||
if (decklink && !static_cast<DeckLinkInput *>(decklink)->buffering) {
|
||||
currentPacket.timestamp = os_gettime_ns();
|
||||
currentPacket.timestamp -=
|
||||
util_mul_div64(frameCount, 1000000000ULL,
|
||||
currentPacket.samples_per_sec);
|
||||
currentPacket.timestamp -= util_mul_div64(frameCount, 1000000000ULL, currentPacket.samples_per_sec);
|
||||
}
|
||||
|
||||
int maxdevicechannel = device->GetMaxChannel();
|
||||
|
||||
if (channelFormat != SPEAKERS_UNKNOWN &&
|
||||
channelFormat != SPEAKERS_MONO &&
|
||||
channelFormat != SPEAKERS_STEREO &&
|
||||
(channelFormat != SPEAKERS_7POINT1 ||
|
||||
static_cast<DeckLinkInput *>(decklink)->swap) &&
|
||||
if (channelFormat != SPEAKERS_UNKNOWN && channelFormat != SPEAKERS_MONO && channelFormat != SPEAKERS_STEREO &&
|
||||
(channelFormat != SPEAKERS_7POINT1 || static_cast<DeckLinkInput *>(decklink)->swap) &&
|
||||
maxdevicechannel >= 8) {
|
||||
|
||||
if (audioRepacker->repack((uint8_t *)bytes, frameCount) < 0) {
|
||||
@@ -174,24 +162,19 @@ void DeckLinkDeviceInstance::HandleAudioPacket(
|
||||
currentPacket.data[0] = (uint8_t *)bytes;
|
||||
}
|
||||
|
||||
nextAudioTS = timestamp +
|
||||
util_mul_div64(frameCount, 1000000000ULL, 48000ULL) + 1;
|
||||
nextAudioTS = timestamp + util_mul_div64(frameCount, 1000000000ULL, 48000ULL) + 1;
|
||||
|
||||
obs_source_output_audio(
|
||||
static_cast<DeckLinkInput *>(decklink)->GetSource(),
|
||||
¤tPacket);
|
||||
obs_source_output_audio(static_cast<DeckLinkInput *>(decklink)->GetSource(), ¤tPacket);
|
||||
}
|
||||
|
||||
void DeckLinkDeviceInstance::HandleVideoFrame(
|
||||
IDeckLinkVideoInputFrame *videoFrame, const uint64_t timestamp)
|
||||
void DeckLinkDeviceInstance::HandleVideoFrame(IDeckLinkVideoInputFrame *videoFrame, const uint64_t timestamp)
|
||||
{
|
||||
if (videoFrame == nullptr)
|
||||
return;
|
||||
|
||||
ComPtr<IDeckLinkVideoFrameAncillaryPackets> packets;
|
||||
|
||||
if (videoFrame->QueryInterface(IID_IDeckLinkVideoFrameAncillaryPackets,
|
||||
(void **)&packets) == S_OK) {
|
||||
if (videoFrame->QueryInterface(IID_IDeckLinkVideoFrameAncillaryPackets, (void **)&packets) == S_OK) {
|
||||
ComPtr<IDeckLinkAncillaryPacketIterator> iterator;
|
||||
packets->GetPacketIterator(&iterator);
|
||||
|
||||
@@ -239,13 +222,11 @@ void DeckLinkDeviceInstance::HandleVideoFrame(
|
||||
enum video_trc trc = VIDEO_TRC_DEFAULT;
|
||||
if (frame->GetFlags() & bmdFrameContainsHDRMetadata) {
|
||||
ComPtr<IDeckLinkVideoFrameMetadataExtensions> metadata;
|
||||
if (SUCCEEDED(videoFrame->QueryInterface(
|
||||
IID_IDeckLinkVideoFrameMetadataExtensions,
|
||||
(void **)&metadata))) {
|
||||
if (SUCCEEDED(videoFrame->QueryInterface(IID_IDeckLinkVideoFrameMetadataExtensions,
|
||||
(void **)&metadata))) {
|
||||
int64_t range;
|
||||
if (SUCCEEDED(metadata->GetInt(
|
||||
bmdDeckLinkFrameMetadataHDRElectroOpticalTransferFunc,
|
||||
&range))) {
|
||||
if (SUCCEEDED(
|
||||
metadata->GetInt(bmdDeckLinkFrameMetadataHDRElectroOpticalTransferFunc, &range))) {
|
||||
switch (range) {
|
||||
case 2:
|
||||
trc = VIDEO_TRC_PQ;
|
||||
@@ -262,13 +243,10 @@ void DeckLinkDeviceInstance::HandleVideoFrame(
|
||||
}
|
||||
currentFrame.trc = trc;
|
||||
|
||||
obs_source_output_video2(
|
||||
static_cast<DeckLinkInput *>(decklink)->GetSource(),
|
||||
¤tFrame);
|
||||
obs_source_output_video2(static_cast<DeckLinkInput *>(decklink)->GetSource(), ¤tFrame);
|
||||
}
|
||||
|
||||
void DeckLinkDeviceInstance::HandleCaptionPacket(
|
||||
IDeckLinkAncillaryPacket *packet, const uint64_t timestamp)
|
||||
void DeckLinkDeviceInstance::HandleCaptionPacket(IDeckLinkAncillaryPacket *packet, const uint64_t timestamp)
|
||||
{
|
||||
const void *data;
|
||||
uint32_t size;
|
||||
@@ -343,17 +321,14 @@ void DeckLinkDeviceInstance::HandleCaptionPacket(
|
||||
|
||||
auto cc_count = bitstream_reader_read_bits(&reader, 5);
|
||||
|
||||
auto *outData =
|
||||
(uint8_t *)bzalloc(sizeof(uint8_t) * cc_count * 3);
|
||||
auto *outData = (uint8_t *)bzalloc(sizeof(uint8_t) * cc_count * 3);
|
||||
memcpy(outData, anc + reader.pos, cc_count * 3);
|
||||
|
||||
currentCaptions.data = outData;
|
||||
currentCaptions.timestamp = timestamp;
|
||||
currentCaptions.packets = cc_count;
|
||||
|
||||
obs_source_output_cea708(
|
||||
static_cast<DeckLinkInput *>(decklink)->GetSource(),
|
||||
¤tCaptions);
|
||||
obs_source_output_cea708(static_cast<DeckLinkInput *>(decklink)->GetSource(), ¤tCaptions);
|
||||
bfree(outData);
|
||||
}
|
||||
}
|
||||
@@ -402,9 +377,8 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_)
|
||||
colorRange = static_cast<DeckLinkInput *>(decklink)->GetColorRange();
|
||||
currentFrame.range = colorRange;
|
||||
|
||||
video_format_get_parameters_for_format(
|
||||
activeColorSpace, colorRange, format, currentFrame.color_matrix,
|
||||
currentFrame.color_range_min, currentFrame.color_range_max);
|
||||
video_format_get_parameters_for_format(activeColorSpace, colorRange, format, currentFrame.color_matrix,
|
||||
currentFrame.color_range_min, currentFrame.color_range_max);
|
||||
|
||||
delete convertFrame;
|
||||
|
||||
@@ -420,21 +394,17 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_)
|
||||
break;
|
||||
}
|
||||
|
||||
convertFrame = new OBSVideoFrame(mode_->GetWidth(), mode_->GetHeight(),
|
||||
convertFormat);
|
||||
convertFrame = new OBSVideoFrame(mode_->GetWidth(), mode_->GetHeight(), convertFormat);
|
||||
|
||||
#ifdef LOG_SETUP_VIDEO_FORMAT
|
||||
LOG(LOG_INFO, "Setup video format: %s, %s, %s",
|
||||
pixelFormat == bmdFormat8BitYUV ? "YUV" : "RGB",
|
||||
LOG(LOG_INFO, "Setup video format: %s, %s, %s", pixelFormat == bmdFormat8BitYUV ? "YUV" : "RGB",
|
||||
activeColorSpace == VIDEO_CS_601 ? "BT.601" : "BT.709",
|
||||
colorRange == VIDEO_RANGE_FULL ? "full" : "limited");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_,
|
||||
bool allow10Bit_,
|
||||
BMDVideoConnection bmdVideoConnection,
|
||||
BMDAudioConnection bmdAudioConnection)
|
||||
bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_, bool allow10Bit_,
|
||||
BMDVideoConnection bmdVideoConnection, BMDAudioConnection bmdAudioConnection)
|
||||
{
|
||||
if (mode != nullptr)
|
||||
return false;
|
||||
@@ -446,32 +416,23 @@ bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_,
|
||||
if (!device->GetInput(&input))
|
||||
return false;
|
||||
|
||||
HRESULT result = input->QueryInterface(IID_IDeckLinkConfiguration,
|
||||
(void **)&deckLinkConfiguration);
|
||||
HRESULT result = input->QueryInterface(IID_IDeckLinkConfiguration, (void **)&deckLinkConfiguration);
|
||||
if (result != S_OK) {
|
||||
LOG(LOG_ERROR,
|
||||
"Could not obtain the IDeckLinkConfiguration interface: %08x\n",
|
||||
result);
|
||||
LOG(LOG_ERROR, "Could not obtain the IDeckLinkConfiguration interface: %08x\n", result);
|
||||
} else {
|
||||
if (bmdVideoConnection > 0) {
|
||||
result = deckLinkConfiguration->SetInt(
|
||||
bmdDeckLinkConfigVideoInputConnection,
|
||||
bmdVideoConnection);
|
||||
result = deckLinkConfiguration->SetInt(bmdDeckLinkConfigVideoInputConnection,
|
||||
bmdVideoConnection);
|
||||
if (result != S_OK) {
|
||||
LOG(LOG_ERROR,
|
||||
"Couldn't set input video port to %d\n\n",
|
||||
bmdVideoConnection);
|
||||
LOG(LOG_ERROR, "Couldn't set input video port to %d\n\n", bmdVideoConnection);
|
||||
}
|
||||
}
|
||||
|
||||
if (bmdAudioConnection > 0) {
|
||||
result = deckLinkConfiguration->SetInt(
|
||||
bmdDeckLinkConfigAudioInputConnection,
|
||||
bmdAudioConnection);
|
||||
result = deckLinkConfiguration->SetInt(bmdDeckLinkConfigAudioInputConnection,
|
||||
bmdAudioConnection);
|
||||
if (result != S_OK) {
|
||||
LOG(LOG_ERROR,
|
||||
"Couldn't set input audio port to %d\n\n",
|
||||
bmdVideoConnection);
|
||||
LOG(LOG_ERROR, "Couldn't set input audio port to %d\n\n", bmdVideoConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,15 +453,13 @@ bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_,
|
||||
flags = bmdVideoInputEnableFormatDetection;
|
||||
} else {
|
||||
displayMode = mode_->GetDisplayMode();
|
||||
pixelFormat =
|
||||
static_cast<DeckLinkInput *>(decklink)->GetPixelFormat();
|
||||
pixelFormat = static_cast<DeckLinkInput *>(decklink)->GetPixelFormat();
|
||||
flags = bmdVideoInputFlagDefault;
|
||||
}
|
||||
|
||||
allow10Bit = allow10Bit_;
|
||||
|
||||
const HRESULT videoResult =
|
||||
input->EnableVideoInput(displayMode, pixelFormat, flags);
|
||||
const HRESULT videoResult = input->EnableVideoInput(displayMode, pixelFormat, flags);
|
||||
if (videoResult != S_OK) {
|
||||
LOG(LOG_ERROR, "Failed to enable video input");
|
||||
return false;
|
||||
@@ -508,8 +467,7 @@ bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_,
|
||||
|
||||
SetupVideoFormat(mode_);
|
||||
|
||||
channelFormat =
|
||||
static_cast<DeckLinkInput *>(decklink)->GetChannelFormat();
|
||||
channelFormat = static_cast<DeckLinkInput *>(decklink)->GetChannelFormat();
|
||||
currentPacket.speakers = channelFormat;
|
||||
swap = static_cast<DeckLinkInput *>(decklink)->swap;
|
||||
|
||||
@@ -517,21 +475,16 @@ bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_,
|
||||
|
||||
if (channelFormat != SPEAKERS_UNKNOWN) {
|
||||
const int channel = ConvertChannelFormat(channelFormat);
|
||||
const HRESULT audioResult = input->EnableAudioInput(
|
||||
bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger,
|
||||
channel);
|
||||
const HRESULT audioResult =
|
||||
input->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, channel);
|
||||
if (audioResult != S_OK)
|
||||
LOG(LOG_WARNING,
|
||||
"Failed to enable audio input; continuing...");
|
||||
LOG(LOG_WARNING, "Failed to enable audio input; continuing...");
|
||||
|
||||
if (channelFormat != SPEAKERS_UNKNOWN &&
|
||||
channelFormat != SPEAKERS_MONO &&
|
||||
channelFormat != SPEAKERS_STEREO &&
|
||||
(channelFormat != SPEAKERS_7POINT1 || swap) &&
|
||||
if (channelFormat != SPEAKERS_UNKNOWN && channelFormat != SPEAKERS_MONO &&
|
||||
channelFormat != SPEAKERS_STEREO && (channelFormat != SPEAKERS_7POINT1 || swap) &&
|
||||
maxdevicechannel >= 8) {
|
||||
|
||||
const audio_repack_mode_t repack_mode =
|
||||
ConvertRepackFormat(channelFormat, swap);
|
||||
const audio_repack_mode_t repack_mode = ConvertRepackFormat(channelFormat, swap);
|
||||
audioRepacker = new AudioRepacker(repack_mode);
|
||||
}
|
||||
}
|
||||
@@ -558,8 +511,7 @@ bool DeckLinkDeviceInstance::StopCapture(void)
|
||||
if (mode == nullptr || input == nullptr)
|
||||
return false;
|
||||
|
||||
LOG(LOG_INFO, "Stopping capture of '%s'...",
|
||||
GetDevice()->GetDisplayName().c_str());
|
||||
LOG(LOG_INFO, "Stopping capture of '%s'...", GetDevice()->GetDisplayName().c_str());
|
||||
|
||||
input->StopStreams();
|
||||
FinalizeStream();
|
||||
@@ -584,16 +536,14 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_)
|
||||
if (!device->GetOutput(&output_))
|
||||
return false;
|
||||
|
||||
const HRESULT videoResult = output_->EnableVideoOutput(
|
||||
mode_->GetDisplayMode(), bmdVideoOutputFlagDefault);
|
||||
const HRESULT videoResult = output_->EnableVideoOutput(mode_->GetDisplayMode(), bmdVideoOutputFlagDefault);
|
||||
if (videoResult != S_OK) {
|
||||
LOG(LOG_ERROR, "Failed to enable video output");
|
||||
return false;
|
||||
}
|
||||
|
||||
const HRESULT audioResult = output_->EnableAudioOutput(
|
||||
bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 2,
|
||||
bmdAudioOutputStreamTimestamped);
|
||||
const HRESULT audioResult = output_->EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger,
|
||||
2, bmdAudioOutputStreamTimestamped);
|
||||
if (audioResult != S_OK) {
|
||||
LOG(LOG_ERROR, "Failed to enable audio output");
|
||||
return false;
|
||||
@@ -627,53 +577,39 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_)
|
||||
activeBlob = nullptr;
|
||||
|
||||
struct obs_video_info ovi;
|
||||
const enum video_colorspace colorspace =
|
||||
obs_get_video_info(&ovi) ? ovi.colorspace : VIDEO_CS_DEFAULT;
|
||||
const bool source_hdr = (colorspace == VIDEO_CS_2100_PQ) ||
|
||||
(colorspace == VIDEO_CS_2100_HLG);
|
||||
const enum video_colorspace colorspace = obs_get_video_info(&ovi) ? ovi.colorspace : VIDEO_CS_DEFAULT;
|
||||
const bool source_hdr = (colorspace == VIDEO_CS_2100_PQ) || (colorspace == VIDEO_CS_2100_HLG);
|
||||
const bool enable_hdr =
|
||||
source_hdr &&
|
||||
(obs_output_get_video_conversion(decklinkOutput->GetOutput())
|
||||
->colorspace == VIDEO_CS_2100_PQ);
|
||||
BMDPixelFormat pixelFormat = enable_hdr ? bmdFormat10BitRGBXLE
|
||||
: bmdFormat8BitBGRA;
|
||||
const int64_t minimumPrerollFrames =
|
||||
std::max(device->GetMinimumPrerollFrames(), INT64_C(3));
|
||||
(obs_output_get_video_conversion(decklinkOutput->GetOutput())->colorspace == VIDEO_CS_2100_PQ);
|
||||
BMDPixelFormat pixelFormat = enable_hdr ? bmdFormat10BitRGBXLE : bmdFormat8BitBGRA;
|
||||
const int64_t minimumPrerollFrames = std::max(device->GetMinimumPrerollFrames(), INT64_C(3));
|
||||
for (int64_t i = 0; i < minimumPrerollFrames; ++i) {
|
||||
ComPtr<IDeckLinkMutableVideoFrame> decklinkOutputFrame;
|
||||
HRESULT result = output_->CreateVideoFrame(
|
||||
decklinkOutput->GetWidth(), decklinkOutput->GetHeight(),
|
||||
rowSize, pixelFormat, bmdFrameFlagDefault,
|
||||
&decklinkOutputFrame);
|
||||
HRESULT result = output_->CreateVideoFrame(decklinkOutput->GetWidth(), decklinkOutput->GetHeight(),
|
||||
rowSize, pixelFormat, bmdFrameFlagDefault,
|
||||
&decklinkOutputFrame);
|
||||
if (result != S_OK) {
|
||||
blog(LOG_ERROR, "failed to create video frame 0x%X",
|
||||
result);
|
||||
blog(LOG_ERROR, "failed to create video frame 0x%X", result);
|
||||
return false;
|
||||
}
|
||||
|
||||
IDeckLinkVideoFrame *theFrame = decklinkOutputFrame.Get();
|
||||
ComPtr<HDRVideoFrame> decklinkOutputHDRFrame;
|
||||
if (enable_hdr) {
|
||||
*decklinkOutputHDRFrame.Assign() =
|
||||
new HDRVideoFrame(decklinkOutputFrame);
|
||||
*decklinkOutputHDRFrame.Assign() = new HDRVideoFrame(decklinkOutputFrame);
|
||||
theFrame = decklinkOutputHDRFrame.Get();
|
||||
}
|
||||
|
||||
result = output_->ScheduleVideoFrame(theFrame,
|
||||
i * frameDuration,
|
||||
frameDuration,
|
||||
frameTimescale);
|
||||
result = output_->ScheduleVideoFrame(theFrame, i * frameDuration, frameDuration, frameTimescale);
|
||||
if (result != S_OK) {
|
||||
blog(LOG_ERROR,
|
||||
"failed to schedule video frame for preroll 0x%X",
|
||||
result);
|
||||
blog(LOG_ERROR, "failed to schedule video frame for preroll 0x%X", result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
totalFramesScheduled = minimumPrerollFrames;
|
||||
|
||||
*renderDelegate.Assign() =
|
||||
new RenderDelegate<DeckLinkDeviceInstance>(this);
|
||||
*renderDelegate.Assign() = new RenderDelegate<DeckLinkDeviceInstance>(this);
|
||||
output_->SetScheduledFrameCompletionCallback(renderDelegate);
|
||||
|
||||
output_->StartScheduledPlayback(0, 100, 1.0);
|
||||
@@ -689,8 +625,7 @@ bool DeckLinkDeviceInstance::StopOutput()
|
||||
if (mode == nullptr || output == nullptr)
|
||||
return false;
|
||||
|
||||
LOG(LOG_INFO, "Stopping output of '%s'...",
|
||||
GetDevice()->GetDisplayName().c_str());
|
||||
LOG(LOG_INFO, "Stopping output of '%s'...", GetDevice()->GetDisplayName().c_str());
|
||||
|
||||
output->SetScheduledFrameCompletionCallback(NULL);
|
||||
output->DisableVideoOutput();
|
||||
@@ -711,8 +646,7 @@ void DeckLinkDeviceInstance::UpdateVideoFrame(video_data *frame)
|
||||
|
||||
uint8_t *const blob = frameQueueDecklinkToObs.pop();
|
||||
if (blob) {
|
||||
memcpy(blob, frame->data[0],
|
||||
frame->linesize[0] * decklinkOutput->GetHeight());
|
||||
memcpy(blob, frame->data[0], frame->linesize[0] * decklinkOutput->GetHeight());
|
||||
frameQueueObsToDecklink.push(blob);
|
||||
}
|
||||
}
|
||||
@@ -736,9 +670,7 @@ void DeckLinkDeviceInstance::ScheduleVideoFrame(IDeckLinkVideoFrame *frame)
|
||||
else
|
||||
memset(bytes, 0, frameSize);
|
||||
|
||||
output->ScheduleVideoFrame(frame,
|
||||
totalFramesScheduled * frameDuration,
|
||||
frameDuration, frameTimescale);
|
||||
output->ScheduleVideoFrame(frame, totalFramesScheduled * frameDuration, frameDuration, frameTimescale);
|
||||
++totalFramesScheduled;
|
||||
}
|
||||
}
|
||||
@@ -746,15 +678,13 @@ void DeckLinkDeviceInstance::ScheduleVideoFrame(IDeckLinkVideoFrame *frame)
|
||||
void DeckLinkDeviceInstance::WriteAudio(audio_data *frames)
|
||||
{
|
||||
uint32_t sampleFramesWritten;
|
||||
output->WriteAudioSamplesSync(frames->data[0], frames->frames,
|
||||
&sampleFramesWritten);
|
||||
output->WriteAudioSamplesSync(frames->data[0], frames->frames, &sampleFramesWritten);
|
||||
}
|
||||
|
||||
#define TIME_BASE 1000000000
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFrameArrived(
|
||||
IDeckLinkVideoInputFrame *videoFrame,
|
||||
IDeckLinkAudioInputPacket *audioPacket)
|
||||
HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFrameArrived(IDeckLinkVideoInputFrame *videoFrame,
|
||||
IDeckLinkAudioInputPacket *audioPacket)
|
||||
{
|
||||
BMDTimeValue videoTS = 0;
|
||||
BMDTimeValue videoDur = 0;
|
||||
@@ -790,30 +720,25 @@ HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFrameArrived(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFormatChanged(
|
||||
BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *newMode,
|
||||
BMDDetectedVideoInputFormatFlags detectedSignalFlags)
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
DeckLinkDeviceInstance::VideoInputFormatChanged(BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *newMode,
|
||||
BMDDetectedVideoInputFormatFlags detectedSignalFlags)
|
||||
{
|
||||
bool formatChanged = false;
|
||||
if (events & bmdVideoInputColorspaceChanged) {
|
||||
constexpr BMDDetectedVideoInputFormatFlags highBitFlags =
|
||||
(bmdDetectedVideoInput12BitDepth |
|
||||
bmdDetectedVideoInput10BitDepth);
|
||||
(bmdDetectedVideoInput12BitDepth | bmdDetectedVideoInput10BitDepth);
|
||||
if (detectedSignalFlags & bmdDetectedVideoInputRGB444) {
|
||||
const BMDPixelFormat nextFormat =
|
||||
((detectedSignalFlags & highBitFlags) &&
|
||||
allow10Bit)
|
||||
? bmdFormat10BitRGBXLE
|
||||
: bmdFormat8BitBGRA;
|
||||
const BMDPixelFormat nextFormat = ((detectedSignalFlags & highBitFlags) && allow10Bit)
|
||||
? bmdFormat10BitRGBXLE
|
||||
: bmdFormat8BitBGRA;
|
||||
formatChanged = pixelFormat != nextFormat;
|
||||
pixelFormat = nextFormat;
|
||||
}
|
||||
if (detectedSignalFlags & bmdDetectedVideoInputYCbCr422) {
|
||||
const BMDPixelFormat nextFormat =
|
||||
((detectedSignalFlags & highBitFlags) &&
|
||||
allow10Bit)
|
||||
? bmdFormat10BitYUV
|
||||
: bmdFormat8BitYUV;
|
||||
const BMDPixelFormat nextFormat = ((detectedSignalFlags & highBitFlags) && allow10Bit)
|
||||
? bmdFormat10BitYUV
|
||||
: bmdFormat8BitYUV;
|
||||
formatChanged = pixelFormat != nextFormat;
|
||||
pixelFormat = nextFormat;
|
||||
}
|
||||
@@ -824,9 +749,8 @@ HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFormatChanged(
|
||||
mode->SetMode(newMode);
|
||||
displayMode = mode->GetDisplayMode();
|
||||
|
||||
const HRESULT videoResult = input->EnableVideoInput(
|
||||
displayMode, pixelFormat,
|
||||
bmdVideoInputEnableFormatDetection);
|
||||
const HRESULT videoResult =
|
||||
input->EnableVideoInput(displayMode, pixelFormat, bmdVideoInputEnableFormatDetection);
|
||||
if (videoResult != S_OK) {
|
||||
LOG(LOG_ERROR, "Failed to enable video input");
|
||||
input->StopStreams();
|
||||
@@ -847,8 +771,7 @@ ULONG STDMETHODCALLTYPE DeckLinkDeviceInstance::AddRef(void)
|
||||
return os_atomic_inc_long(&refCount);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::QueryInterface(REFIID iid,
|
||||
LPVOID *ppv)
|
||||
HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::QueryInterface(REFIID iid, LPVOID *ppv)
|
||||
{
|
||||
HRESULT result = E_NOINTERFACE;
|
||||
|
||||
@@ -859,8 +782,7 @@ HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::QueryInterface(REFIID iid,
|
||||
*ppv = this;
|
||||
AddRef();
|
||||
result = S_OK;
|
||||
} else if (memcmp(&iid, &IID_IDeckLinkNotificationCallback,
|
||||
sizeof(REFIID)) == 0) {
|
||||
} else if (memcmp(&iid, &IID_IDeckLinkNotificationCallback, sizeof(REFIID)) == 0) {
|
||||
*ppv = (IDeckLinkNotificationCallback *)this;
|
||||
AddRef();
|
||||
result = S_OK;
|
||||
|
||||
Reference in New Issue
Block a user