[SCM] morituri/master: Add new command: rip debug maxsample

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:10:04 UTC 2014


The following commit has been merged in the master branch:
commit 32000bd0d0d4f2626cd5b742c1c7ea525a39fa83
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Fri May 10 22:06:38 2013 +0200

    Add new command: rip debug maxsample
    
    Calculates the maximum absolute sample value.
    Helpful to verify whether HTOA tracks are pure silence or not.

diff --git a/morituri/common/checksum.py b/morituri/common/checksum.py
index d424175..330af9d 100644
--- a/morituri/common/checksum.py
+++ b/morituri/common/checksum.py
@@ -387,3 +387,20 @@ class TRMTask(task.GstPipelineTask):
 
     def stopped(self):
         self.trm = self._trm
+
+class MaxSampleTask(ChecksumTask):
+    """
+    I check for the biggest sample value.
+    """
+
+    description = 'Finding highest sample value'
+
+    def do_checksum_buffer(self, buf, checksum):
+        values = struct.unpack("<%dh" % (len(buf) / 2), buf)
+        absvalues = [abs(v) for v in values]
+        m = max(absvalues)
+        if checksum < m:
+            checksum = m
+
+        return checksum
+
diff --git a/morituri/rip/debug.py b/morituri/rip/debug.py
index 96b14e6..9751aeb 100644
--- a/morituri/rip/debug.py
+++ b/morituri/rip/debug.py
@@ -159,6 +159,32 @@ class Encode(logcommand.LogCommand):
         self.stdout.write('Peak level: %r\n' % encodetask.peak)
         self.stdout.write('Encoded to %s\n' % toPath.encode('utf-8'))
 
+
+class MaxSample(logcommand.LogCommand):
+
+    summary = "run a max sample task"
+
+    def do(self, args):
+        if not args:
+            self.stdout.write('Please specify one or more input files.\n')
+            return 3
+
+        runner = task.SyncRunner()
+        # here to avoid import gst eating our options
+        from morituri.common import checksum
+
+        for arg in args:
+            fromPath = unicode(arg.decode('utf-8'))
+
+            checksumtask = checksum.MaxSampleTask(fromPath)
+
+            runner.run(checksumtask)
+
+            self.stdout.write('%s\n' % arg)
+            self.stdout.write('Biggest absolute sample: %04x\n' %
+                checksumtask.checksum)
+
+
 class Tag(logcommand.LogCommand):
 
     summary = "run a tag reading task"
@@ -223,4 +249,4 @@ class Debug(logcommand.LogCommand):
 
     summary = "debug internals"
 
-    subCommandClasses = [Checksum, Encode, Tag, MusicBrainzNGS, ResultCache]
+    subCommandClasses = [Checksum, Encode, MaxSample, Tag, MusicBrainzNGS, ResultCache]

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list