summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libav/asf.c14
-rw-r--r--libav/au.c2
-rw-r--r--libav/audio.c12
-rw-r--r--libav/avformat.h3
-rw-r--r--libav/avidec.c9
-rw-r--r--libav/avienc.c10
-rw-r--r--libav/avio.c6
-rw-r--r--libav/aviobuf.c10
-rw-r--r--libav/crc.c1
-rw-r--r--libav/ffm.c20
-rw-r--r--libav/gif.c6
-rw-r--r--libav/grab.c8
-rw-r--r--libav/http.c4
-rw-r--r--libav/img.c12
-rw-r--r--libav/jpeg.c8
-rw-r--r--libav/libav.dsp160
-rw-r--r--libav/mov.c37
-rw-r--r--libav/mpeg.c9
-rw-r--r--libav/rm.c12
-rw-r--r--libav/swf.c8
-rw-r--r--libav/udp.c2
-rw-r--r--libav/utils.c22
-rw-r--r--libav/wav.c8
23 files changed, 110 insertions, 273 deletions
diff --git a/libav/asf.c b/libav/asf.c
index 178354fcbc..7cb9fca067 100644
--- a/libav/asf.c
+++ b/libav/asf.c
@@ -431,7 +431,7 @@ static int asf_write_header(AVFormatContext *s)
asf->nb_packets = 0;
if (asf_write_header1(s, 0, 50) < 0) {
- free(asf);
+ av_free(asf);
return -1;
}
@@ -615,7 +615,7 @@ static int asf_write_trailer(AVFormatContext *s)
put_flush_packet(&s->pb);
- free(asf);
+ av_free(asf);
return 0;
}
@@ -869,10 +869,10 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
if (st)
- free(st->priv_data);
- free(st);
+ av_free(st->priv_data);
+ av_free(st);
}
- free(asf);
+ av_free(asf);
return -1;
}
@@ -1009,9 +1009,9 @@ static int asf_read_close(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
- free(st->priv_data);
+ av_free(st->priv_data);
}
- free(asf);
+ av_free(asf);
return 0;
}
diff --git a/libav/au.c b/libav/au.c
index 5f57ce2372..797f36472e 100644
--- a/libav/au.c
+++ b/libav/au.c
@@ -128,7 +128,7 @@ static int au_read_header(AVFormatContext *s,
}
/* now we are ready: build format streams */
- st = malloc(sizeof(AVStream));
+ st = av_malloc(sizeof(AVStream));
if (!st)
return -1;
s->nb_streams = 1;
diff --git a/libav/audio.c b/libav/audio.c
index ddbe382d60..ab9e4757d2 100644
--- a/libav/audio.c
+++ b/libav/audio.c
@@ -161,7 +161,7 @@ static int audio_write_header(AVFormatContext *s1)
s->channels = st->codec.channels;
ret = audio_open(s, 1);
if (ret < 0) {
- free(s);
+ av_free(s);
return -EIO;
} else {
return 0;
@@ -201,7 +201,7 @@ static int audio_write_trailer(AVFormatContext *s1)
AudioData *s = s1->priv_data;
audio_close(s);
- free(s);
+ av_free(s);
return 0;
}
@@ -221,7 +221,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
return -ENOMEM;
st = av_mallocz(sizeof(AVStream));
if (!st) {
- free(s);
+ av_free(s);
return -ENOMEM;
}
s1->priv_data = s;
@@ -232,8 +232,8 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
ret = audio_open(s, 0);
if (ret < 0) {
- free(st);
- free(s);
+ av_free(st);
+ av_free(s);
return -EIO;
} else {
/* take real parameters */
@@ -284,7 +284,7 @@ static int audio_read_close(AVFormatContext *s1)
AudioData *s = s1->priv_data;
audio_close(s);
- free(s);
+ av_free(s);
return 0;
}
diff --git a/libav/avformat.h b/libav/avformat.h
index c982336f42..fd3052d3c1 100644
--- a/libav/avformat.h
+++ b/libav/avformat.h
@@ -142,6 +142,9 @@ extern AVFormat au_format;
/* wav.c */
extern AVFormat wav_format;
+/* crc.c */
+extern AVFormat crc_format;
+
/* img.c */
extern AVFormat pgm_format;
extern AVFormat ppm_format;
diff --git a/libav/avidec.c b/libav/avidec.c
index a3d5a8fa6d..4af2d661b9 100644
--- a/libav/avidec.c
+++ b/libav/avidec.c
@@ -54,7 +54,7 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
int i, bps;
AVStream *st;
- avi = malloc(sizeof(AVIContext));
+ avi = av_malloc(sizeof(AVIContext));
if (!avi)
return -1;
memset(avi, 0, sizeof(AVIContext));
@@ -106,7 +106,7 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
s->nb_streams = get_le32(pb);
for(i=0;i<s->nb_streams;i++) {
AVStream *st;
- st = malloc(sizeof(AVStream));
+ st = av_malloc(sizeof(AVStream));
if (!st)
goto fail;
memset(st, 0, sizeof(AVStream));
@@ -198,8 +198,7 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (stream_index != s->nb_streams - 1) {
fail:
for(i=0;i<s->nb_streams;i++) {
- if (s->streams[i])
- free(s->streams[i]);
+ av_freep(&s->streams[i]);
}
return -1;
}
@@ -248,6 +247,6 @@ int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
int avi_read_close(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
- free(avi);
+ av_free(avi);
return 0;
}
diff --git a/libav/avienc.c b/libav/avienc.c
index 2290600add..6d2b0ab444 100644
--- a/libav/avienc.c
+++ b/libav/avienc.c
@@ -149,7 +149,7 @@ static int avi_write_header(AVFormatContext *s)
AVCodecContext *stream, *video_enc;
offset_t list1, list2, strh, strf;
- avi = malloc(sizeof(AVIContext));
+ avi = av_malloc(sizeof(AVIContext));
if (!avi)
return -1;
memset(avi, 0, sizeof(AVIContext));
@@ -177,7 +177,7 @@ static int avi_write_header(AVFormatContext *s)
}
if (!video_enc) {
- free(avi);
+ av_free(avi);
return -1;
}
nb_frames = 0;
@@ -259,7 +259,7 @@ static int avi_write_header(AVFormatContext *s)
break;
case CODEC_TYPE_AUDIO:
if (put_wav_header(pb, stream) < 0) {
- free(avi);
+ av_free(avi);
return -1;
}
break;
@@ -309,7 +309,7 @@ static int avi_write_packet(AVFormatContext *s, int stream_index,
avi->audio_strm_length[stream_index] += size;
if (!url_is_streamed(&s->pb)) {
- idx = malloc(sizeof(AVIIndex));
+ idx = av_malloc(sizeof(AVIIndex));
memcpy(idx->tag, tag, 4);
idx->flags = flags;
idx->pos = url_ftell(pb) - avi->movi_list;
@@ -389,7 +389,7 @@ static int avi_write_trailer(AVFormatContext *s)
}
put_flush_packet(pb);
- free(avi);
+ av_free(avi);
return 0;
}
diff --git a/libav/avio.c b/libav/avio.c
index c3d9961db7..7f12571061 100644
--- a/libav/avio.c
+++ b/libav/avio.c
@@ -60,7 +60,7 @@ int url_open(URLContext **puc, const char *filename, int flags)
}
return -ENOENT;
found:
- uc = malloc(sizeof(URLContext));
+ uc = av_malloc(sizeof(URLContext));
if (!uc)
return -ENOMEM;
uc->prot = up;
@@ -69,7 +69,7 @@ int url_open(URLContext **puc, const char *filename, int flags)
uc->packet_size = 1; /* default packet size */
err = up->url_open(uc, filename, flags);
if (err < 0) {
- free(uc);
+ av_free(uc);
*puc = NULL;
return err;
}
@@ -118,7 +118,7 @@ int url_close(URLContext *h)
int ret;
ret = h->prot->url_close(h);
- free(h);
+ av_free(h);
return ret;
}
diff --git a/libav/aviobuf.c b/libav/aviobuf.c
index 888378df40..522891c902 100644
--- a/libav/aviobuf.c
+++ b/libav/aviobuf.c
@@ -337,14 +337,14 @@ int url_fdopen(ByteIOContext *s, URLContext *h)
int buffer_size;
buffer_size = (IO_BUFFER_SIZE / h->packet_size) * h->packet_size;
- buffer = malloc(buffer_size);
+ buffer = av_malloc(buffer_size);
if (!buffer)
return -ENOMEM;
if (init_put_byte(s, buffer, buffer_size,
(h->flags & URL_WRONLY) != 0, h,
url_read_packet, url_write_packet, url_seek_packet) < 0) {
- free(buffer);
+ av_free(buffer);
return -EIO;
}
s->is_streamed = h->is_streamed;
@@ -356,11 +356,11 @@ int url_fdopen(ByteIOContext *s, URLContext *h)
int url_setbufsize(ByteIOContext *s, int buf_size)
{
UINT8 *buffer;
- buffer = malloc(buf_size);
+ buffer = av_malloc(buf_size);
if (!buffer)
return -ENOMEM;
- free(s->buffer);
+ av_free(s->buffer);
s->buffer = buffer;
s->buffer_size = buf_size;
s->buf_ptr = buffer;
@@ -391,7 +391,7 @@ int url_fclose(ByteIOContext *s)
{
URLContext *h = s->opaque;
- free(s->buffer);
+ av_free(s->buffer);
memset(s, 0, sizeof(ByteIOContext));
return url_close(h);
}
diff --git a/libav/crc.c b/libav/crc.c
index 84786c6294..b1e6d0bea2 100644
--- a/libav/crc.c
+++ b/libav/crc.c
@@ -93,6 +93,7 @@ static int crc_write_trailer(struct AVFormatContext *s)
snprintf(buf, sizeof(buf), "CRC=%08x\n", crc->crcval);
put_buffer(&s->pb, buf, strlen(buf));
put_flush_packet(&s->pb);
+ av_free(crc);
return 0;
}
diff --git a/libav/ffm.c b/libav/ffm.c
index 98fde8345a..a9892a68a6 100644
--- a/libav/ffm.c
+++ b/libav/ffm.c
@@ -198,10 +198,9 @@ static int ffm_write_header(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
fst = st->priv_data;
- if (fst)
- free(fst);
+ av_free(fst);
}
- free(ffm);
+ av_free(ffm);
return -1;
}
@@ -252,8 +251,8 @@ static int ffm_write_trailer(AVFormatContext *s)
put_flush_packet(pb);
for(i=0;i<s->nb_streams;i++)
- free(s->streams[i]->priv_data);
- free(ffm);
+ av_free(s->streams[i]->priv_data);
+ av_free(ffm);
return 0;
}
@@ -433,13 +432,12 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st = s->streams[i];
if (st) {
fst = st->priv_data;
- if (fst)
- free(fst);
- free(st);
+ av_free(fst);
+ av_free(st);
}
}
if (ffm)
- free(ffm);
+ av_free(ffm);
return -1;
}
@@ -615,9 +613,9 @@ static int ffm_read_close(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
- free(st->priv_data);
+ av_free(st->priv_data);
}
- free(s->priv_data);
+ av_free(s->priv_data);
return 0;
}
diff --git a/libav/gif.c b/libav/gif.c
index f8a7fc0f1d..4aa1ba0b82 100644
--- a/libav/gif.c
+++ b/libav/gif.c
@@ -202,7 +202,7 @@ static int gif_write_header(AVFormatContext *s)
return -1;
*/
- gif = malloc(sizeof(GIFContext));
+ gif = av_malloc(sizeof(GIFContext));
if (!gif)
return -1;
s->priv_data = gif;
@@ -218,7 +218,7 @@ static int gif_write_header(AVFormatContext *s)
}
if (!video_enc) {
- free(gif);
+ av_free(gif);
return -1;
} else {
width = video_enc->width;
@@ -382,7 +382,7 @@ static int gif_write_trailer(AVFormatContext *s)
put_byte(pb, 0x3b);
put_flush_packet(&s->pb);
- free(gif);
+ av_free(gif);
return 0;
}
diff --git a/libav/grab.c b/libav/grab.c
index 389b241ff0..e456468c4e 100644
--- a/libav/grab.c
+++ b/libav/grab.c
@@ -67,7 +67,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
return -ENOMEM;
st = av_mallocz(sizeof(AVStream));
if (!st) {
- free(s);
+ av_free(s);
return -ENOMEM;
}
s1->priv_data = s;
@@ -231,8 +231,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
fail:
if (video_fd >= 0)
close(video_fd);
- free(st);
- free(s);
+ av_free(st);
+ av_free(s);
return -EIO;
}
@@ -327,7 +327,7 @@ static int grab_read_close(AVFormatContext *s1)
ioctl(s->fd, VIDIOCSAUDIO, &audio_saved);
close(s->fd);
- free(s);
+ av_free(s);
return 0;
}
diff --git a/libav/http.c b/libav/http.c
index d3cf883f79..940883b4f4 100644
--- a/libav/http.c
+++ b/libav/http.c
@@ -58,7 +58,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
h->is_streamed = 1;
- s = malloc(sizeof(HTTPContext));
+ s = av_malloc(sizeof(HTTPContext));
if (!s) {
return -ENOMEM;
}
@@ -129,7 +129,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
fail:
if (fd >= 0)
close(fd);
- free(s);
+ av_free(s);
return -EIO;
}
diff --git a/libav/img.c b/libav/img.c
index 57cc0c303a..3ac8b52bfc 100644
--- a/libav/img.c
+++ b/libav/img.c
@@ -255,7 +255,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
ByteIOContext pb1, *f = &pb1;
AVStream *st;
- s = malloc(sizeof(VideoData));
+ s = av_malloc(sizeof(VideoData));
if (!s)
return -ENOMEM;
@@ -264,7 +264,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s1->nb_streams = 1;
st = av_mallocz(sizeof(AVStream));
if (!st) {
- free(s);
+ av_free(s);
return -ENOMEM;
}
s1->streams[0] = st;
@@ -372,14 +372,14 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (!s->is_pipe)
url_fclose(f);
fail:
- free(s);
+ av_free(s);
return -EIO;
}
static int img_read_close(AVFormatContext *s1)
{
VideoData *s = s1->priv_data;
- free(s);
+ av_free(s);
return 0;
}
@@ -510,7 +510,7 @@ static int img_write_header(AVFormatContext *s)
}
return 0;
fail:
- free(img);
+ av_free(img);
return -EIO;
}
@@ -591,7 +591,7 @@ static int img_write_packet(AVFormatContext *s, int stream_index,
static int img_write_trailer(AVFormatContext *s)
{
VideoData *img = s->priv_data;
- free(img);
+ av_free(img);
return 0;
}
diff --git a/libav/jpeg.c b/libav/jpeg.c
index 94971d9f8f..732898252b 100644
--- a/libav/jpeg.c
+++ b/libav/jpeg.c
@@ -144,7 +144,7 @@ static int jpeg_write_packet(AVFormatContext *s1, int stream_index,
static int jpeg_write_trailer(AVFormatContext *s1)
{
JpegContext *s = s1->priv_data;
- free(s);
+ av_free(s);
return 0;
}
@@ -167,7 +167,7 @@ static int jpeg_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s1->nb_streams = 1;
st = av_mallocz(sizeof(AVStream));
if (!st) {
- free(s);
+ av_free(s);
return -ENOMEM;
}
s1->streams[0] = st;
@@ -193,7 +193,7 @@ static int jpeg_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st->codec.frame_rate = ap->frame_rate;
return 0;
fail:
- free(s);
+ av_free(s);
return -EIO;
}
@@ -227,7 +227,7 @@ static int jpeg_read_packet(AVFormatContext *s1, AVPacket *pkt)
static int jpeg_read_close(AVFormatContext *s1)
{
JpegContext *s = s1->priv_data;
- free(s);
+ av_free(s);
return 0;
}
diff --git a/libav/libav.dsp b/libav/libav.dsp
deleted file mode 100644
index e158548cdc..0000000000
--- a/libav/libav.dsp
+++ /dev/null
@@ -1,160 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libav" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libav - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "libav.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "libav.mak" CFG="libav - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "libav - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libav - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "libav - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "../Release/libav"
-# PROP Intermediate_Dir "../Release/libav"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../libavcodec" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD BASE RSC /l 0x40c /d "NDEBUG"
-# ADD RSC /l 0x40c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libav - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "../Debug/libav"
-# PROP Intermediate_Dir "../Debug/libav"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libavcodec" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x40c /d "_DEBUG"
-# ADD RSC /l 0x40c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# SUBTRACT LIB32 /nologo
-
-!ENDIF
-
-# Begin Target
-
-# Name "libav - Win32 Release"
-# Name "libav - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\asf.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\avformat.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\avi.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\avidec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\avienc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\avio.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\avio.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\aviobuf.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\file.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\img.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\jpegenc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mpeg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\raw.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\rm.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\swf.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\utils.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\wav.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# End Target
-# End Project
diff --git a/libav/mov.c b/libav/mov.c
index b2b3e9a3d8..89732c0003 100644
--- a/libav/mov.c
+++ b/libav/mov.c
@@ -335,11 +335,11 @@ static int parse_trak(const MOVParseTableEntry *parse_table, ByteIOContext *pb,
#endif
c = (MOVContext *)param;
- st = malloc(sizeof(AVStream));
- if (!st) return -2;
+ st = av_malloc(sizeof(AVStream));
+ if (!st) return -2;
memset(st, 0, sizeof(AVStream));
c->fc->streams[c->fc->nb_streams] = st;
- sc = malloc(sizeof(MOVStreamContext));
+ sc = av_malloc(sizeof(MOVStreamContext));
st->priv_data = sc;
st->codec.codec_type = CODEC_TYPE_MOV_OTHER;
c->streams[c->fc->nb_streams++] = sc;
@@ -461,13 +461,13 @@ static int parse_hdlr(const MOVParseTableEntry *parse_table, ByteIOContext *pb,
} else {
len = get_byte(pb);
if(len) {
- buf = malloc(len+1);
+ buf = av_malloc(len+1);
get_buffer(pb, buf, len);
buf[len] = '\0';
#ifdef DEBUG
puts(buf);
#endif
- free(buf);
+ av_free(buf);
}
}
@@ -578,11 +578,11 @@ static int parse_stsd(const MOVParseTableEntry *parse_table, ByteIOContext *pb,
}
/*
if(len) {
- buf = malloc(len+1);
+ buf = av_malloc(len+1);
get_buffer(pb, buf, len);
buf[len] = '\0';
puts(buf);
- free(buf);
+ av_free(buf);
}
*/
return 0;
@@ -606,7 +606,7 @@ static int parse_stco(const MOVParseTableEntry *parse_table, ByteIOContext *pb,
entries = get_be32(pb);
sc->chunk_count = entries;
- sc->chunk_offsets = malloc(entries * sizeof(INT64));
+ sc->chunk_offsets = av_malloc(entries * sizeof(INT64));
if(atom_type == MKTAG('s', 't', 'c', 'o')) {
for(i=0; i<entries; i++) {
sc->chunk_offsets[i] = get_be32(pb);
@@ -640,7 +640,7 @@ static int parse_stsc(const MOVParseTableEntry *parse_table, ByteIOContext *pb,
entries = get_be32(pb);
sc->sample_to_chunk_sz = entries;
- sc->sample_to_chunk = malloc(entries * sizeof(MOV_sample_to_chunk_tbl));
+ sc->sample_to_chunk = av_malloc(entries * sizeof(MOV_sample_to_chunk_tbl));
for(i=0; i<entries; i++) {
sc->sample_to_chunk[i].first = get_be32(pb);
sc->sample_to_chunk[i].count = get_be32(pb);
@@ -674,7 +674,7 @@ static int parse_stsz(const MOVParseTableEntry *parse_table, ByteIOContext *pb,
printf("sample_size = %ld sample_count = %ld\n", sc->sample_size, sc->sample_count);
if(sc->sample_size)
return 0; /* there isn't any table following */
- sc->sample_sizes = malloc(entries * sizeof(long));
+ sc->sample_sizes = av_malloc(entries * sizeof(long));
for(i=0; i<entries; i++) {
sc->sample_sizes[i] = get_be32(pb);
#ifdef DEBUG
@@ -757,11 +757,9 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
static void mov_free_stream_context(MOVStreamContext *sc)
{
if(sc) {
- if(sc->chunk_offsets)
- free(sc->chunk_offsets);
- if(sc->sample_to_chunk)
- free(sc->sample_to_chunk);
- free(sc);
+ av_free(sc->chunk_offsets);
+ av_free(sc->sample_to_chunk);
+ av_free(sc);
}
}
@@ -772,10 +770,9 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
int i, j, nb, err;
INT64 size;
- mov = malloc(sizeof(MOVContext));
+ mov = av_mallocz(sizeof(MOVContext));
if (!mov)
return -1;
- memset(mov, 0, sizeof(MOVContext));
s->priv_data = mov;
mov->fc = s;
@@ -817,7 +814,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
#if 1
for(i=0; i<s->nb_streams;) {
if(s->streams[i]->codec.codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */
- free(s->streams[i]);
+ av_free(s->streams[i]);
for(j=i+1; j<s->nb_streams; j++)
s->streams[j-1] = s->streams[j];
s->nb_streams--;
@@ -918,8 +915,8 @@ static int mov_read_close(AVFormatContext *s)
for(i=0; i<mov->total_streams; i++)
mov_free_stream_context(mov->streams[i]);
for(i=0; i<s->nb_streams; i++)
- free(s->streams[i]);
- free(mov);
+ av_free(s->streams[i]);
+ av_free(mov);
return 0;
}
diff --git a/libav/mpeg.c b/libav/mpeg.c
index 6443b18bb3..f14ce0a2d2 100644
--- a/libav/mpeg.c
+++ b/libav/mpeg.c
@@ -155,10 +155,9 @@ static int mpeg_mux_init(AVFormatContext *ctx)
AVStream *st;
StreamInfo *stream;
- s = malloc(sizeof(MpegMuxContext));
+ s = av_mallocz(sizeof(MpegMuxContext));
if (!s)
return -1;
- memset(s, 0, sizeof(MpegMuxContext));
ctx->priv_data = s;
s->packet_number = 0;
@@ -251,9 +250,9 @@ static int mpeg_mux_init(AVFormatContext *ctx)
return 0;
fail:
for(i=0;i<ctx->nb_streams;i++) {
- free(ctx->streams[i]->priv_data);
+ av_free(ctx->streams[i]->priv_data);
}
- free(s);
+ av_free(s);
return -ENOMEM;
}
@@ -873,7 +872,7 @@ static int mpeg_mux_check_packet(AVFormatContext *s, int *size)
static int mpeg_mux_read_close(AVFormatContext *s)
{
MpegDemuxContext *m = s->priv_data;
- free(m);
+ av_free(m);
return 0;
}
diff --git a/libav/rm.c b/libav/rm.c
index 91e42a16b0..5608499979 100644
--- a/libav/rm.c
+++ b/libav/rm.c
@@ -286,7 +286,7 @@ static int rm_write_header(AVFormatContext *s)
int n;
AVCodecContext *codec;
- rm = malloc(sizeof(RMContext));
+ rm = av_malloc(sizeof(RMContext));
if (!rm)
return -1;
memset(rm, 0, sizeof(RMContext));
@@ -337,7 +337,7 @@ static int rm_write_audio(AVFormatContext *s, UINT8 *buf, int size)
int i;
/* XXX: suppress this malloc */
- buf1= (UINT8*) malloc( size * sizeof(UINT8) );
+ buf1= (UINT8*) av_malloc( size * sizeof(UINT8) );
write_packet_header(s, stream, size, stream->enc->key_frame);
@@ -349,7 +349,7 @@ static int rm_write_audio(AVFormatContext *s, UINT8 *buf, int size)
put_buffer(pb, buf1, size);
put_flush_packet(pb);
stream->nb_frames++;
- free(buf1);
+ av_free(buf1);
return 0;
}
@@ -439,7 +439,7 @@ static int rm_write_trailer(AVFormatContext *s)
}
put_flush_packet(pb);
- free(rm);
+ av_free(rm);
return 0;
}
@@ -638,7 +638,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
fail:
for(i=0;i<s->nb_streams;i++) {
- free(s->streams[i]);
+ av_free(s->streams[i]);
}
return -EIO;
}
@@ -707,7 +707,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
static int rm_read_close(AVFormatContext *s)
{
RMContext *rm = s->priv_data;
- free(rm);
+ av_free(rm);
return 0;
}
diff --git a/libav/swf.c b/libav/swf.c
index 27755a3969..092f1d72c6 100644
--- a/libav/swf.c
+++ b/libav/swf.c
@@ -196,7 +196,7 @@ static int swf_write_header(AVFormatContext *s)
UINT8 buf1[256];
int i, width, height, rate;
- swf = malloc(sizeof(SWFContext));
+ swf = av_malloc(sizeof(SWFContext));
if (!swf)
return -1;
s->priv_data = swf;
@@ -294,7 +294,7 @@ static int swf_write_header(AVFormatContext *s)
break;
default:
/* not supported */
- free(swf);
+ av_free(swf);
return -1;
}
if (audio_enc->channels == 2)
@@ -414,7 +414,7 @@ static int swf_write_trailer(AVFormatContext *s)
url_fseek(pb, swf->duration_pos, SEEK_SET);
put_le16(pb, video_enc->frame_number);
}
- free(swf);
+ av_free(swf);
return 0;
}
@@ -488,7 +488,7 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec.sample_rate = 44100;
break;
default:
- free(st);
+ av_free(st);
return -EIO;
}
st->codec.codec_type = CODEC_TYPE_AUDIO;
diff --git a/libav/udp.c b/libav/udp.c
index f761832177..4ad6a15871 100644
--- a/libav/udp.c
+++ b/libav/udp.c
@@ -92,7 +92,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
goto fail;
}
- s = malloc(sizeof(UDPContext));
+ s = av_malloc(sizeof(UDPContext));
if (!s)
return -ENOMEM;
h->priv_data = s;
diff --git a/libav/utils.c b/libav/utils.c
index 161e72ceef..78258f9dd6 100644
--- a/libav/utils.c
+++ b/libav/utils.c
@@ -159,6 +159,8 @@ void register_all(void)
register_avformat(&gif_format);
register_avformat(&au_format);
register_avformat(&wav_format);
+ register_avformat(&crc_format);
+
register_avformat(&pcm_s16le_format);
register_avformat(&pcm_s16be_format);
register_avformat(&pcm_u16le_format);
@@ -196,7 +198,7 @@ void register_all(void)
int av_new_packet(AVPacket *pkt, int size)
{
- pkt->data = malloc(size);
+ pkt->data = av_malloc(size);
if (!pkt->data)
return -ENOMEM;
pkt->size = size;
@@ -209,9 +211,8 @@ int av_new_packet(AVPacket *pkt, int size)
void av_free_packet(AVPacket *pkt)
{
- free(pkt->data);
+ av_freep(&pkt->data);
/* fail safe */
- pkt->data = NULL;
pkt->size = 0;
}
@@ -219,7 +220,7 @@ void av_free_packet(AVPacket *pkt)
int fifo_init(FifoBuffer *f, int size)
{
- f->buffer = malloc(size);
+ f->buffer = av_malloc(size);
if (!f->buffer)
return -1;
f->end = f->buffer + size;
@@ -229,7 +230,7 @@ int fifo_init(FifoBuffer *f, int size)
void fifo_free(FifoBuffer *f)
{
- free(f->buffer);
+ av_free(f->buffer);
}
int fifo_size(FifoBuffer *f, UINT8 *rptr)
@@ -343,8 +344,7 @@ AVFormatContext *av_open_input_file(const char *filename,
return ic;
fail:
- if (ic)
- free(ic);
+ av_free(ic);
return NULL;
}
@@ -357,7 +357,7 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt)
/* read packet from packet buffer, if there is data */
*pkt = pktl->pkt;
s->packet_buffer = pktl->next;
- free(pktl);
+ av_free(pktl);
return 0;
} else {
return s->format->read_packet(s, pkt);
@@ -371,7 +371,7 @@ void av_close_input_file(AVFormatContext *s)
if (s->format->read_close)
s->format->read_close(s);
for(i=0;i<s->nb_streams;i++) {
- free(s->streams[i]);
+ av_free(s->streams[i]);
}
if (s->packet_buffer) {
AVPacketList *p, *p1;
@@ -379,7 +379,7 @@ void av_close_input_file(AVFormatContext *s)
while (p != NULL) {
p1 = p->next;
av_free_packet(&p->pkt);
- free(p);
+ av_free(p);
p = p1;
}
s->packet_buffer = NULL;
@@ -387,7 +387,7 @@ void av_close_input_file(AVFormatContext *s)
if (!(s->format->flags & AVFMT_NOFILE)) {
url_fclose(&s->pb);
}
- free(s);
+ av_free(s);
}
diff --git a/libav/wav.c b/libav/wav.c
index 6fcd4d7077..a50d6f86f3 100644
--- a/libav/wav.c
+++ b/libav/wav.c
@@ -114,7 +114,7 @@ static int wav_write_header(AVFormatContext *s)
ByteIOContext *pb = &s->pb;
offset_t fmt;
- wav = malloc(sizeof(WAVContext));
+ wav = av_malloc(sizeof(WAVContext));
if (!wav)
return -1;
memset(wav, 0, sizeof(WAVContext));
@@ -127,7 +127,7 @@ static int wav_write_header(AVFormatContext *s)
/* format header */
fmt = start_tag(pb, "fmt ");
if (put_wav_header(pb, &s->streams[0]->codec) < 0) {
- free(wav);
+ av_free(wav);
return -1;
}
end_tag(pb, fmt);
@@ -166,7 +166,7 @@ static int wav_write_trailer(AVFormatContext *s)
put_flush_packet(pb);
}
- free(wav);
+ av_free(wav);
return 0;
}
@@ -233,7 +233,7 @@ static int wav_read_header(AVFormatContext *s,
return -1;
/* now we are ready: build format streams */
- st = malloc(sizeof(AVStream));
+ st = av_malloc(sizeof(AVStream));
if (!st)
return -1;
s->nb_streams = 1;