update to ffmpeg-0.4.9-pre1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBAVFORMAT_BUILD 4608
|
||||
#define LIBAVFORMAT_BUILD 4616
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT
|
||||
#define LIBAVFORMAT_VERSION FFMPEG_VERSION
|
||||
#define LIBAVFORMAT_IDENT "FFmpeg" FFMPEG_VERSION "b" AV_STRINGIFY(LIBAVFORMAT_BUILD)
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <stdio.h> /* FILE */
|
||||
#include "avcodec.h"
|
||||
|
||||
#include "avio.h"
|
||||
@@ -27,29 +27,33 @@ extern "C" {
|
||||
#define MININT64 int64_t_C(0x8000000000000000)
|
||||
#endif
|
||||
|
||||
#define AV_NOPTS_VALUE MININT64
|
||||
#define AV_TIME_BASE 1000000
|
||||
|
||||
typedef struct AVPacket {
|
||||
int64_t pts; /* presentation time stamp in stream units (set av_set_pts_info) */
|
||||
int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or
|
||||
pts_den units in muxers or demuxers) */
|
||||
int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or
|
||||
pts_den units in muxers or demuxers) */
|
||||
uint8_t *data;
|
||||
int size;
|
||||
int stream_index;
|
||||
int flags;
|
||||
int duration;
|
||||
int duration; /* presentation duration (0 if not available) */
|
||||
void (*destruct)(struct AVPacket *);
|
||||
void *priv;
|
||||
} AVPacket;
|
||||
#define PKT_FLAG_KEY 0x0001
|
||||
|
||||
/* initialize optional fields of a packet */
|
||||
static inline void av_init_packet(AVPacket *pkt)
|
||||
{
|
||||
pkt->pts = AV_NOPTS_VALUE;
|
||||
pkt->dts = AV_NOPTS_VALUE;
|
||||
pkt->duration = 0;
|
||||
pkt->flags = 0;
|
||||
pkt->stream_index = 0;
|
||||
}
|
||||
|
||||
int av_new_packet(AVPacket *pkt, int size);
|
||||
int av_dup_packet(AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Free a packet
|
||||
@@ -102,12 +106,16 @@ typedef struct AVFormatParameters {
|
||||
int channel; /* used to select dv channel */
|
||||
const char *device; /* video4linux, audio or DV device */
|
||||
const char *standard; /* tv standard, NTSC, PAL, SECAM */
|
||||
int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
|
||||
int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
|
||||
stream packet (only meaningful if
|
||||
mpeg2ts_raw is TRUE */
|
||||
int initial_pause:1; /* do not begin to play the stream
|
||||
immediately (RTSP only) */
|
||||
} AVFormatParameters;
|
||||
|
||||
#define AVFMT_NOFILE 0x0001 /* no file should be opened */
|
||||
#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
|
||||
#define AVFMT_NOHEADER 0x0004 /* signal that no header is present
|
||||
(streams are added dynamically) */
|
||||
#define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
|
||||
#define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
|
||||
raw picture data */
|
||||
@@ -123,9 +131,7 @@ typedef struct AVOutputFormat {
|
||||
enum CodecID audio_codec; /* default audio codec */
|
||||
enum CodecID video_codec; /* default video codec */
|
||||
int (*write_header)(struct AVFormatContext *);
|
||||
int (*write_packet)(struct AVFormatContext *,
|
||||
int stream_index,
|
||||
const uint8_t *buf, int size, int64_t pts);
|
||||
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
|
||||
int (*write_trailer)(struct AVFormatContext *);
|
||||
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
|
||||
int flags;
|
||||
@@ -150,15 +156,21 @@ typedef struct AVInputFormat {
|
||||
AVFormatParameters *ap);
|
||||
/* read one packet and put it in 'pkt'. pts and flags are also
|
||||
set. 'av_new_stream' can be called only if the flag
|
||||
AVFMT_NOHEADER is used. */
|
||||
AVFMTCTX_NOHEADER is used. */
|
||||
int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
|
||||
/* close the stream. The AVFormatContext and AVStreams are not
|
||||
freed by this function */
|
||||
int (*read_close)(struct AVFormatContext *);
|
||||
/* seek at or before a given pts (given in microsecond). The pts
|
||||
origin is defined by the stream */
|
||||
int (*read_seek)(struct AVFormatContext *, int64_t pts);
|
||||
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
|
||||
/* seek at or before a given timestamp (given in AV_TIME_BASE
|
||||
units) relative to the frames in stream component stream_index */
|
||||
int (*read_seek)(struct AVFormatContext *,
|
||||
int stream_index, int64_t timestamp);
|
||||
/**
|
||||
* gets the next timestamp in AV_TIME_BASE units.
|
||||
*/
|
||||
int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
|
||||
int64_t *pos, int64_t pos_limit);
|
||||
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
|
||||
int flags;
|
||||
/* if extensions are defined, then no probe is done. You should
|
||||
usually not use extension format guessing because it is not
|
||||
@@ -166,10 +178,28 @@ typedef struct AVInputFormat {
|
||||
const char *extensions;
|
||||
/* general purpose read only value that the format can use */
|
||||
int value;
|
||||
|
||||
/* start/resume playing - only meaningful if using a network based format
|
||||
(RTSP) */
|
||||
int (*read_play)(struct AVFormatContext *);
|
||||
|
||||
/* pause playing - only meaningful if using a network based format
|
||||
(RTSP) */
|
||||
int (*read_pause)(struct AVFormatContext *);
|
||||
|
||||
/* private fields */
|
||||
struct AVInputFormat *next;
|
||||
} AVInputFormat;
|
||||
|
||||
typedef struct AVIndexEntry {
|
||||
int64_t pos;
|
||||
int64_t timestamp;
|
||||
#define AVINDEX_KEYFRAME 0x0001
|
||||
/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */
|
||||
int flags;
|
||||
int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
|
||||
} AVIndexEntry;
|
||||
|
||||
typedef struct AVStream {
|
||||
int index; /* stream index in AVFormatContext */
|
||||
int id; /* format specific stream id */
|
||||
@@ -178,11 +208,12 @@ typedef struct AVStream {
|
||||
int r_frame_rate_base;/* real frame rate base of the stream */
|
||||
void *priv_data;
|
||||
/* internal data used in av_find_stream_info() */
|
||||
int codec_info_state;
|
||||
int codec_info_nb_repeat_frames;
|
||||
int codec_info_nb_real_frames;
|
||||
/* PTS generation when outputing stream */
|
||||
int64_t codec_info_duration;
|
||||
int codec_info_nb_frames;
|
||||
/* encoding: PTS generation when outputing stream */
|
||||
AVFrac pts;
|
||||
AVRational time_base;
|
||||
int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
|
||||
/* ffmpeg.c private use */
|
||||
int stream_copy; /* if TRUE, just copy stream */
|
||||
/* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
|
||||
@@ -194,12 +225,29 @@ typedef struct AVStream {
|
||||
/* decoding: duration of the stream, in AV_TIME_BASE fractional
|
||||
seconds. */
|
||||
int64_t duration;
|
||||
|
||||
/* av_read_frame() support */
|
||||
int need_parsing;
|
||||
struct AVCodecParserContext *parser;
|
||||
|
||||
int64_t cur_dts;
|
||||
int last_IP_duration;
|
||||
int64_t last_IP_pts;
|
||||
/* av_seek_frame() support */
|
||||
AVIndexEntry *index_entries; /* only used if the format does not
|
||||
support seeking natively */
|
||||
int nb_index_entries;
|
||||
int index_entries_allocated_size;
|
||||
} AVStream;
|
||||
|
||||
#define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
|
||||
(streams are added dynamically) */
|
||||
|
||||
#define MAX_STREAMS 20
|
||||
|
||||
/* format I/O context */
|
||||
typedef struct AVFormatContext {
|
||||
AVClass *av_class; /* set by av_alloc_format_context */
|
||||
/* can only be iformat or oformat, not both at the same time */
|
||||
struct AVInputFormat *iformat;
|
||||
struct AVOutputFormat *oformat;
|
||||
@@ -209,6 +257,7 @@ typedef struct AVFormatContext {
|
||||
AVStream *streams[MAX_STREAMS];
|
||||
char filename[1024]; /* input or output filename */
|
||||
/* stream info */
|
||||
int64_t timestamp;
|
||||
char title[512];
|
||||
char author[512];
|
||||
char copyright[512];
|
||||
@@ -218,10 +267,8 @@ typedef struct AVFormatContext {
|
||||
int track; /* track number, 0 if none */
|
||||
char genre[32]; /* ID3 genre */
|
||||
|
||||
int flags; /* format specific flags */
|
||||
int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
|
||||
/* private data for pts handling (do not modify directly) */
|
||||
int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
|
||||
int pts_num, pts_den; /* value to convert to seconds */
|
||||
/* This buffer is only needed when packets were already buffered but
|
||||
not decoded, for example to get the codec parameters in mpeg
|
||||
streams */
|
||||
@@ -241,6 +288,16 @@ typedef struct AVFormatContext {
|
||||
available. Never set it directly if the file_size and the
|
||||
duration are known as ffmpeg can compute it automatically. */
|
||||
int bit_rate;
|
||||
|
||||
/* av_read_frame() support */
|
||||
AVStream *cur_st;
|
||||
const uint8_t *cur_ptr;
|
||||
int cur_len;
|
||||
AVPacket cur_pkt;
|
||||
|
||||
/* av_seek_frame() support */
|
||||
int64_t data_offset; /* offset of the first packet */
|
||||
int index_built;
|
||||
} AVFormatContext;
|
||||
|
||||
typedef struct AVPacketList {
|
||||
@@ -306,6 +363,7 @@ extern AVImageFormat png_image_format;
|
||||
#endif
|
||||
extern AVImageFormat jpeg_image_format;
|
||||
extern AVImageFormat gif_image_format;
|
||||
extern AVImageFormat sgi_image_format;
|
||||
|
||||
/* XXX: use automatic init with either ELF sections or C file parser */
|
||||
/* modules */
|
||||
@@ -364,9 +422,11 @@ int au_init(void);
|
||||
int amr_init(void);
|
||||
|
||||
/* wav.c */
|
||||
int wav_init(void);
|
||||
int ff_wav_init(void);
|
||||
|
||||
/* raw.c */
|
||||
int pcm_read_seek(AVFormatContext *s,
|
||||
int stream_index, int64_t timestamp);
|
||||
int raw_init(void);
|
||||
|
||||
/* mp3.c */
|
||||
@@ -379,7 +439,7 @@ int yuv4mpeg_init(void);
|
||||
int ogg_init(void);
|
||||
|
||||
/* dv.c */
|
||||
int dv_init(void);
|
||||
int ff_dv_init(void);
|
||||
|
||||
/* ffm.c */
|
||||
int ffm_init(void);
|
||||
@@ -406,6 +466,24 @@ int nut_init(void);
|
||||
/* wc3movie.c */
|
||||
int wc3_init(void);
|
||||
|
||||
/* westwood.c */
|
||||
int westwood_init(void);
|
||||
|
||||
/* segafilm.c */
|
||||
int film_init(void);
|
||||
|
||||
/* idcin.c */
|
||||
int idcin_init(void);
|
||||
|
||||
/* flic.c */
|
||||
int flic_init(void);
|
||||
|
||||
/* sierravmd.c */
|
||||
int vmd_init(void);
|
||||
|
||||
/* matroska.c */
|
||||
int matroska_init(void);
|
||||
|
||||
#include "rtp.h"
|
||||
|
||||
#include "rtsp.h"
|
||||
@@ -421,7 +499,8 @@ AVOutputFormat *guess_stream_format(const char *short_name,
|
||||
AVOutputFormat *guess_format(const char *short_name,
|
||||
const char *filename, const char *mime_type);
|
||||
|
||||
void av_hex_dump(uint8_t *buf, int size);
|
||||
void av_hex_dump(FILE *f, uint8_t *buf, int size);
|
||||
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
|
||||
|
||||
void av_register_all(void);
|
||||
|
||||
@@ -439,10 +518,15 @@ void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr);
|
||||
/* media file input */
|
||||
AVInputFormat *av_find_input_format(const char *short_name);
|
||||
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
|
||||
int av_open_input_stream(AVFormatContext **ic_ptr,
|
||||
ByteIOContext *pb, const char *filename,
|
||||
AVInputFormat *fmt, AVFormatParameters *ap);
|
||||
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
|
||||
AVInputFormat *fmt,
|
||||
int buf_size,
|
||||
AVFormatParameters *ap);
|
||||
/* no av_open for output, so applications will need this: */
|
||||
AVFormatContext *av_alloc_format_context(void);
|
||||
|
||||
#define AVERROR_UNKNOWN (-1) /* unknown error */
|
||||
#define AVERROR_IO (-2) /* i/o error */
|
||||
@@ -450,19 +534,31 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
|
||||
#define AVERROR_INVALIDDATA (-4) /* invalid data found */
|
||||
#define AVERROR_NOMEM (-5) /* not enough memory */
|
||||
#define AVERROR_NOFMT (-6) /* unknown format */
|
||||
|
||||
#define AVERROR_NOTSUPP (-7) /* operation not supported */
|
||||
|
||||
int av_find_stream_info(AVFormatContext *ic);
|
||||
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
|
||||
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
|
||||
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp);
|
||||
int av_read_play(AVFormatContext *s);
|
||||
int av_read_pause(AVFormatContext *s);
|
||||
void av_close_input_file(AVFormatContext *s);
|
||||
AVStream *av_new_stream(AVFormatContext *s, int id);
|
||||
void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits,
|
||||
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
|
||||
int pts_num, int pts_den);
|
||||
|
||||
int av_find_default_stream_index(AVFormatContext *s);
|
||||
int av_index_search_timestamp(AVStream *st, int timestamp);
|
||||
int av_add_index_entry(AVStream *st,
|
||||
int64_t pos, int64_t timestamp, int distance, int flags);
|
||||
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts);
|
||||
|
||||
/* media file output */
|
||||
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
|
||||
int av_write_header(AVFormatContext *s);
|
||||
int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf,
|
||||
int size);
|
||||
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
|
||||
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
|
||||
|
||||
int av_write_trailer(AVFormatContext *s);
|
||||
|
||||
void dump_format(AVFormatContext *ic,
|
||||
|
||||
@@ -78,6 +78,9 @@ typedef struct {
|
||||
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);
|
||||
} ByteIOContext;
|
||||
|
||||
int init_put_byte(ByteIOContext *s,
|
||||
@@ -110,7 +113,7 @@ int url_feof(ByteIOContext *s);
|
||||
#define URL_EOF (-1)
|
||||
int url_fgetc(ByteIOContext *s);
|
||||
#ifdef __GNUC__
|
||||
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
#else
|
||||
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
|
||||
#endif
|
||||
@@ -119,6 +122,7 @@ 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);
|
||||
int get_byte(ByteIOContext *s);
|
||||
unsigned int get_le32(ByteIOContext *s);
|
||||
uint64_t get_le64(ByteIOContext *s);
|
||||
@@ -149,6 +153,10 @@ int url_open_dyn_buf(ByteIOContext *s);
|
||||
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
|
||||
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;
|
||||
extern URLProtocol pipe_protocol;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
# define CONFIG_WIN32
|
||||
# define EMULATE_INTTYPES
|
||||
#endif
|
||||
|
||||
//#define ALT_BITSTREAM_WRITER
|
||||
@@ -18,6 +19,10 @@
|
||||
//#define A32_BITSTREAM_READER
|
||||
#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
/* only include the following when compiling package */
|
||||
# include "config.h"
|
||||
@@ -26,6 +31,7 @@
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <ctype.h>
|
||||
# include <limits.h>
|
||||
# ifndef __BEOS__
|
||||
# include <errno.h>
|
||||
# else
|
||||
@@ -37,10 +43,6 @@
|
||||
# define ENODATA 61
|
||||
# endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#ifndef offsetof
|
||||
# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
|
||||
@@ -76,51 +78,103 @@ extern const struct AVOption avoptions_workaround_bug[11];
|
||||
# define restrict
|
||||
#endif
|
||||
|
||||
#ifndef always_inline
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define always_inline __attribute__((always_inline)) inline
|
||||
#else
|
||||
# define always_inline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef attribute_used
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define attribute_used __attribute__((used))
|
||||
#else
|
||||
# define attribute_used
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EMULATE_INTTYPES
|
||||
# include <inttypes.h>
|
||||
#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;
|
||||
|
||||
# ifdef CONFIG_WIN32
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# else /* other OS */
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# endif /* other OS */
|
||||
#endif /* HAVE_INTTYPES_H */
|
||||
|
||||
#ifndef INT64_MAX
|
||||
#define INT64_MAX int64_t_C(9223372036854775807)
|
||||
#endif
|
||||
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF)
|
||||
#endif
|
||||
|
||||
#ifdef EMULATE_FAST_INT
|
||||
/* note that we don't emulate 64bit ints */
|
||||
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;
|
||||
#endif
|
||||
|
||||
#ifndef INT_BIT
|
||||
# if INT_MAX != 2147483647
|
||||
# define INT_BIT 64
|
||||
# else
|
||||
# define INT_BIT 32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_OS2) || defined(CONFIG_SUNOS)
|
||||
static inline float floorf(float f) {
|
||||
return floor(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WIN32
|
||||
|
||||
/* windows */
|
||||
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef signed char int8_t;
|
||||
typedef signed int int32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
|
||||
# ifndef __MINGW32__
|
||||
# if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
# define int64_t_C(c) (c ## i64)
|
||||
# define uint64_t_C(c) (c ## i64)
|
||||
|
||||
# define inline __inline
|
||||
# ifdef HAVE_AV_CONFIG_H
|
||||
# define inline __inline
|
||||
# endif
|
||||
|
||||
# else
|
||||
# define int64_t_C(c) (c ## LL)
|
||||
# define uint64_t_C(c) (c ## ULL)
|
||||
# endif /* __MINGW32__ */
|
||||
|
||||
# ifdef _DEBUG
|
||||
# ifndef DEBUG
|
||||
# define DEBUG
|
||||
# endif
|
||||
# endif
|
||||
# ifdef HAVE_AV_CONFIG_H
|
||||
# ifdef _DEBUG
|
||||
# define DEBUG
|
||||
# endif
|
||||
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
|
||||
/* CONFIG_WIN32 end */
|
||||
#elif defined (CONFIG_OS2)
|
||||
/* OS/2 EMX */
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef int64_t_C
|
||||
#define int64_t_C(c) (c ## LL)
|
||||
#define uint64_t_C(c) (c ## ULL)
|
||||
@@ -141,8 +195,6 @@ typedef signed __int64 int64_t;
|
||||
|
||||
/* unix */
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef int64_t_C
|
||||
#define int64_t_C(c) (c ## LL)
|
||||
#define uint64_t_C(c) (c ## ULL)
|
||||
@@ -176,24 +228,24 @@ typedef signed __int64 int64_t;
|
||||
# include <assert.h>
|
||||
|
||||
/* dprintf macros */
|
||||
# if defined(CONFIG_WIN32) && !defined(__MINGW32__)
|
||||
# if defined(CONFIG_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
|
||||
inline void dprintf(const char* fmt,...) {}
|
||||
|
||||
# else
|
||||
|
||||
# ifdef DEBUG
|
||||
# define dprintf(fmt,args...) printf(fmt, ## args)
|
||||
# define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__)
|
||||
# else
|
||||
# define dprintf(fmt,args...)
|
||||
# define dprintf(fmt,...)
|
||||
# endif
|
||||
|
||||
# endif /* !CONFIG_WIN32 */
|
||||
|
||||
# define av_abort() do { fprintf(stderr, "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)
|
||||
|
||||
//rounded divison & shift
|
||||
#define RSHIFT(a,b) ((a) > 0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b))
|
||||
#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)))
|
||||
@@ -243,10 +295,7 @@ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
|
||||
|
||||
/* bit output */
|
||||
|
||||
struct PutBitContext;
|
||||
|
||||
typedef void (*WriteDataFunc)(void *, uint8_t *, int);
|
||||
|
||||
/* buf and buf_end must be present and used by every alternative writer. */
|
||||
typedef struct PutBitContext {
|
||||
#ifdef ALT_BITSTREAM_WRITER
|
||||
uint8_t *buf, *buf_end;
|
||||
@@ -256,21 +305,56 @@ typedef struct PutBitContext {
|
||||
int bit_left;
|
||||
uint8_t *buf, *buf_ptr, *buf_end;
|
||||
#endif
|
||||
int64_t data_out_size; /* in bytes */
|
||||
} PutBitContext;
|
||||
|
||||
void init_put_bits(PutBitContext *s,
|
||||
uint8_t *buffer, int buffer_size,
|
||||
void *opaque,
|
||||
void (*write_data)(void *, uint8_t *, int));
|
||||
static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
|
||||
{
|
||||
s->buf = buffer;
|
||||
s->buf_end = s->buf + buffer_size;
|
||||
#ifdef ALT_BITSTREAM_WRITER
|
||||
s->index=0;
|
||||
((uint32_t*)(s->buf))[0]=0;
|
||||
// memset(buffer, 0, buffer_size);
|
||||
#else
|
||||
s->buf_ptr = s->buf;
|
||||
s->bit_left=32;
|
||||
s->bit_buf=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* return the number of bits output */
|
||||
static inline int put_bits_count(PutBitContext *s)
|
||||
{
|
||||
#ifdef ALT_BITSTREAM_WRITER
|
||||
return s->index;
|
||||
#else
|
||||
return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* pad the end of the output stream with zeros */
|
||||
static inline void flush_put_bits(PutBitContext *s)
|
||||
{
|
||||
#ifdef ALT_BITSTREAM_WRITER
|
||||
align_put_bits(s);
|
||||
#else
|
||||
s->bit_buf<<= s->bit_left;
|
||||
while (s->bit_left < 32) {
|
||||
/* XXX: should test end of buffer */
|
||||
*s->buf_ptr++=s->bit_buf >> 24;
|
||||
s->bit_buf<<=8;
|
||||
s->bit_left+=8;
|
||||
}
|
||||
s->bit_left=32;
|
||||
s->bit_buf=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */
|
||||
void align_put_bits(PutBitContext *s);
|
||||
void flush_put_bits(PutBitContext *s);
|
||||
void put_string(PutBitContext * pbc, char *s);
|
||||
void put_string(PutBitContext * pbc, char *s, int put_zero);
|
||||
|
||||
/* bit input */
|
||||
|
||||
/* buffer, buffer_end and size_in_bits must be present and used by every reader */
|
||||
typedef struct GetBitContext {
|
||||
const uint8_t *buffer, *buffer_end;
|
||||
#ifdef ALT_BITSTREAM_READER
|
||||
@@ -288,8 +372,6 @@ typedef struct GetBitContext {
|
||||
int size_in_bits;
|
||||
} GetBitContext;
|
||||
|
||||
static inline int get_bits_count(GetBitContext *s);
|
||||
|
||||
#define VLC_TYPE int16_t
|
||||
|
||||
typedef struct VLC {
|
||||
@@ -304,7 +386,7 @@ typedef struct RL_VLC_ELEM {
|
||||
uint8_t run;
|
||||
} RL_VLC_ELEM;
|
||||
|
||||
#ifdef ARCH_SPARC64
|
||||
#ifdef ARCH_SPARC
|
||||
#define UNALIGNED_STORES_ARE_BAD
|
||||
#endif
|
||||
|
||||
@@ -355,7 +437,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
|
||||
bit_buf<<=bit_left;
|
||||
bit_buf |= value >> (n - bit_left);
|
||||
#ifdef UNALIGNED_STORES_ARE_BAD
|
||||
if (3 & (int) s->buf_ptr) {
|
||||
if (3 & (intptr_t) s->buf_ptr) {
|
||||
s->buf_ptr[0] = bit_buf >> 24;
|
||||
s->buf_ptr[1] = bit_buf >> 16;
|
||||
s->buf_ptr[2] = bit_buf >> 8;
|
||||
@@ -451,6 +533,28 @@ static inline uint8_t* pbBufPtr(PutBitContext *s)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* PutBitContext must be flushed & aligned to a byte boundary before calling this.
|
||||
*/
|
||||
static inline void skip_put_bytes(PutBitContext *s, int n){
|
||||
assert((put_bits_count(s)&7)==0);
|
||||
#ifdef ALT_BITSTREAM_WRITER
|
||||
FIXME may need some cleaning of the buffer
|
||||
s->index += n<<3;
|
||||
#else
|
||||
assert(s->bit_left==32);
|
||||
s->buf_ptr += n;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the end of the buffer.
|
||||
*/
|
||||
static inline void set_put_bits_buffer_size(PutBitContext *s, int size){
|
||||
s->buf_end= s->buf + size;
|
||||
}
|
||||
|
||||
/* Bitstream reader API docs:
|
||||
name
|
||||
abritary name which is used as prefix for the internal variables
|
||||
@@ -773,8 +877,52 @@ static inline void skip_bits1(GetBitContext *s){
|
||||
skip_bits(s, 1);
|
||||
}
|
||||
|
||||
void init_get_bits(GetBitContext *s,
|
||||
const uint8_t *buffer, int buffer_size);
|
||||
/**
|
||||
* init GetBitContext.
|
||||
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
|
||||
* because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
|
||||
* @param bit_size the size of the buffer in bits
|
||||
*/
|
||||
static inline void init_get_bits(GetBitContext *s,
|
||||
const uint8_t *buffer, int bit_size)
|
||||
{
|
||||
const int buffer_size= (bit_size+7)>>3;
|
||||
|
||||
s->buffer= buffer;
|
||||
s->size_in_bits= bit_size;
|
||||
s->buffer_end= buffer + buffer_size;
|
||||
#ifdef ALT_BITSTREAM_READER
|
||||
s->index=0;
|
||||
#elif defined LIBMPEG2_BITSTREAM_READER
|
||||
#ifdef LIBMPEG2_BITSTREAM_READER_HACK
|
||||
if ((int)buffer&1) {
|
||||
/* word alignment */
|
||||
s->cache = (*buffer++)<<24;
|
||||
s->buffer_ptr = buffer;
|
||||
s->bit_count = 16-8;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
s->buffer_ptr = buffer;
|
||||
s->bit_count = 16;
|
||||
s->cache = 0;
|
||||
}
|
||||
#elif defined A32_BITSTREAM_READER
|
||||
s->buffer_ptr = (uint32_t*)buffer;
|
||||
s->bit_count = 32;
|
||||
s->cache0 = 0;
|
||||
s->cache1 = 0;
|
||||
#endif
|
||||
{
|
||||
OPEN_READER(re, s)
|
||||
UPDATE_CACHE(re, s)
|
||||
UPDATE_CACHE(re, s)
|
||||
CLOSE_READER(re, s)
|
||||
}
|
||||
#ifdef A32_BITSTREAM_READER
|
||||
s->cache1 = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int check_marker(GetBitContext *s, const char *msg);
|
||||
void align_get_bits(GetBitContext *s);
|
||||
@@ -927,10 +1075,10 @@ static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *fun
|
||||
#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
|
||||
#define tprintf printf
|
||||
#define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__)
|
||||
|
||||
#else //TRACE
|
||||
#define tprintf(_arg...) {}
|
||||
#define tprintf(...) {}
|
||||
#endif
|
||||
|
||||
/* define it to include statistics code (useful only for optimizing
|
||||
@@ -992,23 +1140,31 @@ static inline int av_log2_16bit(unsigned int v)
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/* median of 3 */
|
||||
static inline int mid_pred(int a, int b, int c)
|
||||
{
|
||||
int vmin, vmax;
|
||||
vmax = vmin = a;
|
||||
if (b < vmin)
|
||||
vmin = b;
|
||||
else
|
||||
vmax = b;
|
||||
#if 0
|
||||
int t= (a-b)&((a-b)>>31);
|
||||
a-=t;
|
||||
b+=t;
|
||||
b-= (b-c)&((b-c)>>31);
|
||||
b+= (a-b)&((a-b)>>31);
|
||||
|
||||
if (c < vmin)
|
||||
vmin = c;
|
||||
else if (c > vmax)
|
||||
vmax = c;
|
||||
|
||||
return a + b + c - vmin - vmax;
|
||||
return b;
|
||||
#else
|
||||
if(a>b){
|
||||
if(c>b){
|
||||
if(c>a) b=a;
|
||||
else b=c;
|
||||
}
|
||||
}else{
|
||||
if(b>c){
|
||||
if(c>a) b=c;
|
||||
else b=a;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int clip(int a, int amin, int amax)
|
||||
@@ -1021,6 +1177,12 @@ static inline int clip(int a, int amin, int amax)
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline int clip_uint8(int a)
|
||||
{
|
||||
if (a&(~255)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/* math */
|
||||
extern const uint8_t ff_sqrt_tab[128];
|
||||
|
||||
@@ -1057,9 +1219,6 @@ static inline int ff_get_fourcc(const char *s){
|
||||
#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
|
||||
|
||||
|
||||
void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max);
|
||||
|
||||
|
||||
#ifdef ARCH_X86
|
||||
#define MASK_ABS(mask, level)\
|
||||
asm volatile(\
|
||||
@@ -1105,21 +1264,23 @@ static inline long long rdtsc()
|
||||
}
|
||||
|
||||
#define START_TIMER \
|
||||
static uint64_t tsum=0;\
|
||||
static int tcount=0;\
|
||||
static int tskip_count=0;\
|
||||
uint64_t tend;\
|
||||
uint64_t tstart= rdtsc();\
|
||||
|
||||
#define STOP_TIMER(id) \
|
||||
tend= rdtsc();\
|
||||
if(tcount<2 || tend - tstart < 4*tsum/tcount){\
|
||||
tsum+= tend - tstart;\
|
||||
tcount++;\
|
||||
}else\
|
||||
tskip_count++;\
|
||||
if(256*256*256*64%(tcount+tskip_count)==0){\
|
||||
fprintf(stderr, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\
|
||||
{\
|
||||
static uint64_t tsum=0;\
|
||||
static int tcount=0;\
|
||||
static int tskip_count=0;\
|
||||
if(tcount<2 || tend - tstart < 8*tsum/tcount){\
|
||||
tsum+= tend - tstart;\
|
||||
tcount++;\
|
||||
}else\
|
||||
tskip_count++;\
|
||||
if(256*256*256*64%(tcount+tskip_count)==0){\
|
||||
av_log(NULL, AV_LOG_DEBUG, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\
|
||||
}\
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1129,6 +1290,13 @@ if(256*256*256*64%(tcount+tskip_count)==0){\
|
||||
#define malloc please_use_av_malloc
|
||||
#define free please_use_av_free
|
||||
#define realloc please_use_av_realloc
|
||||
#define time time_is_forbidden_due_to_security_issues
|
||||
#define rand rand_is_forbidden_due_to_state_trashing
|
||||
#define srand srand_is_forbidden_due_to_state_trashing
|
||||
#if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H))
|
||||
#define printf please_use_av_log
|
||||
#define fprintf please_use_av_log
|
||||
#endif
|
||||
|
||||
#define CHECKED_ALLOCZ(p, size)\
|
||||
{\
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user