[mythtv] MythMusic playlists still not intelligent enough IMHO

f-myth-users at media.mit.edu f-myth-users at media.mit.edu
Thu Apr 19 18:47:43 UTC 2007


    > Date: Thu, 19 Apr 2007 10:49:16 -0700
    > From: Poul Petersen <petersp at alleft.com>

    >   Given a generic value of n, the most painful part of this calculation is
    > probably #2, since you must factor n. It's unlikely that many people have 
    > a song list with so many songs as to make this calculation infeasable, on
    > modern hardware. Rather, it's just that no one may want to code up a 
    > factoring algorithm just for this application.

Just steal the code from GNU factor, or call it externally.  (No doubt
there are zillions of even simpler implementations hanging out on the
net that don't use bignums; I haven't looked.  At least GNU factor is
guaranteed GPL'ed.)

And yes, for any hardware you can run Myth on, factoring any number
less than 2^32 is free.  For example, for 2^32 - 67:

  $ time factor 4294967229
  4294967229: 3 3 7 977 69779

  real    0m0.006s
  user    0m0.000s
  sys     0m0.001s

I daresay nobody is going to have ~2^32 songs anyway on a single Myth
anyway, even if that many separate chunks of audio exist on Earth.

(It only took 2.3 seconds to factor 2^64 - 67.  Of course, there's a
fair amount of variability there; 2^64 - 927834 took only 26ms.  And
yes, the manpage points out that there's a 64-bit worst-case which
takes me 55s, but I doubt there are ~2^64 songs within our observable
universe. :)

It's not as if we're talking crypto-sized primes where serious time
and probabalistic algorithms come into play...


More information about the mythtv-dev mailing list