Revert. See stepmania-devs.

This commit is contained in:
Steve Checkoway
2006-06-10 21:49:51 +00:00
parent 8cdce5cfda
commit 52371ff5f7
8 changed files with 1339 additions and 1240 deletions
@@ -166,8 +166,8 @@ public:
int GetFrame( RageSurface *pOut, float fTargetTime ); int GetFrame( RageSurface *pOut, float fTargetTime );
int GetWidth() const { return m_pStream->codec->width; } int GetWidth() const { return m_pStream->codec.width; }
int GetHeight() const { return m_pStream->codec->height; } int GetHeight() const { return m_pStream->codec.height; }
RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor ); RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor );
@@ -333,7 +333,7 @@ int MovieDecoder_FFMpeg::DecodePacket( RageSurface *pOut, float fTargetTime )
bool bSkipThisFrame = bool bSkipThisFrame =
fTargetTime != -1 && fTargetTime != -1 &&
GetTimestamp() + GetFrameDuration() <= fTargetTime && GetTimestamp() + GetFrameDuration() <= fTargetTime &&
(m_pStream->codec->frame_number % 2) == 0; (m_pStream->codec.frame_number % 2) == 0;
int iGotFrame; int iGotFrame;
CHECKPOINT; CHECKPOINT;
@@ -341,7 +341,7 @@ int MovieDecoder_FFMpeg::DecodePacket( RageSurface *pOut, float fTargetTime )
* to give it a buffer to read from since it tries to read anyway. */ * to give it a buffer to read from since it tries to read anyway. */
static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 }; static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
int len = avcodec::avcodec_decode_video( int len = avcodec::avcodec_decode_video(
m_pStream->codec, &m_pStream->codec,
&m_Frame, &iGotFrame, &m_Frame, &iGotFrame,
m_Packet.size? m_Packet.data:dummy, m_Packet.size ); m_Packet.size? m_Packet.data:dummy, m_Packet.size );
CHECKPOINT; CHECKPOINT;
@@ -375,7 +375,7 @@ int MovieDecoder_FFMpeg::DecodePacket( RageSurface *pOut, float fTargetTime )
} }
/* Length of this frame: */ /* Length of this frame: */
m_fLastFrameDelay = (m_pStream->r_frame_rate.num * m_pStream->codec->time_base.den) / (m_pStream->r_frame_rate.den * m_pStream->codec->time_base.num); m_fLastFrameDelay = (float)m_pStream->codec.frame_rate_base / m_pStream->codec.frame_rate;
m_fLastFrameDelay += m_Frame.repeat_pict * (m_fLastFrameDelay * 0.5f); m_fLastFrameDelay += m_Frame.repeat_pict * (m_fLastFrameDelay * 0.5f);
++m_iFrameNumber; ++m_iFrameNumber;
@@ -416,8 +416,8 @@ void MovieDecoder_FFMpeg::ConvertToSurface( RageSurface *pSurface ) const
pict.linesize[0] = pSurface->pitch; pict.linesize[0] = pSurface->pitch;
avcodec::img_convert( &pict, m_AVTexfmt, avcodec::img_convert( &pict, m_AVTexfmt,
(avcodec::AVPicture *) &m_Frame, m_pStream->codec->pix_fmt, (avcodec::AVPicture *) &m_Frame, m_pStream->codec.pix_fmt,
m_pStream->codec->width, m_pStream->codec->height ); m_pStream->codec.width, m_pStream->codec.height );
} }
static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx ) static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx )
@@ -425,7 +425,7 @@ static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx )
for( int stream = 0; stream < m_fctx->nb_streams; ++stream ) for( int stream = 0; stream < m_fctx->nb_streams; ++stream )
{ {
avcodec::AVStream *enc = m_fctx->streams[stream]; avcodec::AVStream *enc = m_fctx->streams[stream];
if( enc->codec->codec_type == avcodec::CODEC_TYPE_VIDEO ) if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO )
return enc; return enc;
} }
return NULL; return NULL;
@@ -549,21 +549,21 @@ RString MovieDecoder_FFMpeg::Open( RString sFile )
if ( stream == NULL ) if ( stream == NULL )
return ssprintf( "AVCodec (%s): Couldn't find any video streams", sFile.c_str() ); return ssprintf( "AVCodec (%s): Couldn't find any video streams", sFile.c_str() );
if( stream->codec->codec_id == avcodec::CODEC_ID_NONE ) if( stream->codec.codec_id == avcodec::CODEC_ID_NONE )
return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec->codec_tag ); return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec.codec_tag );
avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( stream->codec->codec_id ); avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( stream->codec.codec_id );
if( codec == NULL ) if( codec == NULL )
return ssprintf( "AVCodec (%s): Couldn't find decoder %i", sFile.c_str(), stream->codec->codec_id ); return ssprintf( "AVCodec (%s): Couldn't find decoder %i", sFile.c_str(), stream->codec.codec_id );
LOG->Trace("Opening codec %s", codec->name ); LOG->Trace("Opening codec %s", codec->name );
ret = avcodec::avcodec_open( stream->codec, codec ); ret = avcodec::avcodec_open( &stream->codec, codec );
if ( ret < 0 ) if ( ret < 0 )
return ssprintf( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", sFile.c_str(), codec->name) ); return ssprintf( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", sFile.c_str(), codec->name) );
m_pStream = stream; m_pStream = stream;
LOG->Trace( "Bitrate: %i", m_pStream->codec->bit_rate ); LOG->Trace( "Bitrate: %i", m_pStream->codec.bit_rate );
LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec->pix_fmt) ); LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec.pix_fmt) );
return RString(); return RString();
} }
@@ -572,7 +572,7 @@ void MovieDecoder_FFMpeg::Close()
{ {
if( m_pStream ) if( m_pStream )
{ {
avcodec::avcodec_close( m_pStream->codec ); avcodec::avcodec_close( &m_pStream->codec );
m_pStream = NULL; m_pStream = NULL;
} }
File diff suppressed because it is too large Load Diff
+30 -131
View File
@@ -5,11 +5,11 @@
extern "C" { extern "C" {
#endif #endif
#define LIBAVFORMAT_VERSION_INT ((50<<16)+(4<<8)+0) #define LIBAVFORMAT_BUILD 4616
#define LIBAVFORMAT_VERSION 50.4.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) #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 <time.h>
#include <stdio.h> /* FILE */ #include <stdio.h> /* FILE */
@@ -28,36 +28,31 @@ extern "C" {
#endif #endif
typedef struct AVPacket { typedef struct AVPacket {
int64_t pts; ///< presentation time stamp in time_base units int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or
int64_t dts; ///< decompression time stamp in time_base units 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; uint8_t *data;
int size; int size;
int stream_index; int stream_index;
int flags; int flags;
int duration; ///< presentation duration in time_base units (0 if not available) int duration; /* presentation duration (0 if not available) */
void (*destruct)(struct AVPacket *); void (*destruct)(struct AVPacket *);
void *priv; void *priv;
int64_t pos; ///< byte position in stream, -1 if unknown
} AVPacket; } AVPacket;
#define PKT_FLAG_KEY 0x0001 #define PKT_FLAG_KEY 0x0001
void av_destruct_packet_nofree(AVPacket *pkt);
void av_destruct_packet(AVPacket *pkt);
/* initialize optional fields of a packet */ /* initialize optional fields of a packet */
static inline void av_init_packet(AVPacket *pkt) static inline void av_init_packet(AVPacket *pkt)
{ {
pkt->pts = AV_NOPTS_VALUE; pkt->pts = AV_NOPTS_VALUE;
pkt->dts = AV_NOPTS_VALUE; pkt->dts = AV_NOPTS_VALUE;
pkt->pos = -1;
pkt->duration = 0; pkt->duration = 0;
pkt->flags = 0; pkt->flags = 0;
pkt->stream_index = 0; pkt->stream_index = 0;
pkt->destruct= av_destruct_packet_nofree;
} }
int av_new_packet(AVPacket *pkt, int size); int av_new_packet(AVPacket *pkt, int size);
int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
int av_dup_packet(AVPacket *pkt); int av_dup_packet(AVPacket *pkt);
/** /**
@@ -68,7 +63,7 @@ int av_dup_packet(AVPacket *pkt);
static inline void av_free_packet(AVPacket *pkt) static inline void av_free_packet(AVPacket *pkt)
{ {
if (pkt && pkt->destruct) { if (pkt && pkt->destruct) {
pkt->destruct(pkt); pkt->destruct(pkt);
} }
} }
@@ -100,7 +95,8 @@ typedef struct AVProbeData {
#define AVPROBE_SCORE_MAX 100 #define AVPROBE_SCORE_MAX 100
typedef struct AVFormatParameters { typedef struct AVFormatParameters {
AVRational time_base; int frame_rate;
int frame_rate_base;
int sample_rate; int sample_rate;
int channels; int channels;
int width; int width;
@@ -108,7 +104,7 @@ typedef struct AVFormatParameters {
enum PixelFormat pix_fmt; enum PixelFormat pix_fmt;
struct AVImageFormat *image_format; struct AVImageFormat *image_format;
int channel; /* used to select dv channel */ int channel; /* used to select dv channel */
const char *device; /* video, audio or DV device */ const char *device; /* video4linux, audio or DV device */
const char *standard; /* tv standard, NTSC, PAL, SECAM */ const char *standard; /* tv standard, NTSC, PAL, SECAM */
int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */ int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
@@ -116,8 +112,6 @@ typedef struct AVFormatParameters {
mpeg2ts_raw is TRUE */ mpeg2ts_raw is TRUE */
int initial_pause:1; /* do not begin to play the stream int initial_pause:1; /* do not begin to play the stream
immediately (RTSP only) */ immediately (RTSP only) */
enum CodecID video_codec_id;
enum CodecID audio_codec_id;
} AVFormatParameters; } AVFormatParameters;
#define AVFMT_NOFILE 0x0001 /* no file should be opened */ #define AVFMT_NOFILE 0x0001 /* no file should be opened */
@@ -125,7 +119,6 @@ typedef struct AVFormatParameters {
#define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */ #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
#define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
raw picture data */ raw picture data */
#define AVFMT_GLOBALHEADER 0x0040 /* format wants global header */
typedef struct AVOutputFormat { typedef struct AVOutputFormat {
const char *name; const char *name;
@@ -140,11 +133,10 @@ typedef struct AVOutputFormat {
int (*write_header)(struct AVFormatContext *); int (*write_header)(struct AVFormatContext *);
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
int (*write_trailer)(struct AVFormatContext *); int (*write_trailer)(struct AVFormatContext *);
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */ /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
int flags; int flags;
/* currently only used to set pixel format if not YUV420P */ /* currently only used to set pixel format if not YUV420P */
int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
/* private fields */ /* private fields */
struct AVOutputFormat *next; struct AVOutputFormat *next;
} AVOutputFormat; } AVOutputFormat;
@@ -169,15 +161,10 @@ typedef struct AVInputFormat {
/* close the stream. The AVFormatContext and AVStreams are not /* close the stream. The AVFormatContext and AVStreams are not
freed by this function */ freed by this function */
int (*read_close)(struct AVFormatContext *); int (*read_close)(struct AVFormatContext *);
/** /* seek at or before a given timestamp (given in AV_TIME_BASE
* seek to a given timestamp relative to the frames in units) relative to the frames in stream component stream_index */
* 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 (*read_seek)(struct AVFormatContext *,
int stream_index, int64_t timestamp, int flags); int stream_index, int64_t timestamp);
/** /**
* gets the next timestamp in AV_TIME_BASE units. * gets the next timestamp in AV_TIME_BASE units.
*/ */
@@ -208,40 +195,27 @@ typedef struct AVIndexEntry {
int64_t pos; int64_t pos;
int64_t timestamp; int64_t timestamp;
#define AVINDEX_KEYFRAME 0x0001 #define AVINDEX_KEYFRAME 0x0001
int flags:2; /* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */
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 flags;
int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */ int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
} AVIndexEntry; } AVIndexEntry;
typedef struct AVStream { typedef struct AVStream {
int index; /* stream index in AVFormatContext */ int index; /* stream index in AVFormatContext */
int id; /* format specific stream id */ int id; /* format specific stream id */
AVCodecContext *codec; /* codec context */ AVCodecContext codec; /* codec context */
/** int r_frame_rate; /* real frame rate of the stream */
* real base frame rate of the stream. int r_frame_rate_base;/* real frame rate base of the stream */
* 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; void *priv_data;
/* internal data used in av_find_stream_info() */ /* internal data used in av_find_stream_info() */
int64_t codec_info_duration; int64_t codec_info_duration;
int codec_info_nb_frames; int codec_info_nb_frames;
/* encoding: PTS generation when outputing stream */ /* encoding: PTS generation when outputing stream */
AVFrac pts; 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; AVRational time_base;
int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */ int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
/* ffmpeg.c private use */ /* ffmpeg.c private use */
int stream_copy; /* if TRUE, just copy stream */ int stream_copy; /* if TRUE, 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 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
* MN:dunno if thats the right place, for it */ * MN:dunno if thats the right place, for it */
float quality; float quality;
@@ -252,10 +226,8 @@ typedef struct AVStream {
seconds. */ seconds. */
int64_t duration; int64_t duration;
char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
/* av_read_frame() support */ /* av_read_frame() support */
int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack int need_parsing;
struct AVCodecParserContext *parser; struct AVCodecParserContext *parser;
int64_t cur_dts; int64_t cur_dts;
@@ -266,8 +238,6 @@ typedef struct AVStream {
support seeking natively */ support seeking natively */
int nb_index_entries; int nb_index_entries;
int index_entries_allocated_size; int index_entries_allocated_size;
int64_t nb_frames; ///< number of frames in this stream if known or 0
} AVStream; } AVStream;
#define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present #define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
@@ -277,7 +247,7 @@ typedef struct AVStream {
/* format I/O context */ /* format I/O context */
typedef struct AVFormatContext { typedef struct AVFormatContext {
const AVClass *av_class; /* set by av_alloc_format_context */ AVClass *av_class; /* set by av_alloc_format_context */
/* can only be iformat or oformat, not both at the same time */ /* can only be iformat or oformat, not both at the same time */
struct AVInputFormat *iformat; struct AVInputFormat *iformat;
struct AVOutputFormat *oformat; struct AVOutputFormat *oformat;
@@ -328,19 +298,6 @@ typedef struct AVFormatContext {
/* av_seek_frame() support */ /* av_seek_frame() support */
int64_t data_offset; /* offset of the first packet */ int64_t data_offset; /* offset of the first packet */
int index_built; 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
} AVFormatContext; } AVFormatContext;
typedef struct AVPacketList { typedef struct AVPacketList {
@@ -387,7 +344,6 @@ typedef struct AVImageFormat {
void av_register_image_format(AVImageFormat *img_fmt); void av_register_image_format(AVImageFormat *img_fmt);
AVImageFormat *av_probe_image_format(AVProbeData *pd); AVImageFormat *av_probe_image_format(AVProbeData *pd);
AVImageFormat *guess_image_format(const char *filename); AVImageFormat *guess_image_format(const char *filename);
enum CodecID av_guess_image2_codec(const char *filename);
int av_read_image(ByteIOContext *pb, const char *filename, int av_read_image(ByteIOContext *pb, const char *filename,
AVImageFormat *fmt, AVImageFormat *fmt,
int (*alloc_cb)(void *, AVImageInfo *info), void *opaque); int (*alloc_cb)(void *, AVImageInfo *info), void *opaque);
@@ -429,9 +385,6 @@ int crc_init(void);
/* img.c */ /* img.c */
int img_init(void); int img_init(void);
/* img2.c */
int img2_init(void);
/* asf.c */ /* asf.c */
int asf_init(void); int asf_init(void);
@@ -471,12 +424,9 @@ int amr_init(void);
/* wav.c */ /* wav.c */
int ff_wav_init(void); int ff_wav_init(void);
/* mmf.c */
int ff_mmf_init(void);
/* raw.c */ /* raw.c */
int pcm_read_seek(AVFormatContext *s, int pcm_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp, int flags); int stream_index, int64_t timestamp);
int raw_init(void); int raw_init(void);
/* mp3.c */ /* mp3.c */
@@ -485,11 +435,8 @@ int mp3_init(void);
/* yuv4mpeg.c */ /* yuv4mpeg.c */
int yuv4mpeg_init(void); int yuv4mpeg_init(void);
/* ogg2.c */
int ogg_init(void);
/* ogg.c */ /* ogg.c */
int libogg_init(void); int ogg_init(void);
/* dv.c */ /* dv.c */
int ff_dv_init(void); int ff_dv_init(void);
@@ -537,42 +484,6 @@ int vmd_init(void);
/* matroska.c */ /* matroska.c */
int matroska_init(void); int matroska_init(void);
/* sol.c */
int sol_init(void);
/* electronicarts.c */
int ea_init(void);
/* nsvdec.c */
int nsvdec_init(void);
/* daud.c */
int daud_init(void);
/* nuv.c */
int nuv_init(void);
/* aiff.c */
int ff_aiff_init(void);
/* voc.c */
int voc_init(void);
/* tta.c */
int tta_init(void);
/* adts.c */
int ff_adts_init(void);
/* mm.c */
int mm_init(void);
/* avs.c */
int avs_init(void);
/* smacker.c */
int smacker_init(void);
#include "rtp.h" #include "rtp.h"
#include "rtsp.h" #include "rtsp.h"
@@ -587,8 +498,6 @@ AVOutputFormat *guess_stream_format(const char *short_name,
const char *filename, const char *mime_type); const char *filename, const char *mime_type);
AVOutputFormat *guess_format(const char *short_name, AVOutputFormat *guess_format(const char *short_name,
const char *filename, const char *mime_type); const char *filename, const char *mime_type);
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
const char *filename, const char *mime_type, enum CodecType type);
void av_hex_dump(FILE *f, 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_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
@@ -605,8 +514,6 @@ void fifo_free(FifoBuffer *f);
int fifo_size(FifoBuffer *f, uint8_t *rptr); int fifo_size(FifoBuffer *f, uint8_t *rptr);
int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr); int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr);
void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr); void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr);
int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr);
void fifo_realloc(FifoBuffer *f, unsigned int size);
/* media file input */ /* media file input */
AVInputFormat *av_find_input_format(const char *short_name); AVInputFormat *av_find_input_format(const char *short_name);
@@ -632,7 +539,7 @@ AVFormatContext *av_alloc_format_context(void);
int av_find_stream_info(AVFormatContext *ic); int av_find_stream_info(AVFormatContext *ic);
int av_read_packet(AVFormatContext *s, AVPacket *pkt); int av_read_packet(AVFormatContext *s, AVPacket *pkt);
int av_read_frame(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 flags); int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp);
int av_read_play(AVFormatContext *s); int av_read_play(AVFormatContext *s);
int av_read_pause(AVFormatContext *s); int av_read_pause(AVFormatContext *s);
void av_close_input_file(AVFormatContext *s); void av_close_input_file(AVFormatContext *s);
@@ -640,15 +547,11 @@ AVStream *av_new_stream(AVFormatContext *s, int id);
void av_set_pts_info(AVStream *s, int pts_wrap_bits, void av_set_pts_info(AVStream *s, int pts_wrap_bits,
int pts_num, int pts_den); 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); int av_find_default_stream_index(AVFormatContext *s);
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); int av_index_search_timestamp(AVStream *st, int timestamp);
int av_add_index_entry(AVStream *st, int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int size, int distance, int flags); int64_t pos, int64_t timestamp, int distance, int flags);
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts);
/* media file output */ /* media file output */
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
@@ -686,7 +589,6 @@ int audio_init(void);
/* DV1394 */ /* DV1394 */
int dv1394_init(void); int dv1394_init(void);
int dc1394_init(void);
#ifdef HAVE_AV_CONFIG_H #ifdef HAVE_AV_CONFIG_H
@@ -715,7 +617,6 @@ do {\
#endif #endif
time_t mktimegm(struct tm *tm); 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, const char *small_strptime(const char *p, const char *fmt,
struct tm *dt); struct tm *dt);
@@ -723,7 +624,6 @@ struct in_addr;
int resolve_host(struct in_addr *sin_addr, const char *hostname); int resolve_host(struct in_addr *sin_addr, const char *hostname);
void url_split(char *proto, int proto_size, void url_split(char *proto, int proto_size,
char *authorization, int authorization_size,
char *hostname, int hostname_size, char *hostname, int hostname_size,
int *port_ptr, int *port_ptr,
char *path, int path_size, char *path, int path_size,
@@ -738,4 +638,3 @@ int match_ext(const char *filename, const char *extensions);
#endif #endif
#endif /* AVFORMAT_H */ #endif /* AVFORMAT_H */
+6 -11
View File
@@ -70,8 +70,8 @@ typedef struct {
unsigned char *buf_ptr, *buf_end; unsigned char *buf_ptr, *buf_end;
void *opaque; void *opaque;
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); void (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
offset_t (*seek)(void *opaque, offset_t offset, int whence); int (*seek)(void *opaque, offset_t offset, int whence);
offset_t pos; /* position in the file of the current buffer */ offset_t pos; /* position in the file of the current buffer */
int must_flush; /* true if the next seek should flush */ int must_flush; /* true if the next seek should flush */
int eof_reached; /* true if eof reached */ int eof_reached; /* true if eof reached */
@@ -81,7 +81,6 @@ typedef struct {
unsigned long checksum; unsigned long checksum;
unsigned char *checksum_ptr; unsigned char *checksum_ptr;
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); 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; } ByteIOContext;
int init_put_byte(ByteIOContext *s, int init_put_byte(ByteIOContext *s,
@@ -90,8 +89,8 @@ int init_put_byte(ByteIOContext *s,
int write_flag, int write_flag,
void *opaque, void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), void (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
offset_t (*seek)(void *opaque, offset_t offset, int whence)); int (*seek)(void *opaque, offset_t offset, int whence));
void put_byte(ByteIOContext *s, int b); void put_byte(ByteIOContext *s, int b);
void put_buffer(ByteIOContext *s, const unsigned char *buf, int size); void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
@@ -99,20 +98,17 @@ void put_le64(ByteIOContext *s, uint64_t val);
void put_be64(ByteIOContext *s, uint64_t val); void put_be64(ByteIOContext *s, uint64_t val);
void put_le32(ByteIOContext *s, unsigned int val); void put_le32(ByteIOContext *s, unsigned int val);
void put_be32(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_le16(ByteIOContext *s, unsigned int val);
void put_be16(ByteIOContext *s, unsigned int val); void put_be16(ByteIOContext *s, unsigned int val);
void put_tag(ByteIOContext *s, const char *tag); void put_tag(ByteIOContext *s, const char *tag);
void put_be64_double(ByteIOContext *s, double val);
void put_strz(ByteIOContext *s, const char *buf); void put_strz(ByteIOContext *s, const char *buf);
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence); offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
void url_fskip(ByteIOContext *s, offset_t offset); void url_fskip(ByteIOContext *s, offset_t offset);
offset_t url_ftell(ByteIOContext *s); offset_t url_ftell(ByteIOContext *s);
offset_t url_fsize(ByteIOContext *s);
int url_feof(ByteIOContext *s); int url_feof(ByteIOContext *s);
int url_ferror(ByteIOContext *s);
#define URL_EOF (-1) #define URL_EOF (-1)
int url_fgetc(ByteIOContext *s); int url_fgetc(ByteIOContext *s);
@@ -128,14 +124,13 @@ void put_flush_packet(ByteIOContext *s);
int get_buffer(ByteIOContext *s, unsigned char *buf, int size); int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size); int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
int get_byte(ByteIOContext *s); int get_byte(ByteIOContext *s);
unsigned int get_le24(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s); unsigned int get_le32(ByteIOContext *s);
uint64_t get_le64(ByteIOContext *s); uint64_t get_le64(ByteIOContext *s);
unsigned int get_le16(ByteIOContext *s); unsigned int get_le16(ByteIOContext *s);
double get_be64_double(ByteIOContext *s);
char *get_strz(ByteIOContext *s, char *buf, int maxlen); char *get_strz(ByteIOContext *s, char *buf, int maxlen);
unsigned int get_be16(ByteIOContext *s); unsigned int get_be16(ByteIOContext *s);
unsigned int get_be24(ByteIOContext *s);
unsigned int get_be32(ByteIOContext *s); unsigned int get_be32(ByteIOContext *s);
uint64_t get_be64(ByteIOContext *s); uint64_t get_be64(ByteIOContext *s);
File diff suppressed because it is too large Load Diff
+6 -22
View File
@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
@@ -27,39 +27,23 @@
#ifndef RATIONAL_H #ifndef RATIONAL_H
#define RATIONAL_H #define RATIONAL_H
/**
* Rational number num/den.
*/
typedef struct AVRational{ typedef struct AVRational{
int num; ///< numerator int num;
int den; ///< denominator int den;
} AVRational; } AVRational;
/**
* returns 0 if a==b, 1 if a>b and -1 if a<b.
*/
static inline int av_cmp_q(AVRational a, AVRational 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; const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
if(tmp) return (tmp>>63)|1; if (tmp < 0) return -1;
else return 0; else if(tmp == 0) return 0;
else return 1;
} }
/**
* converts the given AVRational to a double.
*/
static inline double av_q2d(AVRational a){ static inline double av_q2d(AVRational a){
return a.num / (double) a.den; return a.num / (double) a.den;
} }
/**
* reduce a fraction.
* this is usefull for framerate calculations
* @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);
AVRational av_mul_q(AVRational b, AVRational c); AVRational av_mul_q(AVRational b, AVRational c);
AVRational av_div_q(AVRational b, AVRational c); AVRational av_div_q(AVRational b, AVRational c);
AVRational av_add_q(AVRational b, AVRational c); AVRational av_add_q(AVRational b, AVRational c);
+3 -88
View File
@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef RTP_H #ifndef RTP_H
#define RTP_H #define RTP_H
@@ -25,13 +25,8 @@
int rtp_init(void); int rtp_init(void);
int rtp_get_codec_info(AVCodecContext *codec, int payload_type); int rtp_get_codec_info(AVCodecContext *codec, int payload_type);
int rtp_get_payload_type(AVCodecContext *codec); int rtp_get_payload_type(AVCodecContext *codec);
int rtp_parse_packet(AVFormatContext *s1, AVPacket *pkt,
typedef struct RTPDemuxContext RTPDemuxContext; const unsigned char *buf, int len);
typedef struct rtp_payload_data_s rtp_payload_data_s;
RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, 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_mux; extern AVOutputFormat rtp_mux;
extern AVInputFormat rtp_demux; extern AVInputFormat rtp_demux;
@@ -42,84 +37,4 @@ void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
extern URLProtocol rtp_protocol; 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 usefull 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;
typedef struct AVRtpDynamicPayloadType_s /* payload type >= 96 */
{
const char enc_name[50]; /* XXX: still why 50 ? ;-) */
enum CodecType codec_type;
enum CodecID codec_id;
} AVRtpDynamicPayloadType_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[];
extern AVRtpDynamicPayloadType_t AVRtpDynamicPayloadTypes[];
#endif /* RTP_H */ #endif /* RTP_H */
+1 -7
View File
@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef RTSP_H #ifndef RTSP_H
#define RTSP_H #define RTSP_H
@@ -35,10 +35,6 @@ enum RTSPProtocol {
#define RTSP_DEFAULT_PORT 554 #define RTSP_DEFAULT_PORT 554
#define RTSP_MAX_TRANSPORTS 8 #define RTSP_MAX_TRANSPORTS 8
#define RTSP_TCP_MAX_PACKET_SIZE 1472 #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 { typedef struct RTSPTransportField {
int interleaved_min, interleaved_max; /* interleave ids, if TCP transport */ int interleaved_min, interleaved_max; /* interleave ids, if TCP transport */
@@ -54,8 +50,6 @@ typedef struct RTSPHeader {
int content_length; int content_length;
enum RTSPStatusCode status_code; /* response code from server */ enum RTSPStatusCode status_code; /* response code from server */
int nb_transports; 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]; RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
int seq; /* sequence number */ int seq; /* sequence number */
char session_id[512]; char session_id[512];