Explicitly include ffmpeg stuff.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,888 @@
|
||||
/*
|
||||
* 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 AVFORMAT_H
|
||||
#define AVFORMAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(11<<8)+0)
|
||||
#define LIBAVFORMAT_VERSION 51.11.0
|
||||
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
|
||||
|
||||
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h> /* FILE */
|
||||
#include "avcodec.h"
|
||||
|
||||
#include "avio.h"
|
||||
|
||||
/* packet functions */
|
||||
|
||||
typedef struct AVPacket {
|
||||
int64_t pts; ///< presentation time stamp in time_base units
|
||||
int64_t dts; ///< decompression time stamp in time_base units
|
||||
uint8_t *data;
|
||||
int size;
|
||||
int stream_index;
|
||||
int flags;
|
||||
int duration; ///< presentation duration in time_base units (0 if not available)
|
||||
void (*destruct)(struct AVPacket *);
|
||||
void *priv;
|
||||
int64_t pos; ///< byte position in stream, -1 if unknown
|
||||
} AVPacket;
|
||||
#define PKT_FLAG_KEY 0x0001
|
||||
|
||||
void av_destruct_packet_nofree(AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Default packet destructor.
|
||||
*/
|
||||
void av_destruct_packet(AVPacket *pkt);
|
||||
|
||||
/* 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->pos = -1;
|
||||
pkt->duration = 0;
|
||||
pkt->flags = 0;
|
||||
pkt->stream_index = 0;
|
||||
pkt->destruct= av_destruct_packet_nofree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the payload of a packet and intialized its fields to default values.
|
||||
*
|
||||
* @param pkt packet
|
||||
* @param size wanted payload size
|
||||
* @return 0 if OK. AVERROR_xxx otherwise.
|
||||
*/
|
||||
int av_new_packet(AVPacket *pkt, int size);
|
||||
|
||||
/**
|
||||
* Allocate and read the payload of a packet and intialized its fields to default values.
|
||||
*
|
||||
* @param pkt packet
|
||||
* @param size wanted payload size
|
||||
* @return >0 (read size) if OK. AVERROR_xxx otherwise.
|
||||
*/
|
||||
int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
|
||||
|
||||
/**
|
||||
* @warning This is a hack - the packet memory allocation stuff is broken. The
|
||||
* packet is allocated if it was not really allocated
|
||||
*/
|
||||
int av_dup_packet(AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Free a packet
|
||||
*
|
||||
* @param pkt packet to free
|
||||
*/
|
||||
static inline void av_free_packet(AVPacket *pkt)
|
||||
{
|
||||
if (pkt && pkt->destruct) {
|
||||
pkt->destruct(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************/
|
||||
/* fractional numbers for exact pts handling */
|
||||
|
||||
/* the exact value of the fractional number is: 'val + num / den'. num
|
||||
is assumed to be such as 0 <= num < den */
|
||||
typedef struct AVFrac {
|
||||
int64_t val, num, den;
|
||||
} AVFrac attribute_deprecated;
|
||||
|
||||
/*************************************************/
|
||||
/* input/output formats */
|
||||
|
||||
struct AVCodecTag;
|
||||
|
||||
struct AVFormatContext;
|
||||
|
||||
/** this structure contains the data a format has to probe a file */
|
||||
typedef struct AVProbeData {
|
||||
const char *filename;
|
||||
unsigned char *buf;
|
||||
int buf_size;
|
||||
} AVProbeData;
|
||||
|
||||
#define AVPROBE_SCORE_MAX 100 ///< max score, half of that is used for file extension based detection
|
||||
|
||||
typedef struct AVFormatParameters {
|
||||
AVRational time_base;
|
||||
int sample_rate;
|
||||
int channels;
|
||||
int width;
|
||||
int height;
|
||||
enum PixelFormat pix_fmt;
|
||||
int channel; /**< used to select dv channel */
|
||||
#if LIBAVFORMAT_VERSION_INT < (52<<16)
|
||||
const char *device; /**< video, audio or DV device */
|
||||
#endif
|
||||
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) */
|
||||
int prealloced_context:1;
|
||||
enum CodecID video_codec_id;
|
||||
enum CodecID audio_codec_id;
|
||||
} AVFormatParameters;
|
||||
|
||||
//! demuxer will use url_fopen, no opened file should be provided by the caller
|
||||
#define AVFMT_NOFILE 0x0001
|
||||
#define AVFMT_NEEDNUMBER 0x0002 /**< needs '%d' in filename */
|
||||
#define AVFMT_SHOW_IDS 0x0008 /**< show format stream IDs numbers */
|
||||
#define AVFMT_RAWPICTURE 0x0020 /**< format wants AVPicture structure for
|
||||
raw picture data */
|
||||
#define AVFMT_GLOBALHEADER 0x0040 /**< format wants global header */
|
||||
#define AVFMT_NOTIMESTAMPS 0x0080 /**< format doesnt need / has any timestamps */
|
||||
#define AVFMT_GENERIC_INDEX 0x0100 /**< use generic index building code */
|
||||
|
||||
typedef struct AVOutputFormat {
|
||||
const char *name;
|
||||
const char *long_name;
|
||||
const char *mime_type;
|
||||
const char *extensions; /**< comma separated filename extensions */
|
||||
/** size of private data so that it can be allocated in the wrapper */
|
||||
int priv_data_size;
|
||||
/* output support */
|
||||
enum CodecID audio_codec; /**< default audio codec */
|
||||
enum CodecID video_codec; /**< default video codec */
|
||||
int (*write_header)(struct AVFormatContext *);
|
||||
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
|
||||
int (*write_trailer)(struct AVFormatContext *);
|
||||
/** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
|
||||
int flags;
|
||||
/** currently only used to set pixel format if not YUV420P */
|
||||
int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
|
||||
int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
|
||||
|
||||
/**
|
||||
* list of supported codec_id-codec_tag pairs, ordered by "better choice first"
|
||||
* the arrays are all CODEC_ID_NONE terminated
|
||||
*/
|
||||
const struct AVCodecTag **codec_tag;
|
||||
|
||||
/* private fields */
|
||||
struct AVOutputFormat *next;
|
||||
} AVOutputFormat;
|
||||
|
||||
typedef struct AVInputFormat {
|
||||
const char *name;
|
||||
const char *long_name;
|
||||
/** size of private data so that it can be allocated in the wrapper */
|
||||
int priv_data_size;
|
||||
/** tell if a given file has a chance of being parsing by this format */
|
||||
int (*read_probe)(AVProbeData *);
|
||||
/** read the format header and initialize the AVFormatContext
|
||||
structure. Return 0 if OK. 'ap' if non NULL contains
|
||||
additionnal paramters. Only used in raw format right
|
||||
now. 'av_new_stream' should be called to create new streams. */
|
||||
int (*read_header)(struct AVFormatContext *,
|
||||
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
|
||||
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 to a given timestamp relative to the frames in
|
||||
* stream component stream_index
|
||||
* @param stream_index must not be -1
|
||||
* @param flags selects which direction should be preferred if no exact
|
||||
* match is available
|
||||
*/
|
||||
int (*read_seek)(struct AVFormatContext *,
|
||||
int stream_index, int64_t timestamp, int flags);
|
||||
/**
|
||||
* 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
|
||||
reliable enough */
|
||||
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 *);
|
||||
|
||||
const struct AVCodecTag **codec_tag;
|
||||
|
||||
/* private fields */
|
||||
struct AVInputFormat *next;
|
||||
} AVInputFormat;
|
||||
|
||||
typedef struct AVIndexEntry {
|
||||
int64_t pos;
|
||||
int64_t timestamp;
|
||||
#define AVINDEX_KEYFRAME 0x0001
|
||||
int flags:2;
|
||||
int size:30; //yeah trying to keep the size of this small to reduce memory requirements (its 24 vs 32 byte due to possible 8byte align)
|
||||
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 */
|
||||
AVCodecContext *codec; /**< codec context */
|
||||
/**
|
||||
* real base frame rate of the stream.
|
||||
* this is the lowest framerate with which all timestamps can be
|
||||
* represented accurately (its the least common multiple of all
|
||||
* framerates in the stream), Note, this value is just a guess!
|
||||
* for example if the timebase is 1/90000 and all frames have either
|
||||
* approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1
|
||||
*/
|
||||
AVRational r_frame_rate;
|
||||
void *priv_data;
|
||||
#if LIBAVFORMAT_VERSION_INT < (52<<16)
|
||||
/* internal data used in av_find_stream_info() */
|
||||
int64_t codec_info_duration;
|
||||
int codec_info_nb_frames;
|
||||
#endif
|
||||
/** encoding: PTS generation when outputing stream */
|
||||
AVFrac pts;
|
||||
|
||||
/**
|
||||
* this is the fundamental unit of time (in seconds) in terms
|
||||
* of which frame timestamps are represented. for fixed-fps content,
|
||||
* timebase should be 1/framerate and timestamp increments should be
|
||||
* identically 1.
|
||||
*/
|
||||
AVRational time_base;
|
||||
int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
|
||||
/* ffmpeg.c private use */
|
||||
int stream_copy; /**< if set, just copy stream */
|
||||
enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
|
||||
//FIXME move stuff to a flags field?
|
||||
/** quality, as it has been removed from AVCodecContext and put in AVVideoFrame
|
||||
* MN:dunno if thats the right place, for it */
|
||||
float quality;
|
||||
/** decoding: position of the first frame of the component, in
|
||||
AV_TIME_BASE fractional seconds. */
|
||||
int64_t start_time;
|
||||
/** decoding: duration of the stream, in AV_TIME_BASE fractional
|
||||
seconds. */
|
||||
int64_t duration;
|
||||
|
||||
char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
|
||||
|
||||
/* av_read_frame() support */
|
||||
int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
|
||||
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;
|
||||
unsigned int index_entries_allocated_size;
|
||||
|
||||
int64_t nb_frames; ///< number of frames in this stream if known or 0
|
||||
|
||||
#define MAX_REORDER_DELAY 4
|
||||
int64_t pts_buffer[MAX_REORDER_DELAY+1];
|
||||
} 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 {
|
||||
const 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;
|
||||
void *priv_data;
|
||||
ByteIOContext pb;
|
||||
unsigned int nb_streams;
|
||||
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];
|
||||
char comment[512];
|
||||
char album[512];
|
||||
int year; /**< ID3 year, 0 if none */
|
||||
int track; /**< track number, 0 if none */
|
||||
char genre[32]; /**< ID3 genre */
|
||||
|
||||
int ctx_flags; /**< format specific flags, see AVFMTCTX_xx */
|
||||
/* private data for pts handling (do not modify directly) */
|
||||
/** This buffer is only needed when packets were already buffered but
|
||||
not decoded, for example to get the codec parameters in mpeg
|
||||
streams */
|
||||
struct AVPacketList *packet_buffer;
|
||||
|
||||
/** decoding: position of the first frame of the component, in
|
||||
AV_TIME_BASE fractional seconds. NEVER set this value directly:
|
||||
it is deduced from the AVStream values. */
|
||||
int64_t start_time;
|
||||
/** decoding: duration of the stream, in AV_TIME_BASE fractional
|
||||
seconds. NEVER set this value directly: it is deduced from the
|
||||
AVStream values. */
|
||||
int64_t duration;
|
||||
/** decoding: total file size. 0 if unknown */
|
||||
int64_t file_size;
|
||||
/** decoding: total stream bitrate in bit/s, 0 if not
|
||||
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;
|
||||
|
||||
int mux_rate;
|
||||
int packet_size;
|
||||
int preload;
|
||||
int max_delay;
|
||||
|
||||
#define AVFMT_NOOUTPUTLOOP -1
|
||||
#define AVFMT_INFINITEOUTPUTLOOP 0
|
||||
/** number of times to loop output in formats that support it */
|
||||
int loop_output;
|
||||
|
||||
int flags;
|
||||
#define AVFMT_FLAG_GENPTS 0x0001 ///< generate pts if missing even if it requires parsing future frames
|
||||
#define AVFMT_FLAG_IGNIDX 0x0002 ///< ignore index
|
||||
|
||||
int loop_input;
|
||||
/** decoding: size of data to probe; encoding unused */
|
||||
unsigned int probesize;
|
||||
|
||||
/**
|
||||
* maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info()
|
||||
*/
|
||||
int max_analyze_duration;
|
||||
|
||||
const uint8_t *key;
|
||||
int keylen;
|
||||
} AVFormatContext;
|
||||
|
||||
typedef struct AVPacketList {
|
||||
AVPacket pkt;
|
||||
struct AVPacketList *next;
|
||||
} AVPacketList;
|
||||
|
||||
extern AVInputFormat *first_iformat;
|
||||
extern AVOutputFormat *first_oformat;
|
||||
|
||||
enum CodecID av_guess_image2_codec(const char *filename);
|
||||
|
||||
/* XXX: use automatic init with either ELF sections or C file parser */
|
||||
/* modules */
|
||||
|
||||
#include "rtp.h"
|
||||
|
||||
#include "rtsp.h"
|
||||
|
||||
/* utils.c */
|
||||
void av_register_input_format(AVInputFormat *format);
|
||||
void av_register_output_format(AVOutputFormat *format);
|
||||
AVOutputFormat *guess_stream_format(const char *short_name,
|
||||
const char *filename, const char *mime_type);
|
||||
AVOutputFormat *guess_format(const char *short_name,
|
||||
const char *filename, const char *mime_type);
|
||||
|
||||
/**
|
||||
* Guesses the codec id based upon muxer and filename.
|
||||
*/
|
||||
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
|
||||
const char *filename, const char *mime_type, enum CodecType type);
|
||||
|
||||
/**
|
||||
* Send a nice hexadecimal dump of a buffer to the specified file stream.
|
||||
*
|
||||
* @param f The file stream pointer where the dump should be sent to.
|
||||
* @param buf buffer
|
||||
* @param size buffer size
|
||||
*
|
||||
* @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
|
||||
*/
|
||||
void av_hex_dump(FILE *f, uint8_t *buf, int size);
|
||||
|
||||
/**
|
||||
* Send a nice hexadecimal dump of a buffer to the log.
|
||||
*
|
||||
* @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 buf buffer
|
||||
* @param size buffer size
|
||||
*
|
||||
* @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
|
||||
*/
|
||||
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
|
||||
|
||||
/**
|
||||
* Send a nice dump of a packet to the specified file stream.
|
||||
*
|
||||
* @param f The file stream pointer where the dump should be sent to.
|
||||
* @param pkt packet to dump
|
||||
* @param dump_payload true if the payload must be displayed too
|
||||
*/
|
||||
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
|
||||
|
||||
/**
|
||||
* Send a nice dump of a packet to the log.
|
||||
*
|
||||
* @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 pkt packet to dump
|
||||
* @param dump_payload true if the payload must be displayed too
|
||||
*/
|
||||
void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
|
||||
|
||||
void av_register_all(void);
|
||||
|
||||
/** codec tag <-> codec id */
|
||||
enum CodecID av_codec_get_id(const struct AVCodecTag **tags, unsigned int tag);
|
||||
unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id);
|
||||
|
||||
/* media file input */
|
||||
|
||||
/**
|
||||
* finds AVInputFormat based on input format's short name.
|
||||
*/
|
||||
AVInputFormat *av_find_input_format(const char *short_name);
|
||||
|
||||
/**
|
||||
* Guess file format.
|
||||
*
|
||||
* @param is_opened whether the file is already opened, determines whether
|
||||
* demuxers with or without AVFMT_NOFILE are probed
|
||||
*/
|
||||
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
|
||||
|
||||
/**
|
||||
* Allocates all the structures needed to read an input stream.
|
||||
* This does not open the needed codecs for decoding the stream[s].
|
||||
*/
|
||||
int av_open_input_stream(AVFormatContext **ic_ptr,
|
||||
ByteIOContext *pb, const char *filename,
|
||||
AVInputFormat *fmt, AVFormatParameters *ap);
|
||||
|
||||
/**
|
||||
* Open a media file as input. The codec are not opened. Only the file
|
||||
* header (if present) is read.
|
||||
*
|
||||
* @param ic_ptr the opened media file handle is put here
|
||||
* @param filename filename to open.
|
||||
* @param fmt if non NULL, force the file format to use
|
||||
* @param buf_size optional buffer size (zero if default is OK)
|
||||
* @param ap additionnal parameters needed when opening the file (NULL if default)
|
||||
* @return 0 if OK. AVERROR_xxx otherwise.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Read packets of a media file to get stream information. This
|
||||
* is useful for file formats with no headers such as MPEG. This
|
||||
* function also computes the real frame rate in case of mpeg2 repeat
|
||||
* frame mode.
|
||||
* The logical file position is not changed by this function;
|
||||
* examined packets may be buffered for later processing.
|
||||
*
|
||||
* @param ic media file handle
|
||||
* @return >=0 if OK. AVERROR_xxx if error.
|
||||
* @todo let user decide somehow what information is needed so we dont waste time geting stuff the user doesnt need
|
||||
*/
|
||||
int av_find_stream_info(AVFormatContext *ic);
|
||||
|
||||
/**
|
||||
* Read a transport packet from a media file.
|
||||
*
|
||||
* This function is absolete and should never be used.
|
||||
* Use av_read_frame() instead.
|
||||
*
|
||||
* @param s media file handle
|
||||
* @param pkt is filled
|
||||
* @return 0 if OK. AVERROR_xxx if error.
|
||||
*/
|
||||
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Return the next frame of a stream.
|
||||
*
|
||||
* The returned packet is valid
|
||||
* until the next av_read_frame() or until av_close_input_file() and
|
||||
* must be freed with av_free_packet. For video, the packet contains
|
||||
* exactly one frame. For audio, it contains an integer number of
|
||||
* frames if each frame has a known fixed size (e.g. PCM or ADPCM
|
||||
* data). If the audio frames have a variable size (e.g. MPEG audio),
|
||||
* then it contains one frame.
|
||||
*
|
||||
* pkt->pts, pkt->dts and pkt->duration are always set to correct
|
||||
* values in AVStream.timebase units (and guessed if the format cannot
|
||||
* provided them). pkt->pts can be AV_NOPTS_VALUE if the video format
|
||||
* has B frames, so it is better to rely on pkt->dts if you do not
|
||||
* decompress the payload.
|
||||
*
|
||||
* @return 0 if OK, < 0 if error or end of file.
|
||||
*/
|
||||
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Seek to the key frame at timestamp.
|
||||
* 'timestamp' in 'stream_index'.
|
||||
* @param stream_index If stream_index is (-1), a default
|
||||
* stream is selected, and timestamp is automatically converted
|
||||
* from AV_TIME_BASE units to the stream specific time_base.
|
||||
* @param timestamp timestamp in AVStream.time_base units
|
||||
* or if there is no stream specified then in AV_TIME_BASE units
|
||||
* @param flags flags which select direction and seeking mode
|
||||
* @return >= 0 on success
|
||||
*/
|
||||
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
|
||||
|
||||
/**
|
||||
* start playing a network based stream (e.g. RTSP stream) at the
|
||||
* current position
|
||||
*/
|
||||
int av_read_play(AVFormatContext *s);
|
||||
|
||||
/**
|
||||
* Pause a network based stream (e.g. RTSP stream).
|
||||
*
|
||||
* Use av_read_play() to resume it.
|
||||
*/
|
||||
int av_read_pause(AVFormatContext *s);
|
||||
|
||||
/**
|
||||
* Close a media file (but not its codecs).
|
||||
*
|
||||
* @param s media file handle
|
||||
*/
|
||||
void av_close_input_file(AVFormatContext *s);
|
||||
|
||||
/**
|
||||
* Add a new stream to a media file.
|
||||
*
|
||||
* Can only be called in the read_header() function. If the flag
|
||||
* AVFMTCTX_NOHEADER is in the format context, then new streams
|
||||
* can be added in read_packet too.
|
||||
*
|
||||
* @param s media file handle
|
||||
* @param id file format dependent stream id
|
||||
*/
|
||||
AVStream *av_new_stream(AVFormatContext *s, int id);
|
||||
|
||||
/**
|
||||
* Set the pts for a given stream.
|
||||
*
|
||||
* @param s stream
|
||||
* @param pts_wrap_bits number of bits effectively used by the pts
|
||||
* (used for wrap control, 33 is the value for MPEG)
|
||||
* @param pts_num numerator to convert to seconds (MPEG: 1)
|
||||
* @param pts_den denominator to convert to seconds (MPEG: 90000)
|
||||
*/
|
||||
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
|
||||
int pts_num, int pts_den);
|
||||
|
||||
#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
|
||||
#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
|
||||
#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non keyframes
|
||||
|
||||
int av_find_default_stream_index(AVFormatContext *s);
|
||||
|
||||
/**
|
||||
* Gets the index for a specific timestamp.
|
||||
* @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to
|
||||
* the timestamp which is <= the requested one, if backward is 0
|
||||
* then it will be >=
|
||||
* if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
|
||||
* @return < 0 if no such timestamp could be found
|
||||
*/
|
||||
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
|
||||
|
||||
/**
|
||||
* Add a index entry into a sorted list updateing if it is already there.
|
||||
*
|
||||
* @param timestamp timestamp in the timebase of the given stream
|
||||
*/
|
||||
int av_add_index_entry(AVStream *st,
|
||||
int64_t pos, int64_t timestamp, int size, int distance, int flags);
|
||||
|
||||
/**
|
||||
* Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp().
|
||||
* this isnt supposed to be called directly by a user application, but by demuxers
|
||||
* @param target_ts target timestamp in the time base of the given stream
|
||||
* @param stream_index stream number
|
||||
*/
|
||||
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
|
||||
|
||||
/**
|
||||
* Updates cur_dts of all streams based on given timestamp and AVStream.
|
||||
*
|
||||
* Stream ref_st unchanged, others set cur_dts in their native timebase
|
||||
* only needed for timestamp wrapping or if (dts not set and pts!=dts)
|
||||
* @param timestamp new dts expressed in time_base of param ref_st
|
||||
* @param ref_st reference stream giving time_base of param timestamp
|
||||
*/
|
||||
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
|
||||
|
||||
/**
|
||||
* Does a binary search using read_timestamp().
|
||||
* this isnt supposed to be called directly by a user application, but by demuxers
|
||||
* @param target_ts target timestamp in the time base of the given stream
|
||||
* @param stream_index stream number
|
||||
*/
|
||||
int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
|
||||
|
||||
/** media file output */
|
||||
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
|
||||
|
||||
/**
|
||||
* allocate the stream private data and write the stream header to an
|
||||
* output media file
|
||||
*
|
||||
* @param s media file handle
|
||||
* @return 0 if OK. AVERROR_xxx if error.
|
||||
*/
|
||||
int av_write_header(AVFormatContext *s);
|
||||
|
||||
/**
|
||||
* Write a packet to an output media file.
|
||||
*
|
||||
* The packet shall contain one audio or video frame.
|
||||
* The packet must be correctly interleaved according to the container specification,
|
||||
* if not then av_interleaved_write_frame must be used
|
||||
*
|
||||
* @param s media file handle
|
||||
* @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
|
||||
* @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
|
||||
*/
|
||||
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Writes a packet to an output media file ensuring correct interleaving.
|
||||
*
|
||||
* The packet must contain one audio or video frame.
|
||||
* If the packets are already correctly interleaved the application should
|
||||
* call av_write_frame() instead as its slightly faster, its also important
|
||||
* to keep in mind that completly non interleaved input will need huge amounts
|
||||
* of memory to interleave with this, so its prefereable to interleave at the
|
||||
* demuxer level
|
||||
*
|
||||
* @param s media file handle
|
||||
* @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
|
||||
* @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
|
||||
*/
|
||||
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Interleave a packet per DTS in an output media file.
|
||||
*
|
||||
* Packets with pkt->destruct == av_destruct_packet will be freed inside this function,
|
||||
* so they cannot be used after it, note calling av_free_packet() on them is still safe.
|
||||
*
|
||||
* @param s media file handle
|
||||
* @param out the interleaved packet will be output here
|
||||
* @param in the input packet
|
||||
* @param flush 1 if no further packets are available as input and all
|
||||
* remaining packets should be output
|
||||
* @return 1 if a packet was output, 0 if no packet could be output,
|
||||
* < 0 if an error occured
|
||||
*/
|
||||
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush);
|
||||
|
||||
/**
|
||||
* @brief Write the stream trailer to an output media file and
|
||||
* free the file private data.
|
||||
*
|
||||
* @param s media file handle
|
||||
* @return 0 if OK. AVERROR_xxx if error.
|
||||
*/
|
||||
int av_write_trailer(AVFormatContext *s);
|
||||
|
||||
void dump_format(AVFormatContext *ic,
|
||||
int index,
|
||||
const char *url,
|
||||
int is_output);
|
||||
|
||||
/**
|
||||
* parses width and height out of string str.
|
||||
*/
|
||||
int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
|
||||
|
||||
/**
|
||||
* Converts frame rate from string to a fraction.
|
||||
*/
|
||||
int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
|
||||
|
||||
/**
|
||||
* Converts date string to number of seconds since Jan 1st, 1970.
|
||||
*
|
||||
* @code
|
||||
* Syntax:
|
||||
* - If not a duration:
|
||||
* [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
|
||||
* Time is localtime unless Z is suffixed to the end. In this case GMT
|
||||
* Return the date in micro seconds since 1970
|
||||
*
|
||||
* - If a duration:
|
||||
* HH[:MM[:SS[.m...]]]
|
||||
* S+[.m...]
|
||||
* @endcode
|
||||
*/
|
||||
int64_t parse_date(const char *datestr, int duration);
|
||||
|
||||
int64_t av_gettime(void);
|
||||
|
||||
/* ffm specific for ffserver */
|
||||
#define FFM_PACKET_SIZE 4096
|
||||
offset_t ffm_read_write_index(int fd);
|
||||
void ffm_write_write_index(int fd, offset_t pos);
|
||||
void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
|
||||
|
||||
/**
|
||||
* Attempts to find a specific tag in a URL.
|
||||
*
|
||||
* syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
|
||||
* Return 1 if found.
|
||||
*/
|
||||
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
|
||||
|
||||
/**
|
||||
* Returns in 'buf' the path with '%d' replaced by number.
|
||||
|
||||
* Also handles the '%0nd' format where 'n' is the total number
|
||||
* of digits and '%%'.
|
||||
*
|
||||
* @param buf destination buffer
|
||||
* @param buf_size destination buffer size
|
||||
* @param path numbered sequence string
|
||||
* @number frame number
|
||||
* @return 0 if OK, -1 if format error.
|
||||
*/
|
||||
int av_get_frame_filename(char *buf, int buf_size,
|
||||
const char *path, int number);
|
||||
|
||||
/**
|
||||
* Check whether filename actually is a numbered sequence generator.
|
||||
*
|
||||
* @param filename possible numbered sequence string
|
||||
* @return 1 if a valid numbered sequence string, 0 otherwise.
|
||||
*/
|
||||
int av_filename_number_test(const char *filename);
|
||||
|
||||
/* grab specific */
|
||||
int video_grab_init(void);
|
||||
int audio_init(void);
|
||||
|
||||
/* DV1394 */
|
||||
int dv1394_init(void);
|
||||
int dc1394_init(void);
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
|
||||
#include "os_support.h"
|
||||
|
||||
int strstart(const char *str, const char *val, const char **ptr);
|
||||
int stristart(const char *str, const char *val, const char **ptr);
|
||||
void pstrcpy(char *buf, int buf_size, const char *str);
|
||||
char *pstrcat(char *buf, int buf_size, const char *s);
|
||||
|
||||
void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define dynarray_add(tab, nb_ptr, elem)\
|
||||
do {\
|
||||
typeof(tab) _tab = (tab);\
|
||||
typeof(elem) _elem = (elem);\
|
||||
(void)sizeof(**_tab == _elem); /* check that types are compatible */\
|
||||
__dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
|
||||
} while(0)
|
||||
#else
|
||||
#define dynarray_add(tab, nb_ptr, elem)\
|
||||
do {\
|
||||
__dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
time_t mktimegm(struct tm *tm);
|
||||
struct tm *brktimegm(time_t secs, struct tm *tm);
|
||||
const char *small_strptime(const char *p, const char *fmt,
|
||||
struct tm *dt);
|
||||
|
||||
struct in_addr;
|
||||
int resolve_host(struct in_addr *sin_addr, const char *hostname);
|
||||
|
||||
void url_split(char *proto, int proto_size,
|
||||
char *authorization, int authorization_size,
|
||||
char *hostname, int hostname_size,
|
||||
int *port_ptr,
|
||||
char *path, int path_size,
|
||||
const char *url);
|
||||
|
||||
int match_ext(const char *filename, const char *extensions);
|
||||
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVFORMAT_H */
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/* output byte stream handling */
|
||||
|
||||
typedef int64_t offset_t;
|
||||
|
||||
/* unbuffered I/O */
|
||||
|
||||
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 */
|
||||
void *priv_data;
|
||||
#if LIBAVFORMAT_VERSION_INT >= (52<<16)
|
||||
char *filename; /**< specified filename */
|
||||
#else
|
||||
char filename[1]; /**< specified filename */
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct URLContext URLContext;
|
||||
|
||||
typedef struct URLPollEntry {
|
||||
URLContext *handle;
|
||||
int events;
|
||||
int revents;
|
||||
} URLPollEntry;
|
||||
|
||||
#define URL_RDONLY 0
|
||||
#define URL_WRONLY 1
|
||||
#define URL_RDWR 2
|
||||
|
||||
typedef int URLInterruptCB(void);
|
||||
|
||||
int url_open(URLContext **h, const char *filename, int flags);
|
||||
int url_read(URLContext *h, unsigned char *buf, int size);
|
||||
int url_write(URLContext *h, unsigned char *buf, int size);
|
||||
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. 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);
|
||||
int (*url_read)(URLContext *h, unsigned char *buf, int size);
|
||||
int (*url_write)(URLContext *h, unsigned char *buf, int size);
|
||||
offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
|
||||
int (*url_close)(URLContext *h);
|
||||
struct URLProtocol *next;
|
||||
} URLProtocol;
|
||||
|
||||
extern URLProtocol *first_protocol;
|
||||
extern URLInterruptCB *url_interrupt_cb;
|
||||
|
||||
int register_protocol(URLProtocol *protocol);
|
||||
|
||||
typedef struct {
|
||||
unsigned char *buffer;
|
||||
int buffer_size;
|
||||
unsigned char *buf_ptr, *buf_end;
|
||||
void *opaque;
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
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,
|
||||
unsigned char *buffer,
|
||||
int buffer_size,
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
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);
|
||||
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_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);
|
||||
|
||||
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);
|
||||
|
||||
static inline int url_is_streamed(ByteIOContext *s)
|
||||
{
|
||||
return s->is_streamed;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
/* file.c */
|
||||
extern URLProtocol file_protocol;
|
||||
extern URLProtocol pipe_protocol;
|
||||
|
||||
/* udp.c */
|
||||
extern URLProtocol udp_protocol;
|
||||
int udp_set_remote_url(URLContext *h, const char *uri);
|
||||
int udp_get_local_port(URLContext *h);
|
||||
int udp_get_file_handle(URLContext *h);
|
||||
|
||||
/* tcp.c */
|
||||
extern URLProtocol tcp_protocol;
|
||||
|
||||
/* http.c */
|
||||
extern URLProtocol http_protocol;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#if 0
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
/* only include the following when compiling package */
|
||||
# include "config.h"
|
||||
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <ctype.h>
|
||||
# include <limits.h>
|
||||
# include <errno.h>
|
||||
# include <math.h>
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#ifndef av_always_inline
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define av_always_inline __attribute__((always_inline)) inline
|
||||
# define av_noinline __attribute__((noinline))
|
||||
#else
|
||||
# define av_always_inline inline
|
||||
# define av_noinline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "internal.h"
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#ifndef attribute_deprecated
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define attribute_deprecated __attribute__((deprecated))
|
||||
#else
|
||||
# define attribute_deprecated
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
//rounded divison & shift
|
||||
#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 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 const uint8_t ff_log2_tab[256];
|
||||
|
||||
static inline int av_log2(unsigned int v)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = 0;
|
||||
if (v & 0xffff0000) {
|
||||
v >>= 16;
|
||||
n += 16;
|
||||
}
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
n += ff_log2_tab[v];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline int av_log2_16bit(unsigned int v)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = 0;
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
n += ff_log2_tab[v];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* median of 3 */
|
||||
static inline int mid_pred(int a, int b, int c)
|
||||
{
|
||||
#ifdef 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;
|
||||
b-= (b-c)&((b-c)>>31);
|
||||
b+= (a-b)&((a-b)>>31);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* clip a signed integer value into the amin-amax range
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline int av_clip(int a, int amin, int amax)
|
||||
{
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* clip a signed integer value into the 0-255 range
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline uint8_t av_clip_uint8(int a)
|
||||
{
|
||||
if (a&(~255)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/* math */
|
||||
int64_t ff_gcd(int64_t a, int64_t b);
|
||||
|
||||
/**
|
||||
* converts fourcc string to int
|
||||
*/
|
||||
static inline int ff_get_fourcc(const char *s){
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
assert( strlen(s)==4 );
|
||||
#endif
|
||||
|
||||
return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
|
||||
}
|
||||
|
||||
#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;\
|
||||
{\
|
||||
int ones= 7 - av_log2(val ^ 255);\
|
||||
if(ones==1)\
|
||||
ERROR\
|
||||
val&= 127>>ones;\
|
||||
while(--ones > 0){\
|
||||
int tmp= GET_BYTE - 128;\
|
||||
if(tmp>>6)\
|
||||
ERROR\
|
||||
val= (val<<6) + tmp;\
|
||||
}\
|
||||
}
|
||||
|
||||
/*!
|
||||
* \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)
|
||||
{
|
||||
uint64_t a, d;
|
||||
asm volatile( "rdtsc\n\t"
|
||||
: "=a" (a), "=d" (d)
|
||||
);
|
||||
return (d << 32) | (a & 0xffffffff);
|
||||
}
|
||||
#elif defined(ARCH_X86_32)
|
||||
static inline long long read_time(void)
|
||||
{
|
||||
long long l;
|
||||
asm volatile( "rdtsc\n\t"
|
||||
: "=A" (l)
|
||||
);
|
||||
return l;
|
||||
}
|
||||
#else //FIXME check ppc64
|
||||
static inline uint64_t read_time(void)
|
||||
{
|
||||
uint32_t tbu, tbl, temp;
|
||||
|
||||
/* from section 2.2.1 of the 32-bit PowerPC PEM */
|
||||
__asm__ __volatile__(
|
||||
"1:\n"
|
||||
"mftbu %2\n"
|
||||
"mftb %0\n"
|
||||
"mftbu %1\n"
|
||||
"cmpw %2,%1\n"
|
||||
"bne 1b\n"
|
||||
: "=r"(tbl), "=r"(tbu), "=r"(temp)
|
||||
:
|
||||
: "cc");
|
||||
|
||||
return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define START_TIMER \
|
||||
uint64_t tend;\
|
||||
uint64_t tstart= read_time();\
|
||||
|
||||
#define STOP_TIMER(id) \
|
||||
tend= read_time();\
|
||||
{\
|
||||
static uint64_t tsum=0;\
|
||||
static int tcount=0;\
|
||||
static int tskip_count=0;\
|
||||
if(tcount<2 || tend - tstart < FFMAX(8*tsum/tcount, 2000)){\
|
||||
tsum+= tend - tstart;\
|
||||
tcount++;\
|
||||
}else\
|
||||
tskip_count++;\
|
||||
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);\
|
||||
}\
|
||||
}
|
||||
#else
|
||||
#define START_TIMER
|
||||
#define STOP_TIMER(id) {}
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_H */
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* arbitrary precision integers
|
||||
* Copyright (c) 2004 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 integer.h
|
||||
* arbitrary precision integers
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#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 <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
|
||||
|
||||
#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 */
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#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 <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
|
||||
|
||||
#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 */
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 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 */
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Rational numbers
|
||||
* Copyright (c) 2003 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 rational.h
|
||||
* Rational numbers.
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef RATIONAL_H
|
||||
#define RATIONAL_H
|
||||
|
||||
/**
|
||||
* Rational number num/den.
|
||||
*/
|
||||
typedef struct AVRational{
|
||||
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) 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
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* RTP 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
|
||||
*/
|
||||
#ifndef RTP_H
|
||||
#define RTP_H
|
||||
|
||||
#define RTP_MIN_PACKET_LENGTH 12
|
||||
#define RTP_MAX_PACKET_LENGTH 1500 /* XXX: suppress this define */
|
||||
|
||||
int rtp_init(void);
|
||||
int rtp_get_codec_info(AVCodecContext *codec, int payload_type);
|
||||
|
||||
/** 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 */
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
#ifndef RTSP_H
|
||||
#define RTSP_H
|
||||
|
||||
#include "rtspcodes.h"
|
||||
|
||||
enum RTSPProtocol {
|
||||
RTSP_PROTOCOL_RTP_UDP = 0,
|
||||
RTSP_PROTOCOL_RTP_TCP = 1,
|
||||
RTSP_PROTOCOL_RTP_UDP_MULTICAST = 2,
|
||||
};
|
||||
|
||||
#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 */
|
||||
enum RTSPProtocol protocol;
|
||||
} RTSPTransportField;
|
||||
|
||||
typedef struct RTSPHeader {
|
||||
int content_length;
|
||||
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 */
|
||||
char session_id[512];
|
||||
} RTSPHeader;
|
||||
|
||||
/** the callback can be used to extend the connection setup/teardown step */
|
||||
enum RTSPCallbackAction {
|
||||
RTSP_ACTION_SERVER_SETUP,
|
||||
RTSP_ACTION_SERVER_TEARDOWN,
|
||||
RTSP_ACTION_CLIENT_SETUP,
|
||||
RTSP_ACTION_CLIENT_TEARDOWN,
|
||||
};
|
||||
|
||||
typedef struct RTSPActionServerSetup {
|
||||
uint32_t ipaddr;
|
||||
char transport_option[512];
|
||||
} RTSPActionServerSetup;
|
||||
|
||||
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);
|
||||
void rtsp_parse_line(RTSPHeader *reply, const char *buf);
|
||||
|
||||
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_demuxer;
|
||||
|
||||
int rtsp_pause(AVFormatContext *s);
|
||||
int rtsp_resume(AVFormatContext *s);
|
||||
|
||||
#endif /* RTSP_H */
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
Reference in New Issue
Block a user