Closed Bug 961044 Opened 10 years ago Closed 10 years ago

vorbis static codebook length tables take up too much space

Categories

(Core :: Audio/Video, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29
blocking-b2g 1.3T+
Tracking Status
b2g-v1.3T --- fixed

People

(Reporter: froydnj, Assigned: xiphmont)

References

(Blocks 1 open bug)

Details

(Whiteboard: [MemShrink:P2])

Attachments

(2 files)

The _vq_lengthlist__* arrays in lib/books/* are all defined as arrays of long, which means they take up not quite 2.5MB on an x86-64 build and half of that on a 32-bit build.

AFAICS, though, there's no need for them to be arrays of long; arrays of uint8_t/unsigned char would work just fine, as none of the entries are ever large (scanning through the code suggests entries are limited to values <= 32).  The lists also don't appear to be used in any sort of vectorized assembly code, suggesting they can be changed freely.

Reducing them to arrays of uint8_t/unsigned char would be a huge space win.

I'm not familiar enough with vorbis to know whether this is a duplicate of bug 937455; omitting them sounds different than shrinking them, but if we can do both, that'd be great!
Monty, can you take a look?
Flags: needinfo?(monty)
Nice find!
Thinking some more... vorbis isn't that common(?), so most of the time this won't affect physical memory consumption, but it will reduce virtual memory consumption, which is good for Win32.
Changing the base time to save footprint is indeed different from trimming the tables themselves. This is a lot easier though!
Blocks: 937455
:derf: Will look yes.

BTW, we should only have encoder tables for modes we actually use.  They're split into a few ranges of sampling rates (8, 16, 44+ IIRC) and channel sets (mono, stereo, surround).  If any of those can be eliminated as unused, that reclaims space too.
OK, looked it over and looked at the code history.  There is no practical reason the lengthlist needs to be long; uint8 is more than sufficient.  There will need to be only minor code work to make it so-- testing will be a bigger deal than the actual modifications.

The long lengthlists appear stem from a time when the lengthlists were just not very big.  When things moved from tesselated to lattice codebooks (and lengthlists became larger), they weren't changed to take less space.

I don't see any external considerations either; shall I make this change upstream?  One reason I'm offering is because there _must_ be something I'm missing, this just seems too obvious.
(In reply to Ralph Giles (:rillian) from comment #4)
> Changing the base time to save footprint is indeed different from trimming
> the tables themselves. This is a lot easier though!

We could do both, both look quite easy really.
Flags: needinfo?(monty)
(In reply to Monty Montgomery (:xiphmont) from comment #6)

> I don't see any external considerations either; shall I make this change
> upstream?

Yes, please.
Assignee: nobody → monty
Whiteboard: [MemShrink] → [MemShrink:P2]
I have landed the lengthlist long -> char conversion upstream.  I used 'char' and not another type to follow the preexisting convention elsewhere in the codebook code.

I'll cut a new libvorbis dot release from the current code today.
Attached patch Upstream fixSplinter Review
Attaching patch for monty's upstream fix. Rather than carry this, I'll prepare a patch moving us to the new 1.3.4 release.
Attachment #8363810 - Flags: review?(cpearce)
Attachment #8363810 - Flags: review?(cpearce) → review+
https://hg.mozilla.org/mozilla-central/rev/6aefaebc145d
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Nominating for 1.3T based on library footprint reduction (somewhere around a megabyte).
blocking-b2g: --- → 1.3T?
can you confirm is this memory saving in RAM or storage size? Thanks
Flags: needinfo?(nfroyd)
Joe, from what I understand this is mainly storage size.  I recommended Nathan nom these since I believe we are short on system partition space on the tarako.
I don't have anything to add to what Ben already said.
Flags: needinfo?(nfroyd)
blocking-b2g: 1.3T? → 1.3T+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: