decklinkvideosrc: Retrieve mode of the ancillary data from the frame

Instead of using the information we stored ourselves for the video frame
itself. Which was also the wrong one: it was the mode from the property,
not the autodetected one.

This fixes vanc extraction with mode=auto
This commit is contained in:
Sebastian Dröge 2019-08-07 12:58:40 +03:00 committed by Sebastian Dröge
parent 2b3a14ff4e
commit 99af098a7b
2 changed files with 15 additions and 6 deletions

View file

@ -1014,12 +1014,13 @@ extract_vbi_line (GstDecklinkVideoSrc * self, GstBuffer ** buffer,
} }
static void static void
extract_vbi (GstDecklinkVideoSrc * self, GstBuffer ** buffer, extract_vbi (GstDecklinkVideoSrc * self, GstBuffer ** buffer, VideoFrame * vf)
VideoFrame * vf, const GstDecklinkMode * mode)
{ {
IDeckLinkVideoFrameAncillary *vanc_frame = NULL; IDeckLinkVideoFrameAncillary *vanc_frame = NULL;
gint line; gint line;
GstVideoFormat videoformat; GstVideoFormat videoformat;
GstDecklinkModeEnum mode_enum;
const GstDecklinkMode *mode;
gboolean found_cc = FALSE, found_afd_bar = FALSE; gboolean found_cc = FALSE, found_afd_bar = FALSE;
if (vf->frame->GetAncillaryData (&vanc_frame) != S_OK) if (vf->frame->GetAncillaryData (&vanc_frame) != S_OK)
@ -1027,6 +1028,9 @@ extract_vbi (GstDecklinkVideoSrc * self, GstBuffer ** buffer,
videoformat = videoformat =
gst_decklink_video_format_from_type (vanc_frame->GetPixelFormat ()); gst_decklink_video_format_from_type (vanc_frame->GetPixelFormat ());
mode_enum =
gst_decklink_get_mode_enum_from_bmd (vanc_frame->GetDisplayMode ());
mode = gst_decklink_get_mode (mode_enum);
if (videoformat == GST_VIDEO_FORMAT_UNKNOWN) { if (videoformat == GST_VIDEO_FORMAT_UNKNOWN) {
GST_DEBUG_OBJECT (self, "Unknown video format for Ancillary data"); GST_DEBUG_OBJECT (self, "Unknown video format for Ancillary data");
@ -1034,7 +1038,8 @@ extract_vbi (GstDecklinkVideoSrc * self, GstBuffer ** buffer,
return; return;
} }
if (videoformat != self->anc_vformat && self->vbiparser) { if ((videoformat != self->anc_vformat || mode->width != self->anc_width)
&& self->vbiparser) {
gst_video_vbi_parser_free (self->vbiparser); gst_video_vbi_parser_free (self->vbiparser);
self->vbiparser = NULL; self->vbiparser = NULL;
} }
@ -1042,6 +1047,7 @@ extract_vbi (GstDecklinkVideoSrc * self, GstBuffer ** buffer,
if (self->vbiparser == NULL) { if (self->vbiparser == NULL) {
self->vbiparser = gst_video_vbi_parser_new (videoformat, mode->width); self->vbiparser = gst_video_vbi_parser_new (videoformat, mode->width);
self->anc_vformat = videoformat; self->anc_vformat = videoformat;
self->anc_width = mode->width;
} }
GST_DEBUG_OBJECT (self, "Checking for ancillary data in VBI"); GST_DEBUG_OBJECT (self, "Checking for ancillary data in VBI");
@ -1288,6 +1294,7 @@ retry:
gst_video_vbi_parser_free (self->vbiparser); gst_video_vbi_parser_free (self->vbiparser);
self->vbiparser = NULL; self->vbiparser = NULL;
self->anc_vformat = GST_VIDEO_FORMAT_UNKNOWN; self->anc_vformat = GST_VIDEO_FORMAT_UNKNOWN;
self->anc_width = 0;
} }
} }
@ -1306,13 +1313,11 @@ retry:
vf->input = self->input->input; vf->input = self->input->input;
vf->input->AddRef (); vf->input->AddRef ();
mode = gst_decklink_get_mode (self->mode);
// If we have a format that supports VANC and we are asked to extract CC, // If we have a format that supports VANC and we are asked to extract CC,
// then do it here. // then do it here.
if ((self->output_cc || self->output_afd_bar) if ((self->output_cc || self->output_afd_bar)
&& self->signal_state != SIGNAL_STATE_LOST) && self->signal_state != SIGNAL_STATE_LOST)
extract_vbi (self, buffer, vf, mode); extract_vbi (self, buffer, vf);
if (f.no_signal) if (f.no_signal)
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_GAP); GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_GAP);
@ -1327,6 +1332,7 @@ retry:
gst_static_caps_get (&hardware_reference), f.hardware_timestamp, gst_static_caps_get (&hardware_reference), f.hardware_timestamp,
f.hardware_duration); f.hardware_duration);
mode = gst_decklink_get_mode (self->caps_mode);
if (mode->interlaced && mode->tff) if (mode->interlaced && mode->tff)
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_SET (*buffer,
GST_VIDEO_BUFFER_FLAG_TFF | GST_VIDEO_BUFFER_FLAG_INTERLACED); GST_VIDEO_BUFFER_FLAG_TFF | GST_VIDEO_BUFFER_FLAG_INTERLACED);
@ -1483,6 +1489,7 @@ gst_decklink_video_src_stop (GstDecklinkVideoSrc * self)
gst_video_vbi_parser_free (self->vbiparser); gst_video_vbi_parser_free (self->vbiparser);
self->vbiparser = NULL; self->vbiparser = NULL;
self->anc_vformat = GST_VIDEO_FORMAT_UNKNOWN; self->anc_vformat = GST_VIDEO_FORMAT_UNKNOWN;
self->anc_width = 0;
} }
return TRUE; return TRUE;
@ -1550,6 +1557,7 @@ gst_decklink_video_src_change_state (GstElement * element,
} }
self->vbiparser = NULL; self->vbiparser = NULL;
self->anc_vformat = GST_VIDEO_FORMAT_UNKNOWN; self->anc_vformat = GST_VIDEO_FORMAT_UNKNOWN;
self->anc_width = 0;
break; break;
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
self->flushing = FALSE; self->flushing = FALSE;

View file

@ -104,6 +104,7 @@ struct _GstDecklinkVideoSrc
GstVideoVBIParser *vbiparser; GstVideoVBIParser *vbiparser;
GstVideoFormat anc_vformat; GstVideoFormat anc_vformat;
gint anc_width;
gboolean output_cc; gboolean output_cc;
gint last_cc_vbi_line; gint last_cc_vbi_line;
gint last_cc_vbi_line_field2; gint last_cc_vbi_line_field2;