summaryrefslogtreecommitdiff
path: root/src/libffmpeg/libavutil
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2006-12-04 22:25:13 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2006-12-04 22:25:13 +0000
commite6d1a700e06ba8a985c29ba212b359c9e33bcc55 (patch)
tree3c98db75ad4f78f4e44c9c6bf974cfff704d1ce2 /src/libffmpeg/libavutil
parente8bcf74e1a8a78e15d3d147f1d485c07a5ac3cd6 (diff)
downloadxine-lib-e6d1a700e06ba8a985c29ba212b359c9e33bcc55.tar.gz
xine-lib-e6d1a700e06ba8a985c29ba212b359c9e33bcc55.tar.bz2
trying an updated ffmpeg version (51.25.0)
CVS patchset: 8405 CVS date: 2006/12/04 22:25:13
Diffstat (limited to 'src/libffmpeg/libavutil')
-rw-r--r--src/libffmpeg/libavutil/Makefile.am1
-rw-r--r--src/libffmpeg/libavutil/adler32.c20
-rw-r--r--src/libffmpeg/libavutil/adler32.h20
-rw-r--r--src/libffmpeg/libavutil/avutil.h107
-rw-r--r--src/libffmpeg/libavutil/bswap.h24
-rw-r--r--src/libffmpeg/libavutil/common.h151
-rw-r--r--src/libffmpeg/libavutil/crc.c20
-rw-r--r--src/libffmpeg/libavutil/crc.h20
-rw-r--r--src/libffmpeg/libavutil/integer.c10
-rw-r--r--src/libffmpeg/libavutil/integer.h10
-rw-r--r--src/libffmpeg/libavutil/internal.h122
-rw-r--r--src/libffmpeg/libavutil/intfloat_readwrite.h20
-rw-r--r--src/libffmpeg/libavutil/lls.c10
-rw-r--r--src/libffmpeg/libavutil/lls.h10
-rw-r--r--src/libffmpeg/libavutil/log.c10
-rw-r--r--src/libffmpeg/libavutil/log.h22
-rw-r--r--src/libffmpeg/libavutil/mathematics.c12
-rw-r--r--src/libffmpeg/libavutil/mathematics.h20
-rw-r--r--src/libffmpeg/libavutil/md5.c20
-rw-r--r--src/libffmpeg/libavutil/md5.h20
-rw-r--r--src/libffmpeg/libavutil/mem.c171
-rw-r--r--src/libffmpeg/libavutil/rational.c27
-rw-r--r--src/libffmpeg/libavutil/rational.h10
-rw-r--r--src/libffmpeg/libavutil/x86_cpu.h22
24 files changed, 721 insertions, 158 deletions
diff --git a/src/libffmpeg/libavutil/Makefile.am b/src/libffmpeg/libavutil/Makefile.am
index 13f645957..76340cf14 100644
--- a/src/libffmpeg/libavutil/Makefile.am
+++ b/src/libffmpeg/libavutil/Makefile.am
@@ -14,6 +14,7 @@ libavutil_la_SOURCES = \
log.c \
mathematics.c \
md5.c \
+ mem.c \
rational.c
libavutil_la_LDFLAGS = -avoid-version -module
diff --git a/src/libffmpeg/libavutil/adler32.c b/src/libffmpeg/libavutil/adler32.c
index e185a77c4..50d57470b 100644
--- a/src/libffmpeg/libavutil/adler32.c
+++ b/src/libffmpeg/libavutil/adler32.c
@@ -1,6 +1,24 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
+ * This is a modified version based on adler32.c from the zlib library.
+ *
* Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ *
*/
#include "common.h"
diff --git a/src/libffmpeg/libavutil/adler32.h b/src/libffmpeg/libavutil/adler32.h
index 4b035dcdf..f56d416fb 100644
--- a/src/libffmpeg/libavutil/adler32.h
+++ b/src/libffmpeg/libavutil/adler32.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Mans Rullgard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef ADLER32_H
#define ADLER32_H
diff --git a/src/libffmpeg/libavutil/avutil.h b/src/libffmpeg/libavutil/avutil.h
index 6f66fbb07..08cc61567 100644
--- a/src/libffmpeg/libavutil/avutil.h
+++ b/src/libffmpeg/libavutil/avutil.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef AVUTIL_H
#define AVUTIL_H
@@ -14,8 +34,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+0)
-#define LIBAVUTIL_VERSION 49.0.0
+#define LIBAVUTIL_VERSION_INT ((49<<16)+(1<<8)+0)
+#define LIBAVUTIL_VERSION 49.1.0
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
@@ -31,7 +51,7 @@ extern "C" {
/**
* Pixel format. Notes:
*
- * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
+ * PIX_FMT_RGB32 is handled in an endian-specific manner. A RGBA
* color is put together as:
* (A << 24) | (R << 16) | (G << 8) | B
* This is stored as BGRA on little endian CPU architectures and ARGB on
@@ -40,7 +60,7 @@ extern "C" {
* When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
* image data is stored in AVFrame.data[0]. The palette is transported in
* AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
- * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
+ * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is
* also endian-specific). Note also that the individual RGB palette
* components stored in AVFrame.data[1] should be in the range 0..255.
* This is important as many custom PAL8 video codecs that were designed
@@ -48,31 +68,68 @@ extern "C" {
*/
enum PixelFormat {
PIX_FMT_NONE= -1,
- PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
- PIX_FMT_YUV422, ///< Packed pixel, Y0 Cb Y1 Cr
- PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
- PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
- PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
- PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
- PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
- PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
- PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
- PIX_FMT_RGB565, ///< always stored in cpu endianness
- PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
- PIX_FMT_GRAY8,
- PIX_FMT_MONOWHITE, ///< 0 is white
- PIX_FMT_MONOBLACK, ///< 0 is black
- PIX_FMT_PAL8, ///< 8 bit with RGBA palette
- PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
- PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
- PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
+ PIX_FMT_YUV420P, ///< Planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
+ PIX_FMT_YUYV422, ///< Packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
+ PIX_FMT_RGB24, ///< Packed RGB 8:8:8, 24bpp, RGBRGB...
+ PIX_FMT_BGR24, ///< Packed RGB 8:8:8, 24bpp, BGRBGR...
+ PIX_FMT_YUV422P, ///< Planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
+ PIX_FMT_YUV444P, ///< Planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
+ PIX_FMT_RGB32, ///< Packed RGB 8:8:8, 32bpp, (msb)8A 8R 8G 8B(lsb), in cpu endianness
+ PIX_FMT_YUV410P, ///< Planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
+ PIX_FMT_YUV411P, ///< Planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
+ PIX_FMT_RGB565, ///< Packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), in cpu endianness
+ PIX_FMT_RGB555, ///< Packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), in cpu endianness most significant bit to 0
+ PIX_FMT_GRAY8, ///< Y , 8bpp
+ PIX_FMT_MONOWHITE, ///< Y , 1bpp, 1 is white
+ PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black
+ PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette
+ PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0, 12bpp, full scale (jpeg)
+ PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2, 16bpp, full scale (jpeg)
+ PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4, 24bpp, full scale (jpeg)
PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
PIX_FMT_XVMC_MPEG2_IDCT,
- PIX_FMT_UYVY422, ///< Packed pixel, Cb Y0 Cr Y1
- PIX_FMT_UYVY411, ///< Packed pixel, Cb Y0 Y1 Cr Y2 Y3
- PIX_FMT_NB,
+ PIX_FMT_UYVY422, ///< Packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
+ PIX_FMT_UYYVYY411, ///< Packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
+ PIX_FMT_BGR32, ///< Packed RGB 8:8:8, 32bpp, (msb)8A 8B 8G 8R(lsb), in cpu endianness
+ PIX_FMT_BGR565, ///< Packed RGB 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), in cpu endianness
+ PIX_FMT_BGR555, ///< Packed RGB 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), in cpu endianness most significant bit to 1
+ PIX_FMT_BGR8, ///< Packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
+ PIX_FMT_BGR4, ///< Packed RGB 1:2:1, 4bpp, (msb)1B 2G 1R(lsb)
+ PIX_FMT_BGR4_BYTE, ///< Packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
+ PIX_FMT_RGB8, ///< Packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
+ PIX_FMT_RGB4, ///< Packed RGB 1:2:1, 4bpp, (msb)2R 3G 3B(lsb)
+ PIX_FMT_RGB4_BYTE, ///< Packed RGB 1:2:1, 8bpp, (msb)2R 3G 3B(lsb)
+ PIX_FMT_NV12, ///< Planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV
+ PIX_FMT_NV21, ///< as above, but U and V bytes are swapped
+
+ PIX_FMT_RGB32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in cpu endianness
+ PIX_FMT_BGR32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in cpu endianness
+
+ PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
+ PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
+ PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
};
+#ifdef WORDS_BIGENDIAN
+#define PIX_FMT_RGBA PIX_FMT_RGB32_1
+#define PIX_FMT_BGRA PIX_FMT_BGR32_1
+#define PIX_FMT_ARGB PIX_FMT_RGB32
+#define PIX_FMT_ABGR PIX_FMT_BGR32
+#define PIX_FMT_GRAY16 PIX_FMT_GRAY16BE
+#else
+#define PIX_FMT_RGBA PIX_FMT_BGR32
+#define PIX_FMT_BGRA PIX_FMT_RGB32
+#define PIX_FMT_ARGB PIX_FMT_BGR32_1
+#define PIX_FMT_ABGR PIX_FMT_RGB32_1
+#define PIX_FMT_GRAY16 PIX_FMT_GRAY16LE
+#endif
+
+#if LIBAVUTIL_VERSION_INT < (50<<16)
+#define PIX_FMT_UYVY411 PIX_FMT_UYYVYY411
+#define PIX_FMT_RGBA32 PIX_FMT_RGB32
+#define PIX_FMT_YUV422 PIX_FMT_YUYV422
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libffmpeg/libavutil/bswap.h b/src/libffmpeg/libavutil/bswap.h
index 25d418c69..4614c9045 100644
--- a/src/libffmpeg/libavutil/bswap.h
+++ b/src/libffmpeg/libavutil/bswap.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
/**
* @file bswap.h
* byte swap.
@@ -16,7 +36,7 @@
# define LEGACY_REGS "=q"
#endif
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if defined(ARCH_X86)
static always_inline uint16_t bswap_16(uint16_t x)
{
__asm("rorw $8, %0" :
@@ -129,7 +149,7 @@ static inline uint64_t bswap_64(uint64_t x)
return r.ll;
#endif
}
-#endif /* !ARCH_X86 */
+#endif /* defined(ARCH_X86) */
#endif /* !HAVE_BYTESWAP_H */
diff --git a/src/libffmpeg/libavutil/common.h b/src/libffmpeg/libavutil/common.h
index b26c821f8..d167404b6 100644
--- a/src/libffmpeg/libavutil/common.h
+++ b/src/libffmpeg/libavutil/common.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
/**
* @file common.h
* common internal and external api header.
@@ -56,18 +76,15 @@
#endif
#endif
-#ifndef EMULATE_INTTYPES
-# include <inttypes.h>
+#ifndef attribute_deprecated
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+# define attribute_deprecated __attribute__((deprecated))
#else
- typedef signed char int8_t;
- typedef signed short int16_t;
- typedef signed int int32_t;
- typedef unsigned char uint8_t;
- typedef unsigned short uint16_t;
- typedef unsigned int uint32_t;
- typedef signed long long int64_t;
- typedef unsigned long long uint64_t;
-#endif /* EMULATE_INTTYPES */
+# define attribute_deprecated
+#endif
+#endif
+
+# include <inttypes.h>
#ifndef PRId64
#define PRId64 "lld"
@@ -81,6 +98,10 @@
#define PRIx64 "llx"
#endif
+#ifndef PRIX64
+#define PRIX64 "llX"
+#endif
+
#ifndef PRId32
#define PRId32 "d"
#endif
@@ -125,16 +146,6 @@
#define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF)
#endif
-#ifdef EMULATE_FAST_INT
-typedef signed char int_fast8_t;
-typedef signed int int_fast16_t;
-typedef signed int int_fast32_t;
-typedef unsigned char uint_fast8_t;
-typedef unsigned int uint_fast16_t;
-typedef unsigned int uint_fast32_t;
-typedef uint64_t uint_fast64_t;
-#endif
-
#ifndef INT_BIT
# if INT_MAX != 2147483647
# define INT_BIT 64
@@ -164,11 +175,14 @@ typedef uint64_t uint_fast64_t;
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
/* assume b>0 */
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
-#define ABS(a) ((a) >= 0 ? (a) : (-(a)))
+#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
+#define FFSIGN(a) ((a) > 0 ? 1 : -1)
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
+
/* misc math functions */
extern FF_IMPORT_ATTR const uint8_t ff_log2_tab[256];
@@ -207,7 +221,21 @@ static inline int av_log2_16bit(unsigned int v)
/* median of 3 */
static inline int mid_pred(int a, int b, int c)
{
-#if 0
+#if HAVE_CMOV
+ int i=b;
+ asm volatile(
+ "cmp %2, %1 \n\t"
+ "cmovg %1, %0 \n\t"
+ "cmovg %2, %1 \n\t"
+ "cmp %3, %1 \n\t"
+ "cmovl %3, %1 \n\t"
+ "cmp %1, %0 \n\t"
+ "cmovg %1, %0 \n\t"
+ :"+&r"(i), "+&r"(a)
+ :"r"(b), "r"(c)
+ );
+ return i;
+#elif 0
int t= (a-b)&((a-b)>>31);
a-=t;
b+=t;
@@ -236,7 +264,7 @@ static inline int mid_pred(int a, int b, int c)
* @param a value to clip
* @param amin minimum value of the clip range
* @param amax maximum value of the clip range
- * @return cliped value
+ * @return clipped value
*/
static inline int clip(int a, int amin, int amax)
{
@@ -248,7 +276,7 @@ static inline int clip(int a, int amin, int amax)
/**
* clip a signed integer value into the 0-255 range
* @param a value to clip
- * @return cliped value
+ * @return clipped value
*/
static inline uint8_t clip_uint8(int a)
{
@@ -273,7 +301,19 @@ static inline int ff_get_fourcc(const char *s){
#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
-
+/*!
+ * \def GET_UTF8(val, GET_BYTE, ERROR)
+ * converts a utf-8 character (up to 4 bytes long) to its 32-bit ucs-4 encoded form
+ * \param val is the output and should be of type uint32_t. It holds the converted
+ * ucs-4 character and should be a left value.
+ * \param GET_BYTE gets utf-8 encoded bytes from any proper source. It can be
+ * a function or a statement whose return value or evaluated value is of type
+ * uint8_t. It will be executed up to 4 times for values in the valid utf-8 range,
+ * and up to 7 times in the general case.
+ * \param ERROR action that should be taken when an invalid utf-8 byte is returned
+ * from GET_BYTE. It should be a statement that jumps out of the macro,
+ * like exit(), goto, return, break, or continue.
+ */
#define GET_UTF8(val, GET_BYTE, ERROR)\
val= GET_BYTE;\
{\
@@ -289,7 +329,43 @@ static inline int ff_get_fourcc(const char *s){
}\
}
-#if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_POWERPC)
+/*!
+ * \def PUT_UTF8(val, tmp, PUT_BYTE)
+ * converts a 32-bit unicode character to its utf-8 encoded form (up to 4 bytes long).
+ * \param val is an input only argument and should be of type uint32_t. It holds
+ * a ucs4 encoded unicode character that is to be converted to utf-8. If
+ * val is given as a function it's executed only once.
+ * \param tmp is a temporary variable and should be of type uint8_t. It
+ * represents an intermediate value during conversion that is to be
+ * outputted by PUT_BYTE.
+ * \param PUT_BYTE writes the converted utf-8 bytes to any proper destination.
+ * It could be a function or a statement, and uses tmp as the input byte.
+ * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
+ * executed up to 4 times for values in the valid utf-8 range and up to
+ * 7 times in the general case, depending on the length of the converted
+ * unicode character.
+ */
+#define PUT_UTF8(val, tmp, PUT_BYTE)\
+ {\
+ int bytes, shift;\
+ uint32_t in = val;\
+ if (in < 0x80) {\
+ tmp = in;\
+ PUT_BYTE\
+ } else {\
+ bytes = (av_log2(in) + 4) / 5;\
+ shift = (bytes - 1) * 6;\
+ tmp = (256 - (256 >> bytes)) | (in >> shift);\
+ PUT_BYTE\
+ while (shift >= 6) {\
+ shift -= 6;\
+ tmp = 0x80 | ((in >> shift) & 0x3f);\
+ PUT_BYTE\
+ }\
+ }\
+ }
+
+#if defined(ARCH_X86) || defined(ARCH_POWERPC)
#if defined(ARCH_X86_64)
static inline uint64_t read_time(void)
{
@@ -344,7 +420,7 @@ tend= read_time();\
tcount++;\
}else\
tskip_count++;\
- if(256*256*256*64%(tcount+tskip_count)==0){\
+ if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\
av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\
}\
}
@@ -354,10 +430,22 @@ tend= read_time();\
#endif
/* memory */
+
+#ifdef __GNUC__
+ #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
+#else
+ #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
+#endif
+
+/* memory */
void *av_malloc(unsigned int size);
void *av_realloc(void *ptr, unsigned int size);
void av_free(void *ptr);
+void *av_mallocz(unsigned int size);
+char *av_strdup(const char *s);
+void av_freep(void *ptr);
+
/* xine: inline causes trouble for debug compiling */
#ifdef DISABLE_INLINE
# ifdef inline
@@ -370,4 +458,11 @@ void av_free(void *ptr);
# define always_inline
#endif
+/* xine: define ASMALIGN here since it's cleaner that generating it in the configure */
+#if HAVE_ASMALIGN_POT
+# define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\n\t"
+#else
+# define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\n\t"
+#endif
+
#endif /* COMMON_H */
diff --git a/src/libffmpeg/libavutil/crc.c b/src/libffmpeg/libavutil/crc.c
index 13be2020d..baa605d32 100644
--- a/src/libffmpeg/libavutil/crc.c
+++ b/src/libffmpeg/libavutil/crc.c
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#include "common.h"
#include "crc.h"
diff --git a/src/libffmpeg/libavutil/crc.h b/src/libffmpeg/libavutil/crc.h
index c5b217017..e739c309b 100644
--- a/src/libffmpeg/libavutil/crc.h
+++ b/src/libffmpeg/libavutil/crc.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef CRC_H
#define CRC_H
diff --git a/src/libffmpeg/libavutil/integer.c b/src/libffmpeg/libavutil/integer.c
index 1820dbf59..5c7b71530 100644
--- a/src/libffmpeg/libavutil/integer.c
+++ b/src/libffmpeg/libavutil/integer.c
@@ -2,18 +2,20 @@
* arbitrary precision integers
* Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
diff --git a/src/libffmpeg/libavutil/integer.h b/src/libffmpeg/libavutil/integer.h
index 523752912..a50ad9bae 100644
--- a/src/libffmpeg/libavutil/integer.h
+++ b/src/libffmpeg/libavutil/integer.h
@@ -2,18 +2,20 @@
* arbitrary precision integers
* Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
diff --git a/src/libffmpeg/libavutil/internal.h b/src/libffmpeg/libavutil/internal.h
index 266976c94..7d850141b 100644
--- a/src/libffmpeg/libavutil/internal.h
+++ b/src/libffmpeg/libavutil/internal.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
/**
* @file internal.h
* common internal api header.
@@ -10,32 +30,17 @@
# define PIC
#endif
-# ifndef ENODATA
-# define ENODATA 61
-# endif
+#ifndef ENODATA
+# define ENODATA 61
+#endif
#include "bswap.h"
#include <stddef.h>
#ifndef offsetof
-# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
+# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
#endif
-#define AVOPTION_CODEC_BOOL(name, help, field) \
- { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_BOOL }
-#define AVOPTION_CODEC_DOUBLE(name, help, field, minv, maxv, defval) \
- { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_DOUBLE, minv, maxv, defval }
-#define AVOPTION_CODEC_FLAG(name, help, field, flag, defval) \
- { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_FLAG, flag, 0, defval }
-#define AVOPTION_CODEC_INT(name, help, field, minv, maxv, defval) \
- { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_INT, minv, maxv, defval }
-#define AVOPTION_CODEC_STRING(name, help, field, str, val) \
- { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_STRING, .defval = val, .defstr = str }
-#define AVOPTION_CODEC_RCOVERRIDE(name, help, field) \
- { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_RCOVERRIDE, .defval = 0, .defstr = NULL }
-#define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
-#define AVOPTION_END() AVOPTION_SUB(NULL)
-
#ifdef __MINGW32__
# ifdef _DEBUG
# define DEBUG
@@ -46,44 +51,45 @@
# ifdef CONFIG_WINCE
# define perror(a)
+# define abort()
# endif
/* __MINGW32__ end */
#elif defined (CONFIG_OS2)
/* OS/2 EMX */
-#include <float.h>
+# include <float.h>
#endif /* !__MINGW32__ && CONFIG_OS2 */
-# ifdef USE_FASTMEMCPY
-# include "fastmemcpy.h"
-# endif
+#ifdef USE_FASTMEMCPY
+# include "libvo/fastmemcpy.h"
+#endif
// Use rip-relative addressing if compiling PIC code on x86-64.
-# if defined(__MINGW32__) || defined(__CYGWIN__) || \
- defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__))
-# if defined(ARCH_X86_64) && defined(PIC)
-# define MANGLE(a) "_" #a"(%%rip)"
-# else
-# define MANGLE(a) "_" #a
-# endif
+#if defined(__MINGW32__) || defined(__CYGWIN__) || \
+ defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__))
+# if defined(ARCH_X86_64) && defined(PIC)
+# define MANGLE(a) "_" #a"(%%rip)"
# else
-# if defined(ARCH_X86_64) && defined(PIC)
-# define MANGLE(a) #a"(%%rip)"
-# elif defined(CONFIG_DARWIN)
-# define MANGLE(a) "_" #a
-# else
-# define MANGLE(a) #a
-# endif
+# define MANGLE(a) "_" #a
+# endif
+#else
+# if defined(ARCH_X86_64) && defined(PIC)
+# define MANGLE(a) #a"(%%rip)"
+# elif defined(CONFIG_DARWIN)
+# define MANGLE(a) "_" #a
+# else
+# define MANGLE(a) #a
# endif
+#endif
/* debug stuff */
-# if !defined(DEBUG) && !defined(NDEBUG)
-# define NDEBUG
-# endif
-# include <assert.h>
+#if !defined(DEBUG) && !defined(NDEBUG)
+# define NDEBUG
+#endif
+#include <assert.h>
/* dprintf macros */
# ifdef DEBUG
@@ -96,32 +102,40 @@
# define dprintf(fmt,...)
# endif
-# ifdef CONFIG_WINCE
-# define abort()
-# endif
+#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
-# define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
+/* math */
-extern const uint32_t inverse[256];
+extern const uint32_t ff_inverse[256];
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if defined(ARCH_X86)
# define FASTDIV(a,b) \
({\
int ret,dmy;\
asm volatile(\
"mull %3"\
:"=d"(ret),"=a"(dmy)\
- :"1"(a),"g"(inverse[b])\
+ :"1"(a),"g"(ff_inverse[b])\
+ );\
+ ret;\
+ })
+#elif defined(ARCH_ARMV4L)
+# define FASTDIV(a,b) \
+ ({\
+ int ret,dmy;\
+ asm volatile(\
+ "umull %1, %0, %2, %3"\
+ :"=&r"(ret),"=&r"(dmy)\
+ :"r"(a),"r"(ff_inverse[b])\
);\
ret;\
})
#elif defined(CONFIG_FASTDIV)
-# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*inverse[b])>>32))
+# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32))
#else
# define FASTDIV(a,b) ((a)/(b))
#endif
-/* math */
extern FF_IMPORT_ATTR const uint8_t ff_sqrt_tab[128];
static inline int ff_sqrt(int a)
@@ -142,7 +156,7 @@ static inline int ff_sqrt(int a)
return ret;
}
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if defined(ARCH_X86)
#define MASK_ABS(mask, level)\
asm volatile(\
"cdq \n\t"\
@@ -156,7 +170,7 @@ static inline int ff_sqrt(int a)
level= (level^mask)-mask;
#endif
-#if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
+#ifdef HAVE_CMOV
#define COPY3_IF_LT(x,y,a,b,c,d)\
asm volatile (\
"cmpl %0, %3 \n\t"\
@@ -205,7 +219,7 @@ if((y)<(x)){\
static always_inline long int lrintf(float x)
{
#ifdef __MINGW32__
-# ifdef ARCH_X86
+# ifdef ARCH_X86_32
int32_t i;
asm volatile(
"fistpl %0\n\t"
@@ -215,7 +229,7 @@ static always_inline long int lrintf(float x)
# else
/* XXX: incorrect, but make it compile */
return (int)(x + (x < 0 ? -0.5 : 0.5));
-# endif /* ARCH_X86 */
+# endif /* ARCH_X86_32 */
#else
return (int)(rint(x));
#endif /* __MINGW32__ */
diff --git a/src/libffmpeg/libavutil/intfloat_readwrite.h b/src/libffmpeg/libavutil/intfloat_readwrite.h
index 33e4c636c..c535b64c8 100644
--- a/src/libffmpeg/libavutil/intfloat_readwrite.h
+++ b/src/libffmpeg/libavutil/intfloat_readwrite.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef INTFLOAT_READWRITE_H
#define INTFLOAT_READWRITE_H
diff --git a/src/libffmpeg/libavutil/lls.c b/src/libffmpeg/libavutil/lls.c
index 6bf4d9278..aa9467dce 100644
--- a/src/libffmpeg/libavutil/lls.c
+++ b/src/libffmpeg/libavutil/lls.c
@@ -3,18 +3,20 @@
*
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
diff --git a/src/libffmpeg/libavutil/lls.h b/src/libffmpeg/libavutil/lls.h
index 944fba75d..59ad2e958 100644
--- a/src/libffmpeg/libavutil/lls.h
+++ b/src/libffmpeg/libavutil/lls.h
@@ -3,18 +3,20 @@
*
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
diff --git a/src/libffmpeg/libavutil/log.c b/src/libffmpeg/libavutil/log.c
index f43593ad9..8b2dc6f6d 100644
--- a/src/libffmpeg/libavutil/log.c
+++ b/src/libffmpeg/libavutil/log.c
@@ -2,18 +2,20 @@
* log functions
* Copyright (c) 2003 Michel Bardiaux
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
diff --git a/src/libffmpeg/libavutil/log.h b/src/libffmpeg/libavutil/log.h
index 13366064e..0ff1f9fcf 100644
--- a/src/libffmpeg/libavutil/log.h
+++ b/src/libffmpeg/libavutil/log.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef LOG_H
#define LOG_H
@@ -13,7 +33,7 @@ struct AVCLASS {
or AVFormatContext, which begin with an AVClass.
Needed because av_log is in libavcodec and has no visibility
of AVIn/OutputFormat */
- struct AVOption *option;
+ const struct AVOption *option;
};
/* av_log API */
diff --git a/src/libffmpeg/libavutil/mathematics.c b/src/libffmpeg/libavutil/mathematics.c
index 951324e99..4be027d9d 100644
--- a/src/libffmpeg/libavutil/mathematics.c
+++ b/src/libffmpeg/libavutil/mathematics.c
@@ -1,18 +1,20 @@
/*
* Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -129,7 +131,7 @@ main(){
if((double)a * (double)b / (double)c > (1LL<<63))
continue;
- if(d!=e) printf("%Ld*%Ld/%Ld= %Ld=%Ld\n", a, b, c, d, e);
+ if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e);
}
}
}
diff --git a/src/libffmpeg/libavutil/mathematics.h b/src/libffmpeg/libavutil/mathematics.h
index 0cf726cbe..0b74b254b 100644
--- a/src/libffmpeg/libavutil/mathematics.h
+++ b/src/libffmpeg/libavutil/mathematics.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef MATHEMATICS_H
#define MATHEMATICS_H
diff --git a/src/libffmpeg/libavutil/md5.c b/src/libffmpeg/libavutil/md5.c
index 32eca3a8e..d33ad1483 100644
--- a/src/libffmpeg/libavutil/md5.c
+++ b/src/libffmpeg/libavutil/md5.c
@@ -2,18 +2,20 @@
* Copyright (C) 2006 Michael Niedermayer (michaelni@gmx.at)
* Copyright (C) 2003-2005 by Christopher R. Hertel (crh@ubiqx.mn.org)
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* References:
@@ -174,11 +176,11 @@ main(){
uint8_t in[1000];
for(i=0; i<1000; i++) in[i]= i*i;
- av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%lld\n", md5val);
- av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%lld\n", md5val);
- av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%lld\n", md5val);
- av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%lld\n", md5val);
+ av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val);
+ av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val);
+ av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val);
+ av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val);
for(i=0; i<1000; i++) in[i]= i % 127;
- av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%lld\n", md5val);
+ av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val);
}
#endif
diff --git a/src/libffmpeg/libavutil/md5.h b/src/libffmpeg/libavutil/md5.h
index c8144b4cc..8d1b4b5fe 100644
--- a/src/libffmpeg/libavutil/md5.h
+++ b/src/libffmpeg/libavutil/md5.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef MD5_H
#define MD5_H
diff --git a/src/libffmpeg/libavutil/mem.c b/src/libffmpeg/libavutil/mem.c
new file mode 100644
index 000000000..f43fb5420
--- /dev/null
+++ b/src/libffmpeg/libavutil/mem.c
@@ -0,0 +1,171 @@
+/*
+ * default memory allocator for libavutil
+ * Copyright (c) 2002 Fabrice Bellard.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file mem.c
+ * default memory allocator for libavutil.
+ */
+
+#include "common.h"
+
+/* here we can use OS dependant allocation functions */
+#undef malloc
+#undef free
+#undef realloc
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
+/* you can redefine av_malloc and av_free in your project to use your
+ memory allocator. You do not need to suppress this file because the
+ linker will do it automatically */
+
+/**
+ * Memory allocation of size byte with alignment suitable for all
+ * memory accesses (including vectors if available on the
+ * CPU). av_malloc(0) must return a non NULL pointer.
+ */
+void *av_malloc(unsigned int size)
+{
+ void *ptr;
+#ifdef CONFIG_MEMALIGN_HACK
+ long diff;
+#endif
+
+ /* let's disallow possible ambiguous cases */
+ if(size > (INT_MAX-16) )
+ return NULL;
+
+#ifdef CONFIG_MEMALIGN_HACK
+ ptr = malloc(size+16);
+ if(!ptr)
+ return ptr;
+ diff= ((-(long)ptr - 1)&15) + 1;
+ ptr += diff;
+ ((char*)ptr)[-1]= diff;
+#elif defined (HAVE_MEMALIGN)
+ ptr = memalign(16,size);
+ /* Why 64?
+ Indeed, we should align it:
+ on 4 for 386
+ on 16 for 486
+ on 32 for 586, PPro - k6-III
+ on 64 for K7 (maybe for P3 too).
+ Because L1 and L2 caches are aligned on those values.
+ But I don't want to code such logic here!
+ */
+ /* Why 16?
+ because some cpus need alignment, for example SSE2 on P4, & most RISC cpus
+ it will just trigger an exception and the unaligned load will be done in the
+ exception handler or it will just segfault (SSE2 on P4)
+ Why not larger? because i didnt see a difference in benchmarks ...
+ */
+ /* benchmarks with p3
+ memalign(64)+1 3071,3051,3032
+ memalign(64)+2 3051,3032,3041
+ memalign(64)+4 2911,2896,2915
+ memalign(64)+8 2545,2554,2550
+ memalign(64)+16 2543,2572,2563
+ memalign(64)+32 2546,2545,2571
+ memalign(64)+64 2570,2533,2558
+
+ btw, malloc seems to do 8 byte alignment by default here
+ */
+#else
+ ptr = malloc(size);
+#endif
+ return ptr;
+}
+
+/**
+ * av_realloc semantics (same as glibc): if ptr is NULL and size > 0,
+ * identical to malloc(size). If size is zero, it is identical to
+ * free(ptr) and NULL is returned.
+ */
+void *av_realloc(void *ptr, unsigned int size)
+{
+#ifdef CONFIG_MEMALIGN_HACK
+ int diff;
+#endif
+
+ /* let's disallow possible ambiguous cases */
+ if(size > (INT_MAX-16) )
+ return NULL;
+
+#ifdef CONFIG_MEMALIGN_HACK
+ //FIXME this isn't aligned correctly, though it probably isn't needed
+ if(!ptr) return av_malloc(size);
+ diff= ((char*)ptr)[-1];
+ return realloc(ptr - diff, size + diff) + diff;
+#else
+ return realloc(ptr, size);
+#endif
+}
+
+/**
+ * Free memory which has been allocated with av_malloc(z)() or av_realloc().
+ * NOTE: ptr = NULL is explicetly allowed
+ * Note2: it is recommended that you use av_freep() instead
+ */
+void av_free(void *ptr)
+{
+ /* XXX: this test should not be needed on most libcs */
+ if (ptr)
+#ifdef CONFIG_MEMALIGN_HACK
+ free(ptr - ((char*)ptr)[-1]);
+#else
+ free(ptr);
+#endif
+}
+
+/**
+ * Frees memory and sets the pointer to NULL.
+ * @param arg pointer to the pointer which should be freed
+ */
+void av_freep(void *arg)
+{
+ void **ptr= (void**)arg;
+ av_free(*ptr);
+ *ptr = NULL;
+}
+
+void *av_mallocz(unsigned int size)
+{
+ void *ptr;
+
+ ptr = av_malloc(size);
+ if (ptr)
+ memset(ptr, 0, size);
+ return ptr;
+}
+
+char *av_strdup(const char *s)
+{
+ char *ptr;
+ int len;
+ len = strlen(s) + 1;
+ ptr = av_malloc(len);
+ if (ptr)
+ memcpy(ptr, s, len);
+ return ptr;
+}
+
diff --git a/src/libffmpeg/libavutil/rational.c b/src/libffmpeg/libavutil/rational.c
index 4a7b0edf7..0e018c41b 100644
--- a/src/libffmpeg/libavutil/rational.c
+++ b/src/libffmpeg/libavutil/rational.c
@@ -2,18 +2,20 @@
* Rational numbers
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
@@ -34,22 +36,29 @@
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
AVRational a0={0,1}, a1={1,0};
int sign= (nom<0) ^ (den<0);
- int64_t gcd= ff_gcd(ABS(nom), ABS(den));
+ int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
- nom = ABS(nom)/gcd;
- den = ABS(den)/gcd;
+ nom = FFABS(nom)/gcd;
+ den = FFABS(den)/gcd;
if(nom<=max && den<=max){
a1= (AVRational){nom, den};
den=0;
}
while(den){
- int64_t x = nom / den;
+ uint64_t x = nom / den;
int64_t next_den= nom - den*x;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.den + a0.den;
- if(a2n > max || a2d > max) break;
+ if(a2n > max || a2d > max){
+ if(a1.num) x= (max - a0.num) / a1.num;
+ if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
+
+ if (den*(2*x*a1.den + a0.den) > nom*a1.den)
+ a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
+ break;
+ }
a0= a1;
a1= (AVRational){a2n, a2d};
diff --git a/src/libffmpeg/libavutil/rational.h b/src/libffmpeg/libavutil/rational.h
index 0fbe0d29d..43fc22114 100644
--- a/src/libffmpeg/libavutil/rational.h
+++ b/src/libffmpeg/libavutil/rational.h
@@ -2,18 +2,20 @@
* Rational numbers
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
diff --git a/src/libffmpeg/libavutil/x86_cpu.h b/src/libffmpeg/libavutil/x86_cpu.h
index 8fd5f8600..3d54b2a60 100644
--- a/src/libffmpeg/libavutil/x86_cpu.h
+++ b/src/libffmpeg/libavutil/x86_cpu.h
@@ -1,3 +1,23 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#ifndef AVUTIL_X86CPU_H
#define AVUTIL_X86CPU_H
@@ -15,6 +35,7 @@
# define REGBP rbp
# define REGa rax
# define REGb rbx
+# define REGc rcx
# define REGSP rsp
#else
@@ -32,6 +53,7 @@
# define REGBP ebp
# define REGa eax
# define REGb ebx
+# define REGc ecx
# define REGSP esp
#endif