decklink, win-dshow: Use obs_source_output_video2

Allows the ability to override and use partial range RGB with the
DirectShow and Decklink device sources when partial range RGB is
implemented.  Fixes certain cases where devices could capture RGB in
limited range via HDMI (per the HDMI specs).
This commit is contained in:
jp9000 2019-04-25 13:32:32 -07:00
parent 8d125dc01d
commit 7d136c3ce1
5 changed files with 16 additions and 21 deletions

View File

@ -135,7 +135,7 @@ void DeckLinkDeviceInstance::HandleVideoFrame(
currentFrame.height = (uint32_t)videoFrame->GetHeight();
currentFrame.timestamp = timestamp;
obs_source_output_video(static_cast<DeckLinkInput*>(decklink)->GetSource(), &currentFrame);
obs_source_output_video2(static_cast<DeckLinkInput*>(decklink)->GetSource(), &currentFrame);
}
void DeckLinkDeviceInstance::FinalizeStream()
@ -177,7 +177,7 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_)
}
colorRange = static_cast<DeckLinkInput*>(decklink)->GetColorRange();
currentFrame.full_range = colorRange == VIDEO_RANGE_FULL;
currentFrame.range = colorRange;
video_format_get_parameters(activeColorSpace, colorRange,
currentFrame.color_matrix, currentFrame.color_range_min,

View File

@ -11,7 +11,7 @@ class DecklinkBase;
class DeckLinkDeviceInstance : public IDeckLinkInputCallback {
protected:
struct obs_source_frame currentFrame;
struct obs_source_frame2 currentFrame;
struct obs_source_audio currentPacket;
DecklinkBase *decklink = nullptr;
DeckLinkDevice *device = nullptr;

View File

@ -181,7 +181,7 @@ bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
uint8_t *data, size_t size, long long *ts,
struct obs_source_frame *frame,
struct obs_source_frame2 *frame,
bool *got_output)
{
AVPacket packet = {0};
@ -230,17 +230,14 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
new_format = convert_pixel_format(decode->frame->format);
if (new_format != frame->format) {
bool success;
enum video_range_type range;
frame->format = new_format;
frame->full_range =
decode->frame->color_range == AVCOL_RANGE_JPEG;
range = frame->full_range ?
VIDEO_RANGE_FULL : VIDEO_RANGE_PARTIAL;
frame->range = decode->frame->color_range == AVCOL_RANGE_JPEG
? VIDEO_RANGE_FULL
: VIDEO_RANGE_DEFAULT;
success = video_format_get_parameters(VIDEO_CS_601,
range, frame->color_matrix,
frame->range, frame->color_matrix,
frame->color_range_min, frame->color_range_max);
if (!success) {
blog(LOG_ERROR, "Failed to get video format "

View File

@ -56,7 +56,7 @@ extern bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
uint8_t *data, size_t size, long long *ts,
struct obs_source_frame *frame,
struct obs_source_frame2 *frame,
bool *got_output);
static inline bool ffmpeg_decode_valid(struct ffmpeg_decode *decode)

View File

@ -176,7 +176,7 @@ struct DShowInput {
VideoConfig videoConfig;
AudioConfig audioConfig;
obs_source_frame frame;
obs_source_frame2 frame;
obs_source_audio audio;
WinHandle semaphore;
@ -327,7 +327,7 @@ void DShowInput::DShowLoop()
obs_data_t *settings;
settings = obs_source_get_settings(source);
if (!Activate(settings)) {
obs_source_output_video(source,
obs_source_output_video2(source,
nullptr);
}
if (block)
@ -468,7 +468,7 @@ void DShowInput::OnEncodedVideoData(enum AVCodecID id,
#if LOG_ENCODED_VIDEO_TS
blog(LOG_DEBUG, "video ts: %llu", frame.timestamp);
#endif
obs_source_output_video(source, &frame);
obs_source_output_video2(source, &frame);
}
}
@ -537,7 +537,7 @@ void DShowInput::OnVideoData(const VideoConfig &config,
return;
}
obs_source_output_video(source, &frame);
obs_source_output_video2(source, &frame);
UNUSED_PARAMETER(endTime); /* it's the enndd tiimmes! */
UNUSED_PARAMETER(size);
@ -1040,15 +1040,13 @@ inline bool DShowInput::Activate(obs_data_t *settings)
return false;
enum video_colorspace cs = GetColorSpace(settings);
video_range_type range = GetColorRange(settings);
frame.full_range = range == VIDEO_RANGE_FULL;
frame.range = GetColorRange(settings);
if (device.Start() != Result::Success)
return false;
bool success = video_format_get_parameters(
cs, range,
cs, frame.range,
frame.color_matrix,
frame.color_range_min,
frame.color_range_max);
@ -1063,7 +1061,7 @@ inline bool DShowInput::Activate(obs_data_t *settings)
inline void DShowInput::Deactivate()
{
device.ResetGraph();
obs_source_output_video(source, nullptr);
obs_source_output_video2(source, nullptr);
}
/* ------------------------------------------------------------------------- */