From 52371ff5f72c3cab5d1536e37f43a6a687d8111c Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 10 Jun 2006 21:49:51 +0000 Subject: [PATCH] Revert. See stepmania-devs. --- .../arch/MovieTexture/MovieTexture_FFMpeg.cpp | 32 +- stepmania/src/ffmpeg/include/ffmpeg/avcodec.h | 1148 ++++++----------- .../src/ffmpeg/include/ffmpeg/avformat.h | 197 +-- stepmania/src/ffmpeg/include/ffmpeg/avio.h | 19 +- stepmania/src/ffmpeg/include/ffmpeg/common.h | 1052 ++++++++++++--- .../src/ffmpeg/include/ffmpeg/rational.h | 30 +- stepmania/src/ffmpeg/include/ffmpeg/rtp.h | 91 +- stepmania/src/ffmpeg/include/ffmpeg/rtsp.h | 10 +- 8 files changed, 1339 insertions(+), 1240 deletions(-) diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index 8c9d867666..fb98778194 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -166,8 +166,8 @@ public: int GetFrame( RageSurface *pOut, float fTargetTime ); - int GetWidth() const { return m_pStream->codec->width; } - int GetHeight() const { return m_pStream->codec->height; } + int GetWidth() const { return m_pStream->codec.width; } + int GetHeight() const { return m_pStream->codec.height; } RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor ); @@ -333,7 +333,7 @@ int MovieDecoder_FFMpeg::DecodePacket( RageSurface *pOut, float fTargetTime ) bool bSkipThisFrame = fTargetTime != -1 && GetTimestamp() + GetFrameDuration() <= fTargetTime && - (m_pStream->codec->frame_number % 2) == 0; + (m_pStream->codec.frame_number % 2) == 0; int iGotFrame; 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. */ static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 }; int len = avcodec::avcodec_decode_video( - m_pStream->codec, + &m_pStream->codec, &m_Frame, &iGotFrame, m_Packet.size? m_Packet.data:dummy, m_Packet.size ); CHECKPOINT; @@ -375,7 +375,7 @@ int MovieDecoder_FFMpeg::DecodePacket( RageSurface *pOut, float fTargetTime ) } /* 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_iFrameNumber; @@ -416,8 +416,8 @@ void MovieDecoder_FFMpeg::ConvertToSurface( RageSurface *pSurface ) const pict.linesize[0] = pSurface->pitch; avcodec::img_convert( &pict, m_AVTexfmt, - (avcodec::AVPicture *) &m_Frame, m_pStream->codec->pix_fmt, - m_pStream->codec->width, m_pStream->codec->height ); + (avcodec::AVPicture *) &m_Frame, m_pStream->codec.pix_fmt, + m_pStream->codec.width, m_pStream->codec.height ); } 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 ) { 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 NULL; @@ -549,21 +549,21 @@ RString MovieDecoder_FFMpeg::Open( RString sFile ) if ( stream == NULL ) return ssprintf( "AVCodec (%s): Couldn't find any video streams", sFile.c_str() ); - if( stream->codec->codec_id == avcodec::CODEC_ID_NONE ) - return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec->codec_tag ); + if( stream->codec.codec_id == avcodec::CODEC_ID_NONE ) + 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 ) - 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 ); - ret = avcodec::avcodec_open( stream->codec, codec ); + ret = avcodec::avcodec_open( &stream->codec, codec ); if ( ret < 0 ) return ssprintf( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", sFile.c_str(), codec->name) ); m_pStream = stream; - 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( "Bitrate: %i", m_pStream->codec.bit_rate ); + LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec.pix_fmt) ); return RString(); } @@ -572,7 +572,7 @@ void MovieDecoder_FFMpeg::Close() { if( m_pStream ) { - avcodec::avcodec_close( m_pStream->codec ); + avcodec::avcodec_close( &m_pStream->codec ); m_pStream = NULL; } diff --git a/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h b/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h index 16b13a3136..03269207ee 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h @@ -11,28 +11,26 @@ extern "C" { #endif -#include "avutil.h" +#include "common.h" +#include "rational.h" #include /* size_t */ -//FIXME the following 2 really dont belong in here -#define FFMPEG_VERSION_INT 0x000409 -#define FFMPEG_VERSION "CVS" +#define FFMPEG_VERSION_INT 0x000409 +#define FFMPEG_VERSION "0.4.9-pre1" +#define LIBAVCODEC_BUILD 4718 -#define AV_STRINGIFY(s) AV_TOSTRING(s) +#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT +#define LIBAVCODEC_VERSION FFMPEG_VERSION + +#define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_TOSTRING(s) #s +#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD) -#define LIBAVCODEC_VERSION_INT ((51<<16)+(9<<8)+0) -#define LIBAVCODEC_VERSION 51.9.0 -#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT - -#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) - -#define AV_NOPTS_VALUE int64_t_C(0x8000000000000000) -#define AV_TIME_BASE 1000000 -#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} +#define AV_NOPTS_VALUE int64_t_C(0x8000000000000000) +#define AV_TIME_BASE 1000000 enum CodecID { - CODEC_ID_NONE, + CODEC_ID_NONE, CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */ CODEC_ID_MPEG2VIDEO_XVMC, @@ -40,11 +38,14 @@ enum CodecID { CODEC_ID_H263, CODEC_ID_RV10, CODEC_ID_RV20, + CODEC_ID_MP2, + CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */ + CODEC_ID_VORBIS, + CODEC_ID_AC3, CODEC_ID_MJPEG, CODEC_ID_MJPEGB, CODEC_ID_LJPEG, CODEC_ID_SP5X, - CODEC_ID_JPEGLS, CODEC_ID_MPEG4, CODEC_ID_RAWVIDEO, CODEC_ID_MSMPEG4V1, @@ -58,12 +59,19 @@ enum CodecID { CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_DVVIDEO, + CODEC_ID_DVAUDIO, + CODEC_ID_WMAV1, + CODEC_ID_WMAV2, + CODEC_ID_MACE3, + CODEC_ID_MACE6, CODEC_ID_HUFFYUV, CODEC_ID_CYUV, CODEC_ID_H264, CODEC_ID_INDEO3, CODEC_ID_VP3, CODEC_ID_THEORA, + CODEC_ID_AAC, + CODEC_ID_MPEG4AAC, CODEC_ID_ASV1, CODEC_ID_ASV2, CODEC_ID_FFV1, @@ -86,44 +94,13 @@ enum CodecID { CODEC_ID_FLIC, CODEC_ID_TRUEMOTION1, CODEC_ID_VMDVIDEO, + CODEC_ID_VMDAUDIO, CODEC_ID_MSZH, CODEC_ID_ZLIB, CODEC_ID_QTRLE, - CODEC_ID_SNOW, - CODEC_ID_TSCC, - CODEC_ID_ULTI, - CODEC_ID_QDRAW, - CODEC_ID_VIXL, - CODEC_ID_QPEG, - CODEC_ID_XVID, - CODEC_ID_PNG, - CODEC_ID_PPM, - CODEC_ID_PBM, - CODEC_ID_PGM, - CODEC_ID_PGMYUV, - CODEC_ID_PAM, - CODEC_ID_FFVHUFF, - CODEC_ID_RV30, - CODEC_ID_RV40, - CODEC_ID_VC9, - CODEC_ID_WMV3, - CODEC_ID_LOCO, - CODEC_ID_WNV1, - CODEC_ID_AASC, - CODEC_ID_INDEO2, - CODEC_ID_FRAPS, - CODEC_ID_TRUEMOTION2, - CODEC_ID_BMP, - CODEC_ID_CSCD, - CODEC_ID_MMVIDEO, - CODEC_ID_ZMBV, - CODEC_ID_AVS, - CODEC_ID_SMACKVIDEO, - CODEC_ID_NUV, - CODEC_ID_KMVC, /* various pcm "codecs" */ - CODEC_ID_PCM_S16LE= 0x10000, + CODEC_ID_PCM_S16LE, CODEC_ID_PCM_S16BE, CODEC_ID_PCM_U16LE, CODEC_ID_PCM_U16BE, @@ -131,18 +108,9 @@ enum CodecID { CODEC_ID_PCM_U8, CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, - CODEC_ID_PCM_S32LE, - CODEC_ID_PCM_S32BE, - CODEC_ID_PCM_U32LE, - CODEC_ID_PCM_U32BE, - CODEC_ID_PCM_S24LE, - CODEC_ID_PCM_S24BE, - CODEC_ID_PCM_U24LE, - CODEC_ID_PCM_U24BE, - CODEC_ID_PCM_S24DAUD, /* various adpcm codecs */ - CODEC_ID_ADPCM_IMA_QT= 0x11000, + CODEC_ID_ADPCM_IMA_QT, CODEC_ID_ADPCM_IMA_WAV, CODEC_ID_ADPCM_IMA_DK3, CODEC_ID_ADPCM_IMA_DK4, @@ -154,62 +122,23 @@ enum CodecID { CODEC_ID_ADPCM_ADX, CODEC_ID_ADPCM_EA, CODEC_ID_ADPCM_G726, - CODEC_ID_ADPCM_CT, - CODEC_ID_ADPCM_SWF, - CODEC_ID_ADPCM_YAMAHA, - CODEC_ID_ADPCM_SBPRO_4, - CODEC_ID_ADPCM_SBPRO_3, - CODEC_ID_ADPCM_SBPRO_2, - /* AMR */ - CODEC_ID_AMR_NB= 0x12000, + /* AMR */ + CODEC_ID_AMR_NB, CODEC_ID_AMR_WB, /* RealAudio codecs*/ - CODEC_ID_RA_144= 0x13000, + CODEC_ID_RA_144, CODEC_ID_RA_288, /* various DPCM codecs */ - CODEC_ID_ROQ_DPCM= 0x14000, + CODEC_ID_ROQ_DPCM, CODEC_ID_INTERPLAY_DPCM, CODEC_ID_XAN_DPCM, - CODEC_ID_SOL_DPCM, - - CODEC_ID_MP2= 0x15000, - CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */ - CODEC_ID_AAC, - CODEC_ID_MPEG4AAC, - CODEC_ID_AC3, - CODEC_ID_DTS, - CODEC_ID_VORBIS, - CODEC_ID_DVAUDIO, - CODEC_ID_WMAV1, - CODEC_ID_WMAV2, - CODEC_ID_MACE3, - CODEC_ID_MACE6, - CODEC_ID_VMDAUDIO, - CODEC_ID_SONIC, - CODEC_ID_SONIC_LS, + CODEC_ID_FLAC, - CODEC_ID_MP3ADU, - CODEC_ID_MP3ON4, - CODEC_ID_SHORTEN, - CODEC_ID_ALAC, - CODEC_ID_WESTWOOD_SND1, - CODEC_ID_GSM, - CODEC_ID_QDM2, - CODEC_ID_COOK, - CODEC_ID_TRUESPEECH, - CODEC_ID_TTA, - CODEC_ID_SMACKAUDIO, - - CODEC_ID_OGGTHEORA= 0x16000, - - /* subtitle codecs */ - CODEC_ID_DVD_SUBTITLE= 0x17000, - CODEC_ID_DVB_SUBTITLE, - - CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport + + CODEC_ID_MPEG2TS, /* _FAKE_ codec to indicate a raw MPEG2 transport stream (only used by libavformat) */ }; @@ -221,38 +150,67 @@ enum CodecType { CODEC_TYPE_VIDEO, CODEC_TYPE_AUDIO, CODEC_TYPE_DATA, - CODEC_TYPE_SUBTITLE, +}; + +/** + * Pixel format. Notes: + * + * PIX_FMT_RGBA32 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_RGBA32 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_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) + PIX_FMT_YUV422, + PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB... + PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR... + PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples) + PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples) + PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness + PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples) + PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples) + PIX_FMT_RGB565, ///< always stored in cpu endianness + PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1 + PIX_FMT_GRAY8, + PIX_FMT_MONOWHITE, ///< 0 is white + PIX_FMT_MONOBLACK, ///< 0 is black + PIX_FMT_PAL8, ///< 8 bit with RGBA palette + PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg) + PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg) + PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg) + PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h) + PIX_FMT_XVMC_MPEG2_IDCT, + PIX_FMT_NB, }; /* currently unused, may be used if 24/32 bits samples ever supported */ -/* all in native endian */ enum SampleFormat { - SAMPLE_FMT_NONE = -1, - SAMPLE_FMT_U8, ///< unsigned 8 bits - SAMPLE_FMT_S16, ///< signed 16 bits - SAMPLE_FMT_S24, ///< signed 24 bits - SAMPLE_FMT_S32, ///< signed 32 bits - SAMPLE_FMT_FLT, ///< float + SAMPLE_FMT_S16 = 0, ///< signed 16 bits }; /* in bytes */ -#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072 /** * Required number of additionally allocated bytes at the end of the input bitstream for decoding. - * this is mainly needed because some optimized bitstream readers read + * this is mainly needed because some optimized bitstream readers read * 32 or 64 bit at once and could read over the end
* Note, if the first 23 bits of the additional bytes are not 0 then damaged * MPEG bitstreams could cause overread and segfault */ #define FF_INPUT_BUFFER_PADDING_SIZE 8 -/** - * minimum encoding buffer size. - * used to avoid some checks during header writing - */ -#define FF_MIN_BUFFER_SIZE 16384 - /* motion estimation type, EPZS by default */ enum Motion_Est_ID { ME_ZERO = 1, @@ -260,20 +218,7 @@ enum Motion_Est_ID { ME_LOG, ME_PHODS, ME_EPZS, - ME_X1, - ME_HEX, - ME_UMH, - ME_ITER, -}; - -enum AVDiscard{ -//we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames) - AVDISCARD_NONE =-16, ///< discard nothing - AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi - AVDISCARD_NONREF = 8, ///< discard all non reference - AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames - AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes - AVDISCARD_ALL = 48, ///< discard all + ME_X1 }; typedef struct RcOverride{ @@ -286,41 +231,41 @@ typedef struct RcOverride{ /* only for ME compatiblity with old apps */ extern int motion_estimation_method; -#define FF_MAX_B_FRAMES 16 +#define FF_MAX_B_FRAMES 8 /* encoding support - these flags can be passed in AVCodecContext.flags before initing - Note: not everything is supported yet. + these flags can be passed in AVCodecContext.flags before initing + Note: note not everything is supported yet */ -#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale +#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263 -#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC -#define CODEC_FLAG_GMC 0x0020 ///< use GMC -#define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0> -#define CODEC_FLAG_PART 0x0080 ///< use data partitioning -/* parent program gurantees that the input for b-frame containing streams is not written to +#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC +#define CODEC_FLAG_GMC 0x0020 ///< use GMC +#define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0> +#define CODEC_FLAG_PART 0x0080 ///< use data partitioning +/* parent program gurantees that the input for b-frame containing streams is not written to for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */ #define CODEC_FLAG_INPUT_PRESERVED 0x0100 -#define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode -#define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode -#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg) -#define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale -#define CODEC_FLAG_EMU_EDGE 0x4000///< don't draw edges -#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding -#define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead +#define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode +#define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode +#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg) +#define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale +#define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges +#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding +#define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead of only at frame boundaries */ -#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization -#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct +#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization +#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay -#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan -#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization -#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe -#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct) +#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan +#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization +#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe +#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct) /* Fx : Flag for h263+ extra options */ #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this) #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction -#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector +#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc @@ -330,27 +275,14 @@ extern int motion_estimation_method; #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data #define CODEC_FLAG_CLOSED_GOP 0x80000000 -#define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks -#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< strictly enforce GOP size -#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< skip bitstream encoding -#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< place global headers at every keyframe instead of in extradata -#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow b-frames to be used as references -#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for b-frames -#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 multiple references per partition -#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform -#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip -#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters -#define CODEC_FLAG2_BRDO 0x00000400 ///< b-frame rate-distortion optimization -#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table - /* Unsupported options : - * Syntax Arithmetic coding (SAC) - * Reference Picture Selection - * Independant Segment Decoding */ + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independant Segment Decoding */ /* /Fx */ /* codec capabilities */ -#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback +#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback /** * Codec uses get_buffer() for allocating buffers. * direct rendering method 1 @@ -362,13 +294,10 @@ extern int motion_estimation_method; #define CODEC_CAP_TRUNCATED 0x0008 /* codec can export data for HW decoding (XvMC) */ #define CODEC_CAP_HWACCEL 0x0010 -/** - * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data. - * if this is not set, the codec is guranteed to never be feeded with NULL data - */ +/** codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data */ #define CODEC_CAP_DELAY 0x0020 -//the following defines may change, don't expect compatibility if you use them +//the following defines might change, so dont expect compatibility if u use them #define MB_TYPE_INTRA4x4 0x0001 #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific @@ -431,7 +360,7 @@ typedef struct AVPanScan{ int linesize[4];\ /**\ * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\ - * this isn't used by lavc unless the default get/release_buffer() is used\ + * this isnt used by lavc unless the default get/release_buffer() is used\ * - encoding: \ * - decoding: \ */\ @@ -451,8 +380,8 @@ typedef struct AVPanScan{ int pict_type;\ \ /**\ - * presentation timestamp in time_base units (time when frame should be shown to user)\ - * if AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed\ + * presentation timestamp in AV_TIME_BASE (=micro seconds currently) (time when frame should be shown to user)\ + * if AV_NOPTS_VALUE then the frame_rate will be used as reference\ * - encoding: MUST be set by user\ * - decoding: set by lavc\ */\ @@ -515,14 +444,7 @@ typedef struct AVPanScan{ uint8_t *mbskip_table;\ \ /**\ - * Motion vector table.\ - * @code\ - * example:\ - * int mv_sample_log2= 4 - motion_subsample_log2;\ - * int mb_width= (width+15)>>4;\ - * int mv_stride= (mb_width << mv_sample_log2) + 1;\ - * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\ - * @endcode\ + * Motion vector table\ * - encoding: set by user\ * - decoding: set by lavc\ */\ @@ -537,8 +459,7 @@ typedef struct AVPanScan{ uint32_t *mb_type;\ \ /**\ - * log2 of the size of the block which a single vector in motion_val represents: \ - * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\ + * Macroblock size: (0->16x16, 1->8x8, 2-> 4x4, 3-> 2x2)\ * - encoding: unused\ * - decoding: set by lavc\ */\ @@ -628,14 +549,13 @@ typedef struct AVPanScan{ */\ int8_t *ref_index[2]; -#define FF_QSCALE_TYPE_MPEG1 0 -#define FF_QSCALE_TYPE_MPEG2 1 -#define FF_QSCALE_TYPE_H264 2 +#define FF_QSCALE_TYPE_MPEG1 0 +#define FF_QSCALE_TYPE_MPEG2 1 #define FF_BUFFER_TYPE_INTERNAL 1 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user) -#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared -#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, don't dealloc anything +#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base), all other tables are not shared +#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything #define FF_I_TYPE 1 // Intra @@ -666,10 +586,9 @@ 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 */ - struct AVOption *option; + or AVFormatContext, which begin with an AVClass. + Needed because av_log is in libavcodec and has no visibility + of AVIn/OutputFormat */ }; /** @@ -684,7 +603,7 @@ typedef struct AVCodecContext { /** * the average bitrate. * - encoding: set by user. unused for constant quantizer encoding - * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream + * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream */ int bit_rate; @@ -694,7 +613,7 @@ typedef struct AVCodecContext { * - encoding: set by user. unused for constant quantizer encoding * - decoding: unused */ - int bit_rate_tolerance; + int bit_rate_tolerance; /** * CODEC_FLAG_*. @@ -705,15 +624,13 @@ typedef struct AVCodecContext { /** * some codecs needs additionnal format info. It is stored here - * - encoding: set by user. + * - encoding: set by user. * - decoding: set by lavc. (FIXME is this ok?) */ int sub_id; /** * motion estimation algorithm used for video coding. - * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), - * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific] * - encoding: MUST be set by user. * - decoding: unused */ @@ -724,35 +641,29 @@ typedef struct AVCodecContext { * mjpeg: huffman tables * rv10: additional flags * mpeg4: global headers (they can be in the bitstream or here) - * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger - * then extradata_size to avoid prolems if its read with the bitstream reader - * the bytewise contents of extradata must not depend on the architecture or cpu endianness * - encoding: set/allocated/freed by lavc. * - decoding: set/allocated/freed by user. */ void *extradata; int extradata_size; - - /** - * 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. - * - encoding: MUST be set by user - * - decoding: set by lavc. - */ - AVRational time_base; - + /* video only */ /** - * picture width / height. - * - encoding: MUST be set by user. - * - decoding: set by lavc. - * Note, for compatibility its possible to set this instead of - * coded_width/height before decoding + * frames per sec multiplied by frame_rate_base. + * for variable fps this is the precission, so if the timestamps + * can be specified in msec precssion then this is 1000*frame_rate_base + * - encoding: MUST be set by user + * - decoding: set by lavc. 0 or the frame_rate if available + */ + int frame_rate; + + /** + * width / height. + * - encoding: MUST be set by user. + * - decoding: set by user if known, codec should override / dynamically change if needed */ int width, height; - + #define FF_ASPECT_EXTENDED 15 /** @@ -764,19 +675,22 @@ typedef struct AVCodecContext { /** * pixel format, see PIX_FMT_xxx. - * - encoding: set by user. + * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt + * conversion is in order. This only works for + * codecs with one supported pix_fmt, we should + * do something for a generic case as well. * - decoding: set by lavc. */ enum PixelFormat pix_fmt; - + /** - * Frame rate emulation. If not zero lower layer (i.e. format handler) + * Frame rate emulation. If not zero lower layer (i.e. format handler) * has to read frames at native frame rate. * - encoding: set by user. * - decoding: unused. */ int rate_emu; - + /** * if non NULL, 'draw_horiz_band' is called by the libavcodec * decoder to draw an horizontal band. It improve cache usage. Not @@ -794,36 +708,27 @@ typedef struct AVCodecContext { int y, int type, int height); /* audio only */ - int sample_rate; ///< samples per sec + int sample_rate; ///< samples per sec int channels; - - /** - * audio sample format. - * - encoding: set by user. - * - decoding: set by lavc. - */ - enum SampleFormat sample_fmt; ///< sample format, currenly unused + int sample_fmt; ///< sample format, currenly unused /* the following data should not be initialized */ + int frame_size; ///< in samples, initialized when calling 'init' + int frame_number; ///< audio or video frame number + int real_pict_num; ///< returns the real picture number of previous encoded frame + /** - * samples per packet. initialized when calling 'init' - */ - int frame_size; - int frame_number; ///< audio or video frame number - int real_pict_num; ///< returns the real picture number of previous encoded frame - - /** - * number of frames the decoded output will be delayed relative to + * number of frames the decoded output will be delayed relative to * the encoded input. * - encoding: set by lavc. * - decoding: unused */ int delay; - + /* - encoding parameters */ float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) - float qblur; ///< amount of qscale smoothing over time (0.0-1.0) - + float qblur; ///< amount of qscale smoothing over time (0.0-1.0) + /** * minimum quantizer. * - encoding: set by user. @@ -859,43 +764,38 @@ typedef struct AVCodecContext { * - decoding: unused */ float b_quant_factor; - + /** obsolete FIXME remove */ int rc_strategy; -#define FF_RC_STRATEGY_XVID 1 - int b_frame_strategy; /** * hurry up amount. - * deprecated in favor of skip_idct and skip_frame * - encoding: unused * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header */ int hurry_up; - + struct AVCodec *codec; - + void *priv_data; /* unused, FIXME remove*/ int rtp_mode; - - int rtp_payload_size; /* The size of the RTP payload: the coder will */ + + int rtp_payload_size; /* The size of the RTP payload, the coder will */ /* do it's best to deliver a chunk with size */ /* below rtp_payload_size, the chunk will start */ /* with a start code on some codecs like H.263 */ /* This doesn't take account of any particular */ /* headers inside the transmited RTP payload */ - - /* The RTP callback: This function is called */ - /* every time the encoder has a packet to send */ - /* Depends on the encoder if the data starts */ - /* with a Start Code (it should) H.263 does. */ - /* mb_nb contains the number of macroblocks */ - /* encoded in the RTP payload */ - void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); + + /* The RTP callcack: This function is called */ + /* every time the encoder as a packet to send */ + /* Depends on the encoder if the data starts */ + /* with a Start Code (it should) H.263 does */ + void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int packet_number); /* statistics, used for 2-pass encoding */ int mv_bits; @@ -906,7 +806,7 @@ typedef struct AVCodecContext { int p_count; int skip_count; int misc_bits; - + /** * number of bits used for the previously encoded frame. * - encoding: set by lavc @@ -924,7 +824,7 @@ typedef struct AVCodecContext { char codec_name[32]; enum CodecType codec_type; /* see CODEC_TYPE_xxx */ enum CodecID codec_id; /* see CODEC_ID_xxx */ - + /** * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). * this is used to workaround some encoder bugs @@ -932,10 +832,10 @@ typedef struct AVCodecContext { * - decoding: set by user, will be converted to upper case by lavc during init */ unsigned int codec_tag; - + /** * workaround bugs in encoders which sometimes cannot be detected automatically. - * - encoding: set by user + * - encoding: unused * - decoding: set by user */ int workaround_bugs; @@ -953,35 +853,29 @@ typedef struct AVCodecContext { #define FF_BUG_EDGE 1024 #define FF_BUG_HPEL_CHROMA 2048 #define FF_BUG_DC_CLIP 4096 -#define FF_BUG_MS 8192 ///< workaround various bugs in microsofts broken decoders //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100% - + /** * luma single coeff elimination threshold. * - encoding: set by user * - decoding: unused */ int luma_elim_threshold; - + /** * chroma single coeff elimination threshold. * - encoding: set by user * - decoding: unused */ int chroma_elim_threshold; - + /** * strictly follow the std (MPEG4, ...). * - encoding: set by user * - decoding: unused */ int strict_std_compliance; -#define FF_COMPLIANCE_VERY_STRICT 2 ///< strictly conform to a older more strict version of the spec or reference software -#define FF_COMPLIANCE_STRICT 1 ///< strictly conform to all the things in the spec no matter what consequences -#define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_INOFFICIAL -1 ///< allow inofficial extensions -#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< allow non standarized experimental things - + /** * qscale offset between ip and b frames. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset) @@ -990,7 +884,7 @@ typedef struct AVCodecContext { * - decoding: unused */ float b_quant_offset; - + /** * error resilience higher values will detect more errors but may missdetect * some more or less valid parts as errors. @@ -998,11 +892,11 @@ typedef struct AVCodecContext { * - decoding: set by user */ int error_resilience; -#define FF_ER_CAREFUL 1 +#define FF_ER_CAREFULL 1 #define FF_ER_COMPLIANT 2 #define FF_ER_AGGRESSIVE 3 #define FF_ER_VERY_AGGRESSIVE 4 - + /** * called at the beginning of each frame to get a buffer for it. * if pic.reference is set then the frame will be read later by lavc @@ -1012,7 +906,7 @@ typedef struct AVCodecContext { * - decoding: set by lavc, user can override */ int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); - + /** * called to release buffers which where allocated with get_buffer. * a released buffer can be reused in get_buffer() @@ -1028,31 +922,27 @@ typedef struct AVCodecContext { * - decoding: set by lavc */ int has_b_frames; - - /** - * number of bytes per packet if constant and known or 0 - * used by some WAV based audio codecs - */ - int block_align; - + + int block_align; ///< used by some WAV based audio codecs + int parse_only; /* - decoding only: if true, only parsing is done (function avcodec_parse_frame()). The frame data is returned. Only MPEG codecs support this now. */ - + /** * 0-> h263 quant 1-> mpeg quant. * - encoding: set by user. * - decoding: unused */ int mpeg_quant; - + /** * pass1 encoding statistics output buffer. * - encoding: set by lavc * - decoding: unused */ char *stats_out; - + /** * pass2 encoding statistics input buffer. * concatenated stuff from stats_out of pass1 should be placed here @@ -1060,7 +950,7 @@ typedef struct AVCodecContext { * - decoding: unused */ char *stats_in; - + /** * ratecontrol qmin qmax limiting method. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax @@ -1071,7 +961,7 @@ typedef struct AVCodecContext { float rc_qmod_amp; int rc_qmod_freq; - + /** * ratecontrol override, see RcOverride. * - encoding: allocated/set/freed by user. @@ -1079,28 +969,28 @@ typedef struct AVCodecContext { */ RcOverride *rc_override; int rc_override_count; - + /** * rate control equation. * - encoding: set by user * - decoding: unused */ char *rc_eq; - + /** * maximum bitrate. * - encoding: set by user. * - decoding: unused */ int rc_max_rate; - + /** * minimum bitrate. * - encoding: set by user. * - decoding: unused */ int rc_min_rate; - + /** * decoder bitstream buffer size. * - encoding: set by user. @@ -1117,14 +1007,14 @@ typedef struct AVCodecContext { * - decoding: unused */ float i_quant_factor; - + /** * qscale offset between p and i frames. * - encoding: set by user. * - decoding: unused */ float i_quant_offset; - + /** * initial complexity for pass1 ratecontrol. * - encoding: set by user. @@ -1145,28 +1035,28 @@ typedef struct AVCodecContext { #define FF_DCT_MLIB 4 #define FF_DCT_ALTIVEC 5 #define FF_DCT_FAAN 6 - + /** * luminance masking (0-> disabled). * - encoding: set by user * - decoding: unused */ float lumi_masking; - + /** * temporary complexity masking (0-> disabled). * - encoding: set by user * - decoding: unused */ float temporal_cplx_masking; - + /** * spatial complexity masking (0-> disabled). * - encoding: set by user * - decoding: unused */ float spatial_cplx_masking; - + /** * p block masking (0-> disabled). * - encoding: set by user @@ -1180,11 +1070,11 @@ typedef struct AVCodecContext { * - decoding: unused */ float dark_masking; - - + + /* for binary compatibility */ int unused; - + /** * idct algorithm, see FF_IDCT_* below. * - encoding: set by user @@ -1202,10 +1092,6 @@ typedef struct AVCodecContext { #define FF_IDCT_ALTIVEC 8 #define FF_IDCT_SH4 9 #define FF_IDCT_SIMPLEARM 10 -#define FF_IDCT_H264 11 -#define FF_IDCT_VP3 12 -#define FF_IDCT_IPP 13 -#define FF_IDCT_XVIDMMX 14 /** * slice count. @@ -1238,19 +1124,15 @@ typedef struct AVCodecContext { * result into program crash) */ unsigned dsp_mask; -#define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */ +#define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */ /* lower 16 bits - CPU features */ #ifdef HAVE_MMX -#define FF_MM_MMX 0x0001 /* standard MMX */ -#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */ -#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */ -#define FF_MM_SSE 0x0008 /* SSE functions */ -#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */ -#define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */ +#define FF_MM_MMX 0x0001 /* standard MMX */ +#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */ +#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */ +#define FF_MM_SSE 0x0008 /* SSE functions */ +#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */ #endif /* HAVE_MMX */ -#ifdef HAVE_IWMMXT -#define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */ -#endif /* HAVE_IWMMXT */ /** * bits per sample/pixel from the demuxer (needed for huffyuv). @@ -1258,7 +1140,7 @@ typedef struct AVCodecContext { * - decoding: set by user */ int bits_per_sample; - + /** * prediction method (needed for huffyuv). * - encoding: set by user @@ -1268,7 +1150,7 @@ typedef struct AVCodecContext { #define FF_PRED_LEFT 0 #define FF_PRED_PLANE 1 #define FF_PRED_MEDIAN 2 - + /** * sample aspect ratio (0 if unknown). * numerator and denominator must be relative prime and smaller then 256 for some video standards @@ -1305,7 +1187,7 @@ typedef struct AVCodecContext { #define FF_DEBUG_BUGS 0x00001000 #define FF_DEBUG_VIS_QP 0x00002000 #define FF_DEBUG_VIS_MB_TYPE 0x00004000 - + /** * debug. * - encoding: set by user. @@ -1322,21 +1204,21 @@ typedef struct AVCodecContext { * - decoding: unused */ uint64_t error[4]; - + /** * minimum MB quantizer. - * - encoding: unused + * - encoding: set by user. * - decoding: unused */ int mb_qmin; /** * maximum MB quantizer. - * - encoding: unused + * - encoding: set by user. * - decoding: unused */ int mb_qmax; - + /** * motion estimation compare function. * - encoding: set by user. @@ -1372,12 +1254,8 @@ typedef struct AVCodecContext { #define FF_CMP_VSAD 8 #define FF_CMP_VSSE 9 #define FF_CMP_NSSE 10 -#define FF_CMP_W53 11 -#define FF_CMP_W97 12 -#define FF_CMP_DCTMAX 13 -#define FF_CMP_DCT264 14 #define FF_CMP_CHROMA 256 - + /** * ME diamond size & shape. * - encoding: set by user. @@ -1435,9 +1313,9 @@ typedef struct AVCodecContext { * DTG active format information (additionnal aspect ratio * information only used in DVB MPEG2 transport streams). 0 if * not set. - * + * * - encoding: unused. - * - decoding: set by decoder + * - decoding: set by decoder */ int dtg_active_format; #define FF_DTG_AFD_SAME 8 @@ -1451,12 +1329,21 @@ typedef struct AVCodecContext { /** * Maximum motion estimation search range in subpel units. * if 0 then no limit - * + * * - encoding: set by user. * - decoding: unused. */ int me_range; + /** + * frame_rate_base. + * for variable fps this is 1 + * - encoding: set by user. + * - decoding: set by lavc. + * @todo move this after frame_rate + */ + + int frame_rate_base; /** * intra quantizer bias. * - encoding: set by user. @@ -1464,7 +1351,7 @@ typedef struct AVCodecContext { */ int intra_quant_bias; #define FF_DEFAULT_QUANT_BIAS 999999 - + /** * inter quantizer bias. * - encoding: set by user. @@ -1479,16 +1366,16 @@ typedef struct AVCodecContext { * table have to be stored somewhere FIXME */ int color_table_id; - + /** - * internal_buffer count. - * Don't touch, used by lavc default_get_buffer() + * internal_buffer count. + * Dont touch, used by lavc default_get_buffer() */ int internal_buffer_count; - + /** - * internal_buffers. - * Don't touch, used by lavc default_get_buffer() + * internal_buffers. + * Dont touch, used by lavc default_get_buffer() */ void *internal_buffer; @@ -1505,7 +1392,7 @@ typedef struct AVCodecContext { * - decoding: unused */ int global_quality; - + #define FF_CODER_TYPE_VLC 0 #define FF_CODER_TYPE_AC 1 /** @@ -1521,15 +1408,7 @@ typedef struct AVCodecContext { * - decoding: unused */ int context_model; -#if 0 - /** - * - * - encoding: unused - * - decoding: set by user. - */ - uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size); -#endif - + /** * slice flags * - encoding: unused @@ -1546,7 +1425,7 @@ typedef struct AVCodecContext { * - decoding: set by decoder */ int xvmc_acceleration; - + /** * macroblock decision mode * - encoding: set by user. @@ -1570,7 +1449,7 @@ typedef struct AVCodecContext { * - decoding: set by lavc */ uint16_t *inter_matrix; - + /** * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). * this is used to workaround some encoder bugs @@ -1614,7 +1493,7 @@ typedef struct AVCodecContext { * - decoding: unused */ int noise_reduction; - + /** * called at the beginning of a frame to get cr buffer for it. * buffer type (size, hints) must be the same. lavc won't check it. @@ -1653,7 +1532,7 @@ typedef struct AVCodecContext { * - decoding: unused. */ int error_rate; - + /** * MP3 antialias algorithm, see FF_AA_* below. * - encoding: unused @@ -1678,7 +1557,7 @@ typedef struct AVCodecContext { * - decoding: set by user */ int thread_count; - + /** * the codec may call this to execute several independant things. it will return only after * finishing all tasks, the user may replace this with some multithreaded implementation, the @@ -1688,7 +1567,7 @@ typedef struct AVCodecContext { * - decoding: set by lavc, user can override */ int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count); - + /** * Thread opaque. * can be used by execute() to store some per AVCodecContext stuff. @@ -1698,9 +1577,9 @@ typedef struct AVCodecContext { void *thread_opaque; /** - * Motion estimation threshold. under which no motion estimation is + * Motion estimation threshold. under which no motion estimation is * performed, but instead the user specified motion vectors are used - * + * * - encoding: set by user * - decoding: unused */ @@ -1728,263 +1607,72 @@ typedef struct AVCodecContext { int nsse_weight; /** - * number of macroblock rows at the top which are skipped. + * number of macroblock rows at the top which are skiped. * - encoding: unused * - decoding: set by user */ int skip_top; /** - * number of macroblock rows at the bottom which are skipped. + * number of macroblock rows at the bottom which are skiped. * - encoding: unused * - decoding: set by user */ int skip_bottom; - - /** - * profile - * - encoding: set by user - * - decoding: set by lavc - */ - int profile; -#define FF_PROFILE_UNKNOWN -99 - - /** - * level - * - encoding: set by user - * - decoding: set by lavc - */ - int level; -#define FF_LEVEL_UNKNOWN -99 - - /** - * low resolution decoding. 1-> 1/2 size, 2->1/4 size - * - encoding: unused - * - decoding: set by user - */ - int lowres; - - /** - * bitsream width / height. may be different from width/height if lowres - * or other things are used - * - encoding: unused - * - decoding: set by user before init if known, codec should override / dynamically change if needed - */ - int coded_width, coded_height; - - /** - * frame skip threshold - * - encoding: set by user - * - decoding: unused - */ - int frame_skip_threshold; - - /** - * frame skip factor - * - encoding: set by user - * - decoding: unused - */ - int frame_skip_factor; - - /** - * frame skip exponent - * - encoding: set by user - * - decoding: unused - */ - int frame_skip_exp; - - /** - * frame skip comparission function - * - encoding: set by user. - * - decoding: unused - */ - int frame_skip_cmp; - - /** - * border processing masking. raises the quantizer for mbs on the borders - * of the picture. - * - encoding: set by user - * - decoding: unused - */ - float border_masking; - - /** - * minimum MB lagrange multipler. - * - encoding: set by user. - * - decoding: unused - */ - int mb_lmin; - - /** - * maximum MB lagrange multipler. - * - encoding: set by user. - * - decoding: unused - */ - int mb_lmax; - - /** - * - * - encoding: set by user. - * - decoding: unused - */ - int me_penalty_compensation; - - /** - * - * - encoding: unused - * - decoding: set by user. - */ - enum AVDiscard skip_loop_filter; - - /** - * - * - encoding: unused - * - decoding: set by user. - */ - enum AVDiscard skip_idct; - - /** - * - * - encoding: unused - * - decoding: set by user. - */ - enum AVDiscard skip_frame; - - /** - * - * - encoding: set by user. - * - decoding: unused - */ - int bidir_refine; - - /** - * - * - encoding: set by user. - * - decoding: unused - */ - int brd_scale; - - /** - * constant rate factor - quality-based VBR - values ~correspond to qps - * - encoding: set by user. - * - decoding: unused - */ - int crf; - - /** - * constant quantization parameter rate control method - * - encoding: set by user. - * - decoding: unused - */ - int cqp; - - /** - * minimum gop size - * - encoding: set by user. - * - decoding: unused - */ - int keyint_min; - - /** - * number of reference frames - * - encoding: set by user. - * - decoding: unused - */ - int refs; - - /** - * chroma qp offset from luma - * - encoding: set by user. - * - decoding: unused - */ - int chromaoffset; - - /** - * influences how often b-frames are used - * - encoding: set by user. - * - decoding: unused - */ - int bframebias; - - /** - * trellis RD quantization - * - encoding: set by user. - * - decoding: unused - */ - int trellis; - - /** - * reduce fluctuations in qp (before curve compression) - * - encoding: set by user. - * - decoding: unused - */ - float complexityblur; - - /** - * in-loop deblocking filter alphac0 parameter - * alpha is in the range -6...6 - * - encoding: set by user. - * - decoding: unused - */ - int deblockalpha; - - /** - * in-loop deblocking filter beta parameter - * beta is in the range -6...6 - * - encoding: set by user. - * - decoding: unused - */ - int deblockbeta; - - /** - * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 - * - encoding: set by user. - * - decoding: unused - */ - int partitions; -#define X264_PART_I4X4 0x001 /* Analyse i4x4 */ -#define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */ -#define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */ -#define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */ -#define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */ - - /** - * direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal) - * - encoding: set by user. - * - decoding: unused - */ - int directpred; - - /** - * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC - * - encoding: set by user. - * - decoding: unused - */ - int cutoff; - - /** - * multiplied by qscale for each frame and added to scene_change_score - * - encoding: set by user. - * - decoding: unused - */ - int scenechange_factor; - - /** - * - * note: value depends upon the compare functin used for fullpel ME - * - encoding: set by user. - * - decoding: unused - */ - int mv0_threshold; } AVCodecContext; + +/** + * AVOption. + */ +typedef struct AVOption { + /** options' name */ + const char *name; /* if name is NULL, it indicates a link to next */ + /** short English text help or const struct AVOption* subpointer */ + const char *help; // const struct AVOption* sub; + /** offset to context structure where the parsed value should be stored */ + int offset; + /** options' type */ + int type; +#define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence) +#define FF_OPT_TYPE_DOUBLE 2 ///< double +#define FF_OPT_TYPE_INT 3 ///< integer +#define FF_OPT_TYPE_STRING 4 ///< string (finished with \0) +#define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags +//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option +#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40) +#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80) + /** min value (min == max -> no limits) */ + double min; + /** maximum value for double/int */ + double max; + /** default boo [0,1]l/double/int value */ + double defval; + /** + * default string value (with optional semicolon delimited extra option-list + * i.e. option1;option2;option3 + * defval might select other then first argument as default + */ + const char *defstr; +#define FF_OPT_MAX_DEPTH 10 +} AVOption; + +/** + * Parse option(s) and sets fields in passed structure + * @param strct structure where the parsed results will be written + * @param list list with AVOptions + * @param opts string with options for parsing + */ +int avoption_parse(void* strct, const AVOption* list, const char* opts); + + /** * AVCodec. */ typedef struct AVCodec { const char *name; enum CodecType type; - enum CodecID id; + int id; int priv_data_size; int (*init)(AVCodecContext *); int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); @@ -1992,9 +1680,7 @@ typedef struct AVCodec { int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, uint8_t *buf, int buf_size); int capabilities; -#if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0) - void *dummy; // FIXME remove next time we break binary compatibility -#endif + const AVOption *options; struct AVCodec *next; void (*flush)(AVCodecContext *); const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0} @@ -2031,35 +1717,13 @@ typedef struct AVPaletteControl { } AVPaletteControl; -typedef struct AVSubtitleRect { - uint16_t x; - uint16_t y; - uint16_t w; - uint16_t h; - uint16_t nb_colors; - int linesize; - uint32_t *rgba_palette; - uint8_t *bitmap; -} AVSubtitleRect; - -typedef struct AVSubtitle { - uint16_t format; /* 0 = graphics */ - uint32_t start_display_time; /* relative to packet pts, in ms */ - uint32_t end_display_time; /* relative to packet pts, in ms */ - uint32_t num_rects; - AVSubtitleRect *rects; -} AVSubtitle; - extern AVCodec ac3_encoder; extern AVCodec mp2_encoder; extern AVCodec mp3lame_encoder; extern AVCodec oggvorbis_encoder; -extern AVCodec oggtheora_encoder; extern AVCodec faac_encoder; -extern AVCodec xvid_encoder; extern AVCodec mpeg1video_encoder; extern AVCodec mpeg2video_encoder; -extern AVCodec h261_encoder; extern AVCodec h263_encoder; extern AVCodec h263p_encoder; extern AVCodec flv_encoder; @@ -2068,13 +1732,6 @@ extern AVCodec rv20_encoder; extern AVCodec dvvideo_encoder; extern AVCodec mjpeg_encoder; extern AVCodec ljpeg_encoder; -extern AVCodec jpegls_encoder; -extern AVCodec png_encoder; -extern AVCodec ppm_encoder; -extern AVCodec pgm_encoder; -extern AVCodec pgmyuv_encoder; -extern AVCodec pbm_encoder; -extern AVCodec pam_encoder; extern AVCodec mpeg4_encoder; extern AVCodec msmpeg4v1_encoder; extern AVCodec msmpeg4v2_encoder; @@ -2082,19 +1739,14 @@ extern AVCodec msmpeg4v3_encoder; extern AVCodec wmv1_encoder; extern AVCodec wmv2_encoder; extern AVCodec huffyuv_encoder; -extern AVCodec ffvhuff_encoder; extern AVCodec h264_encoder; extern AVCodec asv1_encoder; extern AVCodec asv2_encoder; extern AVCodec vcr1_encoder; extern AVCodec ffv1_encoder; -extern AVCodec snow_encoder; extern AVCodec mdec_encoder; extern AVCodec zlib_encoder; -extern AVCodec sonic_encoder; -extern AVCodec sonic_ls_encoder; extern AVCodec svq1_encoder; -extern AVCodec x264_encoder; extern AVCodec h263_decoder; extern AVCodec h261_decoder; @@ -2104,8 +1756,6 @@ extern AVCodec msmpeg4v2_decoder; extern AVCodec msmpeg4v3_decoder; extern AVCodec wmv1_decoder; extern AVCodec wmv2_decoder; -extern AVCodec vc9_decoder; -extern AVCodec wmv3_decoder; extern AVCodec mpeg1video_decoder; extern AVCodec mpeg2video_decoder; extern AVCodec mpegvideo_decoder; @@ -2114,8 +1764,6 @@ extern AVCodec h263i_decoder; extern AVCodec flv_decoder; extern AVCodec rv10_decoder; extern AVCodec rv20_decoder; -extern AVCodec rv30_decoder; -extern AVCodec rv40_decoder; extern AVCodec svq1_decoder; extern AVCodec svq3_decoder; extern AVCodec dvvideo_decoder; @@ -2124,21 +1772,12 @@ extern AVCodec wmav2_decoder; extern AVCodec mjpeg_decoder; extern AVCodec mjpegb_decoder; extern AVCodec sp5x_decoder; -extern AVCodec png_decoder; extern AVCodec mp2_decoder; extern AVCodec mp3_decoder; -extern AVCodec mp3adu_decoder; -extern AVCodec mp3on4_decoder; -extern AVCodec qdm2_decoder; -extern AVCodec cook_decoder; -extern AVCodec truespeech_decoder; -extern AVCodec tta_decoder; extern AVCodec mace3_decoder; extern AVCodec mace6_decoder; extern AVCodec huffyuv_decoder; -extern AVCodec ffvhuff_decoder; extern AVCodec oggvorbis_decoder; -extern AVCodec oggtheora_decoder; extern AVCodec cyuv_decoder; extern AVCodec h264_decoder; extern AVCodec indeo3_decoder; @@ -2155,7 +1794,6 @@ extern AVCodec asv2_decoder; extern AVCodec vcr1_decoder; extern AVCodec cljr_decoder; extern AVCodec ffv1_decoder; -extern AVCodec snow_decoder; extern AVCodec fourxm_decoder; extern AVCodec mdec_decoder; extern AVCodec roq_decoder; @@ -2173,7 +1811,6 @@ extern AVCodec flic_decoder; extern AVCodec vmdvideo_decoder; extern AVCodec vmdaudio_decoder; extern AVCodec truemotion1_decoder; -extern AVCodec truemotion2_decoder; extern AVCodec mszh_decoder; extern AVCodec zlib_decoder; extern AVCodec ra_144_decoder; @@ -2181,50 +1818,14 @@ extern AVCodec ra_288_decoder; extern AVCodec roq_dpcm_decoder; extern AVCodec interplay_dpcm_decoder; extern AVCodec xan_dpcm_decoder; -extern AVCodec sol_dpcm_decoder; -extern AVCodec sonic_decoder; extern AVCodec qtrle_decoder; extern AVCodec flac_decoder; -extern AVCodec tscc_decoder; -extern AVCodec cscd_decoder; -extern AVCodec nuv_decoder; -extern AVCodec ulti_decoder; -extern AVCodec qdraw_decoder; -extern AVCodec xl_decoder; -extern AVCodec qpeg_decoder; -extern AVCodec shorten_decoder; -extern AVCodec loco_decoder; -extern AVCodec wnv1_decoder; -extern AVCodec aasc_decoder; -extern AVCodec alac_decoder; -extern AVCodec ws_snd1_decoder; -extern AVCodec indeo2_decoder; -extern AVCodec vorbis_decoder; -extern AVCodec fraps_decoder; -extern AVCodec libgsm_encoder; -extern AVCodec libgsm_decoder; -extern AVCodec bmp_decoder; -extern AVCodec mmvideo_decoder; -extern AVCodec zmbv_decoder; -extern AVCodec avs_decoder; -extern AVCodec smacker_decoder; -extern AVCodec smackaud_decoder; -extern AVCodec kmvc_decoder; /* pcm codecs */ #define PCM_CODEC(id, name) \ extern AVCodec name ## _decoder; \ extern AVCodec name ## _encoder -PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le); -PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be); -PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le); -PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be); -PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le); -PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be); -PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le); -PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be); -PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud); PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le); PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be); PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le); @@ -2248,12 +1849,6 @@ PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa); PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx); PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea); PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726); -PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct); -PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf); -PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha); -PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4); -PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3); -PCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2); #undef PCM_CODEC @@ -2263,13 +1858,6 @@ extern AVCodec rawvideo_decoder; /* the following codecs use external GPL libs */ extern AVCodec ac3_decoder; -extern AVCodec dts_decoder; - -/* subtitles */ -extern AVCodec dvdsub_encoder; -extern AVCodec dvdsub_decoder; -extern AVCodec dvbsub_encoder; -extern AVCodec dvbsub_decoder; /* resample.c */ @@ -2278,12 +1866,12 @@ struct AVResampleContext; typedef struct ReSampleContext ReSampleContext; -ReSampleContext *audio_resample_init(int output_channels, int input_channels, +ReSampleContext *audio_resample_init(int output_channels, int input_channels, int output_rate, int input_rate); int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); void audio_resample_close(ReSampleContext *s); -struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); +struct AVResampleContext *av_resample_init(int out_rate, int in_rate); int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); void av_resample_close(struct AVResampleContext *c); @@ -2305,7 +1893,7 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight, int padleft, int padright); -void img_resample(ImgReSampleContext *s, +void img_resample(ImgReSampleContext *s, AVPicture *output, const AVPicture *input); void img_resample_close(ImgReSampleContext *s); @@ -2331,9 +1919,7 @@ int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height, int avpicture_get_size(int pix_fmt, int width, int height); void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift); const char *avcodec_get_pix_fmt_name(int pix_fmt); -void avcodec_set_dimensions(AVCodecContext *s, int width, int height); enum PixelFormat avcodec_get_pix_fmt(const char* name); -unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p); #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */ #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */ @@ -2350,11 +1936,11 @@ int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt, #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ int img_get_alpha_info(const AVPicture *src, - int pix_fmt, int width, int height); + int pix_fmt, int width, int height); /* convert among pixel formats */ int img_convert(AVPicture *dst, int dst_pix_fmt, - const AVPicture *src, int pix_fmt, + const AVPicture *src, int pix_fmt, int width, int height); /* deinterlace a picture */ @@ -2387,7 +1973,6 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); -int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); int avcodec_thread_init(AVCodecContext *s, int thread_count); @@ -2402,24 +1987,19 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v */ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); -int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, +int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, uint8_t *buf, int buf_size); -int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, +int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, uint8_t *buf, int buf_size); -int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - const uint8_t *buf, int buf_size); -int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, +int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, int *data_size_ptr, uint8_t *buf, int buf_size); -int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, +int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples); -int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, +int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict); -int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVSubtitle *sub); int avcodec_close(AVCodecContext *avctx); @@ -2427,8 +2007,6 @@ void avcodec_register_all(void); void avcodec_flush_buffers(AVCodecContext *avctx); -void avcodec_default_free_buffers(AVCodecContext *s); - /* misc usefull functions */ /** @@ -2436,13 +2014,103 @@ void avcodec_default_free_buffers(AVCodecContext *s); */ char av_get_pict_type_char(int pict_type); +/** + * 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); + +/** + * rescale a 64bit integer. + * a simple a*b/c isnt possible as it can overflow + */ +int64_t av_rescale(int64_t a, int64_t b, int64_t c); + + +/** + * Interface for 0.5.0 version + * + * do not even think about it's usage for this moment + */ + +typedef struct { + /// compressed size used from given memory buffer + int size; + /// I/P/B frame type + int frame_type; +} avc_enc_result_t; + +/** + * Commands + * order can't be changed - once it was defined + */ +typedef enum { + // general commands + AVC_OPEN_BY_NAME = 0xACA000, + AVC_OPEN_BY_CODEC_ID, + AVC_OPEN_BY_FOURCC, + AVC_CLOSE, + + AVC_FLUSH, + // pin - struct { uint8_t* src, uint_t src_size } + // pout - struct { AVPicture* img, consumed_bytes, + AVC_DECODE, + // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size } + // pout - uint_t used_from_dest_size + AVC_ENCODE, + + // query/get video commands + AVC_GET_VERSION = 0xACB000, + AVC_GET_WIDTH, + AVC_GET_HEIGHT, + AVC_GET_DELAY, + AVC_GET_QUANT_TABLE, + // ... + + // query/get audio commands + AVC_GET_FRAME_SIZE = 0xABC000, + + // maybe define some simple structure which + // might be passed to the user - but they can't + // contain any codec specific parts and these + // calls are usualy necessary only few times + + // set video commands + AVC_SET_WIDTH = 0xACD000, + AVC_SET_HEIGHT, + + // set video encoding commands + AVC_SET_FRAME_RATE = 0xACD800, + AVC_SET_QUALITY, + AVC_SET_HURRY_UP, + + // set audio commands + AVC_SET_SAMPLE_RATE = 0xACE000, + AVC_SET_CHANNELS, + +} avc_cmd_t; + +/** + * \param handle allocated private structure by libavcodec + * for initialization pass NULL - will be returned pout + * user is supposed to know nothing about its structure + * \param cmd type of operation to be performed + * \param pint input parameter + * \param pout output parameter + * + * \returns command status - eventually for query command it might return + * integer resulting value + */ +int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout); /* frame parsing */ typedef struct AVCodecParserContext { void *priv_data; struct AVCodecParser *parser; int64_t frame_offset; /* offset of the current frame */ - int64_t cur_offset; /* current offset + int64_t cur_offset; /* current offset (incremented by each av_parser_parse()) */ int64_t last_frame_offset; /* offset of the last frame */ /* video info */ @@ -2461,21 +2129,17 @@ typedef struct AVCodecParserContext { int64_t cur_frame_offset[AV_PARSER_PTS_NB]; int64_t cur_frame_pts[AV_PARSER_PTS_NB]; int64_t cur_frame_dts[AV_PARSER_PTS_NB]; - - int flags; -#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 } AVCodecParserContext; typedef struct AVCodecParser { - int codec_ids[5]; /* several codec IDs are permitted */ + int codec_ids[3]; /* several codec IDs are permitted */ int priv_data_size; int (*parser_init)(AVCodecParserContext *s); - int (*parser_parse)(AVCodecParserContext *s, + int (*parser_parse)(AVCodecParserContext *s, AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, + uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size); void (*parser_close)(AVCodecParserContext *s); - int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); struct AVCodecParser *next; } AVCodecParser; @@ -2483,15 +2147,11 @@ extern AVCodecParser *av_first_parser; void av_register_codec_parser(AVCodecParser *parser); AVCodecParserContext *av_parser_init(int codec_id); -int av_parser_parse(AVCodecParserContext *s, +int av_parser_parse(AVCodecParserContext *s, AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, + uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts); -int av_parser_change(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); void av_parser_close(AVCodecParserContext *s); extern AVCodecParser mpegvideo_parser; @@ -2499,13 +2159,8 @@ extern AVCodecParser mpeg4video_parser; extern AVCodecParser h261_parser; extern AVCodecParser h263_parser; extern AVCodecParser h264_parser; -extern AVCodecParser mjpeg_parser; -extern AVCodecParser pnm_parser; extern AVCodecParser mpegaudio_parser; extern AVCodecParser ac3_parser; -extern AVCodecParser dvdsub_parser; -extern AVCodecParser dvbsub_parser; -extern AVCodecParser aac_parser; /* memory */ void *av_malloc(unsigned int size); @@ -2519,7 +2174,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); /* call av_free_static to release all staticaly allocated tables */ void av_free_static(void); void *av_mallocz_static(unsigned int size); -void *av_realloc_static(void *ptr, unsigned int size); /* add by bero : in adx.c */ int is_adx(const unsigned char *buf,size_t bufsize); @@ -2527,12 +2181,6 @@ int is_adx(const unsigned char *buf,size_t bufsize); void img_copy(AVPicture *dst, const AVPicture *src, int pix_fmt, int width, int height); -int img_crop(AVPicture *dst, const AVPicture *src, - int pix_fmt, int top_band, int left_band); - -int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt, - int padtop, int padbottom, int padleft, int padright, int *color); - /* av_log API */ #include @@ -2567,8 +2215,6 @@ extern void av_log_set_callback(void (*)(void*, int, const char*, va_list)); ((uint8_t*)(x))[0]) #endif -extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v); - #ifdef __cplusplus } #endif diff --git a/stepmania/src/ffmpeg/include/ffmpeg/avformat.h b/stepmania/src/ffmpeg/include/ffmpeg/avformat.h index 025826892a..578028606c 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/avformat.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/avformat.h @@ -5,11 +5,11 @@ extern "C" { #endif -#define LIBAVFORMAT_VERSION_INT ((50<<16)+(4<<8)+0) -#define LIBAVFORMAT_VERSION 50.4.0 -#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT +#define LIBAVFORMAT_BUILD 4616 -#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 #include /* FILE */ @@ -28,36 +28,31 @@ extern "C" { #endif typedef struct AVPacket { - int64_t pts; ///< presentation time stamp in time_base units - int64_t dts; ///< decompression time stamp in time_base units + int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or + pts_den units in muxers or demuxers) */ + int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or + pts_den units in muxers or demuxers) */ uint8_t *data; int size; int stream_index; int flags; - int duration; ///< presentation duration in time_base units (0 if not available) + int duration; /* presentation duration (0 if not available) */ void (*destruct)(struct AVPacket *); void *priv; - int64_t pos; ///< byte position in stream, -1 if unknown -} AVPacket; +} AVPacket; #define PKT_FLAG_KEY 0x0001 -void av_destruct_packet_nofree(AVPacket *pkt); -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; } int av_new_packet(AVPacket *pkt, int size); -int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size); int av_dup_packet(AVPacket *pkt); /** @@ -68,7 +63,7 @@ int av_dup_packet(AVPacket *pkt); static inline void av_free_packet(AVPacket *pkt) { if (pkt && pkt->destruct) { - pkt->destruct(pkt); + pkt->destruct(pkt); } } @@ -78,7 +73,7 @@ static inline void av_free_packet(AVPacket *pkt) /* 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; + int64_t val, num, den; } AVFrac; void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den); @@ -100,7 +95,8 @@ typedef struct AVProbeData { #define AVPROBE_SCORE_MAX 100 typedef struct AVFormatParameters { - AVRational time_base; + int frame_rate; + int frame_rate_base; int sample_rate; int channels; int width; @@ -108,7 +104,7 @@ typedef struct AVFormatParameters { enum PixelFormat pix_fmt; struct AVImageFormat *image_format; 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 */ int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */ int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport @@ -116,16 +112,13 @@ typedef struct AVFormatParameters { mpeg2ts_raw is TRUE */ int initial_pause:1; /* do not begin to play the stream immediately (RTSP only) */ - enum CodecID video_codec_id; - enum CodecID audio_codec_id; } AVFormatParameters; #define AVFMT_NOFILE 0x0001 /* no file should be opened */ -#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */ +#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 */ typedef struct AVOutputFormat { const char *name; @@ -140,11 +133,10 @@ typedef struct AVOutputFormat { 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 */ + /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ 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); /* private fields */ struct AVOutputFormat *next; } AVOutputFormat; @@ -169,15 +161,10 @@ typedef struct AVInputFormat { /* 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); + /* seek at or before a given timestamp (given in AV_TIME_BASE + units) relative to the frames in stream component stream_index */ + int (*read_seek)(struct AVFormatContext *, + int stream_index, int64_t timestamp); /** * gets the next timestamp in AV_TIME_BASE units. */ @@ -208,54 +195,39 @@ 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) +/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */ + int flags; int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */ } AVIndexEntry; typedef struct AVStream { int index; /* stream index in AVFormatContext */ int id; /* format specific stream id */ - AVCodecContext *codec; /* codec context */ - /** - * real base frame rate 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; + AVCodecContext codec; /* codec context */ + int r_frame_rate; /* real frame rate of the stream */ + int r_frame_rate_base;/* real frame rate base of the stream */ void *priv_data; /* internal data used in av_find_stream_info() */ - int64_t codec_info_duration; + int64_t codec_info_duration; int codec_info_nb_frames; /* 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 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 * MN:dunno if thats the right place, for it */ - float quality; + float quality; /* decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds. */ - int64_t start_time; + 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 + int need_parsing; struct AVCodecParserContext *parser; int64_t cur_dts; @@ -266,8 +238,6 @@ typedef struct AVStream { support seeking natively */ int nb_index_entries; int index_entries_allocated_size; - - int64_t nb_frames; ///< number of frames in this stream if known or 0 } AVStream; #define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present @@ -277,7 +247,7 @@ typedef struct AVStream { /* format I/O context */ 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 */ struct AVInputFormat *iformat; struct AVOutputFormat *oformat; @@ -307,7 +277,7 @@ typedef struct AVFormatContext { /* 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; + 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. */ @@ -328,19 +298,6 @@ typedef struct AVFormatContext { /* 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 } AVFormatContext; typedef struct AVPacketList { @@ -375,7 +332,7 @@ typedef struct AVImageFormat { known so that the caller can allocate the image. If 'allo_cb' returns non zero, then the parsing is aborted. Return '0' if OK. */ - int (*img_read)(ByteIOContext *, + int (*img_read)(ByteIOContext *, int (*alloc_cb)(void *, AVImageInfo *info), void *); /* write the image */ int supported_pixel_formats; /* mask of supported formats for output */ @@ -387,7 +344,6 @@ typedef struct AVImageFormat { void av_register_image_format(AVImageFormat *img_fmt); AVImageFormat *av_probe_image_format(AVProbeData *pd); 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, AVImageFormat *fmt, int (*alloc_cb)(void *, AVImageInfo *info), void *opaque); @@ -429,9 +385,6 @@ int crc_init(void); /* img.c */ int img_init(void); -/* img2.c */ -int img2_init(void); - /* asf.c */ int asf_init(void); @@ -471,12 +424,9 @@ int amr_init(void); /* wav.c */ int ff_wav_init(void); -/* mmf.c */ -int ff_mmf_init(void); - /* raw.c */ -int pcm_read_seek(AVFormatContext *s, - int stream_index, int64_t timestamp, int flags); +int pcm_read_seek(AVFormatContext *s, + int stream_index, int64_t timestamp); int raw_init(void); /* mp3.c */ @@ -485,11 +435,8 @@ int mp3_init(void); /* yuv4mpeg.c */ int yuv4mpeg_init(void); -/* ogg2.c */ -int ogg_init(void); - /* ogg.c */ -int libogg_init(void); +int ogg_init(void); /* dv.c */ int ff_dv_init(void); @@ -537,42 +484,6 @@ int vmd_init(void); /* matroska.c */ 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 "rtsp.h" @@ -583,12 +494,10 @@ extern AVOutputFormat yuv4mpegpipe_oformat; /* utils.c */ void av_register_input_format(AVInputFormat *format); void av_register_output_format(AVOutputFormat *format); -AVOutputFormat *guess_stream_format(const char *short_name, +AVOutputFormat *guess_stream_format(const char *short_name, 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); -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_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); @@ -605,16 +514,14 @@ void fifo_free(FifoBuffer *f); int fifo_size(FifoBuffer *f, uint8_t *rptr); 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); -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 */ AVInputFormat *av_find_input_format(const char *short_name); AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); -int av_open_input_stream(AVFormatContext **ic_ptr, - ByteIOContext *pb, const char *filename, +int av_open_input_stream(AVFormatContext **ic_ptr, + ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap); -int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, +int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap); @@ -628,11 +535,11 @@ AVFormatContext *av_alloc_format_context(void); #define AVERROR_NOMEM (-5) /* not enough memory */ #define AVERROR_NOFMT (-6) /* unknown format */ #define AVERROR_NOTSUPP (-7) /* operation not supported */ - + int av_find_stream_info(AVFormatContext *ic); int av_read_packet(AVFormatContext *s, AVPacket *pkt); int av_read_frame(AVFormatContext *s, AVPacket *pkt); -int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags); +int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp); int av_read_play(AVFormatContext *s); int av_read_pause(AVFormatContext *s); void av_close_input_file(AVFormatContext *s); @@ -640,15 +547,11 @@ AVStream *av_new_stream(AVFormatContext *s, int id); 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); -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, - int64_t pos, int64_t timestamp, int size, int distance, int flags); -int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, 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); /* media file output */ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); @@ -659,7 +562,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); int av_write_trailer(AVFormatContext *s); void dump_format(AVFormatContext *ic, - int index, + int index, const char *url, int is_output); int parse_image_size(int *width_ptr, int *height_ptr, const char *str); @@ -686,7 +589,6 @@ int audio_init(void); /* DV1394 */ int dv1394_init(void); -int dc1394_init(void); #ifdef HAVE_AV_CONFIG_H @@ -715,15 +617,13 @@ do {\ #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, +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, @@ -738,4 +638,3 @@ int match_ext(const char *filename, const char *extensions); #endif #endif /* AVFORMAT_H */ - diff --git a/stepmania/src/ffmpeg/include/ffmpeg/avio.h b/stepmania/src/ffmpeg/include/ffmpeg/avio.h index d015d97a5a..53ed22a3a1 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/avio.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/avio.h @@ -9,7 +9,7 @@ typedef int64_t offset_t; struct URLContext { struct URLProtocol *prot; - int flags; + 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; @@ -70,8 +70,8 @@ typedef struct { 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); + void (*write_packet)(void *opaque, uint8_t *buf, int buf_size); + int (*seek)(void *opaque, offset_t offset, int whence); offset_t pos; /* position in the file of the current buffer */ int must_flush; /* true if the next seek should flush */ int eof_reached; /* true if eof reached */ @@ -81,7 +81,6 @@ typedef struct { 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, @@ -90,8 +89,8 @@ int init_put_byte(ByteIOContext *s, 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 (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*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); @@ -99,20 +98,17 @@ void put_le64(ByteIOContext *s, uint64_t val); void put_be64(ByteIOContext *s, uint64_t val); void put_le32(ByteIOContext *s, unsigned int val); void put_be32(ByteIOContext *s, unsigned int val); -void put_le24(ByteIOContext *s, unsigned int val); -void put_be24(ByteIOContext *s, unsigned int val); void put_le16(ByteIOContext *s, unsigned int val); void put_be16(ByteIOContext *s, unsigned int val); void put_tag(ByteIOContext *s, const char *tag); +void put_be64_double(ByteIOContext *s, double val); void put_strz(ByteIOContext *s, const char *buf); offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence); void url_fskip(ByteIOContext *s, offset_t offset); offset_t url_ftell(ByteIOContext *s); -offset_t url_fsize(ByteIOContext *s); int url_feof(ByteIOContext *s); -int url_ferror(ByteIOContext *s); #define URL_EOF (-1) 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_partial_buffer(ByteIOContext *s, unsigned char *buf, int size); int get_byte(ByteIOContext *s); -unsigned int get_le24(ByteIOContext *s); unsigned int get_le32(ByteIOContext *s); uint64_t get_le64(ByteIOContext *s); unsigned int get_le16(ByteIOContext *s); +double get_be64_double(ByteIOContext *s); char *get_strz(ByteIOContext *s, char *buf, int maxlen); unsigned int get_be16(ByteIOContext *s); -unsigned int get_be24(ByteIOContext *s); unsigned int get_be32(ByteIOContext *s); uint64_t get_be64(ByteIOContext *s); diff --git a/stepmania/src/ffmpeg/include/ffmpeg/common.h b/stepmania/src/ffmpeg/include/ffmpeg/common.h index b03a91a291..d1cde53c68 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/common.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/common.h @@ -8,12 +8,17 @@ #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) # define CONFIG_WIN32 -#endif - -#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(EMULATE_INTTYPES) # define EMULATE_INTTYPES #endif +//#define ALT_BITSTREAM_WRITER +//#define ALIGNED_BITSTREAM_WRITER + +#define ALT_BITSTREAM_READER +//#define LIBMPEG2_BITSTREAM_READER +//#define A32_BITSTREAM_READER +#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -58,6 +63,14 @@ #define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr } #define AVOPTION_END() AVOPTION_SUB(NULL) +struct AVOption; +#ifdef HAVE_MMX +extern const struct AVOption avoptions_common[3 + 5]; +#else +extern const struct AVOption avoptions_common[3]; +#endif +extern const struct AVOption avoptions_workaround_bug[11]; + #endif /* HAVE_AV_CONFIG_H */ /* Suppress restrict if it was not defined in config.h. */ @@ -81,14 +94,6 @@ #endif #endif -#ifndef attribute_unused -#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) -# define attribute_unused __attribute__((unused)) -#else -# define attribute_unused -#endif -#endif - #ifndef EMULATE_INTTYPES # include #else @@ -106,55 +111,7 @@ typedef signed long long int64_t; typedef unsigned long long uint64_t; # endif /* other OS */ -#endif /* EMULATE_INTTYPES */ - -#ifndef PRId64 -#define PRId64 "lld" -#endif - -#ifndef PRIu64 -#define PRIu64 "llu" -#endif - -#ifndef PRIx64 -#define PRIx64 "llx" -#endif - -#ifndef PRId32 -#define PRId32 "d" -#endif - -#ifndef PRIdFAST16 -#define PRIdFAST16 PRId32 -#endif - -#ifndef PRIdFAST32 -#define PRIdFAST32 PRId32 -#endif - -#ifndef INT16_MIN -#define INT16_MIN (-0x7fff-1) -#endif - -#ifndef INT16_MAX -#define INT16_MAX 0x7fff -#endif - -#ifndef INT32_MIN -#define INT32_MIN (-0x7fffffff-1) -#endif - -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif - -#ifndef UINT32_MAX -#define UINT32_MAX 0xffffffff -#endif - -#ifndef INT64_MIN -#define INT64_MIN (-0x7fffffffffffffffLL-1) -#endif +#endif /* HAVE_INTTYPES_H */ #ifndef INT64_MAX #define INT64_MAX int64_t_C(9223372036854775807) @@ -165,13 +122,13 @@ #endif #ifdef EMULATE_FAST_INT +/* note that we don't emulate 64bit ints */ typedef signed char int_fast8_t; typedef signed int int_fast16_t; typedef signed int int_fast32_t; typedef unsigned char uint_fast8_t; typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; -typedef uint64_t uint_fast64_t; #endif #ifndef INT_BIT @@ -183,8 +140,8 @@ typedef uint64_t uint_fast64_t; #endif #if defined(CONFIG_OS2) || defined(CONFIG_SUNOS) -static inline float floorf(float f) { - return floor(f); +static inline float floorf(float f) { + return floor(f); } #endif @@ -212,11 +169,6 @@ static inline float floorf(float f) { # define snprintf _snprintf # define vsnprintf _vsnprintf - -# ifdef CONFIG_WINCE -# define perror(a) -# endif - # endif /* CONFIG_WIN32 end */ @@ -259,31 +211,13 @@ static inline float floorf(float f) { #ifdef HAVE_AV_CONFIG_H -#if defined(__MINGW32__) && !defined(BUILD_AVUTIL) && defined(BUILD_SHARED_AV) -# define FF_IMPORT_ATTR __declspec(dllimport) -#else -# define FF_IMPORT_ATTR -#endif - - # include "bswap.h" -// Use rip-relative addressing if compiling PIC code on x86-64. # if defined(__MINGW32__) || defined(__CYGWIN__) || \ defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__)) -# if defined(ARCH_X86_64) && defined(__PIC__) -# define MANGLE(a) "_" #a"(%%rip)" -# else -# define MANGLE(a) "_" #a -# endif +# define MANGLE(a) "_" #a # else -# if defined(ARCH_X86_64) && defined(__PIC__) -# define MANGLE(a) #a"(%%rip)" -# elif defined(CONFIG_DARWIN) -# define MANGLE(a) "_" #a -# else -# define MANGLE(a) #a -# endif +# define MANGLE(a) #a # endif /* debug stuff */ @@ -307,9 +241,6 @@ inline void dprintf(const char* fmt,...) {} # endif # endif /* !CONFIG_WIN32 */ -# ifdef CONFIG_WINCE -# define abort() -# endif # define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) @@ -324,7 +255,7 @@ inline void dprintf(const char* fmt,...) {} extern const uint32_t inverse[256]; -#if defined(ARCH_X86) || defined(ARCH_X86_64) +#ifdef ARCH_X86 # define FASTDIV(a,b) \ ({\ int ret,dmy;\ @@ -340,6 +271,815 @@ extern const uint32_t inverse[256]; #else # define FASTDIV(a,b) ((a)/(b)) #endif + +#ifdef ARCH_X86 +// avoid +32 for shift optimization (gcc should do that ...) +static inline int32_t NEG_SSR32( int32_t a, int8_t s){ + asm ("sarl %1, %0\n\t" + : "+r" (a) + : "ic" ((uint8_t)(-s)) + ); + return a; +} +static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ + asm ("shrl %1, %0\n\t" + : "+r" (a) + : "ic" ((uint8_t)(-s)) + ); + return a; +} +#else +# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) +# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#endif + +/* bit output */ + +/* buf and buf_end must be present and used by every alternative writer. */ +typedef struct PutBitContext { +#ifdef ALT_BITSTREAM_WRITER + uint8_t *buf, *buf_end; + int index; +#else + uint32_t bit_buf; + int bit_left; + uint8_t *buf, *buf_ptr, *buf_end; +#endif +} PutBitContext; + +static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) +{ + s->buf = buffer; + s->buf_end = s->buf + buffer_size; +#ifdef ALT_BITSTREAM_WRITER + s->index=0; + ((uint32_t*)(s->buf))[0]=0; +// memset(buffer, 0, buffer_size); +#else + s->buf_ptr = s->buf; + s->bit_left=32; + s->bit_buf=0; +#endif +} + +/* return the number of bits output */ +static inline int put_bits_count(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + return s->index; +#else + return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; +#endif +} + +/* pad the end of the output stream with zeros */ +static inline void flush_put_bits(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + align_put_bits(s); +#else + s->bit_buf<<= s->bit_left; + while (s->bit_left < 32) { + /* XXX: should test end of buffer */ + *s->buf_ptr++=s->bit_buf >> 24; + s->bit_buf<<=8; + s->bit_left+=8; + } + s->bit_left=32; + s->bit_buf=0; +#endif +} + +void align_put_bits(PutBitContext *s); +void put_string(PutBitContext * pbc, char *s, int put_zero); + +/* bit input */ +/* buffer, buffer_end and size_in_bits must be present and used by every reader */ +typedef struct GetBitContext { + const uint8_t *buffer, *buffer_end; +#ifdef ALT_BITSTREAM_READER + int index; +#elif defined LIBMPEG2_BITSTREAM_READER + uint8_t *buffer_ptr; + uint32_t cache; + int bit_count; +#elif defined A32_BITSTREAM_READER + uint32_t *buffer_ptr; + uint32_t cache0; + uint32_t cache1; + int bit_count; +#endif + int size_in_bits; +} GetBitContext; + +#define VLC_TYPE int16_t + +typedef struct VLC { + int bits; + VLC_TYPE (*table)[2]; ///< code, bits + int table_size, table_allocated; +} VLC; + +typedef struct RL_VLC_ELEM { + int16_t level; + int8_t len; + uint8_t run; +} RL_VLC_ELEM; + +#ifdef ARCH_SPARC +#define UNALIGNED_STORES_ARE_BAD +#endif + +/* used to avoid missaligned exceptions on some archs (alpha, ...) */ +#ifdef ARCH_X86 +# define unaligned32(a) (*(uint32_t*)(a)) +#else +# ifdef __GNUC__ +static inline uint32_t unaligned32(const void *v) { + struct Unaligned { + uint32_t i; + } __attribute__((packed)); + + return ((const struct Unaligned *) v)->i; +} +# elif defined(__DECC) +static inline uint32_t unaligned32(const void *v) { + return *(const __unaligned uint32_t *) v; +} +# else +static inline uint32_t unaligned32(const void *v) { + return *(const uint32_t *) v; +} +# endif +#endif //!ARCH_X86 + +#ifndef ALT_BITSTREAM_WRITER +static inline void put_bits(PutBitContext *s, int n, unsigned int value) +{ + unsigned int bit_buf; + int bit_left; + +#ifdef STATS + st_out_bit_counts[st_current_index] += n; +#endif + // printf("put_bits=%d %x\n", n, value); + assert(n == 32 || value < (1U << n)); + + bit_buf = s->bit_buf; + bit_left = s->bit_left; + + // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf); + /* XXX: optimize */ + if (n < bit_left) { + bit_buf = (bit_buf<> (n - bit_left); +#ifdef UNALIGNED_STORES_ARE_BAD + if (3 & (intptr_t) s->buf_ptr) { + s->buf_ptr[0] = bit_buf >> 24; + s->buf_ptr[1] = bit_buf >> 16; + s->buf_ptr[2] = bit_buf >> 8; + s->buf_ptr[3] = bit_buf ; + } else +#endif + *(uint32_t *)s->buf_ptr = be2me_32(bit_buf); + //printf("bitbuf = %08x\n", bit_buf); + s->buf_ptr+=4; + bit_left+=32 - n; + bit_buf = value; + } + + s->bit_buf = bit_buf; + s->bit_left = bit_left; +} +#endif + + +#ifdef ALT_BITSTREAM_WRITER +static inline void put_bits(PutBitContext *s, int n, unsigned int value) +{ +# ifdef ALIGNED_BITSTREAM_WRITER +# ifdef ARCH_X86 + asm volatile( + "movl %0, %%ecx \n\t" + "xorl %%eax, %%eax \n\t" + "shrdl %%cl, %1, %%eax \n\t" + "shrl %%cl, %1 \n\t" + "movl %0, %%ecx \n\t" + "shrl $3, %%ecx \n\t" + "andl $0xFFFFFFFC, %%ecx \n\t" + "bswapl %1 \n\t" + "orl %1, (%2, %%ecx) \n\t" + "bswapl %%eax \n\t" + "addl %3, %0 \n\t" + "movl %%eax, 4(%2, %%ecx) \n\t" + : "=&r" (s->index), "=&r" (value) + : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) + : "%eax", "%ecx" + ); +# else + int index= s->index; + uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); + + value<<= 32-n; + + ptr[0] |= be2me_32(value>>(index&31)); + ptr[1] = be2me_32(value<<(32-(index&31))); +//if(n>24) printf("%d %d\n", n, value); + index+= n; + s->index= index; +# endif +# else //ALIGNED_BITSTREAM_WRITER +# ifdef ARCH_X86 + asm volatile( + "movl $7, %%ecx \n\t" + "andl %0, %%ecx \n\t" + "addl %3, %%ecx \n\t" + "negl %%ecx \n\t" + "shll %%cl, %1 \n\t" + "bswapl %1 \n\t" + "movl %0, %%ecx \n\t" + "shrl $3, %%ecx \n\t" + "orl %1, (%%ecx, %2) \n\t" + "addl %3, %0 \n\t" + "movl $0, 4(%%ecx, %2) \n\t" + : "=&r" (s->index), "=&r" (value) + : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) + : "%ecx" + ); +# else + int index= s->index; + uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); + + ptr[0] |= be2me_32(value<<(32-n-(index&7) )); + ptr[1] = 0; +//if(n>24) printf("%d %d\n", n, value); + index+= n; + s->index= index; +# endif +# endif //!ALIGNED_BITSTREAM_WRITER +} +#endif + + +static inline uint8_t* pbBufPtr(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + return s->buf + (s->index>>3); +#else + return s->buf_ptr; +#endif +} + +/** + * + * PutBitContext must be flushed & aligned to a byte boundary before calling this. + */ +static inline void skip_put_bytes(PutBitContext *s, int n){ + assert((put_bits_count(s)&7)==0); +#ifdef ALT_BITSTREAM_WRITER + FIXME may need some cleaning of the buffer + s->index += n<<3; +#else + assert(s->bit_left==32); + s->buf_ptr += n; +#endif +} + +/** + * Changes the end of the buffer. + */ +static inline void set_put_bits_buffer_size(PutBitContext *s, int size){ + s->buf_end= s->buf + size; +} + +/* Bitstream reader API docs: +name + abritary name which is used as prefix for the internal variables + +gb + getbitcontext + +OPEN_READER(name, gb) + loads gb into local variables + +CLOSE_READER(name, gb) + stores local vars in gb + +UPDATE_CACHE(name, gb) + refills the internal cache from the bitstream + after this call at least MIN_CACHE_BITS will be available, + +GET_CACHE(name, gb) + will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) + +SHOW_UBITS(name, gb, num) + will return the nest num bits + +SHOW_SBITS(name, gb, num) + will return the nest num bits and do sign extension + +SKIP_BITS(name, gb, num) + will skip over the next num bits + note, this is equinvalent to SKIP_CACHE; SKIP_COUNTER + +SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) + +SKIP_COUNTER(name, gb, num) + will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) + +LAST_SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing + +LAST_SKIP_BITS(name, gb, num) + is equinvalent to SKIP_LAST_CACHE; SKIP_COUNTER + +for examples see get_bits, show_bits, skip_bits, get_vlc +*/ + +static inline int unaligned32_be(const void *v) +{ +#ifdef CONFIG_ALIGN + const uint8_t *p=v; + return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); +#else + return be2me_32( unaligned32(v)); //original +#endif +} + +#ifdef ALT_BITSTREAM_READER +# define MIN_CACHE_BITS 25 + +# define OPEN_READER(name, gb)\ + int name##_index= (gb)->index;\ + int name##_cache= 0;\ + +# define CLOSE_READER(name, gb)\ + (gb)->index= name##_index;\ + +# define UPDATE_CACHE(name, gb)\ + name##_cache= unaligned32_be( ((uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num);\ + +// FIXME name? +# define SKIP_COUNTER(name, gb, num)\ + name##_index += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) ; + +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(GetBitContext *s){ + return s->index; +} +#elif defined LIBMPEG2_BITSTREAM_READER +//libmpeg2 like reader + +# define MIN_CACHE_BITS 17 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + int name##_cache= (gb)->cache;\ + uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache= name##_cache;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +#ifdef LIBMPEG2_BITSTREAM_READER_HACK + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count >= 0){\ + name##_cache+= (int)be2me_16(*(uint16_t*)name##_buffer_ptr) << name##_bit_count;\ + ((uint16_t*)name##_buffer_ptr)++;\ + name##_bit_count-= 16;\ + }\ + +#else + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count >= 0){\ + name##_cache+= ((name##_buffer_ptr[0]<<8) + name##_buffer_ptr[1]) << name##_bit_count;\ + name##_buffer_ptr+=2;\ + name##_bit_count-= 16;\ + }\ + +#endif + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num);\ + +# define SKIP_COUNTER(name, gb, num)\ + name##_bit_count += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) + +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(GetBitContext *s){ + return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; +} + +#elif defined A32_BITSTREAM_READER + +# define MIN_CACHE_BITS 32 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + uint32_t name##_cache0= (gb)->cache0;\ + uint32_t name##_cache1= (gb)->cache1;\ + uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache0= name##_cache0;\ + (gb)->cache1= name##_cache1;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count > 0){\ + const uint32_t next= be2me_32( *name##_buffer_ptr );\ + name##_cache0 |= NEG_USR32(next,name##_bit_count);\ + name##_cache1 |= next<buffer_ptr - s->buffer)*8 - 32 + s->bit_count; +} + +#endif + +/** + * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). + * if MSB not set it is negative + * @param n length in bits + * @author BERO + */ +static inline int get_xbits(GetBitContext *s, int n){ + register int tmp; + register int32_t cache; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + cache = GET_CACHE(re,s); + if ((int32_t)cache<0) { //MSB=1 + tmp = NEG_USR32(cache,n); + } else { + // tmp = (-1<index+=n for the ALT_READER :)) + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) +} + +static inline unsigned int get_bits1(GetBitContext *s){ +#ifdef ALT_BITSTREAM_READER + int index= s->index; + uint8_t result= s->buffer[ index>>3 ]; + result<<= (index&0x07); + result>>= 8 - 1; + index++; + s->index= index; + + return result; +#else + return get_bits(s, 1); +#endif +} + +static inline unsigned int show_bits1(GetBitContext *s){ + return show_bits(s, 1); +} + +static inline void skip_bits1(GetBitContext *s){ + skip_bits(s, 1); +} + +/** + * init GetBitContext. + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end + * @param bit_size the size of the buffer in bits + */ +static inline void init_get_bits(GetBitContext *s, + const uint8_t *buffer, int bit_size) +{ + const int buffer_size= (bit_size+7)>>3; + + s->buffer= buffer; + s->size_in_bits= bit_size; + s->buffer_end= buffer + buffer_size; +#ifdef ALT_BITSTREAM_READER + s->index=0; +#elif defined LIBMPEG2_BITSTREAM_READER +#ifdef LIBMPEG2_BITSTREAM_READER_HACK + if ((int)buffer&1) { + /* word alignment */ + s->cache = (*buffer++)<<24; + s->buffer_ptr = buffer; + s->bit_count = 16-8; + } else +#endif + { + s->buffer_ptr = buffer; + s->bit_count = 16; + s->cache = 0; + } +#elif defined A32_BITSTREAM_READER + s->buffer_ptr = (uint32_t*)buffer; + s->bit_count = 32; + s->cache0 = 0; + s->cache1 = 0; +#endif + { + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) + } +#ifdef A32_BITSTREAM_READER + s->cache1 = 0; +#endif +} + +int check_marker(GetBitContext *s, const char *msg); +void align_get_bits(GetBitContext *s); +int init_vlc(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size); +void free_vlc(VLC *vlc); + +/** + * + * if the vlc code is invalid and max_depth=1 than no bits will be removed + * if the vlc code is invalid and max_depth>1 than the number of bits removed + * is undefined + */ +#define GET_VLC(code, name, gb, table, bits, max_depth)\ +{\ + int n, index, nb_bits;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + code = table[index][0];\ + n = table[index][1];\ +\ + if(max_depth > 1 && n < 0){\ + LAST_SKIP_BITS(name, gb, bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + if(max_depth > 2 && n < 0){\ + LAST_SKIP_BITS(name, gb, nb_bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + }\ + }\ + SKIP_BITS(name, gb, n)\ +} + +#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth)\ +{\ + int n, index, nb_bits;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + level = table[index].level;\ + n = table[index].len;\ +\ + if(max_depth > 1 && n < 0){\ + LAST_SKIP_BITS(name, gb, bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + level;\ + level = table[index].level;\ + n = table[index].len;\ + }\ + run= table[index].run;\ + SKIP_BITS(name, gb, n)\ +} + +// deprecated, dont use get_vlc for new code, use get_vlc2 instead or use GET_VLC directly +static inline int get_vlc(GetBitContext *s, VLC *vlc) +{ + int code; + VLC_TYPE (*table)[2]= vlc->table; + + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + + GET_VLC(code, re, s, table, vlc->bits, 3) + + CLOSE_READER(re, s) + return code; +} + +/** + * parses a vlc code, faster then get_vlc() + * @param bits is the number of bits which will be read at once, must be + * identical to nb_bits in init_vlc() + * @param max_depth is the number of times bits bits must be readed to completly + * read the longest vlc code + * = (max_vlc_length + bits - 1) / bits + */ +static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], + int bits, int max_depth) +{ + int code; + + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + + GET_VLC(code, re, s, table, bits, max_depth) + + CLOSE_READER(re, s) + return code; +} + +//#define TRACE + +#ifdef TRACE + +static inline void print_bin(int bits, int n){ + int i; + + for(i=n-1; i>=0; i--){ + printf("%d", (bits>>i)&1); + } + for(i=n; i<24; i++) + printf(" "); +} + +static inline int get_bits_trace(GetBitContext *s, int n, char *file, char *func, int line){ + int r= get_bits(s, n); + + print_bin(r, n); + printf("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); + return r; +} +static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, char *func, int line){ + int show= show_bits(s, 24); + int pos= get_bits_count(s); + int r= get_vlc2(s, table, bits, max_depth); + int len= get_bits_count(s) - pos; + int bits2= show>>(24-len); + + print_bin(bits2, len); + + printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); + return r; +} +static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *func, int line){ + int show= show_bits(s, n); + int r= get_xbits(s, n); + + print_bin(show, n); + printf("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); + return r; +} + +#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) + +#define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__) + +#else //TRACE +#define tprintf(...) {} +#endif /* define it to include statistics code (useful only for optimizing codec efficiency */ @@ -366,7 +1106,7 @@ void print_stats(void); #endif /* misc math functions */ -extern FF_IMPORT_ATTR const uint8_t ff_log2_tab[256]; +extern const uint8_t ff_log2_tab[256]; static inline int av_log2(unsigned int v) { @@ -427,13 +1167,6 @@ static inline int mid_pred(int a, int b, int c) #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 cliped value - */ static inline int clip(int a, int amin, int amax) { if (a < amin) @@ -444,19 +1177,14 @@ static inline int clip(int a, int amin, int amax) return a; } -/** - * clip a signed integer value into the 0-255 range - * @param a value to clip - * @return cliped value - */ -static inline uint8_t clip_uint8(int a) +static inline int clip_uint8(int a) { if (a&(~255)) return (-a)>>31; else return a; } /* math */ -extern FF_IMPORT_ATTR const uint8_t ff_sqrt_tab[128]; +extern const uint8_t ff_sqrt_tab[128]; int64_t ff_gcd(int64_t a, int64_t b); @@ -465,9 +1193,9 @@ static inline int ff_sqrt(int a) int ret=0; int s; int ret_sq=0; - + if(a<128) return ff_sqrt_tab[a]; - + for(s=15; s>=0; s--){ int b= ret_sq + (1<<(s*2)) + (ret<>31;\ @@ -509,10 +1237,10 @@ static inline int ff_get_fourcc(const char *s){ #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT) #define COPY3_IF_LT(x,y,a,b,c,d)\ asm volatile (\ - "cmpl %0, %3 \n\t"\ - "cmovl %3, %0 \n\t"\ - "cmovl %4, %1 \n\t"\ - "cmovl %5, %2 \n\t"\ + "cmpl %0, %3 \n\t"\ + "cmovl %3, %0 \n\t"\ + "cmovl %4, %1 \n\t"\ + "cmovl %5, %2 \n\t"\ : "+r" (x), "+r" (a), "+r" (c)\ : "r" (y), "r" (b), "r" (d)\ ); @@ -525,52 +1253,22 @@ if((y)<(x)){\ } #endif -#if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_POWERPC) -#if defined(ARCH_X86_64) -static inline uint64_t read_time(void) +#ifdef ARCH_X86 +static inline long long rdtsc() { - uint64_t a, d; - asm volatile( "rdtsc\n\t" - : "=a" (a), "=d" (d) - ); - return (d << 32) | (a & 0xffffffff); + long long l; + asm volatile( "rdtsc\n\t" + : "=A" (l) + ); + return l; } -#elif defined(ARCH_X86) -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();\ +uint64_t tstart= rdtsc();\ #define STOP_TIMER(id) \ -tend= read_time();\ +tend= rdtsc();\ {\ static uint64_t tsum=0;\ static int tcount=0;\ @@ -581,14 +1279,13 @@ tend= read_time();\ }else\ tskip_count++;\ if(256*256*256*64%(tcount+tskip_count)==0){\ - av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ + av_log(NULL, AV_LOG_DEBUG, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ }\ } -#else -#define START_TIMER -#define STOP_TIMER(id) {} #endif +#define CLAMP_TO_8BIT(d) ((d > 0xff) ? 0xff : (d < 0) ? 0 : d) + /* avoid usage of various functions */ #define malloc please_use_av_malloc #define free please_use_av_free @@ -596,8 +1293,6 @@ tend= read_time();\ #define time time_is_forbidden_due_to_security_issues #define rand rand_is_forbidden_due_to_state_trashing #define srand srand_is_forbidden_due_to_state_trashing -#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf -#define strcat strcat_is_forbidden_due_to_security_issues_use_pstrcat #if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H)) #define printf please_use_av_log #define fprintf please_use_av_log @@ -612,35 +1307,6 @@ tend= read_time();\ }\ } -#ifndef HAVE_LRINTF -/* XXX: add ISOC specific test to avoid specific BSD testing. */ -/* better than nothing implementation. */ -/* btw, rintf() is existing on fbsd too -- alex */ -static always_inline long int lrintf(float x) -{ -#ifdef CONFIG_WIN32 -# ifdef ARCH_X86 - int32_t i; - asm volatile( - "fistpl %0\n\t" - : "=m" (i) : "t" (x) : "st" - ); - return i; -# else - /* XXX: incorrect, but make it compile */ - return (int)(x + (x < 0 ? -0.5 : 0.5)); -# endif /* ARCH_X86 */ -#else - return (int)(rint(x)); -#endif /* CONFIG_WIN32 */ -} -#else -#ifndef _ISOC9X_SOURCE -#define _ISOC9X_SOURCE -#endif -#include -#endif /* HAVE_LRINTF */ - #endif /* HAVE_AV_CONFIG_H */ #endif /* COMMON_H */ diff --git a/stepmania/src/ffmpeg/include/ffmpeg/rational.h b/stepmania/src/ffmpeg/include/ffmpeg/rational.h index 0fbe0d29d6..d5fc77f1a6 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/rational.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/rational.h @@ -14,10 +14,10 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - + /** * @file rational.h * Rational numbers. @@ -27,39 +27,23 @@ #ifndef RATIONAL_H #define RATIONAL_H -/** - * Rational number num/den. - */ typedef struct AVRational{ - int num; ///< numerator - int den; ///< denominator + int num; + int den; } AVRational; -/** - * returns 0 if a==b, 1 if a>b and -1 if a>63)|1; - else return 0; + if (tmp < 0) return -1; + else if(tmp == 0) return 0; + else return 1; } -/** - * converts the given AVRational to a double. - */ static inline double av_q2d(AVRational a){ 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_div_q(AVRational b, AVRational c); AVRational av_add_q(AVRational b, AVRational c); diff --git a/stepmania/src/ffmpeg/include/ffmpeg/rtp.h b/stepmania/src/ffmpeg/include/ffmpeg/rtp.h index d6fb42622e..0c0ae35ac0 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/rtp.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/rtp.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 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 #define RTP_H @@ -25,13 +25,8 @@ int rtp_init(void); int rtp_get_codec_info(AVCodecContext *codec, int 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, 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); +int rtp_parse_packet(AVFormatContext *s1, AVPacket *pkt, + const unsigned char *buf, int len); extern AVOutputFormat rtp_mux; 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; -#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 */ diff --git a/stepmania/src/ffmpeg/include/ffmpeg/rtsp.h b/stepmania/src/ffmpeg/include/ffmpeg/rtsp.h index a58eb43228..83d88633b5 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/rtsp.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/rtsp.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 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 #define RTSP_H @@ -35,10 +35,6 @@ enum RTSPProtocol { #define RTSP_DEFAULT_PORT 554 #define RTSP_MAX_TRANSPORTS 8 #define RTSP_TCP_MAX_PACKET_SIZE 1472 -#define RTSP_DEFAULT_NB_AUDIO_CHANNELS 2 -#define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100 -#define RTSP_RTP_PORT_MIN 5000 -#define RTSP_RTP_PORT_MAX 10000 typedef struct RTSPTransportField { int interleaved_min, interleaved_max; /* interleave ids, if TCP transport */ @@ -54,8 +50,6 @@ 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]; @@ -74,7 +68,7 @@ typedef struct RTSPActionServerSetup { char transport_option[512]; } RTSPActionServerSetup; -typedef int FFRTSPCallback(enum RTSPCallbackAction action, +typedef int FFRTSPCallback(enum RTSPCallbackAction action, const char *session_id, char *buf, int buf_size, void *arg);