[FFmpeg-devel] [PATCH] adpcm: Collapse nodes with similar state only after checking ssd

Martin Storsjö martin
Wed Nov 17 09:25:40 CET 2010


On Wed, 17 Nov 2010, Michael Niedermayer wrote:

> On Mon, Nov 15, 2010 at 03:47:20PM +0200, Martin Storsj? wrote:
> > 
> > +                    /* Collapse any two states with the same previous sample value. \
> > +                     * One could also distinguish states by step and by 2nd to last \
> > +                     * sample, but the effects of that are negligible. \
> > +                     * Since nodes in the previous generation are iterated \
> > +                     * through a heap, they're roughly ordered from better to \
> > +                     * worse, but not strictly ordered. Therefore, an earlier \
> > +                     * node with the same sample value is better in most cases \
> > +                     * (and thus the current is skipped), but not strictly \
> > +                     * in all cases. */ \
> > +                    for (k = 0; k < heap_size; k++)\
> > +                        if (dec_sample == nodes_next[k]->sample1)\
> > +                            goto next_##NAME;\
> 
> should this not check ssd too, so that better ones are kept?

I tested this, and in practice, it actually gave worse results. I guess 
this means it's better to keep a node with a slightly worse ssd than to 
store two nodes with a similar sample value (giving less space for other 
nodes that would give better diversity). A better solution would be to 
replace that particular node instead - I'll test that, too.

> also a hashtable could be used to speed this up in theory
> like:
> h=&hash[dec_sample];
> if(h->generation == generation && h->ssd < ssd){
>     goto next_##NAME;
> }
> h->generation= generation;
> h->ssd= ssd

Hmm, yes, that might be a good idea. I'll see if it works as well in 
practice.

// Martin



More information about the ffmpeg-devel mailing list