Originally committed as revision 78 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -4,7 +4,11 @@ CFLAGS= $(OPTFLAGS) -Wall -g -I../libavcodec -DHAVE_AV_CONFIG_H | |||
| OBJS= rm.o mpeg.o asf.o avienc.o jpegenc.o swf.o wav.o raw.o \ | |||
| avidec.o ffm.o \ | |||
| avio.o aviobuf.o utils.o \ | |||
| udp.o http.o file.o grab.o audio.o img.o | |||
| udp.o http.o file.o img.o | |||
| ifeq ($(CONFIG_GRAB),yes) | |||
| OBJS+= grab.o audio.o | |||
| endif | |||
| LIB= libav.a | |||
| @@ -16,10 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| #include "avi.h" | |||
| @@ -202,8 +198,8 @@ static INT64 unix_to_file_time(int ti) | |||
| { | |||
| INT64 t; | |||
| t = ti * 10000000LL; | |||
| t += 116444736000000000LL; | |||
| t = ti * INT64_C(10000000); | |||
| t += INT64_C(116444736000000000); | |||
| return t; | |||
| } | |||
| @@ -535,13 +531,13 @@ static int asf_write_packet(AVFormatContext *s, int stream_index, | |||
| if (codec->codec_type == CODEC_TYPE_AUDIO) { | |||
| timestamp = (int)((float)codec->frame_number * codec->frame_size * 1000.0 / | |||
| codec->sample_rate); | |||
| duration = (codec->frame_number * codec->frame_size * 10000000LL) / | |||
| duration = (codec->frame_number * codec->frame_size * INT64_C(10000000)) / | |||
| codec->sample_rate; | |||
| } else { | |||
| timestamp = (int)((float)codec->frame_number * 1000.0 * FRAME_RATE_BASE / | |||
| codec->frame_rate); | |||
| duration = codec->frame_number * | |||
| ((10000000LL * FRAME_RATE_BASE) / codec->frame_rate); | |||
| ((INT64_C(10000000) * FRAME_RATE_BASE) / codec->frame_rate); | |||
| } | |||
| if (duration > asf->duration) | |||
| asf->duration = duration; | |||
| @@ -553,7 +549,7 @@ static int asf_write_packet(AVFormatContext *s, int stream_index, | |||
| static int asf_write_trailer(AVFormatContext *s) | |||
| { | |||
| ASFContext *asf = s->priv_data; | |||
| long long file_size; | |||
| INT64 file_size; | |||
| /* flush the current packet */ | |||
| if (asf->pb.buf_ptr > asf->pb.buffer) | |||
| @@ -920,7 +916,7 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) | |||
| break; | |||
| } | |||
| } | |||
| next_frame: | |||
| next_frame:; | |||
| } | |||
| return 0; | |||
| @@ -16,6 +16,8 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include "avformat.h" | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| @@ -24,11 +26,8 @@ | |||
| #include <fcntl.h> | |||
| #include <sys/ioctl.h> | |||
| #include <sys/mman.h> | |||
| #include <errno.h> | |||
| #include <sys/time.h> | |||
| #include "avformat.h" | |||
| const char *audio_device = "/dev/dsp"; | |||
| typedef struct { | |||
| @@ -1,8 +1,6 @@ | |||
| #include "avcodec.h" | |||
| #define FFMPEG_VERSION "0.4.5" | |||
| #include "avio.h" | |||
| /* packet functions */ | |||
| @@ -16,12 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <netinet/in.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| #include "avi.h" | |||
| @@ -157,7 +151,7 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| st->codec.width = get_le32(pb); | |||
| st->codec.height = get_le32(pb); | |||
| if (frame_period) | |||
| st->codec.frame_rate = (1000000LL * FRAME_RATE_BASE) / frame_period; | |||
| st->codec.frame_rate = (INT64_C(1000000) * FRAME_RATE_BASE) / frame_period; | |||
| else | |||
| st->codec.frame_rate = 25 * FRAME_RATE_BASE; | |||
| get_le16(pb); /* panes */ | |||
| @@ -16,11 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <netinet/in.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| #include "avi.h" | |||
| @@ -53,7 +48,7 @@ void end_tag(ByteIOContext *pb, offset_t start) | |||
| pos = url_ftell(pb); | |||
| url_fseek(pb, start - 4, SEEK_SET); | |||
| put_le32(pb, pos - start); | |||
| put_le32(pb, (UINT32)(pos - start)); | |||
| url_fseek(pb, pos, SEEK_SET); | |||
| } | |||
| @@ -179,7 +174,7 @@ static int avi_write_header(AVFormatContext *s) | |||
| } | |||
| nb_frames = 0; | |||
| put_le32(pb, 1000000LL * FRAME_RATE_BASE / video_enc->frame_rate); | |||
| put_le32(pb, (UINT32)(INT64_C(1000000) * FRAME_RATE_BASE / video_enc->frame_rate)); | |||
| put_le32(pb, bitrate / 8); /* XXX: not quite exact */ | |||
| put_le32(pb, 0); /* padding */ | |||
| put_le32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */ | |||
| @@ -340,7 +335,7 @@ static int avi_write_trailer(AVFormatContext *s) | |||
| /* update file size */ | |||
| file_size = url_ftell(pb); | |||
| url_fseek(pb, 4, SEEK_SET); | |||
| put_le32(pb, file_size - 8); | |||
| put_le32(pb, (UINT32)(file_size - 8)); | |||
| url_fseek(pb, file_size, SEEK_SET); | |||
| } | |||
| put_flush_packet(pb); | |||
| @@ -16,11 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| URLProtocol *first_protocol = NULL; | |||
| @@ -1,6 +1,6 @@ | |||
| /* output byte stream handling */ | |||
| typedef long long offset_t; | |||
| typedef INT64 offset_t; | |||
| /* unbuffered I/O */ | |||
| @@ -87,8 +87,8 @@ int init_put_byte(ByteIOContext *s, | |||
| void put_byte(ByteIOContext *s, int b); | |||
| void put_buffer(ByteIOContext *s, unsigned char *buf, int size); | |||
| void put_le64(ByteIOContext *s, unsigned long long val); | |||
| void put_be64(ByteIOContext *s, unsigned long long val); | |||
| void put_le64(ByteIOContext *s, UINT64 val); | |||
| void put_be64(ByteIOContext *s, UINT64 val); | |||
| void put_le32(ByteIOContext *s, unsigned int val); | |||
| void put_be32(ByteIOContext *s, unsigned int val); | |||
| void put_le16(ByteIOContext *s, unsigned int val); | |||
| @@ -105,12 +105,12 @@ void put_flush_packet(ByteIOContext *s); | |||
| int get_buffer(ByteIOContext *s, unsigned char *buf, int size); | |||
| int get_byte(ByteIOContext *s); | |||
| unsigned int get_le32(ByteIOContext *s); | |||
| unsigned long long get_le64(ByteIOContext *s); | |||
| UINT64 get_le64(ByteIOContext *s); | |||
| unsigned int get_le16(ByteIOContext *s); | |||
| unsigned int get_be16(ByteIOContext *s); | |||
| unsigned int get_be32(ByteIOContext *s); | |||
| unsigned long long get_be64(ByteIOContext *s); | |||
| UINT64 get_be64(ByteIOContext *s); | |||
| extern inline int url_is_streamed(ByteIOContext *s) | |||
| { | |||
| @@ -16,17 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <netinet/in.h> | |||
| #include <unistd.h> | |||
| #include <fcntl.h> | |||
| #include <sys/ioctl.h> | |||
| #include <errno.h> | |||
| #include <sys/time.h> | |||
| #include <getopt.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| #define IO_BUFFER_SIZE 32768 | |||
| @@ -186,16 +175,16 @@ void put_be32(ByteIOContext *s, unsigned int val) | |||
| put_byte(s, val); | |||
| } | |||
| void put_le64(ByteIOContext *s, unsigned long long val) | |||
| void put_le64(ByteIOContext *s, UINT64 val) | |||
| { | |||
| put_le32(s, val & 0xffffffff); | |||
| put_le32(s, val >> 32); | |||
| put_le32(s, (UINT32)(val & 0xffffffff)); | |||
| put_le32(s, (UINT32)(val >> 32)); | |||
| } | |||
| void put_be64(ByteIOContext *s, unsigned long long val) | |||
| void put_be64(ByteIOContext *s, UINT64 val) | |||
| { | |||
| put_be32(s, val >> 32); | |||
| put_be32(s, val & 0xffffffff); | |||
| put_be32(s, (UINT32)(val >> 32)); | |||
| put_be32(s, (UINT32)(val & 0xffffffff)); | |||
| } | |||
| void put_le16(ByteIOContext *s, unsigned int val) | |||
| @@ -287,7 +276,7 @@ unsigned int get_le32(ByteIOContext *s) | |||
| return val; | |||
| } | |||
| unsigned long long get_le64(ByteIOContext *s) | |||
| UINT64 get_le64(ByteIOContext *s) | |||
| { | |||
| UINT64 val; | |||
| val = (UINT64)get_le32(s); | |||
| @@ -313,7 +302,7 @@ unsigned int get_be32(ByteIOContext *s) | |||
| return val; | |||
| } | |||
| unsigned long long get_be64(ByteIOContext *s) | |||
| UINT64 get_be64(ByteIOContext *s) | |||
| { | |||
| UINT64 val; | |||
| val = (UINT64)get_be32(s) << 32; | |||
| @@ -335,7 +324,7 @@ int url_read_packet(void *opaque, UINT8 *buf, int buf_size) | |||
| return url_read(h, buf, buf_size); | |||
| } | |||
| int url_seek_packet(void *opaque, long long offset, int whence) | |||
| int url_seek_packet(void *opaque, INT64 offset, int whence) | |||
| { | |||
| URLContext *h = opaque; | |||
| url_seek(h, offset, whence); | |||
| @@ -16,13 +16,8 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <errno.h> | |||
| #include <string.h> | |||
| #include <unistd.h> | |||
| #include "avformat.h" | |||
| #include <unistd.h> | |||
| /* The FFM file is made of blocks of fixed size */ | |||
| #define FFM_HEADER_SIZE 14 | |||
| @@ -345,7 +340,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| if (!url_is_streamed(pb)) { | |||
| ffm->file_size = url_filesize(url_fileno(pb)); | |||
| } else { | |||
| ffm->file_size = (1ULL << 63) - 1; | |||
| ffm->file_size = (UINT64_C(1) << 63) - 1; | |||
| } | |||
| s->nb_streams = get_be32(pb); | |||
| @@ -16,15 +16,17 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <unistd.h> | |||
| #include "avformat.h" | |||
| #include <fcntl.h> | |||
| #ifndef CONFIG_WIN32 | |||
| #include <unistd.h> | |||
| #include <sys/ioctl.h> | |||
| #include <errno.h> | |||
| #include <sys/time.h> | |||
| #else | |||
| #include <io.h> | |||
| #define open(fname,oflag,pmode) _open(fname,oflag,pmode) | |||
| #endif /* CONFIG_WIN32 */ | |||
| #include "avformat.h" | |||
| /* standard file protocol */ | |||
| @@ -38,6 +40,9 @@ static int file_open(URLContext *h, const char *filename, int flags) | |||
| } else { | |||
| access = O_RDONLY; | |||
| } | |||
| #ifdef CONFIG_WIN32 | |||
| access |= O_BINARY; | |||
| #endif | |||
| fd = open(filename, access, 0666); | |||
| if (fd < 0) | |||
| return -ENOENT; | |||
| @@ -61,7 +66,11 @@ static int file_write(URLContext *h, unsigned char *buf, int size) | |||
| static offset_t file_seek(URLContext *h, offset_t pos, int whence) | |||
| { | |||
| int fd = (int)h->priv_data; | |||
| #ifdef CONFIG_WIN32 | |||
| return _lseeki64(fd, pos, whence); | |||
| #else | |||
| return lseek(fd, pos, whence); | |||
| #endif | |||
| } | |||
| static int file_close(URLContext *h) | |||
| @@ -16,18 +16,14 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| #include <linux/videodev.h> | |||
| #include <unistd.h> | |||
| #include <fcntl.h> | |||
| #include <sys/ioctl.h> | |||
| #include <sys/mman.h> | |||
| #include <errno.h> | |||
| #include <sys/time.h> | |||
| #include "avformat.h" | |||
| typedef struct { | |||
| int fd; | |||
| @@ -16,11 +16,8 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| #include <unistd.h> | |||
| #include <errno.h> | |||
| #include <ctype.h> | |||
| #include <sys/types.h> | |||
| #include <sys/socket.h> | |||
| @@ -28,7 +25,6 @@ | |||
| #include <arpa/inet.h> | |||
| #include <netdb.h> | |||
| #include "avformat.h" | |||
| /* XXX: POST protocol is not completly implemented because ffmpeg use | |||
| only a subset of it */ | |||
| @@ -16,14 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <unistd.h> | |||
| #include <fcntl.h> | |||
| #include <errno.h> | |||
| #include <string.h> | |||
| #include <math.h> | |||
| #include "avformat.h" | |||
| #define IMGFMT_YUV 1 | |||
| @@ -336,7 +328,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) | |||
| /* XXX: hack hack */ | |||
| h = url_fileno(f); | |||
| img_size = lseek((int)h->priv_data, 0, SEEK_END); | |||
| img_size = url_seek(h, 0, SEEK_END); | |||
| if (infer_size(&s->width, &s->height, img_size) < 0) { | |||
| goto fail1; | |||
| } | |||
| @@ -16,10 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <netinet/in.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| /* Multipart JPEG */ | |||
| @@ -0,0 +1,160 @@ | |||
| # 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 | |||
| @@ -16,13 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include <sys/time.h> | |||
| #include "avformat.h" | |||
| #define MAX_PAYLOAD_SIZE 4096 | |||
| @@ -67,7 +60,7 @@ typedef struct { | |||
| #define VIDEO_ID 0xe0 | |||
| static int put_pack_header(AVFormatContext *ctx, | |||
| UINT8 *buf, long long timestamp) | |||
| UINT8 *buf, INT64 timestamp) | |||
| { | |||
| MpegMuxContext *s = ctx->priv_data; | |||
| PutBitContext pb; | |||
| @@ -76,11 +69,11 @@ static int put_pack_header(AVFormatContext *ctx, | |||
| put_bits(&pb, 32, PACK_START_CODE); | |||
| put_bits(&pb, 4, 0x2); | |||
| put_bits(&pb, 3, (timestamp >> 30) & 0x07); | |||
| put_bits(&pb, 3, (UINT32)((timestamp >> 30) & 0x07)); | |||
| put_bits(&pb, 1, 1); | |||
| put_bits(&pb, 15, (timestamp >> 15) & 0x7fff); | |||
| put_bits(&pb, 15, (UINT32)((timestamp >> 15) & 0x7fff)); | |||
| put_bits(&pb, 1, 1); | |||
| put_bits(&pb, 15, (timestamp) & 0x7fff); | |||
| put_bits(&pb, 15, (UINT32)((timestamp) & 0x7fff)); | |||
| put_bits(&pb, 1, 1); | |||
| put_bits(&pb, 1, 1); | |||
| put_bits(&pb, 22, s->mux_rate); | |||
| @@ -281,8 +274,8 @@ static void flush_packet(AVFormatContext *ctx, int stream_index) | |||
| (0x02 << 4) | | |||
| (((timestamp >> 30) & 0x07) << 1) | | |||
| 1); | |||
| put_be16(&ctx->pb, (((timestamp >> 15) & 0x7fff) << 1) | 1); | |||
| put_be16(&ctx->pb, (((timestamp) & 0x7fff) << 1) | 1); | |||
| put_be16(&ctx->pb, (UINT16)((((timestamp >> 15) & 0x7fff) << 1) | 1)); | |||
| put_be16(&ctx->pb, (UINT16)((((timestamp) & 0x7fff) << 1) | 1)); | |||
| if (startcode == PRIVATE_STREAM_1) { | |||
| put_byte(&ctx->pb, id); | |||
| @@ -494,7 +487,6 @@ static int mpeg_mux_read_header(AVFormatContext *s, | |||
| codec_id = 0; | |||
| n = 0; | |||
| } | |||
| for(i=0;i<n;i++) { | |||
| st = av_mallocz(sizeof(AVStream)); | |||
| if (!st) | |||
| @@ -16,11 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <netinet/in.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| /* simple formats */ | |||
| @@ -16,11 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| /* in ms */ | |||
| @@ -330,12 +325,15 @@ static int rm_write_header(AVFormatContext *s) | |||
| static int rm_write_audio(AVFormatContext *s, UINT8 *buf, int size) | |||
| { | |||
| UINT8 buf1[size]; | |||
| UINT8 *buf1; | |||
| RMContext *rm = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| StreamInfo *stream = rm->audio_stream; | |||
| int i; | |||
| /* XXX: suppress this malloc */ | |||
| buf1= (UINT8*) malloc( size * sizeof(UINT8) ); | |||
| write_packet_header(s, stream, size, stream->enc->key_frame); | |||
| /* for AC3, the words seems to be reversed */ | |||
| @@ -346,6 +344,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); | |||
| return 0; | |||
| } | |||
| @@ -16,15 +16,8 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| #include <assert.h> | |||
| /* should have a generic way to indicate probable size */ | |||
| #define DUMMY_FILE_SIZE (100 * 1024 * 1024) | |||
| #define DUMMY_DURATION 600 /* in seconds */ | |||
| @@ -51,8 +44,8 @@ | |||
| #define SHAPE_ID 1 | |||
| typedef struct { | |||
| long long duration_pos; | |||
| long long tag_pos; | |||
| offset_t duration_pos; | |||
| offset_t tag_pos; | |||
| int tag; | |||
| } SWFContext; | |||
| @@ -76,7 +69,7 @@ static void put_swf_end_tag(AVFormatContext *s) | |||
| { | |||
| SWFContext *swf = s->priv_data; | |||
| ByteIOContext *pb = &s->pb; | |||
| long long pos; | |||
| offset_t pos; | |||
| int tag_len, tag; | |||
| pos = url_ftell(pb); | |||
| @@ -237,7 +230,7 @@ static int swf_write_header(AVFormatContext *s) | |||
| put_swf_rect(pb, 0, width, 0, height); | |||
| put_le16(pb, (rate * 256) / FRAME_RATE_BASE); /* frame rate */ | |||
| swf->duration_pos = url_ftell(pb); | |||
| put_le16(pb, DUMMY_DURATION * (INT64)rate / FRAME_RATE_BASE); /* frame count */ | |||
| put_le16(pb, (UINT16)(DUMMY_DURATION * (INT64)rate / FRAME_RATE_BASE)); /* frame count */ | |||
| /* define a shape with the jpeg inside */ | |||
| @@ -16,19 +16,14 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| #include <unistd.h> | |||
| #include <errno.h> | |||
| #include <sys/types.h> | |||
| #include <sys/socket.h> | |||
| #include <netinet/in.h> | |||
| #include <arpa/inet.h> | |||
| #include <netdb.h> | |||
| #include "avformat.h" | |||
| typedef struct { | |||
| int udp_socket; | |||
| int max_payload_size; /* in bytes */ | |||
| @@ -16,16 +16,17 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <string.h> | |||
| #include "avformat.h" | |||
| #ifndef CONFIG_WIN32 | |||
| #include <unistd.h> | |||
| #include <fcntl.h> | |||
| #include <errno.h> | |||
| #include <sys/time.h> | |||
| #include <time.h> | |||
| #include "avformat.h" | |||
| #else | |||
| #define strcasecmp _stricmp | |||
| #include <sys/types.h> | |||
| #include <sys/timeb.h> | |||
| #endif | |||
| AVFormat *first_format; | |||
| @@ -141,7 +142,9 @@ void register_all(void) | |||
| register_avformat(&wav_format); | |||
| register_avformat(&pcm_format); | |||
| register_avformat(&rawvideo_format); | |||
| #ifndef CONFIG_WIN32 | |||
| register_avformat(&ffm_format); | |||
| #endif | |||
| register_avformat(&pgm_format); | |||
| register_avformat(&ppm_format); | |||
| register_avformat(&pgmyuv_format); | |||
| @@ -152,10 +155,14 @@ void register_all(void) | |||
| register_protocol(&file_protocol); | |||
| register_protocol(&pipe_protocol); | |||
| #ifdef CONFIG_GRAB | |||
| register_protocol(&audio_protocol); | |||
| register_protocol(&video_protocol); | |||
| #endif | |||
| #ifndef CONFIG_WIN32 | |||
| register_protocol(&udp_protocol); | |||
| register_protocol(&http_protocol); | |||
| #endif | |||
| } | |||
| /* memory handling */ | |||
| @@ -422,9 +429,15 @@ int parse_image_size(int *width_ptr, int *height_ptr, const char *str) | |||
| INT64 gettime(void) | |||
| { | |||
| #ifdef CONFIG_WIN32 | |||
| struct _timeb tb; | |||
| _ftime(&tb); | |||
| return ((INT64)tb.time * INT64_C(1000) + (INT64)tb.millitm) * INT64_C(1000); | |||
| #else | |||
| struct timeval tv; | |||
| gettimeofday(&tv,NULL); | |||
| return (INT64)tv.tv_sec * 1000000 + tv.tv_usec; | |||
| #endif | |||
| } | |||
| /* syntax: [YYYY-MM-DD ][[HH:]MM:]SS[.m...] . Return the date in micro seconds since 1970 */ | |||
| @@ -16,11 +16,6 @@ | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #include <netinet/in.h> | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include "avformat.h" | |||
| #include "avi.h" | |||
| @@ -77,7 +72,7 @@ static int wav_write_trailer(AVFormatContext *s) | |||
| /* update file size */ | |||
| file_size = url_ftell(pb); | |||
| url_fseek(pb, 4, SEEK_SET); | |||
| put_le32(pb, file_size); | |||
| put_le32(pb, (UINT32)file_size); | |||
| url_fseek(pb, file_size, SEEK_SET); | |||
| put_flush_packet(pb); | |||
| @@ -89,7 +84,7 @@ static int wav_write_trailer(AVFormatContext *s) | |||
| /* return the size of the found tag */ | |||
| /* XXX: > 2GB ? */ | |||
| static int find_tag(ByteIOContext *pb, int tag1) | |||
| static int find_tag(ByteIOContext *pb, UINT32 tag1) | |||
| { | |||
| unsigned int tag; | |||
| int size; | |||