[nautilus/wip/hadess/av-properties-fixes: 8/8] audio-video-properties: Make the framerate more precise



commit 3096d7e544514d9f505a4fa0acb1814a45867461
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 11 18:02:06 2019 +0100

    audio-video-properties: Make the framerate more precise
    
    Add a bit more precision to the frames per second property.
    
    Closes: #901

 extensions/audio-video-properties/bacon-video-widget-properties.c | 8 +++-----
 extensions/audio-video-properties/bacon-video-widget-properties.h | 2 +-
 extensions/audio-video-properties/totem-properties-view.c         | 8 ++++----
 3 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/extensions/audio-video-properties/bacon-video-widget-properties.c 
b/extensions/audio-video-properties/bacon-video-widget-properties.c
index f8f6b7d3d..88d62636b 100644
--- a/extensions/audio-video-properties/bacon-video-widget-properties.c
+++ b/extensions/audio-video-properties/bacon-video-widget-properties.c
@@ -222,17 +222,15 @@ bacon_video_widget_properties_set_has_type (BaconVideoWidgetProperties *props,
 
 void
 bacon_video_widget_properties_set_framerate (BaconVideoWidgetProperties *props,
-                                            int                         framerate)
+                                            float                       framerate)
 {
        gchar *temp;
 
        g_return_if_fail (props != NULL);
        g_return_if_fail (BACON_IS_VIDEO_WIDGET_PROPERTIES (props));
 
-       /* The FPS has to be done differently because it's a plural string */
-       if (framerate != 0) {
-               temp = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%d frame per second", "%d frames per 
second", framerate),
-                                       framerate);
+       if (framerate > 1.0) {
+               temp = g_strdup_printf ("%0.2f frames per second", framerate);
        } else {
                temp = g_strdup (C_("Frame rate", "N/A"));
        }
diff --git a/extensions/audio-video-properties/bacon-video-widget-properties.h 
b/extensions/audio-video-properties/bacon-video-widget-properties.h
index cef7e53e9..32ec5e0b8 100644
--- a/extensions/audio-video-properties/bacon-video-widget-properties.h
+++ b/extensions/audio-video-properties/bacon-video-widget-properties.h
@@ -57,6 +57,6 @@ void bacon_video_widget_properties_set_has_type               (BaconVideoWidgetProperties 
*pr
                                                         gboolean                    has_video,
                                                         gboolean                    has_audio);
 void bacon_video_widget_properties_set_framerate       (BaconVideoWidgetProperties *props,
-                                                        int                         framerate);
+                                                        float                       framerate);
 
 #endif /* BACON_VIDEO_WIDGET_PROPERTIES_H */
diff --git a/extensions/audio-video-properties/totem-properties-view.c 
b/extensions/audio-video-properties/totem-properties-view.c
index eb8bcf00b..af50be060 100644
--- a/extensions/audio-video-properties/totem-properties-view.c
+++ b/extensions/audio-video-properties/totem-properties-view.c
@@ -191,11 +191,11 @@ update_video (TotemPropertiesView    *props,
        /* Round up/down to the nearest integer framerate */
        fps_n = gst_discoverer_video_info_get_framerate_num (info);
        fps_d = gst_discoverer_video_info_get_framerate_denom (info);
-       if (fps_d == 0)
-               bacon_video_widget_properties_set_framerate (props->priv->props, 0);
-       else
+       if (fps_d > 0.0)
                bacon_video_widget_properties_set_framerate (props->priv->props,
-                                                            (fps_n + fps_d/2) / fps_d);
+                                                            (float) fps_n / (float) fps_d);
+       else
+               bacon_video_widget_properties_set_framerate (props->priv->props, 0.0);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]