diff aviobuf.c @ 719:0ab9b7331748 libavformat

bypass internal buffer for "large" packets
author michael
date Thu, 24 Mar 2005 22:07:54 +0000
parents 253b5292946a
children cdb845a57ae4
line wrap: on
line diff
--- a/aviobuf.c	Thu Mar 24 21:27:54 2005 +0000
+++ b/aviobuf.c	Thu Mar 24 22:07:54 2005 +0000
@@ -333,10 +333,28 @@
         if (len > size)
             len = size;
         if (len == 0) {
-            fill_buffer(s);
-            len = s->buf_end - s->buf_ptr;
-            if (len == 0)
-                break;
+            if(size > s->buffer_size && !s->update_checksum){
+                len = s->read_packet(s->opaque, buf, size);
+                if (len <= 0) {
+                    /* do not modify buffer if EOF reached so that a seek back can
+                    be done without rereading data */
+                    s->eof_reached = 1;
+                    if(len<0)
+                        s->error= len;
+                    break;
+                } else {
+                    s->pos += len;
+                    size -= len;
+                    buf += len;
+                    s->buf_ptr = s->buffer;
+                    s->buf_end = s->buffer/* + len*/;
+                }
+            }else{
+                fill_buffer(s);
+                len = s->buf_end - s->buf_ptr;
+                if (len == 0)
+                    break;
+            }
         } else {
             memcpy(buf, s->buf_ptr, len);
             buf += len;