mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +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
|
used to configure the following configuration expressions. In practice this
|
||||||
means that it will change the default values for the other configuration
|
means that it will change the default values for the other configuration
|
||||||
expressions.
|
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 #
|
# Example #
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ struct _GstValidateSsimPrivate
|
||||||
gfloat min_lowest_similarity;
|
gfloat min_lowest_similarity;
|
||||||
|
|
||||||
GHashTable *ref_frames_cache;
|
GHashTable *ref_frames_cache;
|
||||||
|
gint fps_n, fps_d;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstValidateSsim, gst_validate_ssim,
|
G_DEFINE_TYPE_WITH_CODE (GstValidateSsim, gst_validate_ssim,
|
||||||
|
@ -532,6 +533,16 @@ _find_frame (GstValidateSsim * self, GArray * frames, GstClockTime ts,
|
||||||
guint i;
|
guint i;
|
||||||
Frame *lframe = &g_array_index (frames, Frame, 0);
|
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) {
|
if (frames->len == 1) {
|
||||||
Frame *iframe = &g_array_index (frames, Frame, 0);
|
Frame *iframe = &g_array_index (frames, Frame, 0);
|
||||||
|
|
||||||
|
@ -1002,13 +1013,16 @@ gst_validate_ssim_init (GstValidateSsim * self)
|
||||||
|
|
||||||
GstValidateSsim *
|
GstValidateSsim *
|
||||||
gst_validate_ssim_new (GstValidateRunner * runner,
|
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 =
|
GstValidateSsim *self =
|
||||||
g_object_new (GST_VALIDATE_SSIM_TYPE, "validate-runner", runner, NULL);
|
g_object_new (GST_VALIDATE_SSIM_TYPE, "validate-runner", runner, NULL);
|
||||||
|
|
||||||
self->priv->min_avg_similarity = min_avg_similarity;
|
self->priv->min_avg_similarity = min_avg_similarity;
|
||||||
self->priv->min_lowest_similarity = min_lowest_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),
|
gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (self),
|
||||||
g_strdup ("gst-validate-images-checker"));
|
g_strdup ("gst-validate-images-checker"));
|
||||||
|
|
|
@ -60,7 +60,9 @@ GType gst_validate_ssim_get_type (void);
|
||||||
|
|
||||||
GstValidateSsim * gst_validate_ssim_new (GstValidateRunner *runner,
|
GstValidateSsim * gst_validate_ssim_new (GstValidateRunner *runner,
|
||||||
gfloat min_avg_similarity,
|
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,
|
gboolean gst_validate_ssim_compare_image_files (GstValidateSsim *self, const gchar *ref_file,
|
||||||
const gchar * file, gfloat * mean, gfloat * lowest,
|
const gchar * file, gfloat * mean, gfloat * lowest,
|
||||||
|
|
|
@ -129,6 +129,7 @@ runner_stopping (GstValidateRunner * runner, ValidateSsimOverride * self)
|
||||||
const gchar *compared_files_dir =
|
const gchar *compared_files_dir =
|
||||||
gst_structure_get_string (self->priv->config,
|
gst_structure_get_string (self->priv->config,
|
||||||
"reference-images-dir");
|
"reference-images-dir");
|
||||||
|
gint fps_n = 0, fps_d = 1;
|
||||||
|
|
||||||
if (!self->priv->is_attached) {
|
if (!self->priv->is_attached) {
|
||||||
gchar *config_str = gst_structure_to_string (self->priv->config);
|
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",
|
gst_structure_get_double (self->priv->config, "min-lowest-priority",
|
||||||
&min_lowest_similarity);
|
&min_lowest_similarity);
|
||||||
|
|
||||||
|
gst_structure_get_fraction (self->priv->config, "framerate", &fps_n, &fps_d);
|
||||||
ssim =
|
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;
|
nfiles = self->priv->frames->len;
|
||||||
for (i = 0; i < nfiles; i++) {
|
for (i = 0; i < nfiles; i++) {
|
||||||
|
|
|
@ -93,7 +93,8 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
runner = gst_validate_runner_new ();
|
runner = gst_validate_runner_new ();
|
||||||
ssim =
|
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,
|
gst_validate_ssim_compare_image_files (ssim, argv[1], argv[2], &mssim,
|
||||||
&lowest, &highest, outfolder);
|
&lowest, &highest, outfolder);
|
||||||
|
|
Loading…
Reference in a new issue