summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c140
1 files changed, 0 insertions, 140 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 77bc84aa10..425db9a28a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -263,146 +263,6 @@ int av_dup_packet(AVPacket *pkt)
return 0;
}
-/* fifo handling */
-
-int fifo_init(FifoBuffer *f, int size)
-{
- f->buffer = av_malloc(size);
- if (!f->buffer)
- return -1;
- f->end = f->buffer + size;
- f->wptr = f->rptr = f->buffer;
- return 0;
-}
-
-void fifo_free(FifoBuffer *f)
-{
- av_free(f->buffer);
-}
-
-int fifo_size(FifoBuffer *f, uint8_t *rptr)
-{
- int size;
-
- if(!rptr)
- rptr= f->rptr;
-
- if (f->wptr >= rptr) {
- size = f->wptr - rptr;
- } else {
- size = (f->end - rptr) + (f->wptr - f->buffer);
- }
- return size;
-}
-
-/**
- * Get data from the fifo (returns -1 if not enough data).
- */
-int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr)
-{
- uint8_t *rptr;
- int size, len;
-
- if(!rptr_ptr)
- rptr_ptr= &f->rptr;
- rptr = *rptr_ptr;
-
- if (f->wptr >= rptr) {
- size = f->wptr - rptr;
- } else {
- size = (f->end - rptr) + (f->wptr - f->buffer);
- }
-
- if (size < buf_size)
- return -1;
- while (buf_size > 0) {
- len = f->end - rptr;
- if (len > buf_size)
- len = buf_size;
- memcpy(buf, rptr, len);
- buf += len;
- rptr += len;
- if (rptr >= f->end)
- rptr = f->buffer;
- buf_size -= len;
- }
- *rptr_ptr = rptr;
- return 0;
-}
-
-/**
- * Resizes a FIFO.
- */
-void fifo_realloc(FifoBuffer *f, unsigned int new_size){
- unsigned int old_size= f->end - f->buffer;
-
- if(old_size < new_size){
- uint8_t *old= f->buffer;
-
- f->buffer= av_realloc(f->buffer, new_size);
-
- f->rptr += f->buffer - old;
- f->wptr += f->buffer - old;
-
- 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;
- }
-}
-
-void fifo_write(FifoBuffer *f, const uint8_t *buf, int size, uint8_t **wptr_ptr)
-{
- int len;
- uint8_t *wptr;
-
- if(!wptr_ptr)
- wptr_ptr= &f->wptr;
- wptr = *wptr_ptr;
-
- while (size > 0) {
- len = f->end - wptr;
- if (len > size)
- len = size;
- memcpy(wptr, buf, len);
- wptr += len;
- if (wptr >= f->end)
- wptr = f->buffer;
- buf += len;
- size -= len;
- }
- *wptr_ptr = wptr;
-}
-
-/* get data from the fifo (return -1 if not enough data) */
-int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr)
-{
- uint8_t *rptr = *rptr_ptr;
- int size, len;
-
- if (f->wptr >= rptr) {
- size = f->wptr - rptr;
- } else {
- size = (f->end - rptr) + (f->wptr - f->buffer);
- }
-
- if (size < buf_size)
- return -1;
- while (buf_size > 0) {
- len = f->end - rptr;
- if (len > buf_size)
- len = buf_size;
- put_buffer(pb, rptr, len);
- rptr += len;
- if (rptr >= f->end)
- rptr = f->buffer;
- buf_size -= len;
- }
- *rptr_ptr = rptr;
- return 0;
-}
-
/**
* Allocate the payload of a packet and intialized its fields to default values.
*