mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
validate:ssim: Allow specifying file framerate to use frame numbers during comparison
This commit is contained in:
parent
f24ca37794
commit
a055c3272e
5 changed files with 30 additions and 7 deletions
|
@ -54,6 +54,9 @@ The following parameters can be passed in the configuration file:
|
|||
used to configure the following configuration expressions. In practice this
|
||||
means that it will change the default values for the other configuration
|
||||
expressions.
|
||||
- framerate: (GstFraction): The framerate to use to compute frame number from
|
||||
timestamp, allowing to compare frames by 'frame number' instead of trying to
|
||||
match timestamp between reference images and output images.
|
||||
|
||||
# Example #
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ struct _GstValidateSsimPrivate
|
|||
gfloat min_lowest_similarity;
|
||||
|
||||
GHashTable *ref_frames_cache;
|
||||
gint fps_n, fps_d;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GstValidateSsim, gst_validate_ssim,
|
||||
|
@ -532,6 +533,16 @@ _find_frame (GstValidateSsim * self, GArray * frames, GstClockTime ts,
|
|||
guint i;
|
||||
Frame *lframe = &g_array_index (frames, Frame, 0);
|
||||
|
||||
if (self->priv->fps_n) {
|
||||
gint64 frame_number = gst_util_uint64_scale (ts, self->priv->fps_n,
|
||||
self->priv->fps_d * GST_SECOND);
|
||||
|
||||
if (frames->len < frame_number)
|
||||
return NULL;
|
||||
|
||||
return &g_array_index (frames, Frame, frame_number);
|
||||
}
|
||||
|
||||
if (frames->len == 1) {
|
||||
Frame *iframe = &g_array_index (frames, Frame, 0);
|
||||
|
||||
|
@ -1002,13 +1013,16 @@ gst_validate_ssim_init (GstValidateSsim * self)
|
|||
|
||||
GstValidateSsim *
|
||||
gst_validate_ssim_new (GstValidateRunner * runner,
|
||||
gfloat min_avg_similarity, gfloat min_lowest_similarity)
|
||||
gfloat min_avg_similarity, gfloat min_lowest_similarity,
|
||||
gint fps_n, gint fps_d)
|
||||
{
|
||||
GstValidateSsim *self =
|
||||
g_object_new (GST_VALIDATE_SSIM_TYPE, "validate-runner", runner, NULL);
|
||||
|
||||
self->priv->min_avg_similarity = min_avg_similarity;
|
||||
self->priv->min_lowest_similarity = min_lowest_similarity;
|
||||
self->priv->fps_n = fps_n;
|
||||
self->priv->fps_d = fps_d;
|
||||
|
||||
gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (self),
|
||||
g_strdup ("gst-validate-images-checker"));
|
||||
|
|
|
@ -60,7 +60,9 @@ GType gst_validate_ssim_get_type (void);
|
|||
|
||||
GstValidateSsim * gst_validate_ssim_new (GstValidateRunner *runner,
|
||||
gfloat min_avg_similarity,
|
||||
gfloat min_lowest_similarity);
|
||||
gfloat min_lowest_similarity,
|
||||
gint fps_n,
|
||||
gint fps_d);
|
||||
|
||||
gboolean gst_validate_ssim_compare_image_files (GstValidateSsim *self, const gchar *ref_file,
|
||||
const gchar * file, gfloat * mean, gfloat * lowest,
|
||||
|
|
|
@ -129,6 +129,7 @@ runner_stopping (GstValidateRunner * runner, ValidateSsimOverride * self)
|
|||
const gchar *compared_files_dir =
|
||||
gst_structure_get_string (self->priv->config,
|
||||
"reference-images-dir");
|
||||
gint fps_n = 0, fps_d = 1;
|
||||
|
||||
if (!self->priv->is_attached) {
|
||||
gchar *config_str = gst_structure_to_string (self->priv->config);
|
||||
|
@ -154,8 +155,10 @@ runner_stopping (GstValidateRunner * runner, ValidateSsimOverride * self)
|
|||
gst_structure_get_double (self->priv->config, "min-lowest-priority",
|
||||
&min_lowest_similarity);
|
||||
|
||||
gst_structure_get_fraction (self->priv->config, "framerate", &fps_n, &fps_d);
|
||||
ssim =
|
||||
gst_validate_ssim_new (runner, min_avg_similarity, min_lowest_similarity);
|
||||
gst_validate_ssim_new (runner, min_avg_similarity, min_lowest_similarity,
|
||||
fps_n, fps_d);
|
||||
|
||||
nfiles = self->priv->frames->len;
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
|
@ -180,10 +183,10 @@ runner_stopping (GstValidateRunner * runner, ValidateSsimOverride * self)
|
|||
min_avg = MIN (min_avg, mssim);
|
||||
min_min = MIN (lowest, min_min);
|
||||
total_avg += mssim;
|
||||
gst_validate_print_position(frame->position, GST_CLOCK_TIME_NONE, 1.0,
|
||||
g_strdup_printf(" %d / %d avg: %f min: %f (Passed: %d failed: %d)",
|
||||
gst_validate_print_position (frame->position, GST_CLOCK_TIME_NONE, 1.0,
|
||||
g_strdup_printf (" %d / %d avg: %f min: %f (Passed: %d failed: %d)",
|
||||
i + 1, nfiles, mssim, lowest, npassed, nfailures));
|
||||
g_free(bname);
|
||||
g_free (bname);
|
||||
}
|
||||
|
||||
gst_validate_printf (NULL,
|
||||
|
|
|
@ -93,7 +93,8 @@ main (int argc, char **argv)
|
|||
|
||||
runner = gst_validate_runner_new ();
|
||||
ssim =
|
||||
gst_validate_ssim_new (runner, min_avg_similarity, min_lowest_similarity);
|
||||
gst_validate_ssim_new (runner, min_avg_similarity, min_lowest_similarity,
|
||||
0, 1);
|
||||
|
||||
gst_validate_ssim_compare_image_files (ssim, argv[1], argv[2], &mssim,
|
||||
&lowest, &highest, outfolder);
|
||||
|
|
Loading…
Reference in a new issue