Originally committed as revision 84 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -16,12 +16,7 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include <inttypes.h> | |||||
| #include "libac3/ac3.h" | #include "libac3/ac3.h" | ||||
| /* currently, I use libac3 which is Copyright (C) Aaron Holtzman and | /* currently, I use libac3 which is Copyright (C) Aaron Holtzman and | ||||
| @@ -16,19 +16,14 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include <math.h> | |||||
| //#define DEBUG | |||||
| //#define DEBUG_BITALLOC | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include <math.h> | |||||
| #include "ac3enc.h" | #include "ac3enc.h" | ||||
| #include "ac3tab.h" | #include "ac3tab.h" | ||||
| //#define DEBUG | |||||
| //#define DEBUG_BITALLOC | |||||
| #define NDEBUG | |||||
| #include <assert.h> | |||||
| #define MDCT_NBITS 9 | #define MDCT_NBITS 9 | ||||
| #define N (1 << MDCT_NBITS) | #define N (1 << MDCT_NBITS) | ||||
| @@ -16,20 +16,8 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #ifdef __FreeBSD__ | |||||
| #include <sys/param.h> | |||||
| #endif | |||||
| #include <netinet/in.h> | |||||
| #include <math.h> | |||||
| #include "common.h" | #include "common.h" | ||||
| #define NDEBUG | |||||
| #include <assert.h> | |||||
| #include "../bswap.h" | |||||
| #include <math.h> | |||||
| void init_put_bits(PutBitContext *s, | void init_put_bits(PutBitContext *s, | ||||
| UINT8 *buffer, int buffer_size, | UINT8 *buffer, int buffer_size, | ||||
| @@ -79,7 +67,7 @@ void put_bits(PutBitContext *s, int n, unsigned int value) | |||||
| bit_cnt+=n; | bit_cnt+=n; | ||||
| } else { | } else { | ||||
| bit_buf |= value >> (n + bit_cnt - 32); | bit_buf |= value >> (n + bit_cnt - 32); | ||||
| *(UINT32 *)s->buf_ptr = htonl(bit_buf); | |||||
| *(UINT32 *)s->buf_ptr = be2me_32(bit_buf); | |||||
| //printf("bitbuf = %08x\n", bit_buf); | //printf("bitbuf = %08x\n", bit_buf); | ||||
| s->buf_ptr+=4; | s->buf_ptr+=4; | ||||
| if (s->buf_ptr >= s->buf_end) | if (s->buf_ptr >= s->buf_end) | ||||
| @@ -97,9 +85,9 @@ void put_bits(PutBitContext *s, int n, unsigned int value) | |||||
| } | } | ||||
| /* return the number of bits output */ | /* return the number of bits output */ | ||||
| long long get_bit_count(PutBitContext *s) | |||||
| INT64 get_bit_count(PutBitContext *s) | |||||
| { | { | ||||
| return (s->buf_ptr - s->buf + s->data_out_size) * 8 + (long long)s->bit_cnt; | |||||
| return (s->buf_ptr - s->buf + s->data_out_size) * 8 + (INT64)s->bit_cnt; | |||||
| } | } | ||||
| void align_put_bits(PutBitContext *s) | void align_put_bits(PutBitContext *s) | ||||
| @@ -1,10 +1,86 @@ | |||||
| #ifndef COMMON_H | #ifndef COMMON_H | ||||
| #define COMMON_H | #define COMMON_H | ||||
| #define FFMPEG_VERSION "0.4.5" | |||||
| #ifdef WIN32 | |||||
| #define CONFIG_WIN32 | |||||
| #endif | |||||
| #ifdef HAVE_AV_CONFIG_H | #ifdef HAVE_AV_CONFIG_H | ||||
| /* only include the following when compiling package */ | |||||
| #include "../config.h" | #include "../config.h" | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include <errno.h> | |||||
| #ifndef ENODATA | |||||
| #define ENODATA 61 | |||||
| #endif | |||||
| #endif | |||||
| #ifdef CONFIG_WIN32 | |||||
| /* windows */ | |||||
| typedef unsigned short UINT16; | |||||
| typedef signed short INT16; | |||||
| typedef unsigned char UINT8; | |||||
| typedef unsigned int UINT32; | |||||
| typedef unsigned __int64 UINT64; | |||||
| typedef signed char INT8; | |||||
| typedef signed int INT32; | |||||
| typedef signed __int64 INT64; | |||||
| typedef UINT8 uint8_t; | |||||
| typedef INT8 int8_t; | |||||
| typedef UINT16 uint16_t; | |||||
| typedef INT16 int16_t; | |||||
| typedef UINT32 uint32_t; | |||||
| typedef INT32 int32_t; | |||||
| #define INT64_C(c) (c ## i64) | |||||
| #define UINT64_C(c) (c ## i64) | |||||
| #define inline __inline | |||||
| /* | |||||
| Disable warning messages: | |||||
| warning C4244: '=' : conversion from 'double' to 'float', possible loss of data | |||||
| warning C4305: 'argument' : truncation from 'const double' to 'float' | |||||
| */ | |||||
| #pragma warning( disable : 4244 ) | |||||
| #pragma warning( disable : 4305 ) | |||||
| #define M_PI 3.14159265358979323846 | |||||
| #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ | |||||
| #ifdef _DEBUG | |||||
| #define DEBUG | |||||
| #endif | #endif | ||||
| // code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. | |||||
| #define bswap_32(x) \ | |||||
| ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ | |||||
| (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) | |||||
| #define be2me_32(x) bswap_32(x) | |||||
| #define snprintf _snprintf | |||||
| #define CONFIG_ENCODERS 1 | |||||
| #define CONFIG_DECODERS 1 | |||||
| #define CONFIG_AC3 1 | |||||
| #define CONFIG_MPGLIB 1 | |||||
| #else | |||||
| /* unix */ | |||||
| #include <inttypes.h> | |||||
| #ifndef __WINE_WINDEF16_H | #ifndef __WINE_WINDEF16_H | ||||
| /* workaround for typedef conflict in MPlayer (wine typedefs) */ | /* workaround for typedef conflict in MPlayer (wine typedefs) */ | ||||
| typedef unsigned short UINT16; | typedef unsigned short UINT16; | ||||
| @@ -18,6 +94,32 @@ typedef signed char INT8; | |||||
| typedef signed int INT32; | typedef signed int INT32; | ||||
| typedef signed long long INT64; | typedef signed long long INT64; | ||||
| #ifdef HAVE_AV_CONFIG_H | |||||
| #ifdef __FreeBSD__ | |||||
| #include <sys/param.h> | |||||
| #endif | |||||
| #ifndef INT64_C | |||||
| #define INT64_C(c) (c ## LL) | |||||
| #define UINT64_C(c) (c ## ULL) | |||||
| #endif | |||||
| #include "../bswap.h" | |||||
| #ifdef USE_FASTMEMCPY | |||||
| #include "fastmemcpy.h" | |||||
| #endif | |||||
| #ifndef DEBUG | |||||
| #define NDEBUG | |||||
| #endif | |||||
| #include <assert.h> | |||||
| #endif /* HAVE_AV_CONFIG_H */ | |||||
| #endif /* !CONFIG_WIN32 */ | |||||
| /* bit output */ | /* bit output */ | ||||
| struct PutBitContext; | struct PutBitContext; | ||||
| @@ -28,7 +130,7 @@ typedef struct PutBitContext { | |||||
| UINT32 bit_buf; | UINT32 bit_buf; | ||||
| int bit_cnt; | int bit_cnt; | ||||
| UINT8 *buf, *buf_ptr, *buf_end; | UINT8 *buf, *buf_ptr, *buf_end; | ||||
| long long data_out_size; /* in bytes */ | |||||
| INT64 data_out_size; /* in bytes */ | |||||
| void *opaque; | void *opaque; | ||||
| WriteDataFunc write_data; | WriteDataFunc write_data; | ||||
| } PutBitContext; | } PutBitContext; | ||||
| @@ -38,7 +140,7 @@ void init_put_bits(PutBitContext *s, | |||||
| void *opaque, | void *opaque, | ||||
| void (*write_data)(void *, UINT8 *, int)); | void (*write_data)(void *, UINT8 *, int)); | ||||
| void put_bits(PutBitContext *s, int n, unsigned int value); | void put_bits(PutBitContext *s, int n, unsigned int value); | ||||
| long long get_bit_count(PutBitContext *s); | |||||
| INT64 get_bit_count(PutBitContext *s); | |||||
| void align_put_bits(PutBitContext *s); | void align_put_bits(PutBitContext *s); | ||||
| void flush_put_bits(PutBitContext *s); | void flush_put_bits(PutBitContext *s); | ||||
| @@ -16,10 +16,6 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include "dsputil.h" | #include "dsputil.h" | ||||
| @@ -481,7 +477,9 @@ static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap, | |||||
| { | { | ||||
| UINT8 *src, *ptr; | UINT8 *src, *ptr; | ||||
| int y, y1, i; | int y, y1, i; | ||||
| UINT8 buf[5 * width]; | |||||
| UINT8 *buf; | |||||
| buf= (UINT8*) malloc(5 * width); | |||||
| src = src1; | src = src1; | ||||
| for(y=0;y<height;y+=2) { | for(y=0;y<height;y+=2) { | ||||
| @@ -511,6 +509,7 @@ static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap, | |||||
| dst += dst_wrap; | dst += dst_wrap; | ||||
| src += (2 + 1) * src_wrap; | src += (2 + 1) * src_wrap; | ||||
| } | } | ||||
| free(buf); | |||||
| } | } | ||||
| @@ -20,10 +20,7 @@ | |||||
| * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| * | * | ||||
| */ | */ | ||||
| #include <inttypes.h> | |||||
| #include <stdlib.h> | |||||
| #include <string.h> | |||||
| #include "../common.h" | |||||
| #include "ac3.h" | #include "ac3.h" | ||||
| #include "ac3_internal.h" | #include "ac3_internal.h" | ||||
| @@ -21,10 +21,7 @@ | |||||
| * | * | ||||
| */ | */ | ||||
| #include <inttypes.h> | |||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include "../common.h" | |||||
| #include "ac3.h" | #include "ac3.h" | ||||
| #include "ac3_internal.h" | #include "ac3_internal.h" | ||||
| #include "bitstream.h" | #include "bitstream.h" | ||||
| @@ -25,11 +25,8 @@ | |||||
| * | * | ||||
| */ | */ | ||||
| #include <inttypes.h> | |||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include "../common.h" | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <string.h> | |||||
| #include "ac3.h" | #include "ac3.h" | ||||
| #include "ac3_internal.h" | #include "ac3_internal.h" | ||||
| @@ -22,11 +22,7 @@ | |||||
| * | * | ||||
| */ | */ | ||||
| //#include "config.h" | |||||
| #include <inttypes.h> | |||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include "../common.h" | |||||
| #include <math.h> | #include <math.h> | ||||
| #include "ac3.h" | #include "ac3.h" | ||||
| #include "ac3_internal.h" | #include "ac3_internal.h" | ||||
| @@ -22,9 +22,7 @@ | |||||
| * | * | ||||
| */ | */ | ||||
| #include <inttypes.h> | |||||
| #include <string.h> | |||||
| #include "../common.h" | |||||
| #include "ac3.h" | #include "ac3.h" | ||||
| #include "ac3_internal.h" | #include "ac3_internal.h" | ||||
| @@ -0,0 +1,304 @@ | |||||
| # Microsoft Developer Studio Project File - Name="libavcodec" - Package Owner=<4> | |||||
| # Microsoft Developer Studio Generated Build File, Format Version 6.00 | |||||
| # ** DO NOT EDIT ** | |||||
| # TARGTYPE "Win32 (x86) Static Library" 0x0104 | |||||
| CFG=libavcodec - 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 "libavcodec.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 "libavcodec.mak" CFG="libavcodec - Win32 Debug" | |||||
| !MESSAGE | |||||
| !MESSAGE Possible choices for configuration are: | |||||
| !MESSAGE | |||||
| !MESSAGE "libavcodec - Win32 Release" (based on "Win32 (x86) Static Library") | |||||
| !MESSAGE "libavcodec - 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)" == "libavcodec - 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/libavcodec" | |||||
| # PROP Intermediate_Dir "../Release/libavcodec" | |||||
| # 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 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /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)" == "libavcodec - 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/libavcodec" | |||||
| # PROP Intermediate_Dir "../Debug/libavcodec" | |||||
| # 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 /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /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 | |||||
| # ADD LIB32 /nologo | |||||
| !ENDIF | |||||
| # Begin Target | |||||
| # Name "libavcodec - Win32 Release" | |||||
| # Name "libavcodec - Win32 Debug" | |||||
| # Begin Group "Source Files" | |||||
| # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" | |||||
| # Begin Group "libac3" | |||||
| # PROP Default_Filter "" | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\ac3.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\ac3_internal.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\bit_allocate.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\bitstream.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\bitstream.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\downmix.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\imdct.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\parse.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\libac3\tables.h | |||||
| # End Source File | |||||
| # End Group | |||||
| # Begin Group "mpglib" | |||||
| # PROP Default_Filter "" | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\dct64_i386.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\decode_i386.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\huffman.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\l2tables.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\layer1.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\layer2.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\layer3.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\mpg123.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpglib\tabinit.c | |||||
| # End Source File | |||||
| # End Group | |||||
| # Begin Source File | |||||
| SOURCE=.\ac3dec.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\ac3enc.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\ac3enc.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\ac3tab.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\avcodec.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\common.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\common.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\dsputil.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\dsputil.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\fastmemcpy.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\h263.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\h263data.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\h263dec.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\imgconvert.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\imgresample.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\jfdctfst.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\jrevdct.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mjpeg.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\motion_est.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpeg12.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpeg12data.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpeg4data.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpegaudio.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpegaudio.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpegaudiodec.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpegaudiotab.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpegvideo.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\mpegvideo.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\msmpeg4.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\msmpeg4data.h | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\resample.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\rv10.c | |||||
| # End Source File | |||||
| # Begin Source File | |||||
| SOURCE=.\utils.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,8 +16,6 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include "dsputil.h" | #include "dsputil.h" | ||||
| #include "mpegvideo.h" | #include "mpegvideo.h" | ||||
| @@ -423,12 +421,20 @@ void mjpeg_encode_mb(MpegEncContext *s, | |||||
| //#define DEBUG | //#define DEBUG | ||||
| #ifndef CONFIG_WIN32 | |||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| #define dprintf(fmt,args...) printf(fmt, ## args) | #define dprintf(fmt,args...) printf(fmt, ## args) | ||||
| #else | #else | ||||
| #define dprintf(fmt,args...) | #define dprintf(fmt,args...) | ||||
| #endif | #endif | ||||
| #else | |||||
| inline void dprintf(const char* fmt,...) {} | |||||
| #endif | |||||
| /* compressed picture size */ | /* compressed picture size */ | ||||
| #define PICTURE_BUFFER_SIZE 100000 | #define PICTURE_BUFFER_SIZE 100000 | ||||
| @@ -16,26 +16,28 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include "dsputil.h" | #include "dsputil.h" | ||||
| #include "mpegvideo.h" | #include "mpegvideo.h" | ||||
| #include "mpeg12data.h" | #include "mpeg12data.h" | ||||
| #ifdef USE_FASTMEMCPY | |||||
| #include "fastmemcpy.h" | |||||
| #endif | |||||
| //#define DEBUG | //#define DEBUG | ||||
| #ifndef CONFIG_WIN32 | |||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| #define dprintf(fmt,args...) printf(fmt, ## args) | #define dprintf(fmt,args...) printf(fmt, ## args) | ||||
| #else | #else | ||||
| #define dprintf(fmt,args...) | #define dprintf(fmt,args...) | ||||
| #endif | #endif | ||||
| #else | |||||
| inline void dprintf(const char* fmt,...) {} | |||||
| #endif | |||||
| /* Start codes. */ | /* Start codes. */ | ||||
| #define SEQ_END_CODE 0x000001b7 | #define SEQ_END_CODE 0x000001b7 | ||||
| #define SEQ_START_CODE 0x000001b3 | #define SEQ_START_CODE 0x000001b3 | ||||
| @@ -118,11 +120,11 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) | |||||
| fps = frame_rate_tab[s->frame_rate_index]; | fps = frame_rate_tab[s->frame_rate_index]; | ||||
| time_code = s->fake_picture_number * FRAME_RATE_BASE; | time_code = s->fake_picture_number * FRAME_RATE_BASE; | ||||
| s->gop_picture_number = s->fake_picture_number; | s->gop_picture_number = s->fake_picture_number; | ||||
| put_bits(&s->pb, 5, (time_code / (fps * 3600)) % 24); | |||||
| put_bits(&s->pb, 6, (time_code / (fps * 60)) % 60); | |||||
| put_bits(&s->pb, 5, (UINT32)((time_code / (fps * 3600)) % 24)); | |||||
| put_bits(&s->pb, 6, (UINT32)((time_code / (fps * 60)) % 60)); | |||||
| put_bits(&s->pb, 1, 1); | put_bits(&s->pb, 1, 1); | ||||
| put_bits(&s->pb, 6, (time_code / fps) % 60); | |||||
| put_bits(&s->pb, 6, (time_code % fps) / FRAME_RATE_BASE); | |||||
| put_bits(&s->pb, 6, (UINT32)((time_code / fps) % 60)); | |||||
| put_bits(&s->pb, 6, (UINT32)((time_code % fps) / FRAME_RATE_BASE)); | |||||
| put_bits(&s->pb, 1, 1); /* closed gop */ | put_bits(&s->pb, 1, 1); /* closed gop */ | ||||
| put_bits(&s->pb, 1, 0); /* broken link */ | put_bits(&s->pb, 1, 0); /* broken link */ | ||||
| } | } | ||||
| @@ -288,27 +288,73 @@ static const UINT8 mbPatTable[63][2] = { | |||||
| #define MB_QUANT 0x10 | #define MB_QUANT 0x10 | ||||
| static const UINT8 table_mb_ptype[32][2] = { | static const UINT8 table_mb_ptype[32][2] = { | ||||
| [ MB_FOR|MB_PAT ] { 1, 1 }, | |||||
| [ MB_PAT ] { 1, 2 }, | |||||
| [ MB_FOR ] { 1, 3 }, | |||||
| [ MB_INTRA ] { 3, 5 }, | |||||
| [ MB_QUANT|MB_FOR|MB_PAT ] { 2, 5 }, | |||||
| [ MB_QUANT|MB_PAT ] { 1, 5 }, | |||||
| [ MB_QUANT|MB_INTRA ] { 1, 6 }, | |||||
| { 0, 0 }, // 0x00 | |||||
| { 3, 5 }, // 0x01 MB_INTRA | |||||
| { 1, 2 }, // 0x02 MB_PAT | |||||
| { 0, 0 }, // 0x03 | |||||
| { 0, 0 }, // 0x04 | |||||
| { 0, 0 }, // 0x05 | |||||
| { 0, 0 }, // 0x06 | |||||
| { 0, 0 }, // 0x07 | |||||
| { 1, 3 }, // 0x08 MB_FOR | |||||
| { 0, 0 }, // 0x09 | |||||
| { 1, 1 }, // 0x0A MB_FOR|MB_PAT | |||||
| { 0, 0 }, // 0x0B | |||||
| { 0, 0 }, // 0x0C | |||||
| { 0, 0 }, // 0x0D | |||||
| { 0, 0 }, // 0x0E | |||||
| { 0, 0 }, // 0x0F | |||||
| { 0, 0 }, // 0x10 | |||||
| { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA | |||||
| { 1, 5 }, // 0x12 MB_QUANT|MB_PAT | |||||
| { 0, 0 }, // 0x13 | |||||
| { 0, 0 }, // 0x14 | |||||
| { 0, 0 }, // 0x15 | |||||
| { 0, 0 }, // 0x16 | |||||
| { 0, 0 }, // 0x17 | |||||
| { 0, 0 }, // 0x18 | |||||
| { 0, 0 }, // 0x19 | |||||
| { 2, 5 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT | |||||
| { 0, 0 }, // 0x1B | |||||
| { 0, 0 }, // 0x1C | |||||
| { 0, 0 }, // 0x1D | |||||
| { 0, 0 }, // 0x1E | |||||
| { 0, 0 }, // 0x1F | |||||
| }; | }; | ||||
| static const UINT8 table_mb_btype[32][2] = { | static const UINT8 table_mb_btype[32][2] = { | ||||
| [ MB_FOR|MB_BACK ] { 2, 2 }, | |||||
| [ MB_FOR|MB_BACK|MB_PAT ] { 3, 2 }, | |||||
| [ MB_BACK ] { 2, 3 }, | |||||
| [ MB_BACK|MB_PAT ] { 3, 3 }, | |||||
| [ MB_FOR ] { 2, 4 }, | |||||
| [ MB_FOR|MB_PAT ] { 3, 4 }, | |||||
| [ MB_INTRA ] { 3, 5 }, | |||||
| [ MB_QUANT|MB_FOR|MB_BACK|MB_PAT ] { 2, 5 }, | |||||
| [ MB_QUANT|MB_FOR|MB_PAT ] { 3, 6 }, | |||||
| [ MB_QUANT|MB_BACK|MB_PAT ] { 2, 6 }, | |||||
| [ MB_QUANT|MB_INTRA ] { 1, 6 }, | |||||
| { 0, 0 }, // 0x00 | |||||
| { 3, 5 }, // 0x01 MB_INTRA | |||||
| { 0, 0 }, // 0x02 | |||||
| { 0, 0 }, // 0x03 | |||||
| { 2, 3 }, // 0x04 MB_BACK | |||||
| { 0, 0 }, // 0x05 | |||||
| { 3, 3 }, // 0x06 MB_BACK|MB_PAT | |||||
| { 0, 0 }, // 0x07 | |||||
| { 2, 4 }, // 0x08 MB_FOR | |||||
| { 0, 0 }, // 0x09 | |||||
| { 3, 4 }, // 0x0A MB_FOR|MB_PAT | |||||
| { 0, 0 }, // 0x0B | |||||
| { 2, 2 }, // 0x0C MB_FOR|MB_BACK | |||||
| { 0, 0 }, // 0x0D | |||||
| { 3, 2 }, // 0x0E MB_FOR|MB_BACK|MB_PAT | |||||
| { 0, 0 }, // 0x0F | |||||
| { 0, 0 }, // 0x10 | |||||
| { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA | |||||
| { 0, 0 }, // 0x12 | |||||
| { 0, 0 }, // 0x13 | |||||
| { 0, 0 }, // 0x14 | |||||
| { 0, 0 }, // 0x15 | |||||
| { 2, 6 }, // 0x16 MB_QUANT|MB_BACK|MB_PAT | |||||
| { 0, 0 }, // 0x17 | |||||
| { 0, 0 }, // 0x18 | |||||
| { 0, 0 }, // 0x19 | |||||
| { 3, 6 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT | |||||
| { 0, 0 }, // 0x1B | |||||
| { 0, 0 }, // 0x1C | |||||
| { 0, 0 }, // 0x1D | |||||
| { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT | |||||
| { 0, 0 }, // 0x1F | |||||
| }; | }; | ||||
| static const UINT8 mbMotionVectorTable[17][2] = { | static const UINT8 mbMotionVectorTable[17][2] = { | ||||
| @@ -16,16 +16,10 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include <math.h> | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include <math.h> | |||||
| #include "mpegaudio.h" | #include "mpegaudio.h" | ||||
| #define NDEBUG | |||||
| #include <assert.h> | |||||
| /* define it to use floats in quantization (I don't like floats !) */ | /* define it to use floats in quantization (I don't like floats !) */ | ||||
| //#define USE_FLOATS | //#define USE_FLOATS | ||||
| @@ -19,7 +19,7 @@ typedef struct MpegAudioContext { | |||||
| int bitrate_index; /* bit rate */ | int bitrate_index; /* bit rate */ | ||||
| int freq_index; | int freq_index; | ||||
| int frame_size; /* frame size, in bits, without padding */ | int frame_size; /* frame size, in bits, without padding */ | ||||
| long long nb_samples; /* total number of samples encoded */ | |||||
| INT64 nb_samples; /* total number of samples encoded */ | |||||
| /* padding computation */ | /* padding computation */ | ||||
| int frame_frac, frame_frac_incr, do_padding; | int frame_frac, frame_frac_incr, do_padding; | ||||
| short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */ | short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */ | ||||
| @@ -81,7 +81,8 @@ static void convert_matrix(int *qmat, const UINT16 *quant_matrix, int qscale) | |||||
| /* 16 <= qscale * quant_matrix[i] <= 7905 */ | /* 16 <= qscale * quant_matrix[i] <= 7905 */ | ||||
| /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ | /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ | ||||
| qmat[i] = (int)((1ULL << (QMAT_SHIFT + 11)) / (aanscales[i] * qscale * quant_matrix[i])); | |||||
| qmat[i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 11)) / | |||||
| (aanscales[i] * qscale * quant_matrix[i])); | |||||
| } | } | ||||
| } else { | } else { | ||||
| for(i=0;i<64;i++) { | for(i=0;i<64;i++) { | ||||
| @@ -983,6 +984,10 @@ static int dct_quantize(MpegEncContext *s, | |||||
| av_fdct (block); | av_fdct (block); | ||||
| /* we need this permutation so that we correct the IDCT | |||||
| permutation. will be moved into DCT code */ | |||||
| block_permute(block); | |||||
| if (s->mb_intra) { | if (s->mb_intra) { | ||||
| if (n < 4) | if (n < 4) | ||||
| q = s->y_dc_scale; | q = s->y_dc_scale; | ||||
| @@ -1251,7 +1256,7 @@ static void rate_control_init(MpegEncContext *s) | |||||
| */ | */ | ||||
| static int rate_estimate_qscale(MpegEncContext *s) | static int rate_estimate_qscale(MpegEncContext *s) | ||||
| { | { | ||||
| long long total_bits = s->total_bits; | |||||
| INT64 total_bits = s->total_bits; | |||||
| float q; | float q; | ||||
| int qscale, diff, qmin; | int qscale, diff, qmin; | ||||
| @@ -1276,9 +1281,9 @@ static int rate_estimate_qscale(MpegEncContext *s) | |||||
| q = 31; | q = 31; | ||||
| qscale = (int)(q + 0.5); | qscale = (int)(q + 0.5); | ||||
| #if defined(DEBUG) | #if defined(DEBUG) | ||||
| printf("%d: total=%Ld br=%0.1f diff=%d qest=%0.1f\n", | |||||
| printf("%d: total=%0.0f br=%0.1f diff=%d qest=%0.1f\n", | |||||
| s->picture_number, | s->picture_number, | ||||
| total_bits, | |||||
| (double)total_bits, | |||||
| (float)s->frame_rate / FRAME_RATE_BASE * | (float)s->frame_rate / FRAME_RATE_BASE * | ||||
| total_bits / s->picture_number, | total_bits / s->picture_number, | ||||
| diff, q); | diff, q); | ||||
| @@ -125,11 +125,14 @@ typedef struct MpegEncContext { | |||||
| /* bit rate control */ | /* bit rate control */ | ||||
| int I_frame_bits; /* wanted number of bits per I frame */ | int I_frame_bits; /* wanted number of bits per I frame */ | ||||
| int P_frame_bits; /* same for P frame */ | int P_frame_bits; /* same for P frame */ | ||||
| long long wanted_bits; | |||||
| long long total_bits; | |||||
| INT64 wanted_bits; | |||||
| INT64 total_bits; | |||||
| /* mpeg4 specific */ | /* mpeg4 specific */ | ||||
| int time_increment_bits; | int time_increment_bits; | ||||
| int shape; | |||||
| int vol_sprite_usage; | |||||
| int quant_precision; | |||||
| /* RV10 specific */ | /* RV10 specific */ | ||||
| int rv10_version; /* RV10 version: 0 or 3 */ | int rv10_version; /* RV10 version: 0 or 3 */ | ||||
| @@ -16,14 +16,8 @@ | |||||
| * along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| */ | */ | ||||
| #include <stdlib.h> | |||||
| #include <stdio.h> | |||||
| #include <string.h> | |||||
| #include <math.h> | |||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #define NDEBUG | |||||
| #include <assert.h> | |||||
| #include <math.h> | |||||
| typedef struct { | typedef struct { | ||||
| /* fractional resampling */ | /* fractional resampling */ | ||||
| @@ -196,9 +190,11 @@ static void stereo_mux(short *output, short *input1, short *input2, int n) | |||||
| static int mono_resample(ReSampleChannelContext *s, short *output, short *input, int nb_samples) | static int mono_resample(ReSampleChannelContext *s, short *output, short *input, int nb_samples) | ||||
| { | { | ||||
| short buf1[nb_samples]; | |||||
| short *buf1; | |||||
| short *buftmp; | short *buftmp; | ||||
| buf1= (short*) malloc( nb_samples * sizeof(short) ); | |||||
| /* first downsample by an integer factor with averaging filter */ | /* first downsample by an integer factor with averaging filter */ | ||||
| if (s->iratio > 1) { | if (s->iratio > 1) { | ||||
| buftmp = buf1; | buftmp = buf1; | ||||
| @@ -213,6 +209,7 @@ static int mono_resample(ReSampleChannelContext *s, short *output, short *input, | |||||
| } else { | } else { | ||||
| memcpy(output, buftmp, nb_samples * sizeof(short)); | memcpy(output, buftmp, nb_samples * sizeof(short)); | ||||
| } | } | ||||
| free(buf1); | |||||
| return nb_samples; | return nb_samples; | ||||
| } | } | ||||
| @@ -251,9 +248,10 @@ ReSampleContext *audio_resample_init(int output_channels, int input_channels, | |||||
| int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples) | int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples) | ||||
| { | { | ||||
| int i, nb_samples1; | int i, nb_samples1; | ||||
| short bufin[2][nb_samples]; | |||||
| short bufout[2][(int)(nb_samples * s->ratio) + 16]; /* make some zoom to avoid round pb */ | |||||
| short *bufin[2]; | |||||
| short *bufout[2]; | |||||
| short *buftmp2[2], *buftmp3[2]; | short *buftmp2[2], *buftmp3[2]; | ||||
| int lenout; | |||||
| if (s->input_channels == s->output_channels && s->ratio == 1.0) { | if (s->input_channels == s->output_channels && s->ratio == 1.0) { | ||||
| /* nothing to do */ | /* nothing to do */ | ||||
| @@ -261,6 +259,15 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl | |||||
| return nb_samples; | return nb_samples; | ||||
| } | } | ||||
| /* XXX: move those malloc to resample init code */ | |||||
| bufin[0]= (short*) malloc( nb_samples * sizeof(short) ); | |||||
| bufin[1]= (short*) malloc( nb_samples * sizeof(short) ); | |||||
| /* make some zoom to avoid round pb */ | |||||
| lenout= (int)(nb_samples * s->ratio) + 16; | |||||
| bufout[0]= (short*) malloc( lenout * sizeof(short) ); | |||||
| bufout[1]= (short*) malloc( lenout * sizeof(short) ); | |||||
| if (s->input_channels == 2 && | if (s->input_channels == 2 && | ||||
| s->output_channels == 1) { | s->output_channels == 1) { | ||||
| buftmp2[0] = bufin[0]; | buftmp2[0] = bufin[0]; | ||||
| @@ -292,6 +299,11 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl | |||||
| stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1); | stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1); | ||||
| } | } | ||||
| free(bufin[0]); | |||||
| free(bufin[1]); | |||||
| free(bufout[0]); | |||||
| free(bufout[1]); | |||||
| return nb_samples1; | return nb_samples1; | ||||
| } | } | ||||