]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Implement av_fifo_realloc2().
authorstefano <stefano@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Tue, 19 Aug 2008 18:43:34 +0000 (18:43 +0000)
committerstefano <stefano@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Tue, 19 Aug 2008 18:43:34 +0000 (18:43 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14846 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavutil/avutil.h
libavutil/fifo.c
libavutil/fifo.h

index 3203ca2875c57bf1471c4638b1d98b269e4aa98d..cefc710de87de49bf715103723e5e9775172d59e 100644 (file)
@@ -35,7 +35,7 @@
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
 #define LIBAVUTIL_VERSION_MAJOR 49
-#define LIBAVUTIL_VERSION_MINOR  9
+#define LIBAVUTIL_VERSION_MINOR 10
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
index eda3558436a738a09bfd6b1eeb541b61b3fc8511..19715ebce46ef007337d1e8eb6abba44d40297e1 100644 (file)
@@ -55,18 +55,24 @@ int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size)
  * Resizes a FIFO.
  */
 void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
+    av_fifo_realloc2(f, new_size);
+}
+
+int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) {
     unsigned int old_size= f->end - f->buffer;
 
     if(old_size <= new_size){
         int len= av_fifo_size(f);
         AVFifoBuffer f2;
 
-        av_fifo_init(&f2, new_size);
+        if (av_fifo_init(&f2, new_size) < 0)
+            return -1;
         av_fifo_read(f, f2.buffer, len);
         f2.wptr += len;
         av_free(f->buffer);
         *f= f2;
     }
+    return 0;
 }
 
 void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
index 6533be921de5e30c4bf5f8207b7981040991b6ce..2384f7021f7f69a6d102353c50fb68127b9f2e9b 100644 (file)
@@ -97,9 +97,18 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void
  * Resizes an AVFifoBuffer.
  * @param *f AVFifoBuffer to resize
  * @param size new AVFifoBuffer size in bytes
+ * @see av_fifo_realloc2()
  */
 void av_fifo_realloc(AVFifoBuffer *f, unsigned int size);
 
+/**
+ * Resizes an AVFifoBuffer.
+ * @param *f AVFifoBuffer to resize
+ * @param size new AVFifoBuffer size in bytes
+ * @return <0 for failure >=0 otherwise
+ */
+int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
+
 /**
  * Reads and discards the specified amount of data from an AVFifoBuffer.
  * @param *f AVFifoBuffer to read from