diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2001-08-13 21:48:05 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2001-08-13 21:48:05 +0000 |
commit | 1a56543279a6fd146c8616781b4160e207bb4f6d (patch) | |
tree | 4ca37977d896e803a3990e8491f75d02edf49dfd /libavcodec | |
parent | d95ecd058e6256b6deacad8b09fbe58b52f07430 (diff) | |
download | ffmpeg-1a56543279a6fd146c8616781b4160e207bb4f6d.tar.gz |
win32 fixes
Originally committed as revision 84 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3dec.c | 5 | ||||
-rw-r--r-- | libavcodec/ac3enc.c | 11 | ||||
-rw-r--r-- | libavcodec/common.c | 20 | ||||
-rw-r--r-- | libavcodec/common.h | 106 | ||||
-rw-r--r-- | libavcodec/imgconvert.c | 9 | ||||
-rw-r--r-- | libavcodec/libac3/bit_allocate.c | 5 | ||||
-rw-r--r-- | libavcodec/libac3/bitstream.c | 5 | ||||
-rw-r--r-- | libavcodec/libac3/downmix.c | 5 | ||||
-rw-r--r-- | libavcodec/libac3/imdct.c | 6 | ||||
-rw-r--r-- | libavcodec/libac3/parse.c | 4 | ||||
-rw-r--r-- | libavcodec/libavcodec.dsp | 304 | ||||
-rw-r--r-- | libavcodec/mjpeg.c | 10 | ||||
-rw-r--r-- | libavcodec/mpeg12.c | 22 | ||||
-rw-r--r-- | libavcodec/mpeg12data.h | 82 | ||||
-rw-r--r-- | libavcodec/mpegaudio.c | 8 | ||||
-rw-r--r-- | libavcodec/mpegaudio.h | 2 | ||||
-rw-r--r-- | libavcodec/mpegvideo.c | 13 | ||||
-rw-r--r-- | libavcodec/mpegvideo.h | 7 | ||||
-rw-r--r-- | libavcodec/resample.c | 32 |
19 files changed, 546 insertions, 110 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index ac8789b63e..bdf5b31586 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -16,12 +16,7 @@ * 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 "avcodec.h" - -#include <inttypes.h> #include "libac3/ac3.h" /* currently, I use libac3 which is Copyright (C) Aaron Holtzman and diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 30e3f87bda..b43557d49c 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -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 <math.h> +//#define DEBUG +//#define DEBUG_BITALLOC #include "avcodec.h" +#include <math.h> #include "ac3enc.h" #include "ac3tab.h" -//#define DEBUG -//#define DEBUG_BITALLOC -#define NDEBUG -#include <assert.h> #define MDCT_NBITS 9 #define N (1 << MDCT_NBITS) diff --git a/libavcodec/common.c b/libavcodec/common.c index 7d299a4d45..2f7cafc6eb 100644 --- a/libavcodec/common.c +++ b/libavcodec/common.c @@ -16,20 +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> -#ifdef __FreeBSD__ -#include <sys/param.h> -#endif -#include <netinet/in.h> -#include <math.h> #include "common.h" - -#define NDEBUG -#include <assert.h> - -#include "../bswap.h" +#include <math.h> void init_put_bits(PutBitContext *s, UINT8 *buffer, int buffer_size, @@ -79,7 +67,7 @@ void put_bits(PutBitContext *s, int n, unsigned int value) bit_cnt+=n; } else { 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); s->buf_ptr+=4; 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 */ -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) diff --git a/libavcodec/common.h b/libavcodec/common.h index 75908245c0..57ce5035b7 100644 --- a/libavcodec/common.h +++ b/libavcodec/common.h @@ -1,10 +1,86 @@ #ifndef COMMON_H #define COMMON_H +#define FFMPEG_VERSION "0.4.5" + +#ifdef WIN32 +#define CONFIG_WIN32 +#endif + #ifdef HAVE_AV_CONFIG_H +/* only include the following when compiling package */ #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 +// 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 /* workaround for typedef conflict in MPlayer (wine typedefs) */ typedef unsigned short UINT16; @@ -18,6 +94,32 @@ typedef signed char INT8; typedef signed int INT32; 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 */ struct PutBitContext; @@ -28,7 +130,7 @@ typedef struct PutBitContext { UINT32 bit_buf; int bit_cnt; UINT8 *buf, *buf_ptr, *buf_end; - long long data_out_size; /* in bytes */ + INT64 data_out_size; /* in bytes */ void *opaque; WriteDataFunc write_data; } PutBitContext; @@ -38,7 +140,7 @@ void init_put_bits(PutBitContext *s, void *opaque, void (*write_data)(void *, UINT8 *, int)); 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 flush_put_bits(PutBitContext *s); diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 403336812d..d39b6c1e9b 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -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 "avcodec.h" #include "dsputil.h" @@ -481,7 +477,9 @@ static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap, { UINT8 *src, *ptr; int y, y1, i; - UINT8 buf[5 * width]; + UINT8 *buf; + + buf= (UINT8*) malloc(5 * width); src = src1; for(y=0;y<height;y+=2) { @@ -511,6 +509,7 @@ static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap, dst += dst_wrap; src += (2 + 1) * src_wrap; } + free(buf); } diff --git a/libavcodec/libac3/bit_allocate.c b/libavcodec/libac3/bit_allocate.c index 307c0074c6..2c76b93c33 100644 --- a/libavcodec/libac3/bit_allocate.c +++ b/libavcodec/libac3/bit_allocate.c @@ -20,10 +20,7 @@ * 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_internal.h" diff --git a/libavcodec/libac3/bitstream.c b/libavcodec/libac3/bitstream.c index 7e9bd1f66a..70aad3d18d 100644 --- a/libavcodec/libac3/bitstream.c +++ b/libavcodec/libac3/bitstream.c @@ -21,10 +21,7 @@ * */ -#include <inttypes.h> -#include <stdlib.h> -#include <stdio.h> - +#include "../common.h" #include "ac3.h" #include "ac3_internal.h" #include "bitstream.h" diff --git a/libavcodec/libac3/downmix.c b/libavcodec/libac3/downmix.c index 9e7fbfb8b6..8147182b12 100644 --- a/libavcodec/libac3/downmix.c +++ b/libavcodec/libac3/downmix.c @@ -25,11 +25,8 @@ * */ -#include <inttypes.h> -#include <stdlib.h> -#include <stdio.h> +#include "../common.h" #include <math.h> -#include <string.h> #include "ac3.h" #include "ac3_internal.h" diff --git a/libavcodec/libac3/imdct.c b/libavcodec/libac3/imdct.c index 7be33897f5..b3516a91e0 100644 --- a/libavcodec/libac3/imdct.c +++ b/libavcodec/libac3/imdct.c @@ -22,11 +22,7 @@ * */ -//#include "config.h" - -#include <inttypes.h> -#include <stdlib.h> -#include <stdio.h> +#include "../common.h" #include <math.h> #include "ac3.h" #include "ac3_internal.h" diff --git a/libavcodec/libac3/parse.c b/libavcodec/libac3/parse.c index c6eae00ba5..99cf8d7c91 100644 --- a/libavcodec/libac3/parse.c +++ b/libavcodec/libac3/parse.c @@ -22,9 +22,7 @@ * */ -#include <inttypes.h> -#include <string.h> - +#include "../common.h" #include "ac3.h" #include "ac3_internal.h" diff --git a/libavcodec/libavcodec.dsp b/libavcodec/libavcodec.dsp new file mode 100644 index 0000000000..10625106f5 --- /dev/null +++ b/libavcodec/libavcodec.dsp @@ -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 diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c index 1f216c2949..7410583f18 100644 --- a/libavcodec/mjpeg.c +++ b/libavcodec/mjpeg.c @@ -16,8 +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 "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" @@ -423,12 +421,20 @@ void mjpeg_encode_mb(MpegEncContext *s, //#define DEBUG +#ifndef CONFIG_WIN32 + #ifdef DEBUG #define dprintf(fmt,args...) printf(fmt, ## args) #else #define dprintf(fmt,args...) #endif +#else + +inline void dprintf(const char* fmt,...) {} + +#endif + /* compressed picture size */ #define PICTURE_BUFFER_SIZE 100000 diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 10e178efbb..79bf31dff0 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -16,26 +16,28 @@ * 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 "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" #include "mpeg12data.h" -#ifdef USE_FASTMEMCPY -#include "fastmemcpy.h" -#endif //#define DEBUG +#ifndef CONFIG_WIN32 + #ifdef DEBUG #define dprintf(fmt,args...) printf(fmt, ## args) #else #define dprintf(fmt,args...) #endif +#else + +inline void dprintf(const char* fmt,...) {} + +#endif + /* Start codes. */ #define SEQ_END_CODE 0x000001b7 #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]; time_code = s->fake_picture_number * FRAME_RATE_BASE; 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, 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, 0); /* broken link */ } diff --git a/libavcodec/mpeg12data.h b/libavcodec/mpeg12data.h index 4f6a95b799..f7d29a5cbb 100644 --- a/libavcodec/mpeg12data.h +++ b/libavcodec/mpeg12data.h @@ -288,27 +288,73 @@ static const UINT8 mbPatTable[63][2] = { #define MB_QUANT 0x10 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] = { - [ 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] = { diff --git a/libavcodec/mpegaudio.c b/libavcodec/mpegaudio.c index af05e29279..7785257821 100644 --- a/libavcodec/mpegaudio.c +++ b/libavcodec/mpegaudio.c @@ -16,16 +16,10 @@ * 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 <math.h> #include "avcodec.h" +#include <math.h> #include "mpegaudio.h" -#define NDEBUG -#include <assert.h> - /* define it to use floats in quantization (I don't like floats !) */ //#define USE_FLOATS diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index 006650a99c..9d5fdfb011 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -19,7 +19,7 @@ typedef struct MpegAudioContext { int bitrate_index; /* bit rate */ int freq_index; 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 */ int frame_frac, frame_frac_incr, do_padding; short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */ diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index e8cc3ced0b..add0c69121 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -81,7 +81,8 @@ static void convert_matrix(int *qmat, const UINT16 *quant_matrix, int qscale) /* 16 <= qscale * quant_matrix[i] <= 7905 */ /* 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 { for(i=0;i<64;i++) { @@ -983,6 +984,10 @@ static int dct_quantize(MpegEncContext *s, 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 (n < 4) q = s->y_dc_scale; @@ -1251,7 +1256,7 @@ static void rate_control_init(MpegEncContext *s) */ static int rate_estimate_qscale(MpegEncContext *s) { - long long total_bits = s->total_bits; + INT64 total_bits = s->total_bits; float q; int qscale, diff, qmin; @@ -1276,9 +1281,9 @@ static int rate_estimate_qscale(MpegEncContext *s) q = 31; qscale = (int)(q + 0.5); #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, - total_bits, + (double)total_bits, (float)s->frame_rate / FRAME_RATE_BASE * total_bits / s->picture_number, diff, q); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a225dedbe0..1da8456f1a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -125,11 +125,14 @@ typedef struct MpegEncContext { /* bit rate control */ int I_frame_bits; /* wanted number of bits per I 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 */ int time_increment_bits; + int shape; + int vol_sprite_usage; + int quant_precision; /* RV10 specific */ int rv10_version; /* RV10 version: 0 or 3 */ diff --git a/libavcodec/resample.c b/libavcodec/resample.c index 29445964f6..94e3a560e1 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -16,14 +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 <math.h> #include "avcodec.h" - -#define NDEBUG -#include <assert.h> +#include <math.h> typedef struct { /* 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) { - short buf1[nb_samples]; + short *buf1; short *buftmp; + buf1= (short*) malloc( nb_samples * sizeof(short) ); + /* first downsample by an integer factor with averaging filter */ if (s->iratio > 1) { buftmp = buf1; @@ -213,6 +209,7 @@ static int mono_resample(ReSampleChannelContext *s, short *output, short *input, } else { memcpy(output, buftmp, nb_samples * sizeof(short)); } + free(buf1); 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 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]; + int lenout; if (s->input_channels == s->output_channels && s->ratio == 1.0) { /* nothing to do */ @@ -261,6 +259,15 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl 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 && s->output_channels == 1) { 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); } + free(bufin[0]); + free(bufin[1]); + + free(bufout[0]); + free(bufout[1]); return nb_samples1; } |