Rockbox Technical Forums

Support and General Use => Audio Playback, Database and Playlists => Topic started by: gaillard on October 02, 2006, 12:52:11 AM

Title: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 12:52:11 AM
Hi guys,

quick question.  I have a very minimal wps, just status bar, progress bar and 3 tags, and all options off except crossfeed (which is all i want) and i am using wavpack.

everysong i get a pause, skip or stall in the music for abour 1 or 2 seconds.

ps. i also have, forgot whos it is, custom firmware that stops cpu scaling.

any ideas?????

i thought wavpack was one of the better decoders
Title: Re: wavpack, very minimal wps
Post by: Davide-NYC on October 02, 2006, 01:19:34 AM
Please use a recent build of Rockbox. CVS build is best.
Also: What target do you own? Ipod? Iriver?

Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 01:32:28 AM
Also, are they lossless or lossy wavpack?
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 09:12:16 AM
this was a recent build as of yesterday, only thing modified was that cpu scaling was turned off.  It did it with the scaling on though too, and the most recent build from cvs.  I have a color ipod.

oh and they are lossless.
hmm
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 11:09:22 AM
Now you say "a pause skip or stall." Do you mean a single gap at some point, or do you mean that every few seconds playback has a small stall, or what? Please, describe clearly what is happening, because depending on which of those is happening, and perhaps even how often it's skipping, there could still be a few different causes.
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 12:09:04 PM
well the audio cuts out completely and then resumes about 2 seconds later as if it couldn't keep up with decoding, although thats not the case right?
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 12:28:00 PM
ok looking at the audio thread screen while a wavpack song is playing the pcm bar stays at 16000 or so and just goes up and down up and down.  but the codec just steadily drops.  when it hits zero the pcm instantly goes to zero and then back up to where it was and the codec goes back to where it started and counts down again.  everytime the codec hits 0 i get the cutout like i am talking about.


hope this helps.
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 01:30:36 PM
Try settings your anti-skip buffer to a little bit higher than it defaults to (just 10 seconds more should be enough). In your case, this is actually the proper solution.

It has to do with a bug for calculating how large the anti-skip should be based upon seconds.
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 02:30:05 PM
i put it on 1 min and it still does it.  it made it through the first song of a cd and on the second it is doing often now, every 8 seconds or so the codec line plumets and then i get the pause and it bumps back up.
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 02:31:38 PM
Do you have disk power off enabled or disabled? Also, how large does it say your compressed buffer is? It should never go from full to empty in 8 seconds time, since uncompressed audio can fit more than that in the buffer.
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 02:37:46 PM
i don't see the option for disk power off but im sure its on its default.  The compressed buffer (i assume the one your talking about being under audio thread and then codec) is never full, it only gets about 1/8 or 1/10 full.  out if 200,000,000 it starts at like 2,000,000 and then counts down.  Now if i go to this audio thread menu when it is paused it fills up right away (well if i touch the scroll wheel), and then last that long if i start it playing again.
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 02:55:10 PM
That is very strange. Is this with an entirely unmodified build, or is this with the patched build? Can you verify this behaviour in an official build downloaded from Rockbox.org?
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 02:58:13 PM
yes this is a stock build dated 10-2 all default options except the like simple 3 line wps i loaded and turned on crossfeed. oh and changing the skip buffer.

this was happening with builds of previous dates as well.
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 03:22:21 PM
Can you try other file formats and see if the compressed buffer fills all the way, or still only to 2mb?
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 03:35:37 PM
no problem give me a few

ok just tried a flac file and it filled almost all the way up, about 25 of 29 megs.  the pcm did go all the way up where as before it wasn't even close

so i guess its a wavpack specific problem...

also with flac it will go down to like 15 megs and then recharge back to like 25.

wavpack it just keeeeeps going down and thats from like 2 megs.

just noticed too with flac boost is on 20 percent whereas its always constant 100 with wavpack.
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 04:06:11 PM
There's definitely something going wrong then. Wavpack should fill the buffer just like any codec. And because it's not filling it, it doesn't refill 'till it's empty, completely negating the anti-skip buffer setting.

I suggest you file a proper bug report describing how the Compressed buffer doesn't refill properly with wavpack.
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 02, 2006, 04:14:20 PM
how? i don't see in the bug tracker anywhere to add one, do you have a link to filespray?
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 02, 2006, 04:15:33 PM
In the bug tracker, there is an add new task button in the top left.
Title: Re: wavpack, very minimal wps
Post by: bryant on October 03, 2006, 02:25:59 AM
I think maybe I can clear this up, at least somewhat.

WavPack files, unlike FLAC files, can vary considerably in their decoding complexity. Only the fastest mode (-f) is close to the decoding complexity of FLAC. The higher modes use progressively more CPU cycles, and the lossy mode requires some additional also. Because the decoding of the "high" mode required such a high boost ratio on my Nano, I recently created a new "high" mode that achieves almost the same compression with lower decoding complexity, and I renamed the previous high mode "very high" and specifically recommend it not be used for portable use. This is discussed here (and there's an alpha version available):

http://www.hydrogenaudio.org/forums/index.php?showtopic=47389

I just measured the boost ratio required to play WavPack lossless on my Nano:

  12%: fast mode
  24%: default mode
  44%: new high mode
  66%: very high mode (old high mode)

I also measured that adding crossfeed adds about another 10%, getting your "high" files to about 76%. However, that should still work okay (and I just tested it here and it works fine even using the peakmeter).

There are two other things I can think of. First of all, I assume your files are 16/44.1, right? If they had to be resampled from 48 Khz or were 24-bit that would take a lot more CPU.

Another more general issue is whether there is any difference between the Nano and the Color as to their CPU usage? Could the Color be using more cycles for display update?

Anyway, I suspect that the decoding complexity of your files combined with the crossfeed and perhaps some difference in the version for the Color is causing the required boost to go over 100%, which produces exactly the symptom you are seeing.

David
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 03, 2006, 02:32:17 AM
Well the thing is he described the compressed buffer never filling. Usually when the decoder can't keep up, the compressed buffer fills just fine, but the PCM buffer frequently empties because the audio can't be decoded fast enough to keep that one from underrunning. His description says that the compressed buffer is underrunning (and then the PCM one does, but that's just because there's no data to feed it.) That shouldn't be a symptom of too much CPU usage, right?
Title: Re: wavpack, very minimal wps
Post by: bryant on October 03, 2006, 08:51:18 AM
I haven't actually followed this in the code, but based on watching the audio thread status I'm pretty sure that there is a mechanism to prevent attempts to fill the compressed buffer when the PCM buffer is below a certain level (about half) unless the compressed buffer is almost empty. So, one of the symptoms of not having enough CPU that I've seen is that the compressed buffer never fills.

My assumption was that filling the compressed buffer also uses a lot of CPU (which is why it boosts then also) and you wouldn't want to risk running out of PCM data during an extended fill operation.

BTW, I have recently created a test suite for WavPack which includes lossless clips at each of the 4 speed modes. Unfortunately, they're only 30 seconds each which is a little short for measuring boost, but I've had good luck putting one file in a folder by itself and having it repeat (the code continues to reload even though the whole file would fit in the buffer). The suite is here:

http://www.rarewares.org/wavpack/test_suite.zip

Title: Re: wavpack, very minimal wps
Post by: gaillard on October 03, 2006, 09:44:53 AM
Thanks for helping bryant.

with cross feed off it seems to stay at around 90 percent, which is still not right correct?  I mean he is showing 66...  this is a very minimal wps, is there anything else that can be taking processor power?

Title: Re: wavpack, very minimal wps
Post by: lowlight on October 03, 2006, 11:12:35 AM
I wonder if this could be an issue with the new scheduler not giving enough priority to buffering.

Can you try an older build? Download one from here on or before 2006-09-16:
http://www.rockbox.org/dl.cgi?bin=ipodcolor
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 03, 2006, 04:07:39 PM
the 9-16 one locks up when ever i play a file, and doesn't start to play.

im going to try and one before the date one sec

k the 9-11 works but has the same problems, flac does play at a lower boost though. but wavpack with crossfeed off even stays at 100 percent boost and doesn't fill up the buffer initially or ever.

i don't understand shouldn't it still fill up the buffer, because when it does go back up after hitting zero it does it quickly...
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 03, 2006, 04:19:59 PM
wavpack without the -h option by the way runs at 75 boost just fine... but who doesn't use -h?!
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 03, 2006, 04:23:06 PM
You can't make a processor faster just by expressing your displeasure.
Title: Re: wavpack, very minimal wps
Post by: lowlight on October 03, 2006, 05:09:04 PM
The issue is that buffering requires the cpu & decoding requires the cpu. They should yield for each other, but if the decoding is too intensive, the buffering may never complete which appears to be the case here. You might be out of luck with these files.
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 03, 2006, 09:02:04 PM
ok well thanks anyways guys, Hopefully things will be better later on... perhaps i'll find sometime after another year of school or so and help with some code..

Goodluck!!
Title: Re: wavpack, very minimal wps
Post by: bryant on October 04, 2006, 02:03:10 AM
wavpack without the -h option by the way runs at 75 boost just fine... but who doesn't use -h?!
Many people who move to WavPack from FLAC use -fx because that gives about the same decoding speed and compression ratio as FLAC (at least according to the comparison on the FLAC site).

People who move from Monkey's Audio probably use -h (or even -hx) to get close to APE in compression. I think the two inside modes (the default and the new high mode) are the best compromises.  :)

What remains a question is why the 4th gen Color would use so much more CPU than the Nano for decoding WavPack. I don't have any other model besides the Nano to find out, but I know the Color has a different version of the PortalPlayer chip, so maybe it has a less efficient cache or something like that. The other possibility is the graphics (or something else) is taking more CPU cycles on the Color. It would be interesting to see of other codecs are affected by this.

Perhaps someday we'll be able to split the codec and the other audio processing into separate threads (and cores). That will solve it...  ;D

Title: Re: wavpack, very minimal wps
Post by: lowlight on October 04, 2006, 02:34:21 PM
I would guess that hard disk vs flash disk and 220x176 vs 176x132 lcds would be the main differences affecting performance.

If it really is the competition between codec and ata cpu usage that is preventing buffering from happening, then I wonder if the new scheduler could be tuned to allow buffering to occur uninterrupted. Obviously playback would stop, but you may get real-time playback thereafter until the buffer needs to be refilled.
Title: Re: wavpack, very minimal wps
Post by: Llorean on October 04, 2006, 02:45:25 PM
It seems to me that disk access should have a very high priority. I wonder if it's the same thing that is causing samples to be lost with recording recently.
Title: Re: wavpack, very minimal wps
Post by: gaillard on October 24, 2006, 01:52:02 AM
Any chance any work is being done on the scheduler?  If the buffer is full, thats a good, what, 5 or more minutes of uninterupted audio?  It fills so fast after that runs out that it is so hard to beleive that the playback and buffer couldn't alternate task to get it done...

Title: Re: wavpack, very minimal wps
Post by: Febs on December 11, 2006, 10:45:37 AM
David Bryant has just announced the release of WavPack 4.40. (http://www.hydrogenaudio.org/forums/index.php?showtopic=50911)

Among the changes:

Quote
new hardware-friendly "high" mode compresses almost as well as old "high" mode but decodes significantly faster (works better on Rockboxed iPods)

Anyone having trouble with WavPack in Rockbox may wish to try the newer version.