1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 15:22:09 +00:00

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.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27314 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2008-07-17 17:14:12 +00:00
parent 6dfb85dc9e
commit 4153f4e21c
6 changed files with 26 additions and 23 deletions

View File

@ -54,9 +54,9 @@ static void asf_descrambling(unsigned char **src,unsigned len, struct asf_priv*
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* asf){
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;
}

View File

@ -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);

View File

@ -378,10 +378,10 @@ static int demux_vivo_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){
} 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);

View File

@ -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);

View File

@ -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_packet(int len){
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;

View File

@ -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;