mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
simplify av_fifo_realloc()
Originally committed as revision 7571 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
765d4f3b4a
commit
96e39edc59
@ -60,18 +60,14 @@ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
|
|||||||
unsigned int old_size= f->end - f->buffer;
|
unsigned int old_size= f->end - f->buffer;
|
||||||
|
|
||||||
if(old_size < new_size){
|
if(old_size < new_size){
|
||||||
uint8_t *old= f->buffer;
|
int len= av_fifo_size(f);
|
||||||
|
AVFifoBuffer f2;
|
||||||
|
|
||||||
f->buffer= av_realloc(f->buffer, new_size);
|
av_fifo_init(&f2, new_size);
|
||||||
|
av_fifo_read(f, f2.buffer, len);
|
||||||
f->rptr += f->buffer - old;
|
f2.wptr += len;
|
||||||
f->wptr += f->buffer - old;
|
av_free(f->buffer);
|
||||||
|
*f= f2;
|
||||||
if(f->wptr < f->rptr){
|
|
||||||
memmove(f->rptr + new_size - old_size, f->rptr, f->buffer + old_size - f->rptr);
|
|
||||||
f->rptr += new_size - old_size;
|
|
||||||
}
|
|
||||||
f->end= f->buffer + new_size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user