mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
iqa: Error out when trying to compare video stream with different sizes
We do not handle it yet and we should let the user know.
This commit is contained in:
parent
2fb83ab641
commit
b1710d7c15
1 changed files with 34 additions and 15 deletions
|
@ -102,7 +102,6 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u",
|
||||||
G_DEFINE_TYPE (GstIqa, gst_iqa, GST_TYPE_VIDEO_AGGREGATOR);
|
G_DEFINE_TYPE (GstIqa, gst_iqa, GST_TYPE_VIDEO_AGGREGATOR);
|
||||||
|
|
||||||
#ifdef HAVE_DSSIM
|
#ifdef HAVE_DSSIM
|
||||||
|
|
||||||
inline static unsigned char
|
inline static unsigned char
|
||||||
to_byte (float in)
|
to_byte (float in)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +112,7 @@ to_byte (float in)
|
||||||
return in * 256.f;
|
return in * 256.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
do_dssim (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
do_dssim (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
||||||
GstBuffer * outbuf, GstStructure * msg_structure, gchar * padname)
|
GstBuffer * outbuf, GstStructure * msg_structure, gchar * padname)
|
||||||
{
|
{
|
||||||
|
@ -138,9 +137,18 @@ do_dssim (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
||||||
dssim_set_save_ssim_maps (attr, 1, 1);
|
dssim_set_save_ssim_maps (attr, 1, 1);
|
||||||
if (ref->info.width != cmp->info.width ||
|
if (ref->info.width != cmp->info.width ||
|
||||||
ref->info.height != cmp->info.height) {
|
ref->info.height != cmp->info.height) {
|
||||||
GST_WARNING_OBJECT (self,
|
GST_OBJECT_UNLOCK (self);
|
||||||
"Cannot compare two images with a different geometry yet");
|
|
||||||
return;
|
GST_ELEMENT_ERROR (self, STREAM, FAILED,
|
||||||
|
("Video streams do not have the same sizes (add videoscale"
|
||||||
|
" and force the sizes to be equal on all sink pads.)"),
|
||||||
|
("Reference width %d - compared width: %d. "
|
||||||
|
"Reference height %d - compared height: %d",
|
||||||
|
ref->info.width, cmp->info.width, ref->info.height,
|
||||||
|
cmp->info.height));
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (self);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_map (ref->buffer, &ref_info, GST_MAP_READ);
|
gst_buffer_map (ref->buffer, &ref_info, GST_MAP_READ);
|
||||||
|
@ -198,21 +206,23 @@ do_dssim (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
||||||
dssim_dealloc_image (ref_image);
|
dssim_dealloc_image (ref_image);
|
||||||
dssim_dealloc_image (cmp_image);
|
dssim_dealloc_image (cmp_image);
|
||||||
dssim_dealloc_attr (attr);
|
dssim_dealloc_attr (attr);
|
||||||
}
|
|
||||||
#else
|
return TRUE;
|
||||||
static void
|
|
||||||
do_dssim (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
|
||||||
GstBuffer * outbuf, GstStructure * msg_structure, gchar * padname)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
compare_frames (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
compare_frames (GstIqa * self, GstVideoFrame * ref, GstVideoFrame * cmp,
|
||||||
GstBuffer * outbuf, GstStructure * msg_structure, gchar * padname)
|
GstBuffer * outbuf, GstStructure * msg_structure, gchar * padname)
|
||||||
{
|
{
|
||||||
if (self->do_dssim)
|
#ifdef HAVE_DSSIM
|
||||||
do_dssim (self, ref, cmp, outbuf, msg_structure, padname);
|
if (self->do_dssim) {
|
||||||
|
if (!do_dssim (self, ref, cmp, outbuf, msg_structure, padname))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -239,12 +249,16 @@ gst_iqa_aggregate_frames (GstVideoAggregator * vagg, GstBuffer * outbuf)
|
||||||
if (!ref_frame) {
|
if (!ref_frame) {
|
||||||
ref_frame = pad->aggregated_frame;
|
ref_frame = pad->aggregated_frame;
|
||||||
} else {
|
} else {
|
||||||
|
gboolean res;
|
||||||
gchar *padname = gst_pad_get_name (pad);
|
gchar *padname = gst_pad_get_name (pad);
|
||||||
GstVideoFrame *cmp_frame = pad->aggregated_frame;
|
GstVideoFrame *cmp_frame = pad->aggregated_frame;
|
||||||
|
|
||||||
compare_frames (self, ref_frame, cmp_frame, outbuf, msg_structure,
|
res = compare_frames (self, ref_frame, cmp_frame, outbuf, msg_structure,
|
||||||
padname);
|
padname);
|
||||||
g_free (padname);
|
g_free (padname);
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
goto failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,6 +272,11 @@ gst_iqa_aggregate_frames (GstVideoAggregator * vagg, GstBuffer * outbuf)
|
||||||
agg->segment.position, NULL);
|
agg->segment.position, NULL);
|
||||||
gst_element_post_message (GST_ELEMENT (self), m);
|
gst_element_post_message (GST_ELEMENT (self), m);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
failed:
|
||||||
|
GST_OBJECT_UNLOCK (vagg);
|
||||||
|
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue