changeset 27282:16beae919ff1

Avoid including avcodec.h in demuxer.h (and thus many other files) just to get FF_INPUT_BUFFER_PADDING_SIZE. Instead use MP_INPUT_BUFFER_PADDING_SIZE and add a preprocessor check that it is big enough.
author reimar
date Thu, 17 Jul 2008 17:14:12 +0000
parents e47193172586
children 3a4275b18bb7
files libmpdemux/demux_asf.c libmpdemux/demux_real.c libmpdemux/demux_viv.c libmpdemux/demuxer.c libmpdemux/demuxer.h libmpdemux/video.c
diffstat 6 files changed, 26 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_asf.c	Thu Jul 17 17:11:30 2008 +0000
+++ b/libmpdemux/demux_asf.c	Thu Jul 17 17:14:12 2008 +0000
@@ -54,9 +54,9 @@
   unsigned char *dst;
   unsigned char *s2=*src;
   unsigned i=0,x,y;
-  if (len > UINT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
+  if (len > UINT_MAX - MP_INPUT_BUFFER_PADDING_SIZE)
 	return;
-  dst = malloc(len + FF_INPUT_BUFFER_PADDING_SIZE);
+  dst = malloc(len + MP_INPUT_BUFFER_PADDING_SIZE);
   while(len>=asf->scrambling_h*asf->scrambling_w*asf->scrambling_b+i){
 //    mp_msg(MSGT_DEMUX,MSGL_DBG4,"descrambling! (w=%d  b=%d)\n",w,asf_scrambling_b);
 	//i+=asf_scrambling_h*asf_scrambling_w;
@@ -86,9 +86,9 @@
 static void demux_asf_append_to_packet(demux_packet_t* dp,unsigned char *data,int len,int offs)
 {
   if(dp->len!=offs && offs!=-1) mp_msg(MSGT_DEMUX,MSGL_V,"warning! fragment.len=%d BUT next fragment offset=%d  \n",dp->len,offs);
-  dp->buffer=realloc(dp->buffer,dp->len+len+FF_INPUT_BUFFER_PADDING_SIZE);
+  dp->buffer=realloc(dp->buffer,dp->len+len+MP_INPUT_BUFFER_PADDING_SIZE);
   fast_memcpy(dp->buffer+dp->len,data,len);
-  memset(dp->buffer+dp->len+len, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+  memset(dp->buffer+dp->len+len, 0, MP_INPUT_BUFFER_PADDING_SIZE);
   mp_dbg(MSGT_DEMUX,MSGL_DBG4,"data appended! %d+%d\n",dp->len,len);
   dp->len+=len;
 }
--- a/libmpdemux/demux_real.c	Thu Jul 17 17:11:30 2008 +0000
+++ b/libmpdemux/demux_real.c	Thu Jul 17 17:14:12 2008 +0000
@@ -934,8 +934,8 @@
 			    // increase buffer size, this should not happen!
 			    mp_msg(MSGT_DEMUX,MSGL_WARN, "chunktab buffer too small!!!!!\n");
 			    dp->len=dp_hdr->chunktab+8*(4+dp_hdr->chunks);
-			    dp->buffer=realloc(dp->buffer,dp->len+FF_INPUT_BUFFER_PADDING_SIZE);
-			    memset(dp->buffer + dp->len, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+			    dp->buffer=realloc(dp->buffer,dp->len+MP_INPUT_BUFFER_PADDING_SIZE);
+			    memset(dp->buffer + dp->len, 0, MP_INPUT_BUFFER_PADDING_SIZE);
 			    // re-calc pointers:
 			    dp_hdr=(dp_hdr_t*)dp->buffer;
 			    dp_data=dp->buffer+sizeof(dp_hdr_t);
--- a/libmpdemux/demux_viv.c	Thu Jul 17 17:11:30 2008 +0000
+++ b/libmpdemux/demux_viv.c	Thu Jul 17 17:14:12 2008 +0000
@@ -378,10 +378,10 @@
       } else {
         // append data to it!
         demux_packet_t* dp=ds->asf_packet;
-        if(dp->len + len + FF_INPUT_BUFFER_PADDING_SIZE < 0)
+        if(dp->len + len + MP_INPUT_BUFFER_PADDING_SIZE < 0)
 	    return 0;
-        dp->buffer=realloc(dp->buffer,dp->len+len+FF_INPUT_BUFFER_PADDING_SIZE);
-        memset(dp->buffer+dp->len+len, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+        dp->buffer=realloc(dp->buffer,dp->len+len+MP_INPUT_BUFFER_PADDING_SIZE);
+        memset(dp->buffer+dp->len+len, 0, MP_INPUT_BUFFER_PADDING_SIZE);
         //memcpy(dp->buffer+dp->len,data,len);
 	stream_read(demux->stream,dp->buffer+dp->len,len);
         mp_dbg(MSGT_DEMUX,MSGL_DBG4,"data appended! %d+%d\n",dp->len,len);
--- a/libmpdemux/demuxer.c	Thu Jul 17 17:11:30 2008 +0000
+++ b/libmpdemux/demuxer.c	Thu Jul 17 17:14:12 2008 +0000
@@ -27,6 +27,13 @@
 #include "libass/ass_mp.h"
 #endif
 
+#ifdef USE_LIBAVCODEC
+#include "libavcodec/avcodec.h"
+#if MP_INPUT_BUFFER_PADDING_SIZE < FF_INPUT_BUFFER_PADDING_SIZE
+#error MP_INPUT_BUFFER_PADDING_SIZE is too small!
+#endif
+#endif
+
 extern void resync_video_stream(sh_video_t *sh_video);
 extern void resync_audio_stream(sh_audio_t *sh_audio);
 
--- a/libmpdemux/demuxer.h	Thu Jul 17 17:11:30 2008 +0000
+++ b/libmpdemux/demuxer.h	Thu Jul 17 17:14:12 2008 +0000
@@ -93,11 +93,7 @@
 #define SEEK_ABSOLUTE (1 << 0)
 #define SEEK_FACTOR   (1 << 1)
 
-#ifdef USE_LIBAVCODEC
-#include "libavcodec/avcodec.h"
-#else
-#define FF_INPUT_BUFFER_PADDING_SIZE 8
-#endif
+#define MP_INPUT_BUFFER_PADDING_SIZE 8
 
 // Holds one packet/frame/whatever
 typedef struct demux_packet_st {
@@ -249,7 +245,7 @@
   dp->refcount=1;
   dp->master=NULL;
   dp->buffer=NULL;
-  if (len > 0 && (dp->buffer = (unsigned char *)malloc(len + FF_INPUT_BUFFER_PADDING_SIZE)))
+  if (len > 0 && (dp->buffer = (unsigned char *)malloc(len + MP_INPUT_BUFFER_PADDING_SIZE)))
     memset(dp->buffer + len, 0, 8);
   else
     dp->len = 0;
--- a/libmpdemux/video.c	Thu Jul 17 17:11:30 2008 +0000
+++ b/libmpdemux/video.c	Thu Jul 17 17:14:12 2008 +0000
@@ -111,8 +111,8 @@
    }
    mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
    if(!videobuffer) {
-     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
        return 0;
@@ -204,8 +204,8 @@
    }
    mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
    if(!videobuffer) {
-     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
        return 0;
@@ -267,8 +267,8 @@
    mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
    // ========= Read & process sequence header & extension ============
    if(!videobuffer) {
-     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
        return 0;
@@ -335,8 +335,8 @@
    }
    mp_msg(MSGT_DECVIDEO,MSGL_INFO,"found\n");
    if(!videobuffer) {
-     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
      else {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
        return 0;