Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
ffmpeg
Commits
c9a65ca8
Commit
c9a65ca8
authored
May 20, 2002
by
Fabrice Bellard
Browse files
converted to new API
Originally committed as revision 547 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
db7f1f95
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
709 additions
and
504 deletions
+709
-504
libav/Makefile
libav/Makefile
+7
-4
libav/asf.c
libav/asf.c
+46
-19
libav/au.c
libav/au.c
+31
-5
libav/audio.c
libav/audio.c
+24
-26
libav/avi.h
libav/avi.h
+0
-5
libav/avidec.c
libav/avidec.c
+31
-9
libav/avienc.c
libav/avienc.c
+9
-14
libav/avio.c
libav/avio.c
+0
-8
libav/avio.h
libav/avio.h
+0
-14
libav/crc.c
libav/crc.c
+10
-9
libav/ffm.c
libav/ffm.c
+30
-23
libav/gif.c
libav/gif.c
+9
-15
libav/grab.c
libav/grab.c
+12
-23
libav/img.c
libav/img.c
+134
-51
libav/jpeg.c
libav/jpeg.c
+31
-11
libav/mov.c
libav/mov.c
+45
-47
libav/raw.c
libav/raw.c
+187
-174
libav/rm.c
libav/rm.c
+35
-22
libav/swf.c
libav/swf.c
+32
-5
libav/wav.c
libav/wav.c
+36
-20
No files found.
libav/Makefile
View file @
c9a65ca8
...
...
@@ -5,10 +5,13 @@ PWD=$(shell pwd)
CFLAGS
=
$(OPTFLAGS)
-Wall
-g
-I
..
-I
$(SRC_PATH)
-I
$(SRC_PATH)
/libavcodec
-DHAVE_AV_CONFIG_H
OBJS
=
rm.o mpeg.o asf.o avienc.o jpeg.o swf.o wav.o raw.o
\
avidec.o ffm.o
\
avio.o aviobuf.o utils.o
\
file.o img.o au.o gif.o mov.o crc.o
OBJS
=
utils.o
# mux and demuxes
OBJS
+=
mpeg.o mpegts.o ffm.o crc.o img.o raw.o rm.o asf.o
\
avienc.o avidec.o wav.o swf.o au.o gif.o mov.o jpeg.o
# file I/O
OBJS
+=
avio.o aviobuf.o file.o
ifeq
($(CONFIG_GRAB),yes)
OBJS
+=
grab.o audio.o
...
...
libav/asf.c
View file @
c9a65ca8
...
...
@@ -420,12 +420,7 @@ static int asf_write_header1(AVFormatContext *s, INT64 file_size, INT64 data_chu
static
int
asf_write_header
(
AVFormatContext
*
s
)
{
ASFContext
*
asf
;
asf
=
av_mallocz
(
sizeof
(
ASFContext
));
if
(
!
asf
)
return
-
1
;
s
->
priv_data
=
asf
;
ASFContext
*
asf
=
s
->
priv_data
;
asf
->
packet_size
=
PACKET_SIZE
;
asf
->
nb_packets
=
0
;
...
...
@@ -614,8 +609,6 @@ static int asf_write_trailer(AVFormatContext *s)
}
put_flush_packet
(
&
s
->
pb
);
av_free
(
asf
);
return
0
;
}
...
...
@@ -679,9 +672,34 @@ static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size)
*
q
=
'\0'
;
}
static
int
asf_probe
(
AVProbeData
*
pd
)
{
GUID
g
;
const
unsigned
char
*
p
;
int
i
;
/* check file header */
if
(
pd
->
buf_size
<=
32
)
return
0
;
p
=
pd
->
buf
;
g
.
v1
=
p
[
0
]
|
(
p
[
1
]
<<
8
)
|
(
p
[
2
]
<<
16
)
|
(
p
[
3
]
<<
24
);
p
+=
4
;
g
.
v2
=
p
[
0
]
|
(
p
[
1
]
<<
8
);
p
+=
2
;
g
.
v3
=
p
[
0
]
|
(
p
[
1
]
<<
8
);
p
+=
2
;
for
(
i
=
0
;
i
<
8
;
i
++
)
g
.
v4
[
i
]
=
*
p
++
;
if
(
!
memcmp
(
&
g
,
&
asf_header
,
sizeof
(
GUID
)))
return
AVPROBE_SCORE_MAX
;
else
return
0
;
}
static
int
asf_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
{
ASFContext
*
asf
;
ASFContext
*
asf
=
s
->
priv_data
;
GUID
g
;
ByteIOContext
*
pb
=
&
s
->
pb
;
AVStream
*
st
;
...
...
@@ -689,11 +707,6 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
int
size
,
i
,
bps
;
INT64
gsize
;
asf
=
av_mallocz
(
sizeof
(
ASFContext
));
if
(
!
asf
)
return
-
1
;
s
->
priv_data
=
asf
;
get_guid
(
pb
,
&
g
);
if
(
memcmp
(
&
g
,
&
asf_header
,
sizeof
(
GUID
)))
goto
fail
;
...
...
@@ -1015,11 +1028,22 @@ static int asf_read_close(AVFormatContext *s)
return
0
;
}
AVFormat
asf_format
=
{
AVInputFormat
asf_iformat
=
{
"asf"
,
"asf format"
,
sizeof
(
ASFContext
),
asf_probe
,
asf_read_header
,
asf_read_packet
,
asf_read_close
,
};
AVOutputFormat
asf_oformat
=
{
"asf"
,
"asf format"
,
"application/octet-stream"
,
"asf,wmv"
,
sizeof
(
ASFContext
),
#ifdef CONFIG_MP3LAME
CODEC_ID_MP3LAME
,
#else
...
...
@@ -1029,8 +1053,11 @@ AVFormat asf_format = {
asf_write_header
,
asf_write_packet
,
asf_write_trailer
,
asf_read_header
,
asf_read_packet
,
asf_read_close
,
};
int
asf_init
(
void
)
{
av_register_input_format
(
&
asf_iformat
);
av_register_output_format
(
&
asf_oformat
);
return
0
;
}
libav/au.c
View file @
c9a65ca8
...
...
@@ -99,6 +99,18 @@ static int au_write_trailer(AVFormatContext *s)
return
0
;
}
static
int
au_probe
(
AVProbeData
*
p
)
{
/* check file header */
if
(
p
->
buf_size
<=
24
)
return
0
;
if
(
p
->
buf
[
0
]
==
'.'
&&
p
->
buf
[
1
]
==
's'
&&
p
->
buf
[
2
]
==
'n'
&&
p
->
buf
[
3
]
==
'd'
)
return
AVPROBE_SCORE_MAX
;
else
return
0
;
}
/* au input */
static
int
au_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
...
...
@@ -175,18 +187,32 @@ static int au_read_close(AVFormatContext *s)
return
0
;
}
AVFormat
au_format
=
{
static
AVInputFormat
au_iformat
=
{
"au"
,
"SUN AU Format"
,
0
,
au_probe
,
au_read_header
,
au_read_packet
,
au_read_close
,
};
static
AVOutputFormat
au_oformat
=
{
"au"
,
"SUN AU Format"
,
"audio/basic"
,
"au"
,
0
,
CODEC_ID_PCM_S16BE
,
CODEC_ID_NONE
,
au_write_header
,
au_write_packet
,
au_write_trailer
,
au_read_header
,
au_read_packet
,
au_read_close
,
};
int
au_init
(
void
)
{
av_register_input_format
(
&
au_iformat
);
av_register_output_format
(
&
au_oformat
);
return
0
;
}
libav/audio.c
View file @
c9a65ca8
...
...
@@ -147,21 +147,15 @@ static int audio_close(AudioData *s)
/* sound output support */
static
int
audio_write_header
(
AVFormatContext
*
s1
)
{
AudioData
*
s
;
AudioData
*
s
=
s1
->
priv_data
;
AVStream
*
st
;
int
ret
;
s
=
av_mallocz
(
sizeof
(
AudioData
));
if
(
!
s
)
return
-
ENOMEM
;
s1
->
priv_data
=
s
;
st
=
s1
->
streams
[
0
];
s
->
sample_rate
=
st
->
codec
.
sample_rate
;
s
->
channels
=
st
->
codec
.
channels
;
ret
=
audio_open
(
s
,
1
);
if
(
ret
<
0
)
{
av_free
(
s
);
return
-
EIO
;
}
else
{
return
0
;
...
...
@@ -201,7 +195,6 @@ static int audio_write_trailer(AVFormatContext *s1)
AudioData
*
s
=
s1
->
priv_data
;
audio_close
(
s
);
av_free
(
s
);
return
0
;
}
...
...
@@ -209,31 +202,23 @@ static int audio_write_trailer(AVFormatContext *s1)
static
int
audio_read_header
(
AVFormatContext
*
s1
,
AVFormatParameters
*
ap
)
{
AudioData
*
s
;
AudioData
*
s
=
s1
->
priv_data
;
AVStream
*
st
;
int
ret
;
if
(
!
ap
||
ap
->
sample_rate
<=
0
||
ap
->
channels
<=
0
)
return
-
1
;
s
=
av_mallocz
(
sizeof
(
AudioData
));
if
(
!
s
)
return
-
ENOMEM
;
st
=
av_mallocz
(
sizeof
(
AVStream
));
st
=
av_new_stream
(
s1
,
0
);
if
(
!
st
)
{
av_free
(
s
);
return
-
ENOMEM
;
}
s1
->
priv_data
=
s
;
s1
->
nb_streams
=
1
;
s1
->
streams
[
0
]
=
st
;
s
->
sample_rate
=
ap
->
sample_rate
;
s
->
channels
=
ap
->
channels
;
ret
=
audio_open
(
s
,
0
);
if
(
ret
<
0
)
{
av_free
(
st
);
av_free
(
s
);
return
-
EIO
;
}
else
{
/* take real parameters */
...
...
@@ -284,15 +269,26 @@ static int audio_read_close(AVFormatContext *s1)
AudioData
*
s
=
s1
->
priv_data
;
audio_close
(
s
);
av_free
(
s
);
return
0
;
}
AVFormat
audio_device_format
=
{
AVInputFormat
audio_in_format
=
{
"audio_device"
,
"audio grab and output"
,
sizeof
(
AudioData
),
NULL
,
audio_read_header
,
audio_read_packet
,
audio_read_close
,
flags:
AVFMT_NOFILE
,
};
AVOutputFormat
audio_out_format
=
{
"audio_device"
,
"audio grab and output"
,
""
,
""
,
sizeof
(
AudioData
),
/* XXX: we make the assumption that the soundcard accepts this format */
/* XXX: find better solution with "preinit" method, needed also in
other formats */
...
...
@@ -305,10 +301,12 @@ AVFormat audio_device_format = {
audio_write_header
,
audio_write_packet
,
audio_write_trailer
,
audio_read_header
,
audio_read_packet
,
audio_read_close
,
NULL
,
AVFMT_NOFILE
,
flags:
AVFMT_NOFILE
,
};
int
audio_init
(
void
)
{
av_register_input_format
(
&
audio_in_format
);
av_register_output_format
(
&
audio_out_format
);
return
0
;
}
libav/avi.h
View file @
c9a65ca8
...
...
@@ -23,8 +23,3 @@ extern CodecTag codec_wav_tags[];
unsigned
int
codec_get_tag
(
const
CodecTag
*
tags
,
int
id
);
int
codec_get_id
(
const
CodecTag
*
tags
,
unsigned
int
tag
);
/* avidec.c */
int
avi_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
);
int
avi_read_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
);
int
avi_read_close
(
AVFormatContext
*
s
);
libav/avidec.c
View file @
c9a65ca8
...
...
@@ -47,19 +47,13 @@ void print_tag(const char *str, unsigned int tag, int size)
int
avi_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
{
AVIContext
*
avi
;
AVIContext
*
avi
=
s
->
priv_data
;
ByteIOContext
*
pb
=
&
s
->
pb
;
UINT32
tag
,
tag1
;
int
codec_type
,
stream_index
,
size
,
frame_period
,
bit_rate
;
int
i
,
bps
;
AVStream
*
st
;
avi
=
av_malloc
(
sizeof
(
AVIContext
));
if
(
!
avi
)
return
-
1
;
memset
(
avi
,
0
,
sizeof
(
AVIContext
));
s
->
priv_data
=
avi
;
/* check RIFF header */
tag
=
get_le32
(
pb
);
...
...
@@ -246,7 +240,35 @@ int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
int
avi_read_close
(
AVFormatContext
*
s
)
{
AVIContext
*
avi
=
s
->
priv_data
;
av_free
(
avi
);
return
0
;
}
static
int
avi_probe
(
AVProbeData
*
p
)
{
/* check file header */
if
(
p
->
buf_size
<=
32
)
return
0
;
if
(
p
->
buf
[
0
]
==
'R'
&&
p
->
buf
[
1
]
==
'I'
&&
p
->
buf
[
2
]
==
'F'
&&
p
->
buf
[
3
]
==
'F'
&&
p
->
buf
[
8
]
==
'A'
&&
p
->
buf
[
9
]
==
'V'
&&
p
->
buf
[
10
]
==
'I'
&&
p
->
buf
[
11
]
==
' '
)
return
AVPROBE_SCORE_MAX
;
else
return
0
;
}
static
AVInputFormat
avi_iformat
=
{
"avi"
,
"avi format"
,
sizeof
(
AVIContext
),
avi_probe
,
avi_read_header
,
avi_read_packet
,
avi_read_close
,
};
int
avidec_init
(
void
)
{
av_register_input_format
(
&
avi_iformat
);
return
0
;
}
libav/avienc.c
View file @
c9a65ca8
...
...
@@ -143,18 +143,12 @@ void parse_specific_params(AVCodecContext *stream, int *au_byterate, int *au_ssi
static
int
avi_write_header
(
AVFormatContext
*
s
)
{
AVIContext
*
avi
;
AVIContext
*
avi
=
s
->
priv_data
;
ByteIOContext
*
pb
=
&
s
->
pb
;
int
bitrate
,
n
,
i
,
nb_frames
,
au_byterate
,
au_ssize
,
au_scale
;
AVCodecContext
*
stream
,
*
video_enc
;
offset_t
list1
,
list2
,
strh
,
strf
;
avi
=
av_malloc
(
sizeof
(
AVIContext
));
if
(
!
avi
)
return
-
1
;
memset
(
avi
,
0
,
sizeof
(
AVIContext
));
s
->
priv_data
=
avi
;
put_tag
(
pb
,
"RIFF"
);
put_le32
(
pb
,
0
);
/* file length */
put_tag
(
pb
,
"AVI "
);
...
...
@@ -388,23 +382,24 @@ static int avi_write_trailer(AVFormatContext *s)
url_fseek
(
pb
,
file_size
,
SEEK_SET
);
}
put_flush_packet
(
pb
);
av_free
(
avi
);
return
0
;
}
AV
Format
avi_format
=
{
static
AVOutput
Format
avi_
o
format
=
{
"avi"
,
"avi format"
,
"video/x-msvideo"
,
"avi"
,
sizeof
(
AVIContext
),
CODEC_ID_MP2
,
CODEC_ID_MSMPEG4
,
avi_write_header
,
avi_write_packet
,
avi_write_trailer
,
avi_read_header
,
avi_read_packet
,
avi_read_close
,
};
int
avienc_init
(
void
)
{
av_register_output_format
(
&
avi_oformat
);
return
0
;
}
libav/avio.c
View file @
c9a65ca8
...
...
@@ -105,14 +105,6 @@ offset_t url_seek(URLContext *h, offset_t pos, int whence)
return
ret
;
}
int
url_getformat
(
URLContext
*
h
,
URLFormat
*
f
)
{
memset
(
f
,
0
,
sizeof
(
*
f
));
if
(
!
h
->
prot
->
url_getformat
)
return
-
ENODATA
;
return
h
->
prot
->
url_getformat
(
h
,
f
);
}
int
url_close
(
URLContext
*
h
)
{
int
ret
;
...
...
libav/avio.h
View file @
c9a65ca8
...
...
@@ -12,16 +12,6 @@ struct URLContext {
void
*
priv_data
;
};
typedef
struct
URLFormat
{
char
format_name
[
32
];
int
sample_rate
;
int
frame_rate
;
int
channels
;
int
height
;
int
width
;
enum
PixelFormat
pix_fmt
;
}
URLFormat
;
typedef
struct
URLContext
URLContext
;
typedef
struct
URLPollEntry
{
...
...
@@ -36,7 +26,6 @@ int url_open(URLContext **h, const char *filename, int flags);
int
url_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
int
url_write
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
offset_t
url_seek
(
URLContext
*
h
,
offset_t
pos
,
int
whence
);
int
url_getformat
(
URLContext
*
h
,
URLFormat
*
f
);
int
url_close
(
URLContext
*
h
);
int
url_exist
(
const
char
*
filename
);
offset_t
url_filesize
(
URLContext
*
h
);
...
...
@@ -50,9 +39,6 @@ typedef struct URLProtocol {
int
(
*
url_write
)(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
offset_t
(
*
url_seek
)(
URLContext
*
h
,
offset_t
pos
,
int
whence
);
int
(
*
url_close
)(
URLContext
*
h
);
/* get precise information about the format, if available. return
-ENODATA if not available */
int
(
*
url_getformat
)(
URLContext
*
h
,
URLFormat
*
f
);
struct
URLProtocol
*
next
;
}
URLProtocol
;
...
...
libav/crc.c
View file @
c9a65ca8
...
...
@@ -61,15 +61,10 @@ typedef struct CRCState {
UINT32
crcval
;
}
CRCState
;
/* simple formats */
static
int
crc_write_header
(
struct
AVFormatContext
*
s
)
{
CRCState
*
crc
;
crc
=
av_malloc
(
sizeof
(
CRCState
));
if
(
!
crc
)
return
-
1
;
s
->
priv_data
=
crc
;
CRCState
*
crc
=
s
->
priv_data
;
/* init CRC */
crc
->
crcval
=
adler32
(
0
,
NULL
,
0
);
...
...
@@ -93,18 +88,24 @@ 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
;
}
AVFormat
crc_format
=
{
AV
Output
Format
crc_format
=
{
"crc"
,
"crc testing format"
,
NULL
,
""
,
sizeof
(
CRCState
),
CODEC_ID_PCM_S16LE
,
CODEC_ID_RAWVIDEO
,
crc_write_header
,
crc_write_packet
,
crc_write_trailer
,
};
int
crc_init
(
void
)
{
av_register_output_format
(
&
crc_format
);
return
0
;
}
libav/ffm.c
View file @
c9a65ca8
...
...
@@ -51,6 +51,9 @@ typedef struct FFMContext {
UINT8
packet
[
1
];
/* must be last */
}
FFMContext
;
/* disable pts hack for testing */
int
ffm_nopts
=
0
;
static
void
flush_packet
(
AVFormatContext
*
s
)
{
FFMContext
*
ffm
=
s
->
priv_data
;
...
...
@@ -112,18 +115,13 @@ static void ffm_write_data(AVFormatContext *s,
static
int
ffm_write_header
(
AVFormatContext
*
s
)
{
FFMContext
*
ffm
=
s
->
priv_data
;
AVStream
*
st
;
FFMStream
*
fst
;
FFMContext
*
ffm
;
ByteIOContext
*
pb
=
&
s
->
pb
;
AVCodecContext
*
codec
;
int
bit_rate
,
i
;
ffm
=
av_mallocz
(
sizeof
(
FFMContext
)
+
FFM_PACKET_SIZE
);
if
(
!
ffm
)
return
-
1
;
s
->
priv_data
=
ffm
;
ffm
->
packet_size
=
FFM_PACKET_SIZE
;
/* header */
...
...
@@ -177,7 +175,10 @@ static int ffm_write_header(AVFormatContext *s)
abort
();
}
/* hack to have real time */
fst
->
pts
=
gettime
();
if
(
ffm_nopts
)
fst
->
pts
=
0
;
else
fst
->
pts
=
gettime
();
}
/* flush until end of block reached */
...
...
@@ -200,7 +201,6 @@ static int ffm_write_header(AVFormatContext *s)
fst
=
st
->
priv_data
;
av_free
(
fst
);
}
av_free
(
ffm
);
return
-
1
;
}
...
...
@@ -252,7 +252,6 @@ static int ffm_write_trailer(AVFormatContext *s)
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
av_free
(
s
->
streams
[
i
]
->
priv_data
);
av_free
(
ffm
);
return
0
;
}
...
...
@@ -342,20 +341,14 @@ static int ffm_read_data(AVFormatContext *s,
static
int
ffm_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
{
FFMContext
*
ffm
=
s
->
priv_data
;
AVStream
*
st
;
FFMStream
*
fst
;
FFMContext
*
ffm
;
ByteIOContext
*
pb
=
&
s
->
pb
;
AVCodecContext
*
codec
;
int
i
;
UINT32
tag
;
ffm
=
av_mallocz
(
sizeof
(
FFMContext
)
+
FFM_PACKET_SIZE
);
if
(
!
ffm
)
return
-
1
;
s
->
priv_data
=
ffm
;
/* header */
tag
=
get_le32
(
pb
);
if
(
tag
!=
MKTAG
(
'F'
,
'F'
,
'M'
,
'1'
))
...
...
@@ -436,8 +429,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_free
(
st
);
}
}
if
(
ffm
)
av_free
(
ffm
);
return
-
1
;
}
...
...
@@ -619,19 +610,35 @@ static int ffm_read_close(AVFormatContext *s)
return
0
;
}
AVFormat
ffm_format
=
{
AVInputFormat
ffm_iformat
=
{
"ffm"
,
"ffm format"
,
sizeof
(
FFMContext
),
NULL
,
ffm_read_header
,
ffm_read_packet
,
ffm_read_close
,
ffm_seek
,
extensions:
"ffm"
,
};
AVOutputFormat
ffm_oformat
=
{
"ffm"
,
"ffm format"
,
""
,
"ffm"
,
sizeof
(
FFMContext
)
+
FFM_PACKET_SIZE
,
/* not really used */
CODEC_ID_MP2
,
CODEC_ID_MPEG1VIDEO
,
ffm_write_header
,
ffm_write_packet
,