ffmpeg upgrade to get packed-pixel YUYV422 support

This commit is contained in:
Glenn Maynard
2007-03-21 05:18:17 +00:00
parent 504866debb
commit aaceb42b61
21 changed files with 2999 additions and 2118 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,14 +1,15 @@
This directory is only for Windows. For other OS's, install it yourself
as usual.
I'm not adding this library source to CVS, because it's still in heavily
active development and there's not yet a stable release, so it's too much
work to keep a copy here, and because it's easier to create diffs to send
upstream if my copy is checked out of the original repository. Check it
out yourself if you want to recompile it.
Compile with MingW.
Configured with ./configure --enable-shared --enable-mingw32 --enable-small --disable-debug
TODO: Don't compile encoders, audio decoders and unneeded video decoders.
svn co -r 8448 svn://svn.mplayerhq.hu/ffmpeg
./configure --enable-shared --disable-static --disable-debug --disable-vhook --enable-memalign-hack --disable-network --enable-small \
--disable-encoders --disable-ffmpeg --disable-ffserver --disable-ffplay --disable-muxers \
--disable-demuxers --enable-demuxer=avi --enable-demuxer=h261 --enable-demuxer=h263 --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mjpeg --enable-demuxer=mov --enable-demuxer=mpegps --enable-demuxer=mpegts --enable-demuxer=mpegvideo --enable-demuxer=ogg --enable-demuxer=rawvideo --enable-demuxer=yuv4mpegpipe \
--disable-decoders --enable-decoder=h261 --enable-decoder=h263 --enable-decoder=h263i --enable-decoder=h264 --enable-decoder=huffyuv --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-decoder=mpeg_xvmc --enable-decoder=mpeg1video --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=rawvideo --enable-decoder=theora \
--disable-parsers --enable-parser=h261 --enable-parser=h263 --enable-parser=h264 --enable-parser=mjpeg --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=ac3 \
--target-os=mingw32
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+114 -19
View File
@@ -1,3 +1,23 @@
/*
* unbuffered io for ffmpeg system
* copyright (c) 2001 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
*/
#ifndef AVIO_H
#define AVIO_H
@@ -9,11 +29,15 @@ typedef int64_t offset_t;
struct URLContext {
struct URLProtocol *prot;
int flags;
int is_streamed; /* true if streamed (no seek possible), default = false */
int max_packet_size; /* if non zero, the stream is packetized with this max packet size */
int flags;
int is_streamed; /**< true if streamed (no seek possible), default = false */
int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */
void *priv_data;
char filename[1]; /* specified filename */
#if LIBAVFORMAT_VERSION_INT >= (52<<16)
char *filename; /**< specified filename */
#else
char filename[1]; /**< specified filename */
#endif
};
typedef struct URLContext URLContext;
@@ -37,18 +61,36 @@ offset_t url_seek(URLContext *h, offset_t pos, int whence);
int url_close(URLContext *h);
int url_exist(const char *filename);
offset_t url_filesize(URLContext *h);
/**
* Return the maximum packet size associated to packetized file
* handle. If the file is not packetized (stream like http or file on
* disk), then 0 is returned.
*
* @param h file handle
* @return maximum packet size in bytes
*/
int url_get_max_packet_size(URLContext *h);
void url_get_filename(URLContext *h, char *buf, int buf_size);
/* the callback is called in blocking functions to test regulary if
asynchronous interruption is needed. -EINTR is returned in this
case by the interrupted function. 'NULL' means no interrupt
callback is given. */
/**
* the callback is called in blocking functions to test regulary if
* asynchronous interruption is needed. AVERROR(EINTR) is returned
* in this case by the interrupted function. 'NULL' means no interrupt
* callback is given. i
*/
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
/* not implemented */
int url_poll(URLPollEntry *poll_table, int n, int timeout);
/**
* passing this as the "whence" parameter to a seek function causes it to
* return the filesize without seeking anywhere, supporting this is optional
* if its not supprted then the seek function will return <0
*/
#define AVSEEK_SIZE 0x10000
typedef struct URLProtocol {
const char *name;
int (*url_open)(URLContext *h, const char *filename, int flags);
@@ -70,17 +112,18 @@ typedef struct {
unsigned char *buf_ptr, *buf_end;
void *opaque;
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
void (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*seek)(void *opaque, offset_t offset, int whence);
offset_t pos; /* position in the file of the current buffer */
int must_flush; /* true if the next seek should flush */
int eof_reached; /* true if eof reached */
int write_flag; /* true if open for writing */
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
offset_t (*seek)(void *opaque, offset_t offset, int whence);
offset_t pos; /**< position in the file of the current buffer */
int must_flush; /**< true if the next seek should flush */
int eof_reached; /**< true if eof reached */
int write_flag; /**< true if open for writing */
int is_streamed;
int max_packet_size;
unsigned long checksum;
unsigned char *checksum_ptr;
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
int error; ///< contains the error code or 0 if no error happened
} ByteIOContext;
int init_put_byte(ByteIOContext *s,
@@ -89,8 +132,8 @@ int init_put_byte(ByteIOContext *s,
int write_flag,
void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
void (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*seek)(void *opaque, offset_t offset, int whence));
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
offset_t (*seek)(void *opaque, offset_t offset, int whence));
void put_byte(ByteIOContext *s, int b);
void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
@@ -98,39 +141,52 @@ void put_le64(ByteIOContext *s, uint64_t val);
void put_be64(ByteIOContext *s, uint64_t val);
void put_le32(ByteIOContext *s, unsigned int val);
void put_be32(ByteIOContext *s, unsigned int val);
void put_le24(ByteIOContext *s, unsigned int val);
void put_be24(ByteIOContext *s, unsigned int val);
void put_le16(ByteIOContext *s, unsigned int val);
void put_be16(ByteIOContext *s, unsigned int val);
void put_tag(ByteIOContext *s, const char *tag);
void put_be64_double(ByteIOContext *s, double val);
void put_strz(ByteIOContext *s, const char *buf);
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
void url_fskip(ByteIOContext *s, offset_t offset);
offset_t url_ftell(ByteIOContext *s);
offset_t url_fsize(ByteIOContext *s);
int url_feof(ByteIOContext *s);
int url_ferror(ByteIOContext *s);
#define URL_EOF (-1)
/** @note return URL_EOF (-1) if EOF */
int url_fgetc(ByteIOContext *s);
/** @warning currently size is limited */
#ifdef __GNUC__
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
#else
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
#endif
/** @note unlike fgets, the EOL character is not returned and a whole
line is parsed. return NULL if first char read was EOF */
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
void put_flush_packet(ByteIOContext *s);
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
/** @note return 0 if EOF, so you cannot use it if EOF handling is
necessary */
int get_byte(ByteIOContext *s);
unsigned int get_le24(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s);
uint64_t get_le64(ByteIOContext *s);
unsigned int get_le16(ByteIOContext *s);
double get_be64_double(ByteIOContext *s);
char *get_strz(ByteIOContext *s, char *buf, int maxlen);
unsigned int get_be16(ByteIOContext *s);
unsigned int get_be24(ByteIOContext *s);
unsigned int get_be32(ByteIOContext *s);
uint64_t get_be64(ByteIOContext *s);
@@ -140,22 +196,61 @@ static inline int url_is_streamed(ByteIOContext *s)
}
int url_fdopen(ByteIOContext *s, URLContext *h);
/** @warning must be called before any I/O */
int url_setbufsize(ByteIOContext *s, int buf_size);
/** @note when opened as read/write, the buffers are only used for
reading */
int url_fopen(ByteIOContext *s, const char *filename, int flags);
int url_fclose(ByteIOContext *s);
URLContext *url_fileno(ByteIOContext *s);
/**
* Return the maximum packet size associated to packetized buffered file
* handle. If the file is not packetized (stream like http or file on
* disk), then 0 is returned.
*
* @param h buffered file handle
* @return maximum packet size in bytes
*/
int url_fget_max_packet_size(ByteIOContext *s);
int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
/** return the written or read size */
int url_close_buf(ByteIOContext *s);
/**
* Open a write only memory stream.
*
* @param s new IO context
* @return zero if no error.
*/
int url_open_dyn_buf(ByteIOContext *s);
/**
* Open a write only packetized memory stream with a maximum packet
* size of 'max_packet_size'. The stream is stored in a memory buffer
* with a big endian 4 byte header giving the packet size in bytes.
*
* @param s new IO context
* @param max_packet_size maximum packet size (must be > 0)
* @return zero if no error.
*/
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
/**
* Return the written size and a pointer to the buffer. The buffer
* must be freed with av_free().
* @param s IO context
* @param pointer to a byte buffer
* @return the length of the byte buffer
*/
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
unsigned long get_checksum(ByteIOContext *s);
void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum);
unsigned long update_adler32(unsigned long adler, const uint8_t *buf, unsigned int len);
/* file.c */
extern URLProtocol file_protocol;
@@ -0,0 +1,137 @@
/*
* copyright (c) 2006 Michael Niedermayer <[email protected]>
*
* 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
/**
* @file avutil.h
* external api header.
*/
#ifdef __cplusplus
extern "C" {
#endif
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
#define LIBAVUTIL_VERSION_INT ((49<<16)+(4<<8)+0)
#define LIBAVUTIL_VERSION 49.4.0
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
#include "common.h"
#include "mathematics.h"
#include "rational.h"
#include "integer.h"
#include "intfloat_readwrite.h"
#include "log.h"
/**
* Pixel format. Notes:
*
* 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
* big endian CPUs.
*
* 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_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
* to run on the IBM VGA graphics adapter use 6-bit palette components.
*/
enum PixelFormat {
PIX_FMT_NONE= -1,
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 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
#endif /* AVUTIL_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,82 @@
/*
* arbitrary precision integers
* Copyright (c) 2004 Michael Niedermayer <[email protected]>
*
* 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 integer.h
* arbitrary precision integers
* @author Michael Niedermayer <[email protected]>
*/
#ifndef INTEGER_H
#define INTEGER_H
#define AV_INTEGER_SIZE 8
typedef struct AVInteger{
uint16_t v[AV_INTEGER_SIZE];
} AVInteger;
AVInteger av_add_i(AVInteger a, AVInteger b);
AVInteger av_sub_i(AVInteger a, AVInteger b);
/**
* returns the rounded down value of the logarithm of base 2 of the given AVInteger.
* this is simply the index of the most significant bit which is 1. Or 0 of all bits are 0
*/
int av_log2_i(AVInteger a);
AVInteger av_mul_i(AVInteger a, AVInteger b);
/**
* returns 0 if a==b, 1 if a>b and -1 if a<b.
*/
int av_cmp_i(AVInteger a, AVInteger b);
/**
* bitwise shift.
* @param s the number of bits by which the value should be shifted right, may be negative for shifting left
*/
AVInteger av_shr_i(AVInteger a, int s);
/**
* returns a % b.
* @param quot a/b will be stored here
*/
AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b);
/**
* returns a/b.
*/
AVInteger av_div_i(AVInteger a, AVInteger b);
/**
* converts the given int64_t to an AVInteger.
*/
AVInteger av_int2i(int64_t a);
/**
* converts the given AVInteger to an int64_t.
* if the AVInteger is too large to fit into an int64_t,
* then only the least significant 64bit will be used
*/
int64_t av_i2int(AVInteger a);
#endif // INTEGER_H
@@ -0,0 +1,39 @@
/*
* copyright (c) 2005 Michael Niedermayer <[email protected]>
*
* 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
#include "common.h"
/* IEEE 80 bits extended float */
typedef struct AVExtFloat {
uint8_t exponent[2];
uint8_t mantissa[8];
} AVExtFloat;
double av_int2dbl(int64_t v);
float av_int2flt(int32_t v);
double av_ext2dbl(const AVExtFloat ext);
int64_t av_dbl2int(double d);
int32_t av_flt2int(float d);
AVExtFloat av_dbl2ext(double d);
#endif /* INTFLOAT_READWRITE_H */
+116
View File
@@ -0,0 +1,116 @@
/*
* copyright (c) 2006 Michael Niedermayer <[email protected]>
*
* 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
#include <stdarg.h>
/**
* Used by av_log
*/
typedef struct AVCLASS AVClass;
struct AVCLASS {
const char* class_name;
const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext
or AVFormatContext, which begin with an AVClass.
Needed because av_log is in libavcodec and has no visibility
of AVIn/OutputFormat */
const struct AVOption *option;
};
/* av_log API */
#if LIBAVUTIL_VERSION_INT < (50<<16)
#define AV_LOG_QUIET -1
#define AV_LOG_FATAL 0
#define AV_LOG_ERROR 0
#define AV_LOG_WARNING 1
#define AV_LOG_INFO 1
#define AV_LOG_VERBOSE 1
#define AV_LOG_DEBUG 2
#else
#define AV_LOG_QUIET -8
/**
* something went really wrong and we will crash now
*/
#define AV_LOG_PANIC 0
/**
* something went wrong and recovery is not possible
* like no header in a format which depends on it or a combination
* of parameters which are not allowed
*/
#define AV_LOG_FATAL 8
/**
* something went wrong and cannot losslessly be recovered
* but not all future data is affected
*/
#define AV_LOG_ERROR 16
/**
* something somehow does not look correct / something which may or may not
* lead to some problems like use of -vstrict -2
*/
#define AV_LOG_WARNING 24
#define AV_LOG_INFO 32
#define AV_LOG_VERBOSE 40
/**
* stuff which is only useful for libav* developers
*/
#define AV_LOG_DEBUG 48
#endif
extern int av_log_level;
/**
* Send the specified message to the log if the level is less than or equal to
* the current av_log_level. By default, all logging messages are sent to
* stderr. This behavior can be altered by setting a different av_vlog callback
* function.
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct.
* @param level The importance level of the message, lower values signifying
* higher importance.
* @param fmt The format string (printf-compatible) that specifies how
* subsequent arguments are converted to output.
* @see av_vlog
*/
#ifdef __GNUC__
extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
#else
extern void av_log(void*, int level, const char *fmt, ...);
#endif
#if LIBAVUTIL_VERSION_INT < (50<<16)
extern void av_vlog(void*, int level, const char *fmt, va_list);
extern int av_log_get_level(void);
extern void av_log_set_level(int);
extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
extern void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
#else
extern void (*av_vlog)(void*, int, const char*, va_list);
#endif
#endif /* LOG_H */
@@ -0,0 +1,51 @@
/*
* copyright (c) 2005 Michael Niedermayer <[email protected]>
*
* 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
#include "rational.h"
enum AVRounding {
AV_ROUND_ZERO = 0, ///< round toward zero
AV_ROUND_INF = 1, ///< round away from zero
AV_ROUND_DOWN = 2, ///< round toward -infinity
AV_ROUND_UP = 3, ///< round toward +infinity
AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
};
/**
* rescale a 64bit integer with rounding to nearest.
* a simple a*b/c isn't possible as it can overflow
*/
int64_t av_rescale(int64_t a, int64_t b, int64_t c);
/**
* rescale a 64bit integer with specified rounding.
* a simple a*b/c isn't possible as it can overflow
*/
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
/**
* rescale a 64bit integer by 2 rational numbers.
*/
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
#endif /* MATHEMATICS_H */
+65
View File
@@ -0,0 +1,65 @@
/*
* copyright (c) 2006 Michael Niedermayer <[email protected]>
*
* 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.h
* Memory handling functions.
*/
#ifndef AV_MEM_H
#define AV_MEM_H
#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 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);
/**
* 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);
/**
* 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);
void *av_mallocz(unsigned int size);
char *av_strdup(const char *s);
/**
* Frees memory and sets the pointer to NULL.
* @param ptr pointer to the pointer which should be freed
*/
void av_freep(void *ptr);
#endif /* AV_MEM_H */
+72 -11
View File
@@ -2,22 +2,24 @@
* Rational numbers
* Copyright (c) 2003 Michael Niedermayer <[email protected]>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/**
* @file rational.h
* Rational numbers.
@@ -27,27 +29,86 @@
#ifndef RATIONAL_H
#define RATIONAL_H
/**
* Rational number num/den.
*/
typedef struct AVRational{
int num;
int den;
int num; ///< numerator
int den; ///< denominator
} AVRational;
/**
* Compare two rationals.
* @param a first rational
* @param b second rational
* @return 0 if a==b, 1 if a>b and -1 if a<b.
*/
static inline int av_cmp_q(AVRational a, AVRational b){
const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
if (tmp < 0) return -1;
else if(tmp == 0) return 0;
else return 1;
if(tmp) return (tmp>>63)|1;
else return 0;
}
/**
* Rational to double conversion.
* @param a rational to convert
* @return (double) a
*/
static inline double av_q2d(AVRational a){
return a.num / (double) a.den;
}
/**
* Reduce a fraction.
* This is useful for framerate calculations.
* @param dst_nom destination numerator
* @param dst_den destination denominator
* @param nom source numerator
* @param den source denominator
* @param max the maximum allowed for dst_nom & dst_den
* @return 1 if exact, 0 otherwise
*/
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
/**
* Multiplies two rationals.
* @param b first rational.
* @param c second rational.
* @return b*c.
*/
AVRational av_mul_q(AVRational b, AVRational c);
/**
* Divides one rational by another.
* @param b first rational.
* @param c second rational.
* @return b/c.
*/
AVRational av_div_q(AVRational b, AVRational c);
/**
* Adds two rationals.
* @param b first rational.
* @param c second rational.
* @return b+c.
*/
AVRational av_add_q(AVRational b, AVRational c);
/**
* Subtracts one rational from another.
* @param b first rational.
* @param c second rational.
* returns b-c.
*/
AVRational av_sub_q(AVRational b, AVRational c);
/**
* Converts a double precision floating point number to a rational.
* @param d double to convert
* @param max the maximum allowed numerator and denominator
* @return (AVRational) d.
*/
AVRational av_d2q(double d, int max);
#endif // RATIONAL_H
+97 -10
View File
@@ -2,19 +2,21 @@
* RTP definitions
* Copyright (c) 2002 Fabrice Bellard.
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef RTP_H
#define RTP_H
@@ -24,17 +26,102 @@
int rtp_init(void);
int rtp_get_codec_info(AVCodecContext *codec, int payload_type);
int rtp_get_payload_type(AVCodecContext *codec);
int rtp_parse_packet(AVFormatContext *s1, AVPacket *pkt,
const unsigned char *buf, int len);
extern AVOutputFormat rtp_mux;
extern AVInputFormat rtp_demux;
/** return < 0 if unknown payload type */
int rtp_get_payload_type(AVCodecContext *codec);
typedef struct RTPDemuxContext RTPDemuxContext;
typedef struct rtp_payload_data_s rtp_payload_data_s;
RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, rtp_payload_data_s *rtp_payload_data);
int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
const uint8_t *buf, int len);
void rtp_parse_close(RTPDemuxContext *s);
extern AVOutputFormat rtp_muxer;
extern AVInputFormat rtp_demuxer;
int rtp_get_local_port(URLContext *h);
int rtp_set_remote_url(URLContext *h, const char *uri);
void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
/**
* some rtp servers assume client is dead if they don't hear from them...
* so we send a Receiver Report to the provided ByteIO context
* (we don't have access to the rtcp handle from here)
*/
int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
extern URLProtocol rtp_protocol;
#define RTP_PT_PRIVATE 96
#define RTP_VERSION 2
#define RTP_MAX_SDES 256 /**< maximum text length for SDES */
/* RTCP paquets use 0.5 % of the bandwidth */
#define RTCP_TX_RATIO_NUM 5
#define RTCP_TX_RATIO_DEN 1000
/** Structure listing useful vars to parse RTP packet payload*/
typedef struct rtp_payload_data_s
{
int sizelength;
int indexlength;
int indexdeltalength;
int profile_level_id;
int streamtype;
int objecttype;
char *mode;
/** mpeg 4 AU headers */
struct AUHeaders {
int size;
int index;
int cts_flag;
int cts;
int dts_flag;
int dts;
int rap_flag;
int streamstate;
} *au_headers;
int nb_au_headers;
int au_headers_length_bytes;
int cur_au_index;
} rtp_payload_data_t;
typedef struct AVRtpPayloadType_s
{
int pt;
const char enc_name[50]; /* XXX: why 50 ? */
enum CodecType codec_type;
enum CodecID codec_id;
int clock_rate;
int audio_channels;
} AVRtpPayloadType_t;
#if 0
typedef enum {
RTCP_SR = 200,
RTCP_RR = 201,
RTCP_SDES = 202,
RTCP_BYE = 203,
RTCP_APP = 204
} rtcp_type_t;
typedef enum {
RTCP_SDES_END = 0,
RTCP_SDES_CNAME = 1,
RTCP_SDES_NAME = 2,
RTCP_SDES_EMAIL = 3,
RTCP_SDES_PHONE = 4,
RTCP_SDES_LOC = 5,
RTCP_SDES_TOOL = 6,
RTCP_SDES_NOTE = 7,
RTCP_SDES_PRIV = 8,
RTCP_SDES_IMG = 9,
RTCP_SDES_DOOR = 10,
RTCP_SDES_SOURCE = 11
} rtcp_sdes_type_t;
#endif
extern AVRtpPayloadType_t AVRtpPayloadTypes[];
#endif /* RTP_H */
+25 -21
View File
@@ -2,29 +2,26 @@
* RTSP definitions
* Copyright (c) 2002 Fabrice Bellard.
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef RTSP_H
#define RTSP_H
/* RTSP handling */
enum RTSPStatusCode {
#define DEF(n, c, s) c = n,
#include "rtspcodes.h"
#undef DEF
};
enum RTSPProtocol {
RTSP_PROTOCOL_RTP_UDP = 0,
@@ -35,27 +32,33 @@ enum RTSPProtocol {
#define RTSP_DEFAULT_PORT 554
#define RTSP_MAX_TRANSPORTS 8
#define RTSP_TCP_MAX_PACKET_SIZE 1472
#define RTSP_DEFAULT_NB_AUDIO_CHANNELS 2
#define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
#define RTSP_RTP_PORT_MIN 5000
#define RTSP_RTP_PORT_MAX 10000
typedef struct RTSPTransportField {
int interleaved_min, interleaved_max; /* interleave ids, if TCP transport */
int port_min, port_max; /* RTP ports */
int client_port_min, client_port_max; /* RTP ports */
int server_port_min, server_port_max; /* RTP ports */
int ttl; /* ttl value */
uint32_t destination; /* destination IP address */
int interleaved_min, interleaved_max; /**< interleave ids, if TCP transport */
int port_min, port_max; /**< RTP ports */
int client_port_min, client_port_max; /**< RTP ports */
int server_port_min, server_port_max; /**< RTP ports */
int ttl; /**< ttl value */
uint32_t destination; /**< destination IP address */
enum RTSPProtocol protocol;
} RTSPTransportField;
typedef struct RTSPHeader {
int content_length;
enum RTSPStatusCode status_code; /* response code from server */
enum RTSPStatusCode status_code; /**< response code from server */
int nb_transports;
/** in AV_TIME_BASE unit, AV_NOPTS_VALUE if not used */
int64_t range_start, range_end;
RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
int seq; /* sequence number */
int seq; /**< sequence number */
char session_id[512];
} RTSPHeader;
/* the callback can be used to extend the connection setup/teardown step */
/** the callback can be used to extend the connection setup/teardown step */
enum RTSPCallbackAction {
RTSP_ACTION_SERVER_SETUP,
RTSP_ACTION_SERVER_TEARDOWN,
@@ -68,11 +71,12 @@ typedef struct RTSPActionServerSetup {
char transport_option[512];
} RTSPActionServerSetup;
typedef int FFRTSPCallback(enum RTSPCallbackAction action,
typedef int FFRTSPCallback(enum RTSPCallbackAction action,
const char *session_id,
char *buf, int buf_size,
void *arg);
/** useful for modules: set RTSP callback function */
void rtsp_set_callback(FFRTSPCallback *rtsp_cb);
int rtsp_init(void);
@@ -82,7 +86,7 @@ extern int rtsp_default_protocols;
extern int rtsp_rtp_port_min;
extern int rtsp_rtp_port_max;
extern FFRTSPCallback *ff_rtsp_callback;
extern AVInputFormat rtsp_demux;
extern AVInputFormat rtsp_demuxer;
int rtsp_pause(AVFormatContext *s);
int rtsp_resume(AVFormatContext *s);
+36 -11
View File
@@ -1,11 +1,36 @@
DEF(200, RTSP_STATUS_OK, "OK")
DEF(405, RTSP_STATUS_METHOD, "Method Not Allowed")
DEF(453, RTSP_STATUS_BANDWIDTH, "Not Enough Bandwidth")
DEF(454, RTSP_STATUS_SESSION, "Session Not Found")
DEF(455, RTSP_STATUS_STATE, "Method Not Valid in This State")
DEF(459, RTSP_STATUS_AGGREGATE, "Aggregate operation not allowed")
DEF(460, RTSP_STATUS_ONLY_AGGREGATE, "Only aggregate operation allowed")
DEF(461, RTSP_STATUS_TRANSPORT, "Unsupported transport")
DEF(500, RTSP_STATUS_INTERNAL, "Internal Server Error")
DEF(503, RTSP_STATUS_SERVICE, "Service Unavailable")
DEF(505, RTSP_STATUS_VERSION, "RTSP Version not supported")
/*
* RTSP definitions
* 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
*/
/** RTSP handling */
enum RTSPStatusCode {
RTSP_STATUS_OK =200, /**< OK */
RTSP_STATUS_METHOD =405, /**< Method Not Allowed */
RTSP_STATUS_BANDWIDTH =453, /**< Not Enough Bandwidth */
RTSP_STATUS_SESSION =454, /**< Session Not Found */
RTSP_STATUS_STATE =455, /**< Method Not Valid in This State */
RTSP_STATUS_AGGREGATE =459, /**< Aggregate operation not allowed */
RTSP_STATUS_ONLY_AGGREGATE =460, /**< Only aggregate operation allowed */
RTSP_STATUS_TRANSPORT =461, /**< Unsupported transport */
RTSP_STATUS_INTERNAL =500, /**< Internal Server Error */
RTSP_STATUS_SERVICE =503, /**< Service Unavailable */
RTSP_STATUS_VERSION =505, /**< RTSP Version not supported */
};
Binary file not shown.
Binary file not shown.
Binary file not shown.