[gnac] Improved display of VBR files' bitrate



commit 3ccfe23d2c0c93aab65c1d9137304ba960c13b1b
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Sat May 29 20:30:57 2010 +0100

    Improved display of VBR files' bitrate

 libgnac/libgnac-metadata-tags.h |    5 +++++
 libgnac/libgnac-metadata.c      |   14 ++++++++++++--
 src/gnac-properties.c           |   11 +++++++++--
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/libgnac/libgnac-metadata-tags.h b/libgnac/libgnac-metadata-tags.h
index 944539d..aed1d33 100644
--- a/libgnac/libgnac-metadata-tags.h
+++ b/libgnac/libgnac-metadata-tags.h
@@ -41,6 +41,7 @@ typedef GHashTable LibgnacTags;
 #define GNAC_TAG_HEIGHT     "height"
 #define GNAC_TAG_MODE       "mode"
 #define GNAC_TAG_RATE       "rate"
+#define GNAC_TAG_VBR        "vbr"
 #define GNAC_TAG_WIDTH      "width"
 
 #define LIBGNAC_METADATA_TAG_IS_ALBUM(tag) \
@@ -93,6 +94,8 @@ typedef GHashTable LibgnacTags;
     (g_str_equal((tag), GST_TAG_TRACK_GAIN))
 #define LIBGNAC_METADATA_TAG_IS_TRACK_PEAK(tag) \
     (g_str_equal((tag), GST_TAG_TRACK_PEAK))
+#define LIBGNAC_METADATA_TAG_IS_VBR(tag) \
+    (g_str_equal((tag), GNAC_TAG_VBR))
 #define LIBGNAC_METADATA_TAG_IS_WIDTH(tag) \
     (g_str_equal((tag), GNAC_TAG_WIDTH))
 
@@ -142,6 +145,8 @@ typedef GHashTable LibgnacTags;
     (g_hash_table_lookup((GHashTable*)(tags), GST_TAG_TRACK_COUNT))
 #define LIBGNAC_METADATA_TAG_TRACK_NUMBER(tags) \
     (g_hash_table_lookup((GHashTable*)(tags), GST_TAG_TRACK_NUMBER))
+#define LIBGNAC_METADATA_TAG_VBR(tags) \
+    (g_hash_table_lookup((GHashTable*)(tags), GNAC_TAG_VBR))
 #define LIBGNAC_METADATA_TAG_WIDTH(tags) \
     (g_hash_table_lookup((GHashTable*)(tags), GNAC_TAG_WIDTH))
 
diff --git a/libgnac/libgnac-metadata.c b/libgnac/libgnac-metadata.c
index 5c6a773..c69e12d 100644
--- a/libgnac/libgnac-metadata.c
+++ b/libgnac/libgnac-metadata.c
@@ -353,8 +353,18 @@ libgnac_metadata_process_tag(const GstTagList *taglist,
   {
     guint32 bitrate;
     bitrate = g_value_get_uint(newval);
-    /* convert the bitrate from bps to kbps */
-    g_value_set_uint(newval, bitrate/1000);
+    g_value_set_uint(newval, bitrate);
+    if (libgnac_metadata_tag_exists(md->priv->metadata, (gpointer)tag_name)) {
+      guint32 old;
+      old = g_value_get_uint(LIBGNAC_METADATA_TAG_BITRATE(md->priv->metadata));
+      if (bitrate != old) {
+        GValue *vbr;
+        vbr = g_new0(GValue, 1);
+        g_value_init(vbr, G_TYPE_UINT);
+        g_value_set_uint(vbr, bitrate);
+        g_hash_table_insert(md->priv->metadata, GNAC_TAG_VBR, vbr);
+      }
+    }
   }
   else if (g_str_equal(tag_name, GST_TAG_DURATION)) 
   {
diff --git a/src/gnac-properties.c b/src/gnac-properties.c
index eb0f7aa..d3c4382 100644
--- a/src/gnac-properties.c
+++ b/src/gnac-properties.c
@@ -116,6 +116,8 @@ static const gchar *nice_properties[] = {
 
 extern LibgnacMetadata *metadata;
 
+static LibgnacTags *tags;
+
 
 static gboolean
 gnac_properties_visible_func(GtkTreeModel *model,
@@ -355,7 +357,13 @@ gnac_properties_get_property_from_value(const gchar  *name,
   {
     guint val = g_value_get_uint(value);
     if (val == 0) return NULL; 
-    else return g_strdup_printf("%d kbps", val);
+    /* convert the bitrate from bps to kbps */
+    val /= 1000;
+    if (libgnac_metadata_tag_exists(tags, GNAC_TAG_VBR)) {
+      return  g_strdup_printf("~%d kbps (VBR)", val);
+    } else {
+      return g_strdup_printf("%d kbps", val);
+    }
   }
   if (LIBGNAC_METADATA_TAG_IS_FILE_SIZE(name)) 
   {
@@ -438,7 +446,6 @@ gnac_properties_update_display(GFile *file)
 {
   if (properties_displayed) 
   {
-    LibgnacTags *tags;
     tags = libgnac_metadata_extract(metadata, file, NULL); 
     gnac_properties_reset_properties();
     if (tags) 



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