--- mp3gain-1.5.1.orig/debian/mp3gain.sgml
+++ mp3gain-1.5.1/debian/mp3gain.sgml
@@ -0,0 +1,441 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [
+
+<!-- Process this file with docbook-to-man to generate an nroff manual
+     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
+     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
+     less'.  A typical entry in a Makefile or Makefile.am is:
+
+manpage.1: manpage.sgml
+	docbook-to-man $< > $@
+
+    
+	The docbook-to-man binary is found in the docbook-to-man package.
+	Please remember that if you create the nroff version in one of the
+	debian/rules file targets (such as build), you will need to include
+	docbook-to-man in your Build-Depends control field.
+
+  -->
+
+  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
+  <!ENTITY dhfirstname "<firstname>STEFAN</firstname>">
+  <!ENTITY dhsurname   "<surname>FRITSCH</surname>">
+  <!-- Please adjust the date whenever revising the manpage. -->
+  <!ENTITY dhdate      "<date>February  4, 2004</date>">
+  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
+       allowed: see man(7), man(1). -->
+  <!ENTITY dhsection   "<manvolnum>1</manvolnum>">
+  <!ENTITY dhemail     "<email>sf@sfritsch.de</email>">
+  <!ENTITY dhusername  "Stefan Fritsch">
+  <!ENTITY dhucpackage "<refentrytitle>MP3GAIN</refentrytitle>">
+  <!ENTITY dhpackage   "mp3gain">
+  <!ENTITY debian      "<productname>Debian</productname>">
+  <!ENTITY gnu         "<acronym>GNU</acronym>">
+  <!ENTITY lgpl         "&gnu; <acronym>LGPL</acronym>">
+]>
+
+<refentry>
+  <refentryinfo>
+    <address>
+      &dhemail;
+    </address>
+    <author>
+      &dhfirstname;
+      &dhsurname;
+    </author>
+    <copyright>
+      <year>2004</year>
+      <holder>Glen Sawyer and &dhusername;</holder>
+    </copyright>
+    &dhdate;
+  </refentryinfo>
+  <refmeta>
+    &dhucpackage;
+
+    &dhsection;
+  </refmeta>
+  <refnamediv>
+    <refname>&dhpackage;</refname>
+
+    <refpurpose>lossless mp3 normalizer</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>&dhpackage;</command>
+
+      <arg><option>options</option></arg>
+
+      <arg><replaceable>infile</replaceable></arg>
+      
+      <arg><option><replaceable>infile 2</replaceable> ...</option></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para>This manual page documents briefly the
+      <command>&dhpackage;</command>
+      command.</para>
+
+    <para>This manual page was written for the &debian; distribution
+      because the original program does not have a manual page.
+     </para>
+
+    <para><command>&dhpackage;</command> can analyze and adjust mp3 files
+    so that they have the same volume.</para>
+    
+    <para><command>&dhpackage;</command> does not just do peak normalization,
+    as many normalizers do. Instead, it does some statistical analysis to
+    determine how loud the file actually sounds to the human ear. Also, the
+    changes <command>&dhpackage;</command> makes are completely lossless. There
+    is no quality lost in the change because the program adjusts the mp3 file
+    directly, without decoding and re-encoding.</para>
+
+    <para><command>&dhpackage;</command> optionally writes gain adjustments
+    directly into the encoded data. In this case, the adjustment works
+    with all mp3 players, i.e. no support for a special tag is required.
+    This mode is activated by any of the options <option>-r</option>,
+    <option>-a</option>, <option>-g</option>, or <option>-l</option>.</para>
+
+    <para>If none of the above options are given, the recommended gain change
+    is instead written to a special tag in the mp3 file. In this case, the
+    adjustment only works with mp3 players that support this tag.
+    Some mp3 players refer to this as ReplayGain.
+    The tag is written either in APEv2 format (default) or in ID3v2 format
+    (with <option>-s&nbsp;i</option>).
+    If you only want to print the recommended gain change (and not modify
+    the file at all) you may use the <option>-s s</option> (skip tag)
+    option. </para>
+
+    <para>The method mp3gain uses to determine the desired volume
+    is described at
+    <ulink url="http://www.replaygain.org/">www.replaygain.org</ulink>.
+    See also <filename>/usr/share/doc/mp3gain/README.method</filename> .
+    </para>
+    
+  
+
+
+  </refsect1>
+  <refsect1>
+    <title>OPTIONS</title>
+
+
+    <variablelist>
+      <varlistentry>
+        <term><option>-?</option>
+          <option>-h</option>
+        </term>
+        <listitem>
+          <para>Show summary of options.</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-g <replaceable>i</replaceable></option>
+        </term>
+        <listitem>
+          <para>apply gain <replaceable>i</replaceable> to mp3 without
+	   doing any analysis</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-l 0 <replaceable>i</replaceable></option>
+        </term>
+        <listitem>
+          <para>apply gain <replaceable>i</replaceable> to channel 0 
+	  	(left channel) of mp3
+                  without doing any analysis (ONLY works for STEREO mp3s,
+                  not Joint Stereo mp3s)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-l 1 <replaceable>i</replaceable></option>
+        </term>
+        <listitem>
+          <para>apply gain <replaceable>i</replaceable> to channel 1
+	  	(right channel) of mp3
+                  without doing any analysis (ONLY works for STEREO mp3s,
+                  not Joint Stereo mp3s)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-r</option>
+        </term>
+        <listitem>
+          <para>apply Track gain automatically (all files set to equal loudness)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-k</option>
+        </term>
+        <listitem>
+          <para>automatically lower Track gain to not clip audio</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-a</option>
+        </term>
+        <listitem>
+          <para>apply Album gain automatically (files are all from the same
+                      album: a single gain change is applied to all files, so
+                      their loudness relative to each other remains unchanged,
+                      but the average album loudness is normalized)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-m <replaceable>i</replaceable></option>
+        </term>
+        <listitem>
+          <para>modify suggested MP3 gain by integer <replaceable>i</replaceable></para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-d <replaceable>n</replaceable></option>
+        </term>
+        <listitem>
+          <para>modify suggested dB gain by floating-point
+	  <replaceable>n</replaceable></para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-c</option>
+        </term>
+        <listitem>
+          <para>ignore clipping warning when applying gain</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-o</option>
+        </term>
+        <listitem>
+          <para>output is a database-friendly tab-delimited list</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-t</option>
+        </term>
+        <listitem>
+          <para>mp3gain writes modified mp3 to temp file, then deletes original
+             instead of modifying bytes in original file (This is the default in
+	     Debian)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-T</option>
+        </term>
+        <listitem>
+          <para>mp3gain modifies bytes in original file instead of
+	   writing to temp file.</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-q</option>
+        </term>
+        <listitem>
+          <para>Quiet mode: no status messages</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-p</option>
+        </term>
+        <listitem>
+          <para>Preserve original file timestamp</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-x</option>
+        </term>
+        <listitem>
+          <para>Only find max. amplitude of mp3</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-f</option>
+        </term>
+        <listitem>
+          <para>Force <command>mp3gain</command> to assume input file
+	  is an MPEG 2 Layer III file
+             (i.e. don't check for mis-named Layer I or Layer II files)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-s c</option>
+        </term>
+        <listitem>
+          <para>only check stored tag info (no other processing)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-s d</option>
+        </term>
+        <listitem>
+          <para>delete stored tag info (no other processing)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-s i</option>
+        </term>
+        <listitem>
+          <para>use ID3v2 tag for gain information;
+          if the file contained gain data in APEv2 format, it is upgraded
+          to ID3v2</para>
+        </listitem>
+      </varlistentry>
+      
+       <varlistentry>
+        <term><option>-s a</option>
+        </term>
+        <listitem>
+          <para>use APEv2 tag for gain information (default)</para>
+        </listitem>
+      </varlistentry>
+      
+       <varlistentry>
+        <term><option>-s s</option>
+        </term>
+        <listitem>
+          <para>skip (ignore) stored tag info (do not read or write tags)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-s r</option>
+        </term>
+        <listitem>
+          <para>force re-calculation (do not read tag info)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-u</option>
+        </term>
+        <listitem>
+          <para>undo changes made by mp3gain (based on stored tag info)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-w</option>
+        </term>
+        <listitem>
+          <para>"wrap" gain change if gain+change &gt; 255 or gain+change &lt; 0
+              (see below or use <option>-? wrap</option> switch for a complete
+	      explanation)</para>
+        </listitem>
+      </varlistentry>
+      
+      <varlistentry>
+        <term><option>-v</option>
+        </term>
+        <listitem>
+          <para>Show version of program.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+    <para>If you specify <option>-r</option> and <option>-a</option>,
+    only the second one will work.</para>
+    <para>If you do not specify <option>-c</option>, the program will
+    stop and ask before
+     applying gain change to a file that might clip</para>
+   <refsect2><title>The WRAP option</title>
+   <para>Here's the problem:
+     The "global gain" field that mp3gain adjusts is an 8-bit unsigned integer, so
+     the possible values are 0 to 255.
+   </para><para>
+     MOST mp3 files (in fact, ALL the mp3 files I've examined so far) don't go
+     over 230. So there's plenty of headroom on top-- you can increase the gain
+     by 37dB (multiplying the amplitude by 76) without a problem.
+   </para><para>
+     The problem is at the bottom of the range. Some encoders create frames with
+     0 as the global gain for silent frames.
+     What happens when you _lower_ the global gain by 1?
+     Well, in the past, mp3gain always simply wrapped the result up to 255.
+     That way, if you lowered the gain by any amount and then raised it by the
+     same amount, the mp3 would always be _exactly_ the same.
+   </para><para>
+     There are a few encoders out there, unfortunately, that create 0-gain frames
+     with other audio data in the frame.
+     As long as the global gain is 0, you'll never hear the data.
+     But if you lower the gain on such a file, the global gain is suddenly _huge_.
+     If you play this modified file, there might be a brief, very loud blip.
+   </para><para>
+     So now the default behavior of mp3gain is to _not_ wrap gain changes.
+     In other words,
+     <orderedlist>
+     <listitem><para>
+        If the gain change would make a frame's global gain drop below 0,
+	then the global gain is set to 0.
+     </para></listitem><listitem><para>
+        If the gain change would make a frame's global gain grow above 255,
+	then the global gain is set to 255.
+     </para></listitem><listitem><para> 
+        If a frame's global gain field is already 0, it is not changed, even if
+	the gain change is a positive number.
+     </para></listitem>
+     </orderedlist>
+   </para><para>
+     To use the original "wrapping" behavior, use the <option>-w</option> switch.
+   </para>
+   </refsect2>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para>The homepage of mp3gain is located at
+     <ulink url="http://mp3gain.sourceforge.net/">http://mp3gain.sourceforge.net/</ulink> .
+    </para>
+  </refsect1> 
+  <refsect1>
+    <title>AUTHOR</title>
+
+    <para>This manual page was written by &dhusername; &dhemail; for
+      the &debian; system (but may be used by others).  Permission is
+      granted to copy, distribute and/or modify this document under
+      the terms of the &gnu; Lesser General Public License, Version 2.1 or 
+      any later version published by the Free Software Foundation.
+    </para>
+	<para>
+	  On Debian systems, the complete text of the GNU Lesser General Public
+	  License can be found in /usr/share/common-licenses/LGPL.
+	</para>
+
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
+
+
--- mp3gain-1.5.1.orig/debian/rules
+++ mp3gain-1.5.1/debian/rules
@@ -0,0 +1,74 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+include /usr/share/dpatch/dpatch.make
+
+
+CFLAGS = -Wall -g
+export CFLAGS
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O3
+endif
+
+
+
+build: build-stamp
+
+build-stamp: patch
+	dh_testdir
+
+	$(MAKE)
+	docbook-to-man  debian/mp3gain.sgml > debian/mp3gain.1
+
+	touch build-stamp
+
+clean: clean-patched unpatch
+
+clean-patched:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	$(MAKE) clean
+	rm -f debian/mp3gain.1
+
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_prep
+	dh_installdirs
+
+	$(MAKE) install DESTDIR=$(CURDIR)/debian/mp3gain
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs 
+	dh_installdocs debian/README.method
+	dh_installman debian/mp3gain.1
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- mp3gain-1.5.1.orig/debian/compat
+++ mp3gain-1.5.1/debian/compat
@@ -0,0 +1 @@
+7
--- mp3gain-1.5.1.orig/debian/copyright
+++ mp3gain-1.5.1/debian/copyright
@@ -0,0 +1,44 @@
+This package was debianized by Stefan Fritsch <sfritsch@ph.tum.de> on
+Wed,  4 Feb 2004 21:33:28 +0100.
+
+Current maintainer email address is sf@sfritsch.de.
+
+It was downloaded from http://mp3gain.sourceforge.net/download.php
+
+Upstream Author: "Glen Sawyer" <mp3gain@hotmail.com>
+
+Copyright: 2001-2004 Glen Sawyer
+           2002 John Zitterkopf
+           2001 David Robinson
+           2000 Mark Taylor
+           2000 Don Melton
+           1999 Takehiro TOMINAGA
+           1999, 2000 Albert L. Faber
+           1995,1996,1997 by Michael Hipp
+	   Stefan Partheymüller
+	   Artur Polaczynski
+	   Frank Klemm
+	   Mark Armbrust
+	 
+Concept and filter values by David Robinson	
+		
+
+
+    This package is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This package is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this package; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+    USA.
+
+On Debian systems, the complete text of the GNU Lesser General
+Public License can be found in `/usr/share/common-licenses/LGPL'.
+
--- mp3gain-1.5.1.orig/debian/changelog
+++ mp3gain-1.5.1/debian/changelog
@@ -0,0 +1,122 @@
+mp3gain (1.5.1-4) unstable; urgency=low
+
+  * Fix various potential segfaults found by cppcheck.
+  * Backport a format string error fix from 1.5.2.
+  * Bump standards version (no changes).
+
+ -- Stefan Fritsch <sf@debian.org>  Sat, 28 Aug 2010 20:20:19 +0200
+
+mp3gain (1.5.1-3) unstable; urgency=low
+
+  * Remove trailing spaces when converting ID3v1 tags to ID3v2.4. Thanks to
+    Alexander Zangerl for the patch. Closes: #564308
+  * Bump standards version (no changes).
+
+ -- Stefan Fritsch <sf@debian.org>  Sun, 10 Jan 2010 08:28:37 +0100
+
+mp3gain (1.5.1-2) unstable; urgency=low
+
+  * Add new options in 1.5.x and some clarifications to the man page. Thanks
+    to Joris van Rantwijk for the patch. Closes: #540622
+  * Also mention the possiblity to use ID3v2 tags in the package description.
+
+ -- Stefan Fritsch <sf@debian.org>  Sun, 09 Aug 2009 11:51:47 +0200
+
+mp3gain (1.5.1-1) unstable; urgency=low
+
+  * New upstream version.
+  * Bump standards version (no changes).
+
+ -- Stefan Fritsch <sf@debian.org>  Fri, 24 Jul 2009 13:17:40 +0200
+
+mp3gain (1.4.6-8) unstable; urgency=medium
+
+  * Rebuild with non-buggy gcc. This fixes mp3gain giving wrong results on
+    i386 (closes: #519949).
+  * Fix lintian warnings: 
+    - Bump standards version:
+      + Add homepage to debian/control.
+      + Add README.source.
+    - Use UTF8 for debian/copyright. 
+    - Switch to debhelper compatibility level 7.
+
+ -- Stefan Fritsch <sf@debian.org>  Mon, 23 Mar 2009 11:51:58 +0100
+
+mp3gain (1.4.6-7) unstable; urgency=low
+
+  * Fix another segfault with not-writable files (Closes: #444373)
+
+ -- Stefan Fritsch <sf@debian.org>  Sat, 29 Sep 2007 11:18:21 +0200
+
+mp3gain (1.4.6-6) unstable; urgency=low
+
+  * fix exit code on error in some more cases (hopefully all, closes: #433757)
+  * fix handling of DEB_BUILD_OPTIONS
+
+ -- Stefan Fritsch <sf@debian.org>  Sat, 28 Jul 2007 22:33:23 +0200
+
+mp3gain (1.4.6-5) unstable; urgency=low
+
+  * Change build system to dpatch.
+  * Assume 'n' on queries if we don't have stdin (Closes: #428301)
+  * Fix typo in man page (Closes: #428703)
+
+ -- Stefan Fritsch <sf@debian.org>  Sun, 17 Jun 2007 17:05:22 +0200
+
+mp3gain (1.4.6-4) unstable; urgency=low
+
+  * Modify description to mention replaygain (Closes: #411321)
+  * Change maintainer email address
+
+ -- Stefan Fritsch <sf@debian.org>  Thu, 15 Mar 2007 00:01:26 +0100
+
+mp3gain (1.4.6-3) unstable; urgency=low
+
+  * fix path to README.method in manpage (closes: #368679)
+  * bump standards version to 3.7.2 (no changes)
+
+ -- Stefan Fritsch <sf@sfritsch.de>  Sat,  9 Sep 2006 17:05:33 +0200
+
+mp3gain (1.4.6-2) unstable; urgency=low
+
+  * Fix segfault if unable to write files (thanks to Michael Thaler for
+    the report).
+  * Clarify man page (thanks to Jameson C. Burt).
+  * Add shiny new watch file using QA's sourceforge redirector.
+  * Bump up standards version (no changes needed).
+
+ -- Stefan Fritsch <sf@sfritsch.de>  Sat,  1 Oct 2005 00:04:01 +0200
+
+mp3gain (1.4.6-1) unstable; urgency=low
+
+  * New upstream release
+  * Closes: #284802: Segfaults on 48khz mp3 files
+  * Remove broken watch file
+
+ -- Stefan Fritsch <sf@sfritsch.de>  Wed, 12 Jan 2005 12:03:18 +0100
+
+mp3gain (1.4.5-1) unstable; urgency=low
+
+  * New upstream release
+  * Add note about method. Closes: #269759
+
+ -- Stefan Fritsch <sf@sfritsch.de>  Fri,  5 Nov 2004 19:37:22 +0100
+
+mp3gain (1.4.3-2) unstable; urgency=low
+
+  * Add watch file.
+  * Make -t the default since it is faster on ReiserFS.
+  * Closes: #264596: mp3gain does exit(1) upon success
+    (thanks to Roderick Schertler)
+  * Change maintainer email
+
+ -- Stefan Fritsch <sf@sfritsch.de>  Tue, 10 Aug 2004 11:24:43 +0200
+
+mp3gain (1.4.3-1) unstable; urgency=low
+
+  * Fixed copyright information.
+  * Initial Upload sponsored by Joachim Breitner; Closes: #241748: ITP
+
+ -- Stefan Fritsch <sfritsch@ph.tum.de>  Thu, 15 Apr 2004 23:12:05 +0200
+
+
--- mp3gain-1.5.1.orig/debian/control
+++ mp3gain-1.5.1/debian/control
@@ -0,0 +1,23 @@
+Source: mp3gain
+Section: sound
+Priority: optional
+Maintainer: Stefan Fritsch <sf@debian.org>
+Build-Depends: debhelper (>= 7.0.0), docbook-to-man, dpatch
+Homepage: http://mp3gain.sourceforge.net/
+Standards-Version: 3.9.1
+
+Package: mp3gain
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Lossless mp3 normalizer with statistical analysis
+ MP3Gain analyzes and adjusts mp3 files so that they have the same volume.
+ MP3Gain does not just do peak normalization, as many normalizers do. Instead,
+ it does some statistical analysis (using the replaygain algorithm) to
+ determine how loud the file actually sounds to the human ear.
+ .
+ MP3Gain can adjust the volume in a completely lossless way by modifying the
+ mp3 file directly, without decoding and re-encoding. This works with all mp3
+ players, i.e. no support for a special tag is required.
+ .
+ MP3Gain can also add replaygain compatible (APE) or ID3v2 gain tags to
+ mp3 files.
--- mp3gain-1.5.1.orig/debian/dirs
+++ mp3gain-1.5.1/debian/dirs
@@ -0,0 +1,3 @@
+usr/bin
+usr/share/man/man1
+
--- mp3gain-1.5.1.orig/debian/README.Debian
+++ mp3gain-1.5.1/debian/README.Debian
@@ -0,0 +1,4 @@
+On ReiserFS (as of kernel 2.4.26 and 2.6.7), writing to a temp file
+(-t option) seems to be a lot faster than modifying the original
+file directly. Therefore, -t is now the default in Debian. The
+original behaviour can be restored with -T.
--- mp3gain-1.5.1.orig/debian/watch
+++ mp3gain-1.5.1/debian/watch
@@ -0,0 +1,2 @@
+version=3
+opts="uversionmangle=s/_/./g" http://sf.net/mp3gain/mp3gain-([0-9].*)-src.zip
--- mp3gain-1.5.1.orig/debian/README.source
+++ mp3gain-1.5.1/debian/README.source
@@ -0,0 +1,2 @@
+This package uses dpatch. See /usr/share/doc/dpatch/README.source.gz for more
+info.
--- mp3gain-1.5.1.orig/debian/README.method
+++ mp3gain-1.5.1/debian/README.method
@@ -0,0 +1,23 @@
+Q: What dB value does mp3gain normalize to? How does this compare with
+normalize-audio?
+
+A: mp3gain and normalize-audio use different methods to determine the 
+perceived volume of a file, so the numbers are not comparable. As I  understand
+it, normalize-audio applies a smoothing filter and then  sets the maximum to
+-12dBFS. mp3gain sorts the volume and then uses  the value at 95% (i.e. 5% of
+the file are louder, 95% are quieter).  This value is set to -20dBFS. I have
+tried a few files and found the  difference in the recomended values to vary
+between 3dB and 6dB.
+
+The method mp3gain uses to determine the perceived volume is described at
+http://www.replaygain.org/.
+
+
+
+
+Q: Why are the files not exactly at the same volume?
+
+A: Since mp3gain changes the global gain value in every mp3 frame, it can only
+use 1.5dB steps for adjusting the volume. It will however write replaygain
+values to tags with finer accuracy than these 1.5dB steps. 
+
--- mp3gain-1.5.1.orig/debian/patches/07_fix_CFLAGS.dpatch
+++ mp3gain-1.5.1/debian/patches/07_fix_CFLAGS.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 07_fix_CFLAGS.dpatch by Stefan Fritsch <sf@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Allow using CFLAGS from debian/rules to fix DEB_BUILD_OPTIONS
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/Makefile mp3gain-1.4.6/Makefile
+--- mp3gain-1.4.6~/Makefile	2007-07-28 22:08:24.000000000 +0200
++++ mp3gain-1.4.6/Makefile	2007-07-28 22:11:27.000000000 +0200
+@@ -6,7 +6,7 @@
+ 
+ CC=     gcc
+ 
+-CFLAGS= -Wall -O3 -DHAVE_MEMCPY
++CFLAGS+= -Wall -DHAVE_MEMCPY
+ 
+ ifneq ($(OSTYPE),beos)
+ INSTALL_PATH= /usr/local/bin
--- mp3gain-1.5.1.orig/debian/patches/05_fix_segfault_when_files_not_writable.dpatch
+++ mp3gain-1.5.1/debian/patches/05_fix_segfault_when_files_not_writable.dpatch
@@ -0,0 +1,80 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 05_fix_segfault_when_files_not_writable.dpatch by Stefan Fritsch <sf@sfritsch.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: don't segfault when files are not writable
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/mp3gain.c mp3gain-1.4.6/mp3gain.c
+--- mp3gain-1.4.6~/mp3gain.c	2007-09-29 11:11:15.792120650 +0200
++++ mp3gain-1.4.6/mp3gain.c	2007-09-29 11:12:27.580211620 +0200
+@@ -705,6 +705,7 @@
+ 			inf = NULL;
+             passError(MP3GAIN_UNSPECIFED_ERROR, 3,
+                 "\nCan't open ", outfilename, " for temp writing\n");
++			NowWriting = 0;
+ 			return M3G_ERR_CANT_MAKE_TMP;
+ 		} 
+  
+@@ -715,10 +716,13 @@
+   }
+ 
+   if (inf == NULL) {
+-	  if (UsingTemp && (outf != NULL))
++	  if (UsingTemp && (outf != NULL)) {
+ 		  fclose(outf);
++		  outf = NULL;
++	  }
+ 	  passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+           "\nCan't open ", filename, " for modifying\n");
++	  NowWriting = 0;
+ 	  return M3G_ERR_CANT_MODIFY_FILE;
+   }
+   else {
+@@ -921,6 +925,7 @@
+ 		fclose(inf);
+ 		if (UsingTemp) {
+ 			fclose(outf);
++			outf = NULL;
+ 			deleteFile(outfilename);
+ 			free(outfilename);
+ 			passError(MP3GAIN_CANCELLED,2,"Cancelled processing of ",filename);
+@@ -930,6 +935,7 @@
+ 		}
+ 		if (saveTime) 
+ 		  fileTime(filename, setStoredTime);		
++		NowWriting = 0;
+ 		return;
+ 	}
+ #endif
+@@ -994,12 +1000,14 @@
+ 		fclose(outf);
+ 		fclose(inf);
+ 		inf = NULL;
++		outf = NULL;
+         
+         if (outlength != inlength) {
+             deleteFile(outfilename);
+ 			passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+                 "Not enough temp space on disk to modify ", filename, 
+                 "\nEither free some space, or switch off \"temp file\" option with -T\n");
++            NowWriting = 0;
+             return M3G_ERR_NOT_ENOUGH_TMP_SPACE;
+         }
+         else {
+@@ -1008,6 +1016,7 @@
+ 				deleteFile(outfilename); //try to delete tmp file
+ 				passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+                     "Can't open ", filename, " for modifying\n");
++			    NowWriting = 0;
+ 			    return M3G_ERR_CANT_MODIFY_FILE;
+ 		    }
+ 		    if (moveFile(outfilename, filename)) {
+@@ -1016,6 +1025,7 @@
+                     "\nThe mp3 was correctly modified, but you will need to re-name ", 
+                     outfilename, " to ", filename, 
+                     " yourself.\n");
++		            NowWriting = 0;
+ 			    return M3G_ERR_RENAME_TMP;
+ 		    };
+ 		    if (saveTime)
--- mp3gain-1.5.1.orig/debian/patches/03_use_tempfile_by_default.dpatch
+++ mp3gain-1.5.1/debian/patches/03_use_tempfile_by_default.dpatch
@@ -0,0 +1,70 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 03_use_tempfile_by_default.dpatch by Stefan Fritsch <sf@sfritsch.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Using a tempfile is a lot faster than direct writes on ReiserFS
+## DP: and has no disadvantages besides diskspace usage.
+## DP: => We make it the default and let -T restore the old behaviour.
+
+@DPATCH@
+diff -urNad mp3gain-1.5.1~/mp3gain.c mp3gain-1.5.1/mp3gain.c
+--- mp3gain-1.5.1~/mp3gain.c	2009-07-24 15:28:57.950388245 +0200
++++ mp3gain-1.5.1/mp3gain.c	2009-07-24 15:30:31.702394680 +0200
+@@ -45,6 +45,9 @@
+  *  So have fun dissecting.
+  */
+ 
++/* stf: make 	-t the default
++		-T restores old behaviour */
++
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <math.h>
+@@ -129,7 +132,7 @@
+ 
+ int writeself = 0;
+ int QuietMode = 0;
+-int UsingTemp = 0;
++int UsingTemp = 1;
+ int NowWriting = 0;
+ double lastfreq = -1.0;
+ 
+@@ -1045,7 +1048,7 @@
+             deleteFile(outfilename);
+ 			passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+                 "Not enough temp space on disk to modify ", filename, 
+-                "\nEither free some space, or do not use \"temp file\" option\n");
++                "\nEither free some space, or switch off \"temp file\" option with -T\n");
+             return M3G_ERR_NOT_ENOUGH_TMP_SPACE;
+         }
+         else {
+@@ -1326,10 +1329,11 @@
+ 		fprintf(stderr,"\t%cd <n> - modify suggested dB gain by floating-point n\n",SWITCH_CHAR);
+ 		fprintf(stderr,"\t%cc - ignore clipping warning when applying gain\n",SWITCH_CHAR);
+ 		fprintf(stderr,"\t%co - output is a database-friendly tab-delimited list\n",SWITCH_CHAR);
+-		fprintf(stderr,"\t%ct - writes modified data to temp file, then deletes original\n",SWITCH_CHAR);
+-		fprintf(stderr,"\t     instead of modifying bytes in original file\n");
++		fprintf(stderr,"\t%ct - mp3gain writes modified mp3 to temp file, then deletes original \n",SWITCH_CHAR);
++		fprintf(stderr,"\t     instead of modifying bytes in original file (default)\n");
++		fprintf(stderr,"\t%cT - mp3gain directly modifies mp3 file (opposite of %ct)\n",SWITCH_CHAR,SWITCH_CHAR);
+ #ifdef AACGAIN
+-		fprintf(stderr,"\t     A temp file is always used for AAC files.\n");
++		fprintf(stderr,"\t     Ignored for AAC files.\n");
+ #endif
+ 		fprintf(stderr,"\t%cq - Quiet mode: no status messages\n",SWITCH_CHAR);
+ 		fprintf(stderr,"\t%cp - Preserve original file timestamp\n",SWITCH_CHAR);
+@@ -1673,10 +1677,13 @@
+                     break;
+ 
+ 				case 't':
+-				case 'T':
+ 					UsingTemp = !0;
+ 					break;
+ 
++				case 'T':
++					UsingTemp = 0;
++					break;
++
+ 				case 'u':
+ 				case 'U':
+ 					undoChanges = !0;
--- mp3gain-1.5.1.orig/debian/patches/06_fix_overwrite_query_loop.dpatch
+++ mp3gain-1.5.1/debian/patches/06_fix_overwrite_query_loop.dpatch
@@ -0,0 +1,29 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 06_fix_overwrite_query_loop.dpatch by Stefan Fritsch <sf@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: assume "n" if we don't have stdin (#428301)
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/mp3gain.c mp3gain-1.4.6/mp3gain.c
+--- mp3gain-1.4.6~/mp3gain.c	2004-12-23 15:47:04.000000000 +0100
++++ mp3gain-1.4.6/mp3gain.c	2007-06-17 17:02:34.000000000 +0200
+@@ -1115,7 +1115,7 @@
+ static 
+ int queryUserForClipping(char * argv_mainloop,int intGainChange)
+ {
+-	char ch;
++	int ch;
+ 
+ 	fprintf(stderr,"\nWARNING: %s may clip with mp3 gain change %d\n",argv_mainloop,intGainChange);
+ 	ch = 0;
+@@ -1125,6 +1125,9 @@
+ 		fprintf(stderr,"Make change? [y/n]:");
+ 		fflush(stderr);
+ 		ch = getchar();
++		if (ch == EOF) {
++			ch='N';
++		}
+ 		ch = toupper(ch);
+ 	}
+ 	if (ch == 'N')
--- mp3gain-1.5.1.orig/debian/patches/08_trailingspace.dpatch
+++ mp3gain-1.5.1/debian/patches/08_trailingspace.dpatch
@@ -0,0 +1,56 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 08_trailingspace.dpatch by  <az@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: when copying tags from v1, remove trailing spaces.
+
+@DPATCH@
+diff -urNad mp3gain-1.5.1~/id3tag.c mp3gain-1.5.1/id3tag.c
+--- mp3gain-1.5.1~/id3tag.c	2009-06-29 14:01:34.000000000 +0200
++++ mp3gain-1.5.1/id3tag.c	2010-01-10 08:21:41.272091362 +0100
+@@ -823,7 +823,7 @@
+ static int id3_parse_v1_tag(FILE *f, struct ID3v2TagStruct *tag)
+ {
+ 	unsigned char buf[128];
+-	char sbuf[32];
++	char sbuf[32],*p;
+ 
+ 	struct ID3v2FrameStruct **pframe;
+ 
+@@ -850,6 +850,8 @@
+ 	if (buf[3] != '\0') {
+ 		memcpy(sbuf, buf + 3, 30);
+ 		sbuf[30] = '\0';
++		/* get rid of trailing spaces */
++		for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0');
+ 		*pframe = id3_make_frame("TIT2", "bs", 0, sbuf);
+ 		pframe = &((*pframe)->next);
+ 	}
+@@ -858,6 +860,9 @@
+ 	if (buf[33] != '\0') {
+ 		memcpy(sbuf, buf + 33, 30);
+ 		sbuf[30] = '\0';
++		/* get rid of trailing spaces */
++		for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0');
++		DBG(("fixed v1 artist: \"%s\"\n",sbuf));
+ 		*pframe = id3_make_frame("TPE1", "bs", 0, sbuf);
+ 		pframe = &((*pframe)->next);
+ 	}
+@@ -866,6 +871,8 @@
+ 	if (buf[63] != '\0') {
+ 		memcpy(sbuf, buf + 63, 30);
+ 		sbuf[30] = '\0';
++		/* get rid of trailing spaces */
++		for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0');
+ 		*pframe = id3_make_frame("TALB", "bs", 0, sbuf);
+ 		pframe = &((*pframe)->next);
+ 	}
+@@ -885,6 +892,8 @@
+ 	if (buf[97] != '\0') {
+ 		memcpy(sbuf, buf + 97, 30);
+ 		sbuf[30] = '\0';
++		/* get rid of trailing spaces */
++		for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0');
+ 		/* assume ISO-8859-1, unknown language, no description */
+ 		*pframe = id3_make_frame("COMM", "bssbs", 0, "XXX", "", 0, sbuf);
+ 		pframe = &((*pframe)->next);
--- mp3gain-1.5.1.orig/debian/patches/01_fix_installdir.dpatch
+++ mp3gain-1.5.1/debian/patches/01_fix_installdir.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 01_fix_installdir.dpatch by Stefan Fritsch <sf@sfritsch.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: use DESTDIR
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/Makefile mp3gain-1.4.6/Makefile
+--- mp3gain-1.4.6~/Makefile	2006-04-06 22:22:35.000000000 +0200
++++ mp3gain-1.4.6/Makefile	2006-04-06 22:36:29.000000000 +0200
+@@ -9,7 +9,7 @@
+ CFLAGS= -Wall -O3 -DHAVE_MEMCPY
+ 
+ ifneq ($(OSTYPE),beos)
+-INSTALL_PATH= /usr/local/bin
++INSTALL_PATH= $(DESTDIR)/usr/bin
+ else
+ INSTALL_PATH= $(HOME)/config/bin
+ endif
--- mp3gain-1.5.1.orig/debian/patches/10_fix_potential_segfaults.dpatch
+++ mp3gain-1.5.1/debian/patches/10_fix_potential_segfaults.dpatch
@@ -0,0 +1,53 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 10_fix_potential_segfaults.dpatch by Stefan Fritsch <sf@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix out of bounds / NULL ptr accesses found by cppcheck
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mp3gain-1.5.1~/mpglibDBL/interface.c mp3gain-1.5.1/mpglibDBL/interface.c
+--- mp3gain-1.5.1~/mpglibDBL/interface.c	2005-01-18 09:56:46.000000000 +0100
++++ mp3gain-1.5.1/mpglibDBL/interface.c	2010-04-21 00:24:02.505591419 +0200
+@@ -336,7 +336,8 @@
+ {
+   int i,pos;
+   struct buf *ibuf=mp->tail;
+-  unsigned char xing[48];
++  /* GetVbrTag may read more than 48 bytes */
++  unsigned char xing[156] = {0};
+   VBRTAGDATA pTagData;
+ 
+   pos = ibuf->pos;
+@@ -344,8 +345,8 @@
+   for (i=0; i<bytes; ++i) {
+     while(pos >= ibuf->size) {
+       ibuf  = ibuf->next;
+-      pos = ibuf->pos;
+       if(!ibuf) 	return -1; /* fatal error */
++      pos = ibuf->pos;
+     }
+     ++pos;
+   }
+@@ -353,8 +354,8 @@
+   for (i=0; i<48; ++i) {
+     while(pos >= ibuf->size) {
+       ibuf  = ibuf->next;
+-      pos = ibuf->pos;
+       if(!ibuf) 	return -1; /* fatal error */
++      pos = ibuf->pos;
+     }
+     xing[i] = ibuf->pnt[pos];
+     ++pos;
+@@ -396,11 +397,11 @@
+     b[0]=b[1]; b[1]=b[2]; b[2]=b[3];
+     while(pos >= buff->size) {
+       buff  = buff->next;
+-      pos = buff->pos;
+       if(!buff) {
+ 	return -1;
+ 	/* not enough data to read 4 bytes */
+       }
++      pos = buff->pos;
+     }
+     b[3] = buff->pnt[pos];
+     ++pos;
--- mp3gain-1.5.1.orig/debian/patches/11_format_string_error.dpatch
+++ mp3gain-1.5.1/debian/patches/11_format_string_error.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 11_format_string_error.dpatch by Stefan Fritsch <sf@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: backport from 1.5.2
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mp3gain-1.5.1~/rg_error.c mp3gain-1.5.1/rg_error.c
+--- mp3gain-1.5.1~/rg_error.c	2008-09-15 14:08:28.000000000 +0200
++++ mp3gain-1.5.1/rg_error.c	2010-08-28 20:18:07.812558320 +0200
+@@ -40,7 +40,7 @@
+ {
+ #ifndef asWIN32DLL
+     gSuccess = 0;
+-	fprintf(stdout, localerrstr);
++	fprintf(stdout, "%s", localerrstr);
+ #else
+ 	//send message to DLL's parent
+     mp3gainerr = localerrnum;
--- mp3gain-1.5.1.orig/debian/patches/00list
+++ mp3gain-1.5.1/debian/patches/00list
@@ -0,0 +1,10 @@
+01_fix_installdir.dpatch
+02_correct_errorcode_on_failure.dpatch
+03_use_tempfile_by_default.dpatch
+05_fix_segfault_when_files_not_writable.dpatch
+06_fix_overwrite_query_loop.dpatch
+07_fix_CFLAGS.dpatch
+08_trailingspace.dpatch
+09_fix_mem_leaks.dpatch
+10_fix_potential_segfaults.dpatch
+11_format_string_error.dpatch
--- mp3gain-1.5.1.orig/debian/patches/02_correct_errorcode_on_failure.dpatch
+++ mp3gain-1.5.1/debian/patches/02_correct_errorcode_on_failure.dpatch
@@ -0,0 +1,87 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 02_correct_errorcode_on_failure.dpatch by Stefan Fritsch <sf@sfritsch.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: don't return 0 on error
+
+@DPATCH@
+diff -urNad mp3gain-1.5.1~/mp3gain.c mp3gain-1.5.1/mp3gain.c
+--- mp3gain-1.5.1~/mp3gain.c	2009-07-24 13:57:12.000000000 +0200
++++ mp3gain-1.5.1/mp3gain.c	2009-07-24 15:23:32.065420323 +0200
+@@ -1985,6 +1985,7 @@
+ 					} else {
+ 						fprintf(stderr,"No undo information in %s\n",argv[mainloop]);
+ 					}
++					gSuccess = 0;
+ 				}
+ 		  }
+ 	  }
+@@ -2051,8 +2052,9 @@
+ #else
+ 		  if ((inf == NULL)&&(tagInfo[mainloop].recalc > 0)) {
+ #endif
+-			  fprintf(stdout, "Can't open %s for reading\n",argv[mainloop]);
+-              fflush(stdout);
++			  fprintf(stderr, "Can't open %s for reading\n",argv[mainloop]);
++			  fflush(stderr);
++			  gSuccess = 0;
+ 		  }
+ 		  else {
+ #ifdef AACGAIN
+@@ -2137,8 +2139,9 @@
+ 				if (!ok) {
+ #endif
+                     if (!BadLayer) {
+-						fprintf(stdout,"Can't find any valid MP3 frames in file %s\n",argv[mainloop]);
+-                        fflush(stdout);
++						fprintf(stderr,"Can't find any valid MP3 frames in file %s\n",argv[mainloop]);
++						fflush(stderr);
++						gSuccess = 0;
+                     }
+ 				}
+ 				else {
+@@ -2173,8 +2176,8 @@
+ 								(Xingcheck[0] == 'I' && Xingcheck[1] == 'n' && Xingcheck[2] == 'f' && Xingcheck[3] == 'o')) {
+ 							bitridx = (curframe[2] >> 4) & 0x0F;
+ 							if (bitridx == 0) {
+-								fprintf(stdout, "%s is free format (not currently supported)\n",curfilename);
+-								fflush(stdout);
++								fprintf(stderr, "%s is free format (not currently supported)\n",curfilename);
++								fflush(stderr);
+ 								ok = 0;
+ 							}
+ 							else {
+@@ -2217,8 +2220,8 @@
+ 						while (ok) {
+ 							bitridx = (curframe[2] >> 4) & 0x0F;
+ 							if (bitridx == 0) {
+-								fprintf(stdout,"%s is free format (not currently supported)\n",curfilename);
+-								fflush(stdout);
++								fprintf(stderr,"%s is free format (not currently supported)\n",curfilename);
++								fflush(stderr);
+ 								ok = 0;
+ 							}
+ 							else {
+@@ -2304,8 +2307,9 @@
+ 					}
+ 
+ 					if (dBchange == GAIN_NOT_ENOUGH_SAMPLES) {
+-						fprintf(stdout,"Not enough samples in %s to do analysis\n",argv[mainloop]);
+-                        fflush(stdout);
++						fprintf(stderr,"Not enough samples in %s to do analysis\n",argv[mainloop]);
++                        			fflush(stderr);
++						gSuccess = 0;
+ 						numFiles--;
+ 					}
+ 					else {
+@@ -2445,8 +2449,8 @@
+ 		}
+ 
+ 		if (dBchange == GAIN_NOT_ENOUGH_SAMPLES) {
+-			fprintf(stdout,"Not enough samples in mp3 files to do analysis\n");
+-            fflush(stdout);
++			fprintf(stderr,"Not enough samples in mp3 files to do analysis\n");
++			fflush(stderr);
+ 		}
+ 		else {
+ 			Float_t maxmaxsample;
--- mp3gain-1.5.1.orig/debian/patches/09_fix_mem_leaks.dpatch
+++ mp3gain-1.5.1/debian/patches/09_fix_mem_leaks.dpatch
@@ -0,0 +1,38 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 09_fix_mem_leaks.dpatch by Stefan Fritsch <sf@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: fix some issues found by cppcheck
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mp3gain-1.5.1~/id3tag.c mp3gain-1.5.1/id3tag.c
+--- mp3gain-1.5.1~/id3tag.c	2010-04-21 00:36:31.810590842 +0200
++++ mp3gain-1.5.1/id3tag.c	2010-04-21 00:36:31.858533970 +0200
+@@ -303,6 +303,8 @@
+ 				break;
+ 			default:
+ 				va_end(ap);
++				free(frame->data);
++				free(frame);
+ 				return NULL;
+ 		}
+ 	}
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mp3gain-1.5.1~/mp3gain.c mp3gain-1.5.1/mp3gain.c
+--- mp3gain-1.5.1~/mp3gain.c	2010-04-21 00:36:31.790535993 +0200
++++ mp3gain-1.5.1/mp3gain.c	2010-04-21 00:38:28.717567899 +0200
+@@ -765,6 +765,7 @@
+             passError(MP3GAIN_UNSPECIFED_ERROR, 3,
+                 "\nCan't open ", outfilename, " for temp writing\n");
+ 			NowWriting = 0;
++			free(outfilename);
+ 			return M3G_ERR_CANT_MAKE_TMP;
+ 		} 
+  
+@@ -782,6 +783,7 @@
+ 	  passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+           "\nCan't open ", filename, " for modifying\n");
+ 	  NowWriting = 0;
++	  free(outfilename);
+ 	  return M3G_ERR_CANT_MODIFY_FILE;
+   }
+   else {
