Index: apps/metadata/mpc.c
===================================================================
--- apps/metadata/mpc.c	(revision 25073)
+++ apps/metadata/mpc.c	(working copy)
@@ -31,30 +31,51 @@
 /* Needed for replay gain in sv8, please search MPC_OLD_GAIN_REF in libmusepack */
 #define SV8_TO_SV7_CONVERT_GAIN (6482) /* 64.82 * 100 */

-static int set_replaygain_sv7(struct mp3entry* id3, 
-                              bool album, 
-                              long value, 
-                              long used)
+static int set_replaygain(struct mp3entry* id3,
+                          bool album,
+                          long gain,
+                          long peak,
+                          long used)
 {
-    long gain = (int16_t) ((value >> 16) & 0xffff);
-    long peak = (uint16_t) (value & 0xffff);
-    
-    /* Remark: mpc sv7 outputs peak as amplitude, not as dB. The following 
-     * useage of peak is not correct and needs to be fixed. */
-    
     /* We use a peak value of 0 to indicate a given gain type isn't used. */
     if (peak != 0) {
         /* Use the Xing TOC field to store ReplayGain strings for use in the
          * ID3 screen, since Musepack files shouldn't need to use it in any
          * other way.
          */
+
+        char* replaygain_string = id3->toc + used;
+
+        if (album)
+        {
+            id3->album_gain_string = replaygain_string;
+        }
+        else
+        {
+            id3->track_gain_string = replaygain_string;
+        }
+
         used += parse_replaygain_int(album, gain * 512 / 100, peak << 9,
-            id3, id3->toc + used, sizeof(id3->toc) - used);
+            id3, replaygain_string, sizeof(id3->toc) - used);
     }

     return used;
 }

+static int set_replaygain_sv7(struct mp3entry* id3,
+                              bool album,
+                              long value,
+                              long used)
+{
+    long gain = (int16_t) ((value >> 16) & 0xffff);
+    long peak = (uint16_t) (value & 0xffff);
+
+    /* Remark: mpc sv7 outputs peak as amplitude, not as dB. The following
+     * useage of peak is not correct and needs to be fixed. */
+
+    return set_replaygain(id3, album, gain, peak, used);
+}
+
 static int set_replaygain_sv8(struct mp3entry* id3, 
                               bool album, 
                               long gain, 
@@ -62,18 +83,7 @@
                               long used)
 {
     gain = (long)(SV8_TO_SV7_CONVERT_GAIN - ((gain*100)/256));
-
-    /* We use a peak value of 0 to indicate a given gain type isn't used. */
-    if (peak != 0) {
-        /* Use the Xing TOC field to store ReplayGain strings for use in the
-         * ID3 screen, since Musepack files shouldn't need to use it in any
-         * other way.
-         */
-        used += parse_replaygain_int(album, gain * 512 / 100, peak << 9,
-            id3, id3->toc + used, sizeof(id3->toc) - used);
-    }
-    
-    return used;
+    return set_replaygain(id3, album, gain, peak, used);
 }

 static int sv8_get_size(uint8_t *buffer, int index, uint64_t *p_size)