Mercurial > libavutil.hg
comparison fifo.c @ 224:a9880a7685e7 libavutil
remove near duplicate function
author | michael |
---|---|
date | Wed, 17 Jan 2007 19:46:33 +0000 |
parents | df2f250bda3f |
children | 0b93dab98397 |
comparison
equal
deleted
inserted
replaced
223:df2f250bda3f | 224:a9880a7685e7 |
---|---|
48 /** | 48 /** |
49 * Get data from the fifo (returns -1 if not enough data). | 49 * Get data from the fifo (returns -1 if not enough data). |
50 */ | 50 */ |
51 int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size) | 51 int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size) |
52 { | 52 { |
53 int size = av_fifo_size(f); | 53 return av_fifo_generic_read(f, buf_size, NULL, buf); |
54 | |
55 if (size < buf_size) | |
56 return -1; | |
57 while (buf_size > 0) { | |
58 int len = FFMIN(f->end - f->rptr, buf_size); | |
59 memcpy(buf, f->rptr, len); | |
60 buf += len; | |
61 f->rptr += len; | |
62 if (f->rptr >= f->end) | |
63 f->rptr = f->buffer; | |
64 buf_size -= len; | |
65 } | |
66 return 0; | |
67 } | 54 } |
68 | 55 |
69 /** | 56 /** |
70 * Resizes a FIFO. | 57 * Resizes a FIFO. |
71 */ | 58 */ |
109 | 96 |
110 if (size < buf_size) | 97 if (size < buf_size) |
111 return -1; | 98 return -1; |
112 while (buf_size > 0) { | 99 while (buf_size > 0) { |
113 int len = FFMIN(f->end - f->rptr, buf_size); | 100 int len = FFMIN(f->end - f->rptr, buf_size); |
114 func(dest, f->rptr, len); | 101 if(func) func(dest, f->rptr, len); |
102 else{ | |
103 memcpy(dest, f->rptr, len); | |
104 dest = (uint8_t*)dest + len; | |
105 } | |
115 f->rptr += len; | 106 f->rptr += len; |
116 if (f->rptr >= f->end) | 107 if (f->rptr >= f->end) |
117 f->rptr = f->buffer; | 108 f->rptr = f->buffer; |
118 buf_size -= len; | 109 buf_size -= len; |
119 } | 110 } |