Hello,

Background:

The idea behind this patch is to keep LAME from putting LAME name and
versions into each frame of the mp3.  I know that it is nice to have LAME
information in frames for debugging and testing, but sometimes there is a
want to have _clean_ (so to speak) mp3s.  I have consulted with other
collegues that use LAME and one of the repetitive comments about LAME is
'do you like that they put their name and version in each frame of the
mp3'?  Truthfully, I don't.  Besides, soon, I will be building a complete
(as near as) studio archive of mp3s out of about 250 CD and I do not want
software name and versions in my mp3s.  This patch is handy for me, maybe
it will be handy for others.

Implementation:

The default functionality of LAME _has_ _not_ _changed_.  Functionality is
only changed when the new flag '--no-grafiti-frames' is added.  When this
flag is added, the LAME name and version _are_ _not_ added into the
ancillary data in each frame.  Insead, only 0xff's are used.  There is
absolutely no difference in size of file, or sound or any other functional
part of the mp3.

Now, I dug this up in the ChangeLog.

----
  2000-11-01 17:56  markt
    * libmp3lame/: bitstream.c, bitstream.h, util.h:

      restored bitstream.c to original.
      drain_into_ancillary_data was written the way it is
      on purpose.  dont change it without checking with me first
----

I am modifying that function, but I _have_ _not_ changed the functionality
of drain_into_ancillary_data, but only changed from adding 'LAME version'
into the frame to only adding 0xff's.  This simply makes it nicer for
people who want to have an un-tainted (so to speak) archive.  It just
makes it more flexible for those people who want _clean_ frames.  Nothing
more, nothing less.

So, now, I'm officially asking to change drain_into_ancillary_data.  Feel
free to apply the patch and note that I have (hopefully) not missed
anything.

Thank you,
Jeremy

Credit for the patch goes to Josh Samuelson <[EMAIL PROTECTED]> who
found and modified drain_into_ancillary_data initially to only fill with
0xff's.  Credit for adding the option, command line flag, struct change,
and the rest go to Jeremy Brand <[EMAIL PROTECTED]>.  I'm only mentioning
this in hopes that the patch gets included in CVS and that credit goes
where credit is due.

--
     /   Jeremy Brand, B.S.      \     Sr. Software Engineer          /
    /   phone://39-34-853-23988   \   mailto:[EMAIL PROTECTED]      /
   /   http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html    /
  /  "LINUX is obsolete"  -- Andy Tanenbaum, January 29th, 1992    /
 /  Get your own Free, Private email at http://www.smackdown.com/ /
Index: frontend/parse.c
===================================================================
RCS file: /cvsroot/lame/lame/frontend/parse.c,v
retrieving revision 1.101
diff -u -U6 -r1.101 parse.c
--- frontend/parse.c    2001/09/07 23:45:39     1.101
+++ frontend/parse.c    2001/09/26 18:20:37
@@ -477,12 +477,13 @@
               "    -c              mark as copyright\n"
               "    -o              mark as non-original\n"
               "    -p              error protection.  adds 16 bit checksum to every 
frame\n"
               "                    (the checksum is computed correctly)\n"
               "    --nores         disable the bit reservoir\n"
               "    --strictly-enforce-ISO   comply as much as possible to ISO MPEG 
spec\n"
+              "    --no-grafiti-frames      do not let LAME grafiti frames\n"
               "\n"
               "  Filter options:\n"
               "    -k              keep ALL frequencies (disables all filters),\n"
               "                    Can cause ringing and twinkling\n"
               "  --lowpass <freq>        frequency(kHz), lowpass filter cutoff above 
freq\n"
               "  --lowpass-width <freq>  frequency(kHz) - default 15%% of lowpass 
freq\n"
@@ -1136,12 +1137,15 @@
                 T_ELIF ("nores")
                     lame_set_disable_reservoir(gfp,1);
                     lame_set_padding_type(gfp,0);
                 
                 T_ELIF ("strictly-enforce-ISO")
                     lame_set_strict_ISO(gfp,1);
+
+                T_ELIF ("no-grafiti-frames")
+                    lame_set_no_grafiti_frames(gfp,1);
                 
                 T_ELIF ("athonly")
                     (void) lame_set_ATHonly( gfp, 1 );
                 
                 T_ELIF ("athlower")
                     argUsed=1;
Index: include/lame.h
===================================================================
RCS file: /cvsroot/lame/lame/include/lame.h,v
retrieving revision 1.89
diff -u -U6 -r1.89 lame.h
--- include/lame.h      2001/09/17 21:17:53     1.89
+++ include/lame.h      2001/09/26 18:20:37
@@ -232,12 +232,16 @@
 int CDECL lame_set_extension(lame_global_flags *, int);
 int CDECL lame_get_extension(const lame_global_flags *);
 
 // enforce strict ISO complience.  default=0
 int CDECL lame_set_strict_ISO(lame_global_flags *, int);
 int CDECL lame_get_strict_ISO(const lame_global_flags *);
+
+// do not let LAME grafiti frames.
+int CDECL lame_set_no_grafiti_frames(lame_global_flags *, int);
+int CDECL lame_get_no_grafiti_frames(const lame_global_flags *);
  
 
 /********************************************************************
  * quantization/noise shaping 
  ***********************************************************************/
 
Index: libmp3lame/bitstream.c
===================================================================
RCS file: /cvsroot/lame/lame/libmp3lame/bitstream.c,v
retrieving revision 1.40
diff -u -U6 -r1.40 bitstream.c
--- libmp3lame/bitstream.c      2001/06/18 18:51:52     1.40
+++ libmp3lame/bitstream.c      2001/09/26 18:20:37
@@ -151,48 +151,58 @@
 */
 
 inline static void
 drain_into_ancillary(lame_global_flags *gfp,int remainingBits)
 {
     lame_internal_flags *gfc=gfp->internal_flags;
-    int i;
     assert(remainingBits >= 0);
 
-    if (remainingBits >= 8) {
-      putbits2(gfp,0x4c,8);
-      remainingBits -= 8;
-    }
-    if (remainingBits >= 8) {
-      putbits2(gfp,0x41,8);
-      remainingBits -= 8;
-    }
-    if (remainingBits >= 8) {
-      putbits2(gfp,0x4d,8);
-      remainingBits -= 8;
-    }
-    if (remainingBits >= 8) {
-      putbits2(gfp,0x45,8);
-      remainingBits -= 8;
-    }
-      
-    if (remainingBits >= 32) {
-      const char *version = get_lame_short_version ();
-      if (remainingBits >= 32) 
-       for (i=0; i<(int)strlen(version) && remainingBits >=8 ; ++i) {
-         remainingBits -= 8;
-         putbits2(gfp,version[i],8);
-       }
+    if (lame_get_no_grafiti_frames(gfp)) {
+
+        for (; remainingBits >= 8; remainingBits -= 8 ) {
+            putbits2 ( gfp, 0xff, 8 ); 
+        }
+
+    } else {
+
+        int i;
+
+        if (remainingBits >= 8) {
+          putbits2(gfp,0x4c,8);
+          remainingBits -= 8;
+        }
+        if (remainingBits >= 8) {
+          putbits2(gfp,0x41,8);
+          remainingBits -= 8;
+        }
+        if (remainingBits >= 8) {
+          putbits2(gfp,0x4d,8);
+          remainingBits -= 8;
+        }
+        if (remainingBits >= 8) {
+          putbits2(gfp,0x45,8);
+          remainingBits -= 8;
+        }
+          
+        if (remainingBits >= 32) {
+          const char *version = get_lame_short_version ();
+          if (remainingBits >= 32) 
+             for (i=0; i<(int)strlen(version) && remainingBits >=8 ; ++i) {
+                 remainingBits -= 8;
+                 putbits2(gfp,version[i],8);
+             }
+        }
+
     }
 
     for (; remainingBits >= 1; remainingBits -= 1 ) {
         putbits2 ( gfp, gfc->ancillary_flag, 1 );
         gfc->ancillary_flag ^= 1;
     }
 
     assert (remainingBits == 0);
-
 }
 
 /*write N bits into the header */
 inline static void
 writeheader(lame_internal_flags *gfc,int val, int j)
 {
Index: libmp3lame/lame_global_flags.h
===================================================================
RCS file: /cvsroot/lame/lame/libmp3lame/lame_global_flags.h,v
retrieving revision 1.5
diff -u -U6 -r1.5 lame_global_flags.h
--- libmp3lame/lame_global_flags.h      2001/09/17 20:05:16     1.5
+++ libmp3lame/lame_global_flags.h      2001/09/26 18:20:37
@@ -67,12 +67,16 @@
                                      PAD_ALL = always pad,
                                      PAD_ADJUST = adjust padding,
                                      default=2                              */
   int extension;                  /* the MP3 'private extension' bit.
                                      Meaningless                            */
   int strict_ISO;                 /* enforce ISO spec as much as possible   */
+  int no_grafiti_frames;          /* do no let LAME grafiti each frame 
+                                     with it's name and version string. 
+                                     default 0.                             */ 
+  
 
   /* quantization/noise shaping */
   int disable_reservoir;          /* use bit reservoir?                     */
   int experimentalX;            
   int experimentalY;
   int experimentalZ;
Index: libmp3lame/set_get.c
===================================================================
RCS file: /cvsroot/lame/lame/libmp3lame/set_get.c,v
retrieving revision 1.18
diff -u -U6 -r1.18 set_get.c
--- libmp3lame/set_get.c        2001/09/17 20:05:16     1.18
+++ libmp3lame/set_get.c        2001/09/26 18:20:37
@@ -602,12 +602,38 @@
     assert( 0 <= gfp->extension && 1 >= gfp->extension );
 
     return gfp->extension;
 }
 
 
+/* Do not let LAME grafiti frames. */
+int
+lame_set_no_grafiti_frames( lame_global_flags*  gfp,
+                     int                 grafiti_frames)
+{
+    /* default = 0 (disabled) */
+
+    /* enforce disable/enable meaning, if we need more than two values
+       we need to switch to an enum to have an apropriate representation
+       of the possible meanings of the value */
+    if ( 0 > grafiti_frames || 1 < grafiti_frames)
+        return -1;
+
+    gfp->no_grafiti_frames = grafiti_frames;
+
+    return 0;
+}
+
+int
+lame_get_no_grafiti_frames( const lame_global_flags*  gfp )
+{
+    assert( 0 <= gfp->no_grafiti_frames && 1 >= gfp->no_frafiti_frames);
+
+    return gfp->no_grafiti_frames;
+}
+
 /* Enforce strict ISO compliance. */
 int
 lame_set_strict_ISO( lame_global_flags*  gfp,
                      int                 strict_ISO )
 {
     /* default = 0 (disabled) */

Reply via email to