[FFmpeg-devel] [PATCH] adpcm: Reset the ssd back to zero more often

Martin Storsjö martin
Sun Nov 21 07:43:27 CET 2010


On Sat, 20 Nov 2010, Jason Garrett-Glaser wrote:

> On Sat, Nov 20, 2010 at 3:11 PM, Martin Storsj? <martin at martin.st> wrote:
> > On Sat, 20 Nov 2010, Michael Niedermayer wrote:
> >
> >> have you tried to change ssd to 64bit ?
> >> maybe its faster
> >
> > In 64 bit mode, changing ssd to 64 bit is a bit faster (current code 61
> > sec, adding the wraparound check 64 sec, 64 bit ssd 62 sec), but in 32 bit
> > mode, it's quite a bit slower (current code 69.6 sec, with wraparound
> > check 69.8 sec, 64 bit ssd 79.6 sec), so I wouldn't suggest that solution.
> 
> Have you tried limiting the amount of 64-bit math that needs to be
> done?  Usually with 64-bit counters in trellises, you can get away
> with doing 64-bit in relatively few parts of the process.

There's not much math done on these that could be done in 32 bit mode 
while keeping the counters themselves 64 bit. These are the only 
operations done on the ssd variables currently:

typedef struct TrellisNode {
    uint32_t ssd;
    int path;
    int sample1;
    int sample2;
    int step;
} TrellisNode;

    uint32_t ssd;
    ssd = nodes[j]->ssd + d*d;
    if (ssd > nodes_next[pos]->ssd)
        goto next_##NAME;
    u->ssd = ssd;

    // Sifting up in the heap
    if (nodes_next[parent]->ssd <= ssd)
        break;

    if(nodes[0]->ssd > (1<<28)) {
        for(j=1; j<frontier && nodes[j]; j++)
            nodes[j]->ssd -= nodes[0]->ssd;
        nodes[0]->ssd = 0;
    }

So if the ssd variable declarations are switched to uin64_t, I don't see 
how any of the rest of this code could be kept doing 32 bit arithmetic 
only.

// Martin



More information about the ffmpeg-devel mailing list