[FFmpeg-devel] [PATCH 3/6] avcodec/ffwavesynth: use uint32_t to compute difference, it is enough

Nicolas George george at nsup.org
Sat Jul 20 13:28:24 EEST 2019


Nicolas George (12019-07-19):
> Sorry, I thought I missed the spot and you already applied it.
> 
> This patch could be merged with this one:
> 
> avcodec/ffwavesynth: More correct cast in wavesynth_seek()
> 
> but it is not very important.
> 
> As for:
> 
> avcodec/ffwavesynth: Fix backward lcg_seek()
> avcodec/ffwavesynth: Simplify lcg_seek(), avoid negative case
> 
> If you checked they generate the same sequence, then ok and thanks. If
> not, then I can do the testing tomorrow.

I tested with the following testing code, and the new version behaves
perfectly.

I do not believe this requires including the test program as part of the
code base. It would have been if somebody had not had the bad idea of
removing the possibility of having just "#if TEST \n int main() {...}"
for quick tests.

Regards,

-- 
  Nicolas George


#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

#define N 10000000
static uint32_t val[N];

int
main(void)
{
    uint32_t state = 'P' | ('I' << 8) | ('N' << 16) | ('K' << 24);
    unsigned i, pos, target;
    int64_t off;

    for (i = 0; i < N; i++) {
        val[i] = state;
        state = lcg_next(&state);
    }
    printf("final state = %08x\n", (unsigned)state);
    pos = 0;
    state = val[pos];
    for (i = 0; i < 10000; i++) {
        target = val[pos] % N;
        off = (int64_t)target - (int64_t)pos;
        lcg_seek(&state, off);
        printf("seeking from %10d to %10d by %10"PRId64": %08x vs %08x\n",
            pos, target, off, (unsigned)state, (unsigned)val[target]);
        if (state != val[target])
            exit(1);
        pos = target;
    }
    return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190720/05c814f8/attachment.sig>


More information about the ffmpeg-devel mailing list