/* src must NOT be const as it can be a context for func that may need
* updating (like a pointer or byte counter) */
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size,
int (*func)(void *, void *, int))
{
int total = size;
uint32_t wndx= f->wndx;
uint8_t *wptr= f->wptr;
do {
int len = FFMIN(f->end - wptr, size);
if (func) {
len = func(src, wptr, len);
if (len <= 0)
break;
} else {
memcpy(wptr, src, len);
src = (uint8_t *)src + len;
}
// Write memory barrier needed for SMP here in theory
wptr += len;
if (wptr >= f->end)
wptr = f->buffer;
wndx += len;
size -= len;
} while (size > 0);
f->wndx= wndx;
f->wptr= wptr;
return total - size;
}
先看看快乐路径,就是把数据库复制到缓冲区。更新wptr指针。
memcpy(wptr, src, len);
有写爆的可能。
C:\project\bin>test_ffmpeg.exe turbojpeg.dll
adler32_code is:ef270018
space is :1024
write 556032 data to fifo
space is :-555008