[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    [PATCH] audiocd - Ogg Vorbis settings
From:       Jason Lane <jglane () btopenworld ! com>
Date:       2002-08-31 7:31:48
[Download RAW message or body]

The attached patch to audiocd.cpp and audiocd.h addresses the following 
behaviour where the vorbis quality setting isn't reflected in the estimated 
file sizes. The estimates for quality/bitrate I obtained by averaging 
information at: http://www.xiph.org/archives/vorbis-faq/200203/0030.html

Fixes a bug, and works with my patch to kcmaudiocd -- for me anyway ;-). As I 
don't have CVS access, can someone review and apply a version, if it's 
useful.

Regards, 

Jason 

On Thursday 29 August 2002 12:06 am, Jason Lane wrote:
> One issue I have noticed while testing it, is that audiocd appears only to
> use the bitrate to estimate the file sizes -- changing the quality variable
> has no effect on the file list when viewing the Ogg files in Konqueror, and
> leads to odd results in the file copy progress window. However, the
> resulting Oggs are correct -- as verified by ogginfo. I could have a look
> at this, but it'll have to wait until tomorrow evening...

["audiocd.patch" (text/x-diff)]

Index: audiocd.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kioslave/audiocd/audiocd.cpp,v
retrieving revision 1.54
diff -u -3 -p -r1.54 audiocd.cpp
--- audiocd.cpp	27 Jul 2002 01:27:49 -0000	1.54
+++ audiocd.cpp	31 Aug 2002 06:45:29 -0000
@@ -860,7 +860,7 @@ AudioCDProtocol::get(const KURL & url)
 
 #ifdef HAVE_VORBIS
   if (filetype == "ogg") {
-    totalSize((time_secs * d->vorbis_bitrate)/8);
+    totalSize( vorbisSize(time_secs) );
     mimeType("audio/x-ogg-vorbis");
   }
 #endif
@@ -939,7 +939,7 @@ AudioCDProtocol::stat(const KURL & url)
 
 #ifdef HAVE_VORBIS
       if (filetype == "ogg")
-        atom.m_long = (length_seconds * d->vorbis_bitrate) / 8;
+        atom.m_long = vorbisSize(length_seconds);
 #endif
 
       if (filetype == "cda") atom.m_long = filesize;
@@ -1077,6 +1077,35 @@ app_file(UDSEntry& e, const QString & n,
   app_entry(e, KIO::UDS_SIZE, s);
 }
 
+#ifdef HAVE_VORBIS
+  long
+AudioCDProtocol::vorbisSize(long time_secs)
+{
+  long vorbis_size;
+    switch (d->vorbis_encode_method) {
+       case 0:
+  /* Support very old libvorbis by simply falling through.  */
+#if HAVE_VORBIS >= 2
+       /* quality setting - an estimate based on the Vorbis FAQ */
+       {
+         static long vorbis_q_bitrate[11] = { 60, 74, 86, 106, 120,
+                                              152, 183, 207, 239, 309, 440};
+         long quality = static_cast<long>(d->vorbis_quality);
+         if (quality < 0 || quality > 10) quality = 3;
+         vorbis_size = (time_secs * vorbis_q_bitrate[quality] * 1000)/8;
+         break;
+       }
+#endif
+       default:
+         // bitrate setting
+         vorbis_size = (time_secs * d->vorbis_bitrate/8);
+         break;
+  }
+  return vorbis_size;
+
+}
+#endif
+
   void
 AudioCDProtocol::listDir(const KURL & url)
 {
@@ -1183,7 +1212,7 @@ AudioCDProtocol::listDir(const KURL & ur
 #ifdef HAVE_VORBIS
             case Vorbis:
               name = d->titles[i - 1] + s3;
-              size = (length_seconds * d->vorbis_bitrate) / 8; // length * bitrate / 8; 
+              size = vorbisSize(length_seconds); 
               break;
 #endif
 
@@ -1619,7 +1648,7 @@ void AudioCDProtocol::getParameters() {
      int method = config->readNumEntry("encmethod",0);
     
      if (method == 0) { 
-       
+
        // Constant Bitrate Encoding
        (_lamelib_lame_set_VBR)(d->gf, vbr_off);
        (_lamelib_lame_set_brate)(d->gf,config->readNumEntry("cbrbitrate",160));
Index: audiocd.h
===================================================================
RCS file: /home/kde/kdemultimedia/kioslave/audiocd/audiocd.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 audiocd.h
--- audiocd.h	20 Aug 2001 20:11:30 -0000	1.8
+++ audiocd.h	31 Aug 2002 06:45:29 -0000
@@ -86,13 +86,16 @@ class AudioCDProtocol : public KIO::Slav
 
     class Private;
     Private * d;
-    
+
   private:
     cdrom_drive * pickDrive();
     unsigned int get_discid(cdrom_drive *);
 #ifdef HAVE_LAME
     KLibrary *_lamelib;
     bool      initLameLib();
+#endif
+#ifdef HAVE_VORBIS
+    long vorbisSize(long time_secs);
 #endif
 };
 

_______________________________________________
kde-multimedia mailing list
kde-multimedia@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-multimedia

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic