[FFmpeg-devel] [PATCH] NellyMoser audio decoder

Rich Felker dalias
Wed Sep 12 06:41:53 CEST 2007

On Wed, Sep 12, 2007 at 06:36:38AM +0400, Andrew Savchenko wrote:
> Hi,
> On Wednesday 12 September 2007 04:57, Michael Niedermayer wrote:
> [...]
> > but i suspect that even 2 mplayer/mencoder with different input
> > files would end up with quite a few identical pages which are
> > not simple tables or directly part of the object files
> > an example would be tables generated depening on user
> > parameters, coefficient tables for audio resampling which depend
> > on input and output frequencies similarely for video/imag
> > rescaling
> But just imagine that such kind of page will be changed at runtime, 
> e.g. due to current movie aspect ratio chang at runtime by first 
> instance of mplayer. There are 2 possibilities: 1) pages should be 
> marked somehow as absolutely unchangable by application (and this 
> will reduce memory saving greatly)

Not possible in any portable way -> not useful. Having applications
have to be aware of the underlying memory architecture is exactly what
locks you into particular memory architectures and prevents
revolutionary implementation-improvements like what Michael is

> or 2) kernel must perform check 
> for no changes (probably rehash) each reused page each time 
> accessing it, this may utilize CPU greatly. So statement about 
> efficiency of reusing memory pages seems to be rather questionable 
> for me.

No, apparently you've never heard of COW. It's the way paging has
worked on Unix and all sane systems for the past 10-15 years, maybe
longer... Very minimal cost. Google "copy on write", or, well, the
idea is very very simple. The kernel just marks the pages unwritable
and thus captures the first attempt to write them with a page fault,
at which part it forks them into separate copies.

All writable parts of process memory are implemented as COW, such as
initialized and uninitialized data. Uninitialized is just a single
'zero page' shared by all processes on the system. Initialized data
segment is shared with the cached copy of the page on disk. Also,
after fork(), even the heap is shared COW memory.


More information about the ffmpeg-devel mailing list