Enlightenment CVS committal

Author  : tsauerbeck
Project : misc
Module  : eplayer

Dir     : misc/eplayer/src/input/avcodec


Modified Files:
        avcodec.c 


Log Message:
Cleaned up input plugin buffer handling.
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/input/avcodec/avcodec.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- avcodec.c   24 Oct 2003 18:56:39 -0000      1.2
+++ avcodec.c   9 Nov 2003 14:43:03 -0000       1.3
@@ -8,7 +8,7 @@
 #include <assert.h>
 #include "../../plugin.h"
 
-#define BUF_SIZE 2048
+#define INBUF_SIZE 2048
 
 static FILE *fp = NULL;
 static AVCodecContext *ctx = NULL;
@@ -31,13 +31,13 @@
 }
 
 static void avdec_init() {
-       static unsigned char inbuf[BUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
+       static unsigned char inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
        static short outbuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
        int read, written;
 
-       memset(&inbuf[BUF_SIZE], 0, FF_INPUT_BUFFER_PADDING_SIZE);
+       memset(&inbuf[INBUF_SIZE], 0, FF_INPUT_BUFFER_PADDING_SIZE);
        
-       if (!(read = fread(inbuf, 1, BUF_SIZE, fp)))
+       if (!(read = fread(inbuf, 1, INBUF_SIZE, fp)))
                return;
 
        avcodec_decode_audio(ctx, outbuf, &written, inbuf, read);
@@ -138,15 +138,19 @@
        return sample_rate;
 }
 
-int avdec_read(unsigned char *outbuf, int outbuf_len) {
-       static unsigned char inbuf[BUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
+int avdec_read(unsigned char **buf) {
+#define OUTBUF_SIZE 65536
+       static unsigned char inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
+       static unsigned char outbuf[OUTBUF_SIZE];
        static short tmp[AVCODEC_MAX_AUDIO_FRAME_SIZE];
-       char *ptr = inbuf;
+       unsigned char *ptr = inbuf;
        int read = 0, decoded, written, total = 0;
 
-       memset(&inbuf[BUF_SIZE], 0, FF_INPUT_BUFFER_PADDING_SIZE);
+       *buf = outbuf;
+
+       memset(&inbuf[INBUF_SIZE], 0, FF_INPUT_BUFFER_PADDING_SIZE);
        
-       if (!(read = fread(inbuf, 1, BUF_SIZE, fp)))
+       if (!(read = fread(inbuf, 1, INBUF_SIZE, fp)))
                return 0;
        
        while (read > 0) {
@@ -161,7 +165,7 @@
                
                if (written) {
                        /* make sure we don't overflow the output buffer */
-                       assert(total + written <= outbuf_len);
+                       assert(total + written <= OUTBUF_SIZE);
                        memcpy(&outbuf[total], tmp, written);
                        total += written;
                }




-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to