mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 08:55:33 +00:00
decklink: Validate video input format
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2892>
This commit is contained in:
parent
0c42c4801c
commit
45408db258
3 changed files with 26 additions and 9 deletions
|
@ -1090,20 +1090,35 @@ public:
|
||||||
VideoInputFormatChanged (BMDVideoInputFormatChangedEvents,
|
VideoInputFormatChanged (BMDVideoInputFormatChangedEvents,
|
||||||
IDeckLinkDisplayMode * mode, BMDDetectedVideoInputFormatFlags formatFlags)
|
IDeckLinkDisplayMode * mode, BMDDetectedVideoInputFormatFlags formatFlags)
|
||||||
{
|
{
|
||||||
/* use the user-set format, defaulting to 8BitYUV */
|
BMDPixelFormat pixelFormat = bmdFormatUnspecified;
|
||||||
BMDPixelFormat pixelFormat = m_input->format;
|
|
||||||
|
|
||||||
GST_INFO ("Video input format changed");
|
GST_INFO ("Video input format changed");
|
||||||
|
|
||||||
if (m_input->format == bmdFormat8BitYUV) {
|
/* Detect input format */
|
||||||
/* user-set format was auto or 8BitYUV */
|
if ((formatFlags & bmdDetectedVideoInputRGB444)
|
||||||
if (formatFlags & bmdDetectedVideoInputRGB444) {
|
&& (formatFlags & bmdDetectedVideoInput8BitDepth)) {
|
||||||
|
/* Cannot detect ARGB vs BGRA, so assume ARGB unless user sets BGRA */
|
||||||
|
if (m_input->format == bmdFormat8BitBGRA) {
|
||||||
|
pixelFormat = bmdFormat8BitBGRA;
|
||||||
|
} else {
|
||||||
pixelFormat = bmdFormat8BitARGB;
|
pixelFormat = bmdFormat8BitARGB;
|
||||||
} else if (formatFlags & bmdDetectedVideoInputYCbCr422) {
|
|
||||||
if (formatFlags & bmdDetectedVideoInput10BitDepth) {
|
|
||||||
pixelFormat = bmdFormat10BitYUV;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if (formatFlags & bmdDetectedVideoInputYCbCr422) {
|
||||||
|
if (formatFlags & bmdDetectedVideoInput10BitDepth) {
|
||||||
|
pixelFormat = bmdFormat10BitYUV;
|
||||||
|
} else if (formatFlags & bmdDetectedVideoInput8BitDepth) {
|
||||||
|
pixelFormat = bmdFormat8BitYUV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pixelFormat == bmdFormatUnspecified) {
|
||||||
|
GST_ERROR ("Video input format is not supported");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_input->auto_format && (m_input->format != pixelFormat)) {
|
||||||
|
GST_ERROR ("Video input format does not match the user-set format");
|
||||||
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock (&m_input->lock);
|
g_mutex_lock (&m_input->lock);
|
||||||
|
|
|
@ -440,6 +440,7 @@ struct _GstDecklinkInput {
|
||||||
/* Configured mode or NULL */
|
/* Configured mode or NULL */
|
||||||
const GstDecklinkMode *mode;
|
const GstDecklinkMode *mode;
|
||||||
BMDPixelFormat format;
|
BMDPixelFormat format;
|
||||||
|
gboolean auto_format;
|
||||||
|
|
||||||
/* Set by the audio source */
|
/* Set by the audio source */
|
||||||
void (*got_audio_packet) (GstElement *videosrc, IDeckLinkAudioInputPacket * packet, GstClockTime capture_time, GstClockTime stream_time, GstClockTime stream_duration, GstClockTime hardware_time, GstClockTime hardware_duration, gboolean no_signal);
|
void (*got_audio_packet) (GstElement *videosrc, IDeckLinkAudioInputPacket * packet, GstClockTime capture_time, GstClockTime stream_time, GstClockTime stream_duration, GstClockTime hardware_time, GstClockTime hardware_duration, gboolean no_signal);
|
||||||
|
|
|
@ -1537,6 +1537,7 @@ gst_decklink_video_src_open (GstDecklinkVideoSrc * self)
|
||||||
g_mutex_lock (&self->input->lock);
|
g_mutex_lock (&self->input->lock);
|
||||||
self->input->mode = mode;
|
self->input->mode = mode;
|
||||||
self->input->format = self->caps_format;
|
self->input->format = self->caps_format;
|
||||||
|
self->input->auto_format = self->video_format == GST_DECKLINK_VIDEO_FORMAT_AUTO;
|
||||||
self->input->got_video_frame = gst_decklink_video_src_got_frame;
|
self->input->got_video_frame = gst_decklink_video_src_got_frame;
|
||||||
self->input->start_streams = gst_decklink_video_src_start_streams;
|
self->input->start_streams = gst_decklink_video_src_start_streams;
|
||||||
g_mutex_unlock (&self->input->lock);
|
g_mutex_unlock (&self->input->lock);
|
||||||
|
|
Loading…
Reference in a new issue