comparison fifo.c @ 223:df2f250bda3f libavutil

simplify
author michael
date Wed, 17 Jan 2007 19:30:23 +0000
parents a8a9454b0874
children a9880a7685e7
comparison
equal deleted inserted replaced
222:a8a9454b0874 223:df2f250bda3f
88 } 88 }
89 } 89 }
90 90
91 void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size) 91 void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
92 { 92 {
93 int len;
94
95 while (size > 0) { 93 while (size > 0) {
96 len = FFMIN(f->end - f->wptr, size); 94 int len = FFMIN(f->end - f->wptr, size);
97 memcpy(f->wptr, buf, len); 95 memcpy(f->wptr, buf, len);
98 f->wptr += len; 96 f->wptr += len;
99 if (f->wptr >= f->end) 97 if (f->wptr >= f->end)
100 f->wptr = f->buffer; 98 f->wptr = f->buffer;
101 buf += len; 99 buf += len;
105 103
106 104
107 /* get data from the fifo (return -1 if not enough data) */ 105 /* get data from the fifo (return -1 if not enough data) */
108 int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest) 106 int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest)
109 { 107 {
110 int len; 108 int size = av_fifo_size(f);
111 int size = f->wptr - f->rptr;
112 if (size < 0)
113 size += f->end - f->buffer;
114 109
115 if (size < buf_size) 110 if (size < buf_size)
116 return -1; 111 return -1;
117 while (buf_size > 0) { 112 while (buf_size > 0) {
118 len = FFMIN(f->end - f->rptr, buf_size); 113 int len = FFMIN(f->end - f->rptr, buf_size);
119 func(dest, f->rptr, len); 114 func(dest, f->rptr, len);
120 f->rptr += len; 115 f->rptr += len;
121 if (f->rptr >= f->end) 116 if (f->rptr >= f->end)
122 f->rptr = f->buffer; 117 f->rptr = f->buffer;
123 buf_size -= len; 118 buf_size -= len;