[MPlayer-cvslog] r27314 - in trunk/libmpdemux: demux_asf.c demux_real.c demux_viv.c demuxer.c demuxer.h video.c
reimar
subversion at mplayerhq.hu
Thu Jul 17 19:14:13 CEST 2008
Author: reimar
Date: Thu Jul 17 19:14:12 2008
New Revision: 27314
Log:
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.
Modified:
trunk/libmpdemux/demux_asf.c
trunk/libmpdemux/demux_real.c
trunk/libmpdemux/demux_viv.c
trunk/libmpdemux/demuxer.c
trunk/libmpdemux/demuxer.h
trunk/libmpdemux/video.c
Modified: trunk/libmpdemux/demux_asf.c
==============================================================================
--- trunk/libmpdemux/demux_asf.c (original)
+++ trunk/libmpdemux/demux_asf.c Thu Jul 17 19:14:12 2008
@@ -54,9 +54,9 @@ static void asf_descrambling(unsigned ch
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 init_priv (struct asf_priv*
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;
}
Modified: trunk/libmpdemux/demux_real.c
==============================================================================
--- trunk/libmpdemux/demux_real.c (original)
+++ trunk/libmpdemux/demux_real.c Thu Jul 17 19:14:12 2008
@@ -934,8 +934,8 @@ got_video:
// 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);
Modified: trunk/libmpdemux/demux_viv.c
==============================================================================
--- trunk/libmpdemux/demux_viv.c (original)
+++ trunk/libmpdemux/demux_viv.c Thu Jul 17 19:14:12 2008
@@ -378,10 +378,10 @@ static int demux_vivo_fill_buffer(demuxe
} 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);
Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c (original)
+++ trunk/libmpdemux/demuxer.c Thu Jul 17 19:14:12 2008
@@ -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);
Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h (original)
+++ trunk/libmpdemux/demuxer.h Thu Jul 17 19:14:12 2008
@@ -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 @@ static inline demux_packet_t* new_demux_
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;
Modified: trunk/libmpdemux/video.c
==============================================================================
--- trunk/libmpdemux/video.c (original)
+++ trunk/libmpdemux/video.c Thu Jul 17 19:14:12 2008
@@ -111,8 +111,8 @@ switch(video_codec){
}
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 @@ switch(video_codec){
}
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 @@ mpeg_header_parser:
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 @@ mpeg_header_parser:
}
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;
More information about the MPlayer-cvslog
mailing list