diff --git a/stepmania/Program/avcodec.dll b/stepmania/Program/avcodec.dll index 72be82cefa..6dca011e6c 100644 Binary files a/stepmania/Program/avcodec.dll and b/stepmania/Program/avcodec.dll differ diff --git a/stepmania/Program/avformat.dll b/stepmania/Program/avformat.dll index 63ead52e40..bd32aa7c4c 100644 Binary files a/stepmania/Program/avformat.dll and b/stepmania/Program/avformat.dll differ diff --git a/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h b/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h index bb81d00021..03269207ee 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/avcodec.h @@ -12,10 +12,12 @@ extern "C" { #endif #include "common.h" +#include "rational.h" +#include /* size_t */ -#define FFMPEG_VERSION_INT 0x000408 -#define FFMPEG_VERSION "0.4.8" -#define LIBAVCODEC_BUILD 4680 +#define FFMPEG_VERSION_INT 0x000409 +#define FFMPEG_VERSION "0.4.9-pre1" +#define LIBAVCODEC_BUILD 4718 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -24,13 +26,18 @@ extern "C" { #define AV_TOSTRING(s) #s #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD) +#define AV_NOPTS_VALUE int64_t_C(0x8000000000000000) +#define AV_TIME_BASE 1000000 + enum CodecID { CODEC_ID_NONE, CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */ CODEC_ID_MPEG2VIDEO_XVMC, + CODEC_ID_H261, 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, @@ -38,6 +45,7 @@ enum CodecID { CODEC_ID_MJPEG, CODEC_ID_MJPEGB, CODEC_ID_LJPEG, + CODEC_ID_SP5X, CODEC_ID_MPEG4, CODEC_ID_RAWVIDEO, CODEC_ID_MSMPEG4V1, @@ -61,6 +69,7 @@ enum CodecID { CODEC_ID_H264, CODEC_ID_INDEO3, CODEC_ID_VP3, + CODEC_ID_THEORA, CODEC_ID_AAC, CODEC_ID_MPEG4AAC, CODEC_ID_ASV1, @@ -74,6 +83,21 @@ enum CodecID { CODEC_ID_INTERPLAY_VIDEO, CODEC_ID_XAN_WC3, CODEC_ID_XAN_WC4, + CODEC_ID_RPZA, + CODEC_ID_CINEPAK, + CODEC_ID_WS_VQA, + CODEC_ID_MSRLE, + CODEC_ID_MSVIDEO1, + CODEC_ID_IDCIN, + CODEC_ID_8BPS, + CODEC_ID_SMC, + CODEC_ID_FLIC, + CODEC_ID_TRUEMOTION1, + CODEC_ID_VMDVIDEO, + CODEC_ID_VMDAUDIO, + CODEC_ID_MSZH, + CODEC_ID_ZLIB, + CODEC_ID_QTRLE, /* various pcm "codecs" */ CODEC_ID_PCM_S16LE, @@ -90,11 +114,19 @@ enum CodecID { CODEC_ID_ADPCM_IMA_WAV, CODEC_ID_ADPCM_IMA_DK3, CODEC_ID_ADPCM_IMA_DK4, + CODEC_ID_ADPCM_IMA_WS, + CODEC_ID_ADPCM_IMA_SMJPEG, CODEC_ID_ADPCM_MS, CODEC_ID_ADPCM_4XM, + CODEC_ID_ADPCM_XA, + CODEC_ID_ADPCM_ADX, + CODEC_ID_ADPCM_EA, + CODEC_ID_ADPCM_G726, /* AMR */ CODEC_ID_AMR_NB, + CODEC_ID_AMR_WB, + /* RealAudio codecs*/ CODEC_ID_RA_144, CODEC_ID_RA_288, @@ -103,6 +135,11 @@ enum CodecID { CODEC_ID_ROQ_DPCM, CODEC_ID_INTERPLAY_DPCM, CODEC_ID_XAN_DPCM, + + CODEC_ID_FLAC, + + CODEC_ID_MPEG2TS, /* _FAKE_ codec to indicate a raw MPEG2 transport + stream (only used by libavformat) */ }; /* CODEC_ID_MP3LAME is absolete */ @@ -112,6 +149,7 @@ enum CodecType { CODEC_TYPE_UNKNOWN = -1, CODEC_TYPE_VIDEO, CODEC_TYPE_AUDIO, + CODEC_TYPE_DATA, }; /** @@ -127,7 +165,10 @@ enum CodecType { * 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). + * 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) @@ -190,11 +231,6 @@ typedef struct RcOverride{ /* only for ME compatiblity with old apps */ extern int motion_estimation_method; -/* ME algos sorted by quality */ -static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, - ME_X1, ME_EPZS, ME_FULL }; - - #define FF_MAX_B_FRAMES 8 /* encoding support @@ -203,9 +239,10 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, */ #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale -#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed +#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 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */ @@ -226,17 +263,22 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, #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 ///< Advanced intra coding +#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 -/* For advanced prediction mode, we reuse the 4MV flag */ +#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 +#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC +#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter +#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 +#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 /* Unsupported options : * Syntax Arithmetic coding (SAC) - * Deblocking filter internal loop - * Slice structured * Reference Picture Selection - * Independant Segment Decoding - * Alternative Inter * VLC - * Modified Quantization */ + * Independant Segment Decoding */ /* /Fx */ /* codec capabilities */ @@ -250,6 +292,62 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, used */ #define CODEC_CAP_PARSE_ONLY 0x0004 #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 */ +#define CODEC_CAP_DELAY 0x0020 + +//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 +#define MB_TYPE_16x16 0x0008 +#define MB_TYPE_16x8 0x0010 +#define MB_TYPE_8x16 0x0020 +#define MB_TYPE_8x8 0x0040 +#define MB_TYPE_INTERLACED 0x0080 +#define MB_TYPE_DIRECT2 0x0100 //FIXME +#define MB_TYPE_ACPRED 0x0200 +#define MB_TYPE_GMC 0x0400 +#define MB_TYPE_SKIP 0x0800 +#define MB_TYPE_P0L0 0x1000 +#define MB_TYPE_P1L0 0x2000 +#define MB_TYPE_P0L1 0x4000 +#define MB_TYPE_P1L1 0x8000 +#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) +#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) +#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) +#define MB_TYPE_QUANT 0x00010000 +#define MB_TYPE_CBP 0x00020000 +//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) + +/** + * Pan Scan area. + * this specifies the area which should be displayed. Note there may be multiple such areas for one frame + */ +typedef struct AVPanScan{ + /** + * id. + * - encoding: set by user. + * - decoding: set by lavc + */ + int id; + + /** + * width and height in 1/16 pel + * - encoding: set by user. + * - decoding: set by lavc + */ + int width; + int height; + + /** + * position of the top left corner in 1/16 pel for up to 3 fields/frames. + * - encoding: set by user. + * - decoding: set by lavc + */ + int16_t position[3][2]; +}AVPanScan; #define FF_COMMON_FRAME \ /**\ @@ -282,8 +380,8 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, int pict_type;\ \ /**\ - * presentation timestamp in micro seconds (time when frame should be shown to user)\ - * if 0 then the frame_rate will be used as reference\ + * 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\ */\ @@ -303,15 +401,15 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, int display_picture_number;\ \ /**\ - * quality (between 1 (good) and 31 (bad)) \ + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \ * - encoding: set by lavc for coded_picture (and set by user for input)\ * - decoding: set by lavc\ */\ - float quality; \ + int quality; \ \ /**\ * buffer age (1->was last buffer and dint change, 2->..., ...).\ - * set to something large if the buffer has not been used yet \ + * set to INT_MAX if the buffer has not been used yet \ * - encoding: unused\ * - decoding: MUST be set by get_buffer()\ */\ @@ -344,6 +442,28 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, * - decoding: set by lavc\ */\ uint8_t *mbskip_table;\ +\ + /**\ + * Motion vector table\ + * - encoding: set by user\ + * - decoding: set by lavc\ + */\ + int16_t (*motion_val[2])[2];\ +\ + /**\ + * Macroblock type table\ + * mb_type_base + mb_width + 2\ + * - encoding: set by user\ + * - decoding: set by lavc\ + */\ + uint32_t *mb_type;\ +\ + /**\ + * Macroblock size: (0->16x16, 1->8x8, 2-> 4x4, 3-> 2x2)\ + * - encoding: unused\ + * - decoding: set by lavc\ + */\ + uint8_t motion_subsample_log2;\ \ /**\ * for some private data of the user\ @@ -379,13 +499,62 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, * \ */\ int qscale_type;\ + \ + /**\ + * The content of the picture is interlaced.\ + * - encoding: set by user\ + * - decoding: set by lavc (default 0)\ + */\ + int interlaced_frame;\ + \ + /**\ + * if the content is interlaced, is top field displayed first.\ + * - encoding: set by user\ + * - decoding: set by lavc\ + */\ + int top_field_first;\ + \ + /**\ + * Pan scan.\ + * - encoding: set by user\ + * - decoding: set by lavc\ + */\ + AVPanScan *pan_scan;\ + \ + /**\ + * tell user application that palette has changed from previous frame.\ + * - encoding: ??? (no palette-enabled encoder yet)\ + * - decoding: set by lavc (default 0)\ + */\ + int palette_has_changed;\ + \ + /**\ + * Codec suggestion on buffer type if != 0\ + * - encoding: unused\ + * - decoding: set by lavc (before get_buffer() call))\ + */\ + int buffer_hints;\ +\ + /**\ + * DCT coeffitients\ + * - encoding: unused\ + * - decoding: set by lavc\ + */\ + short *dct_coeff;\ +\ + /**\ + * Motion referece frame index\ + * - encoding: set by user\ + * - decoding: set by lavc\ + */\ + int8_t *ref_index[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 somewher else, dont dealloc image (data/base) +#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 @@ -396,6 +565,11 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, #define FF_SI_TYPE 5 #define FF_SP_TYPE 6 +#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore) +#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer +#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content +#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update) + /** * Audio Video Frame. */ @@ -405,10 +579,27 @@ typedef struct AVFrame { #define DEFAULT_FRAME_RATE_BASE 1001000 +/** + * Used by av_log + */ +typedef struct AVCLASS AVClass; +struct AVCLASS { + const char* class_name; + const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext + or AVFormatContext, which begin with an AVClass. + Needed because av_log is in libavcodec and has no visibility + of AVIn/OutputFormat */ +}; + /** * main external api structure. */ typedef struct AVCodecContext { + /** + * Info on struct for av_log + * - set by avcodec_alloc_context + */ + AVClass *av_class; /** * the average bitrate. * - encoding: set by user. unused for constant quantizer encoding @@ -469,15 +660,10 @@ typedef struct AVCodecContext { /** * width / height. * - encoding: MUST be set by user. - * - decoding: set by user, some codecs might override / change it during playback + * - decoding: set by user if known, codec should override / dynamically change if needed */ int width, height; -#define FF_ASPECT_SQUARE 1 -#define FF_ASPECT_4_3_625 2 -#define FF_ASPECT_4_3_525 3 -#define FF_ASPECT_16_9_625 4 -#define FF_ASPECT_16_9_525 5 #define FF_ASPECT_EXTENDED 15 /** @@ -518,7 +704,7 @@ typedef struct AVCodecContext { * @param offset offset into the AVFrame.data from which the slice should be read */ void (*draw_horiz_band)(struct AVCodecContext *s, - AVFrame *src, int offset[4], + const AVFrame *src, int offset[4], int y, int type, int height); /* audio only */ @@ -594,11 +780,8 @@ typedef struct AVCodecContext { void *priv_data; - /* The following data is for RTP friendly coding */ - /* By now only H.263/H.263+/MPEG4 coder honours this */ - int rtp_mode; /* 1 for activate RTP friendly-mode */ - /* highers numbers represent more error-prone */ - /* enviroments, by now just "1" exist */ + /* unused, FIXME remove*/ + int rtp_mode; int rtp_payload_size; /* The size of the RTP payload, the coder will */ /* do it's best to deliver a chunk with size */ @@ -612,7 +795,7 @@ typedef struct AVCodecContext { /* 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)(void *data, int size, int packet_number); + void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int packet_number); /* statistics, used for 2-pass encoding */ int mv_bits; @@ -661,12 +844,15 @@ typedef struct AVCodecContext { #define FF_BUG_XVID_ILACE 4 #define FF_BUG_UMP4 8 #define FF_BUG_NO_PADDING 16 -#define FF_BUG_AC_VLC 32 +#define FF_BUG_AMV 32 +#define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default #define FF_BUG_QPEL_CHROMA 64 #define FF_BUG_STD_QPEL 128 #define FF_BUG_QPEL_CHROMA2 256 #define FF_BUG_DIRECT_BLOCKSIZE 512 #define FF_BUG_EDGE 1024 +#define FF_BUG_HPEL_CHROMA 2048 +#define FF_BUG_DC_CLIP 4096 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100% /** @@ -714,7 +900,8 @@ typedef struct AVCodecContext { /** * 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 - * width and height should be rounded up to the next multiple of 16 + * avcodec_align_dimensions() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16 * - encoding: unused * - decoding: set by lavc, user can override */ @@ -730,8 +917,8 @@ typedef struct AVCodecContext { void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); /** - * is 1 if the decoded stream contains b frames, 0 otherwise. - * - encoding: unused + * if 1 the stream has a 1 frame delay during decoding. + * - encoding: set by lavc * - decoding: set by lavc */ int has_b_frames; @@ -814,6 +1001,8 @@ typedef struct AVCodecContext { /** * qscale factor between p and i frames. + * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset) + * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset) * - encoding: set by user. * - decoding: unused */ @@ -821,8 +1010,6 @@ typedef struct AVCodecContext { /** * qscale offset between p and i frames. - * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset) - * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset) * - encoding: set by user. * - decoding: unused */ @@ -847,6 +1034,7 @@ typedef struct AVCodecContext { #define FF_DCT_MMX 3 #define FF_DCT_MLIB 4 #define FF_DCT_ALTIVEC 5 +#define FF_DCT_FAAN 6 /** * luminance masking (0-> disabled). @@ -964,11 +1152,12 @@ typedef struct AVCodecContext { #define FF_PRED_MEDIAN 2 /** - * aspect ratio (0 if unknown). + * sample aspect ratio (0 if unknown). + * numerator and denominator must be relative prime and smaller then 256 for some video standards * - encoding: set by user. * - decoding: set by lavc. */ - float aspect_ratio; + AVRational sample_aspect_ratio; /** * the picture in the bitstream. @@ -989,14 +1178,26 @@ typedef struct AVCodecContext { #define FF_DEBUG_MB_TYPE 8 #define FF_DEBUG_QP 16 #define FF_DEBUG_MV 32 -#define FF_DEBUG_VIS_MV 0x00000040 +#define FF_DEBUG_DCT_COEFF 0x00000040 #define FF_DEBUG_SKIP 0x00000080 #define FF_DEBUG_STARTCODE 0x00000100 #define FF_DEBUG_PTS 0x00000200 #define FF_DEBUG_ER 0x00000400 #define FF_DEBUG_MMCO 0x00000800 #define FF_DEBUG_BUGS 0x00001000 +#define FF_DEBUG_VIS_QP 0x00002000 +#define FF_DEBUG_VIS_MB_TYPE 0x00004000 + /** + * debug. + * - encoding: set by user. + * - decoding: set by user. + */ + int debug_mv; +#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames +#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames +#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames + /** * error. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR @@ -1036,6 +1237,12 @@ typedef struct AVCodecContext { * - decoding: unused */ int mb_cmp; + /** + * interlaced dct compare function + * - encoding: set by user. + * - decoding: unused + */ + int ildct_cmp; #define FF_CMP_SAD 0 #define FF_CMP_SSE 1 #define FF_CMP_SATD 2 @@ -1044,6 +1251,9 @@ typedef struct AVCodecContext { #define FF_CMP_BIT 5 #define FF_CMP_RD 6 #define FF_CMP_ZERO 7 +#define FF_CMP_VSAD 8 +#define FF_CMP_VSSE 9 +#define FF_CMP_NSSE 10 #define FF_CMP_CHROMA 256 /** @@ -1097,7 +1307,7 @@ typedef struct AVCodecContext { * - encoding: unused * - decoding: set by user, if not set then the native format will always be choosen */ - enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt); + enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt); /** * DTG active format information (additionnal aspect ratio @@ -1168,8 +1378,13 @@ typedef struct AVCodecContext { * Dont touch, used by lavc default_get_buffer() */ void *internal_buffer; - -#define FF_QUALITY_SCALE 256 + +#define FF_LAMBDA_SHIFT 7 +#define FF_LAMBDA_SCALE (1< + +#define AV_LOG_QUIET -1 +#define AV_LOG_ERROR 0 +#define AV_LOG_INFO 1 +#define AV_LOG_DEBUG 2 + +#ifdef __GNUC__ +extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); +#else +extern void av_log(void*, int level, const char *fmt, ...); +#endif + +extern void av_vlog(void*, int level, const char *fmt, va_list); +extern int av_log_get_level(void); +extern void av_log_set_level(int); +extern void av_log_set_callback(void (*)(void*, int, const char*, va_list)); + +/* endian macros */ +#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32) +#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) +#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ + (((uint8_t*)(x))[1] << 16) | \ + (((uint8_t*)(x))[2] << 8) | \ + ((uint8_t*)(x))[3]) +#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) +#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ + (((uint8_t*)(x))[2] << 16) | \ + (((uint8_t*)(x))[1] << 8) | \ + ((uint8_t*)(x))[0]) +#endif #ifdef __cplusplus } diff --git a/stepmania/src/ffmpeg/include/ffmpeg/avformat.h b/stepmania/src/ffmpeg/include/ffmpeg/avformat.h index f10c212d33..578028606c 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/avformat.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/avformat.h @@ -5,14 +5,14 @@ extern "C" { #endif -#define LIBAVFORMAT_BUILD 4608 +#define LIBAVFORMAT_BUILD 4616 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT #define LIBAVFORMAT_VERSION FFMPEG_VERSION #define LIBAVFORMAT_IDENT "FFmpeg" FFMPEG_VERSION "b" AV_STRINGIFY(LIBAVFORMAT_BUILD) #include - +#include /* FILE */ #include "avcodec.h" #include "avio.h" @@ -27,29 +27,33 @@ extern "C" { #define MININT64 int64_t_C(0x8000000000000000) #endif -#define AV_NOPTS_VALUE MININT64 -#define AV_TIME_BASE 1000000 - typedef struct AVPacket { - int64_t pts; /* presentation time stamp in stream units (set av_set_pts_info) */ + int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or + pts_den units in muxers or demuxers) */ + int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or + pts_den units in muxers or demuxers) */ uint8_t *data; int size; int stream_index; int flags; - int duration; + int duration; /* presentation duration (0 if not available) */ void (*destruct)(struct AVPacket *); void *priv; } AVPacket; #define PKT_FLAG_KEY 0x0001 +/* initialize optional fields of a packet */ static inline void av_init_packet(AVPacket *pkt) { pkt->pts = AV_NOPTS_VALUE; + pkt->dts = AV_NOPTS_VALUE; + pkt->duration = 0; pkt->flags = 0; pkt->stream_index = 0; } int av_new_packet(AVPacket *pkt, int size); +int av_dup_packet(AVPacket *pkt); /** * Free a packet @@ -102,12 +106,16 @@ typedef struct AVFormatParameters { int channel; /* used to select dv channel */ const char *device; /* video4linux, audio or DV device */ const char *standard; /* tv standard, NTSC, PAL, SECAM */ + int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */ + int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport + stream packet (only meaningful if + mpeg2ts_raw is TRUE */ + int initial_pause:1; /* do not begin to play the stream + immediately (RTSP only) */ } AVFormatParameters; #define AVFMT_NOFILE 0x0001 /* no file should be opened */ #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */ -#define AVFMT_NOHEADER 0x0004 /* signal that no header is present - (streams are added dynamically) */ #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */ #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for raw picture data */ @@ -123,9 +131,7 @@ typedef struct AVOutputFormat { enum CodecID audio_codec; /* default audio codec */ enum CodecID video_codec; /* default video codec */ int (*write_header)(struct AVFormatContext *); - int (*write_packet)(struct AVFormatContext *, - int stream_index, - const uint8_t *buf, int size, int64_t pts); + int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); int (*write_trailer)(struct AVFormatContext *); /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ int flags; @@ -150,15 +156,21 @@ typedef struct AVInputFormat { AVFormatParameters *ap); /* read one packet and put it in 'pkt'. pts and flags are also set. 'av_new_stream' can be called only if the flag - AVFMT_NOHEADER is used. */ + AVFMTCTX_NOHEADER is used. */ int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); /* close the stream. The AVFormatContext and AVStreams are not freed by this function */ int (*read_close)(struct AVFormatContext *); - /* seek at or before a given pts (given in microsecond). The pts - origin is defined by the stream */ - int (*read_seek)(struct AVFormatContext *, int64_t pts); - /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */ + /* seek at or before a given timestamp (given in AV_TIME_BASE + units) relative to the frames in stream component stream_index */ + int (*read_seek)(struct AVFormatContext *, + int stream_index, int64_t timestamp); + /** + * gets the next timestamp in AV_TIME_BASE units. + */ + int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, + int64_t *pos, int64_t pos_limit); + /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ int flags; /* if extensions are defined, then no probe is done. You should usually not use extension format guessing because it is not @@ -166,10 +178,28 @@ typedef struct AVInputFormat { const char *extensions; /* general purpose read only value that the format can use */ int value; + + /* start/resume playing - only meaningful if using a network based format + (RTSP) */ + int (*read_play)(struct AVFormatContext *); + + /* pause playing - only meaningful if using a network based format + (RTSP) */ + int (*read_pause)(struct AVFormatContext *); + /* private fields */ struct AVInputFormat *next; } AVInputFormat; +typedef struct AVIndexEntry { + int64_t pos; + int64_t timestamp; +#define AVINDEX_KEYFRAME 0x0001 +/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */ + int flags; + int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */ +} AVIndexEntry; + typedef struct AVStream { int index; /* stream index in AVFormatContext */ int id; /* format specific stream id */ @@ -178,11 +208,12 @@ typedef struct AVStream { int r_frame_rate_base;/* real frame rate base of the stream */ void *priv_data; /* internal data used in av_find_stream_info() */ - int codec_info_state; - int codec_info_nb_repeat_frames; - int codec_info_nb_real_frames; - /* PTS generation when outputing stream */ + int64_t codec_info_duration; + int codec_info_nb_frames; + /* encoding: PTS generation when outputing stream */ AVFrac pts; + AVRational time_base; + int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */ /* ffmpeg.c private use */ int stream_copy; /* if TRUE, just copy stream */ /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame @@ -194,12 +225,29 @@ typedef struct AVStream { /* decoding: duration of the stream, in AV_TIME_BASE fractional seconds. */ int64_t duration; + + /* av_read_frame() support */ + int need_parsing; + struct AVCodecParserContext *parser; + + int64_t cur_dts; + int last_IP_duration; + int64_t last_IP_pts; + /* av_seek_frame() support */ + AVIndexEntry *index_entries; /* only used if the format does not + support seeking natively */ + int nb_index_entries; + int index_entries_allocated_size; } AVStream; +#define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present + (streams are added dynamically) */ + #define MAX_STREAMS 20 /* format I/O context */ typedef struct AVFormatContext { + AVClass *av_class; /* set by av_alloc_format_context */ /* can only be iformat or oformat, not both at the same time */ struct AVInputFormat *iformat; struct AVOutputFormat *oformat; @@ -209,6 +257,7 @@ typedef struct AVFormatContext { AVStream *streams[MAX_STREAMS]; char filename[1024]; /* input or output filename */ /* stream info */ + int64_t timestamp; char title[512]; char author[512]; char copyright[512]; @@ -218,10 +267,8 @@ typedef struct AVFormatContext { int track; /* track number, 0 if none */ char genre[32]; /* ID3 genre */ - int flags; /* format specific flags */ + int ctx_flags; /* format specific flags, see AVFMTCTX_xx */ /* private data for pts handling (do not modify directly) */ - int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */ - int pts_num, pts_den; /* value to convert to seconds */ /* This buffer is only needed when packets were already buffered but not decoded, for example to get the codec parameters in mpeg streams */ @@ -241,6 +288,16 @@ typedef struct AVFormatContext { available. Never set it directly if the file_size and the duration are known as ffmpeg can compute it automatically. */ int bit_rate; + + /* av_read_frame() support */ + AVStream *cur_st; + const uint8_t *cur_ptr; + int cur_len; + AVPacket cur_pkt; + + /* av_seek_frame() support */ + int64_t data_offset; /* offset of the first packet */ + int index_built; } AVFormatContext; typedef struct AVPacketList { @@ -306,6 +363,7 @@ extern AVImageFormat png_image_format; #endif extern AVImageFormat jpeg_image_format; extern AVImageFormat gif_image_format; +extern AVImageFormat sgi_image_format; /* XXX: use automatic init with either ELF sections or C file parser */ /* modules */ @@ -364,9 +422,11 @@ int au_init(void); int amr_init(void); /* wav.c */ -int wav_init(void); +int ff_wav_init(void); /* raw.c */ +int pcm_read_seek(AVFormatContext *s, + int stream_index, int64_t timestamp); int raw_init(void); /* mp3.c */ @@ -379,7 +439,7 @@ int yuv4mpeg_init(void); int ogg_init(void); /* dv.c */ -int dv_init(void); +int ff_dv_init(void); /* ffm.c */ int ffm_init(void); @@ -406,6 +466,24 @@ int nut_init(void); /* wc3movie.c */ int wc3_init(void); +/* westwood.c */ +int westwood_init(void); + +/* segafilm.c */ +int film_init(void); + +/* idcin.c */ +int idcin_init(void); + +/* flic.c */ +int flic_init(void); + +/* sierravmd.c */ +int vmd_init(void); + +/* matroska.c */ +int matroska_init(void); + #include "rtp.h" #include "rtsp.h" @@ -421,7 +499,8 @@ AVOutputFormat *guess_stream_format(const char *short_name, AVOutputFormat *guess_format(const char *short_name, const char *filename, const char *mime_type); -void av_hex_dump(uint8_t *buf, int size); +void av_hex_dump(FILE *f, uint8_t *buf, int size); +void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); void av_register_all(void); @@ -439,10 +518,15 @@ void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr); /* media file input */ AVInputFormat *av_find_input_format(const char *short_name); AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); +int av_open_input_stream(AVFormatContext **ic_ptr, + ByteIOContext *pb, const char *filename, + AVInputFormat *fmt, AVFormatParameters *ap); int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap); +/* no av_open for output, so applications will need this: */ +AVFormatContext *av_alloc_format_context(void); #define AVERROR_UNKNOWN (-1) /* unknown error */ #define AVERROR_IO (-2) /* i/o error */ @@ -450,19 +534,31 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, #define AVERROR_INVALIDDATA (-4) /* invalid data found */ #define AVERROR_NOMEM (-5) /* not enough memory */ #define AVERROR_NOFMT (-6) /* unknown format */ - +#define AVERROR_NOTSUPP (-7) /* operation not supported */ + int av_find_stream_info(AVFormatContext *ic); int av_read_packet(AVFormatContext *s, AVPacket *pkt); +int av_read_frame(AVFormatContext *s, AVPacket *pkt); +int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp); +int av_read_play(AVFormatContext *s); +int av_read_pause(AVFormatContext *s); void av_close_input_file(AVFormatContext *s); AVStream *av_new_stream(AVFormatContext *s, int id); -void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits, +void av_set_pts_info(AVStream *s, int pts_wrap_bits, int pts_num, int pts_den); +int av_find_default_stream_index(AVFormatContext *s); +int av_index_search_timestamp(AVStream *st, int timestamp); +int av_add_index_entry(AVStream *st, + int64_t pos, int64_t timestamp, int distance, int flags); +int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts); + /* media file output */ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); int av_write_header(AVFormatContext *s); -int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf, - int size); +int av_write_frame(AVFormatContext *s, AVPacket *pkt); +int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); + int av_write_trailer(AVFormatContext *s); void dump_format(AVFormatContext *ic, diff --git a/stepmania/src/ffmpeg/include/ffmpeg/avio.h b/stepmania/src/ffmpeg/include/ffmpeg/avio.h index cc0b5f9b05..53ed22a3a1 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/avio.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/avio.h @@ -78,6 +78,9 @@ typedef struct { int write_flag; /* true if open for writing */ int is_streamed; int max_packet_size; + unsigned long checksum; + unsigned char *checksum_ptr; + unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); } ByteIOContext; int init_put_byte(ByteIOContext *s, @@ -110,7 +113,7 @@ int url_feof(ByteIOContext *s); #define URL_EOF (-1) int url_fgetc(ByteIOContext *s); #ifdef __GNUC__ -int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); #else int url_fprintf(ByteIOContext *s, const char *fmt, ...); #endif @@ -119,6 +122,7 @@ char *url_fgets(ByteIOContext *s, char *buf, int buf_size); void put_flush_packet(ByteIOContext *s); int get_buffer(ByteIOContext *s, unsigned char *buf, int size); +int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size); int get_byte(ByteIOContext *s); unsigned int get_le32(ByteIOContext *s); uint64_t get_le64(ByteIOContext *s); @@ -149,6 +153,10 @@ int url_open_dyn_buf(ByteIOContext *s); int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size); int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer); +unsigned long get_checksum(ByteIOContext *s); +void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum); +unsigned long update_adler32(unsigned long adler, const uint8_t *buf, unsigned int len); + /* file.c */ extern URLProtocol file_protocol; extern URLProtocol pipe_protocol; diff --git a/stepmania/src/ffmpeg/include/ffmpeg/common.h b/stepmania/src/ffmpeg/include/ffmpeg/common.h index 11d611819c..d1cde53c68 100644 --- a/stepmania/src/ffmpeg/include/ffmpeg/common.h +++ b/stepmania/src/ffmpeg/include/ffmpeg/common.h @@ -8,6 +8,7 @@ #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) # define CONFIG_WIN32 +# define EMULATE_INTTYPES #endif //#define ALT_BITSTREAM_WRITER @@ -18,6 +19,10 @@ //#define A32_BITSTREAM_READER #define LIBMPEG2_BITSTREAM_READER_HACK //add BERO +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #ifdef HAVE_AV_CONFIG_H /* only include the following when compiling package */ # include "config.h" @@ -26,6 +31,7 @@ # include # include # include +# include # ifndef __BEOS__ # include # else @@ -37,10 +43,6 @@ # define ENODATA 61 # endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - #include #ifndef offsetof # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) @@ -76,51 +78,103 @@ extern const struct AVOption avoptions_workaround_bug[11]; # define restrict #endif +#ifndef always_inline #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) # define always_inline __attribute__((always_inline)) inline #else # define always_inline inline #endif +#endif + +#ifndef attribute_used +#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) +# define attribute_used __attribute__((used)) +#else +# define attribute_used +#endif +#endif + +#ifndef EMULATE_INTTYPES +# include +#else + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + +# ifdef CONFIG_WIN32 + typedef signed __int64 int64_t; + typedef unsigned __int64 uint64_t; +# else /* other OS */ + typedef signed long long int64_t; + typedef unsigned long long uint64_t; +# endif /* other OS */ +#endif /* HAVE_INTTYPES_H */ + +#ifndef INT64_MAX +#define INT64_MAX int64_t_C(9223372036854775807) +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF) +#endif + +#ifdef EMULATE_FAST_INT +/* note that we don't emulate 64bit ints */ +typedef signed char int_fast8_t; +typedef signed int int_fast16_t; +typedef signed int int_fast32_t; +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +#endif + +#ifndef INT_BIT +# if INT_MAX != 2147483647 +# define INT_BIT 64 +# else +# define INT_BIT 32 +# endif +#endif + +#if defined(CONFIG_OS2) || defined(CONFIG_SUNOS) +static inline float floorf(float f) { + return floor(f); +} +#endif #ifdef CONFIG_WIN32 /* windows */ -typedef unsigned short uint16_t; -typedef signed short int16_t; -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; -typedef signed char int8_t; -typedef signed int int32_t; -typedef signed __int64 int64_t; - -# ifndef __MINGW32__ +# if !defined(__MINGW32__) && !defined(__CYGWIN__) # define int64_t_C(c) (c ## i64) # define uint64_t_C(c) (c ## i64) -# define inline __inline +# ifdef HAVE_AV_CONFIG_H +# define inline __inline +# endif # else # define int64_t_C(c) (c ## LL) # define uint64_t_C(c) (c ## ULL) # endif /* __MINGW32__ */ -# ifdef _DEBUG -# ifndef DEBUG -# define DEBUG -# endif -# endif +# ifdef HAVE_AV_CONFIG_H +# ifdef _DEBUG +# define DEBUG +# endif -# define snprintf _snprintf -# define vsnprintf _vsnprintf +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# endif /* CONFIG_WIN32 end */ #elif defined (CONFIG_OS2) /* OS/2 EMX */ -#include - #ifndef int64_t_C #define int64_t_C(c) (c ## LL) #define uint64_t_C(c) (c ## ULL) @@ -141,8 +195,6 @@ typedef signed __int64 int64_t; /* unix */ -#include - #ifndef int64_t_C #define int64_t_C(c) (c ## LL) #define uint64_t_C(c) (c ## ULL) @@ -176,24 +228,24 @@ typedef signed __int64 int64_t; # include /* dprintf macros */ -# if defined(CONFIG_WIN32) && !defined(__MINGW32__) +# if defined(CONFIG_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) inline void dprintf(const char* fmt,...) {} # else # ifdef DEBUG -# define dprintf(fmt,args...) printf(fmt, ## args) +# define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__) # else -# define dprintf(fmt,args...) +# define dprintf(fmt,...) # endif # endif /* !CONFIG_WIN32 */ -# define av_abort() do { fprintf(stderr, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) +# define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) //rounded divison & shift -#define RSHIFT(a,b) ((a) > 0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b)) +#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) /* assume b>0 */ #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) #define ABS(a) ((a) >= 0 ? (a) : (-(a))) @@ -243,10 +295,7 @@ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ /* bit output */ -struct PutBitContext; - -typedef void (*WriteDataFunc)(void *, uint8_t *, int); - +/* buf and buf_end must be present and used by every alternative writer. */ typedef struct PutBitContext { #ifdef ALT_BITSTREAM_WRITER uint8_t *buf, *buf_end; @@ -256,21 +305,56 @@ typedef struct PutBitContext { int bit_left; uint8_t *buf, *buf_ptr, *buf_end; #endif - int64_t data_out_size; /* in bytes */ } PutBitContext; -void init_put_bits(PutBitContext *s, - uint8_t *buffer, int buffer_size, - void *opaque, - void (*write_data)(void *, uint8_t *, int)); +static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) +{ + s->buf = buffer; + s->buf_end = s->buf + buffer_size; +#ifdef ALT_BITSTREAM_WRITER + s->index=0; + ((uint32_t*)(s->buf))[0]=0; +// memset(buffer, 0, buffer_size); +#else + s->buf_ptr = s->buf; + s->bit_left=32; + s->bit_buf=0; +#endif +} + +/* return the number of bits output */ +static inline int put_bits_count(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + return s->index; +#else + return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; +#endif +} + +/* pad the end of the output stream with zeros */ +static inline void flush_put_bits(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + align_put_bits(s); +#else + s->bit_buf<<= s->bit_left; + while (s->bit_left < 32) { + /* XXX: should test end of buffer */ + *s->buf_ptr++=s->bit_buf >> 24; + s->bit_buf<<=8; + s->bit_left+=8; + } + s->bit_left=32; + s->bit_buf=0; +#endif +} -int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */ void align_put_bits(PutBitContext *s); -void flush_put_bits(PutBitContext *s); -void put_string(PutBitContext * pbc, char *s); +void put_string(PutBitContext * pbc, char *s, int put_zero); /* bit input */ - +/* buffer, buffer_end and size_in_bits must be present and used by every reader */ typedef struct GetBitContext { const uint8_t *buffer, *buffer_end; #ifdef ALT_BITSTREAM_READER @@ -288,8 +372,6 @@ typedef struct GetBitContext { int size_in_bits; } GetBitContext; -static inline int get_bits_count(GetBitContext *s); - #define VLC_TYPE int16_t typedef struct VLC { @@ -304,7 +386,7 @@ typedef struct RL_VLC_ELEM { uint8_t run; } RL_VLC_ELEM; -#ifdef ARCH_SPARC64 +#ifdef ARCH_SPARC #define UNALIGNED_STORES_ARE_BAD #endif @@ -355,7 +437,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) bit_buf<<=bit_left; bit_buf |= value >> (n - bit_left); #ifdef UNALIGNED_STORES_ARE_BAD - if (3 & (int) s->buf_ptr) { + if (3 & (intptr_t) s->buf_ptr) { s->buf_ptr[0] = bit_buf >> 24; s->buf_ptr[1] = bit_buf >> 16; s->buf_ptr[2] = bit_buf >> 8; @@ -451,6 +533,28 @@ static inline uint8_t* pbBufPtr(PutBitContext *s) #endif } +/** + * + * PutBitContext must be flushed & aligned to a byte boundary before calling this. + */ +static inline void skip_put_bytes(PutBitContext *s, int n){ + assert((put_bits_count(s)&7)==0); +#ifdef ALT_BITSTREAM_WRITER + FIXME may need some cleaning of the buffer + s->index += n<<3; +#else + assert(s->bit_left==32); + s->buf_ptr += n; +#endif +} + +/** + * Changes the end of the buffer. + */ +static inline void set_put_bits_buffer_size(PutBitContext *s, int size){ + s->buf_end= s->buf + size; +} + /* Bitstream reader API docs: name abritary name which is used as prefix for the internal variables @@ -773,8 +877,52 @@ static inline void skip_bits1(GetBitContext *s){ skip_bits(s, 1); } -void init_get_bits(GetBitContext *s, - const uint8_t *buffer, int buffer_size); +/** + * init GetBitContext. + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end + * @param bit_size the size of the buffer in bits + */ +static inline void init_get_bits(GetBitContext *s, + const uint8_t *buffer, int bit_size) +{ + const int buffer_size= (bit_size+7)>>3; + + s->buffer= buffer; + s->size_in_bits= bit_size; + s->buffer_end= buffer + buffer_size; +#ifdef ALT_BITSTREAM_READER + s->index=0; +#elif defined LIBMPEG2_BITSTREAM_READER +#ifdef LIBMPEG2_BITSTREAM_READER_HACK + if ((int)buffer&1) { + /* word alignment */ + s->cache = (*buffer++)<<24; + s->buffer_ptr = buffer; + s->bit_count = 16-8; + } else +#endif + { + s->buffer_ptr = buffer; + s->bit_count = 16; + s->cache = 0; + } +#elif defined A32_BITSTREAM_READER + s->buffer_ptr = (uint32_t*)buffer; + s->bit_count = 32; + s->cache0 = 0; + s->cache1 = 0; +#endif + { + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) + } +#ifdef A32_BITSTREAM_READER + s->cache1 = 0; +#endif +} int check_marker(GetBitContext *s, const char *msg); void align_get_bits(GetBitContext *s); @@ -927,10 +1075,10 @@ static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *fun #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define tprintf printf +#define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__) #else //TRACE -#define tprintf(_arg...) {} +#define tprintf(...) {} #endif /* define it to include statistics code (useful only for optimizing @@ -992,23 +1140,31 @@ static inline int av_log2_16bit(unsigned int v) return n; } - /* median of 3 */ static inline int mid_pred(int a, int b, int c) { - int vmin, vmax; - vmax = vmin = a; - if (b < vmin) - vmin = b; - else - vmax = b; +#if 0 + int t= (a-b)&((a-b)>>31); + a-=t; + b+=t; + b-= (b-c)&((b-c)>>31); + b+= (a-b)&((a-b)>>31); - if (c < vmin) - vmin = c; - else if (c > vmax) - vmax = c; - - return a + b + c - vmin - vmax; + return b; +#else + if(a>b){ + if(c>b){ + if(c>a) b=a; + else b=c; + } + }else{ + if(b>c){ + if(c>a) b=c; + else b=a; + } + } + return b; +#endif } static inline int clip(int a, int amin, int amax) @@ -1021,6 +1177,12 @@ static inline int clip(int a, int amin, int amax) return a; } +static inline int clip_uint8(int a) +{ + if (a&(~255)) return (-a)>>31; + else return a; +} + /* math */ extern const uint8_t ff_sqrt_tab[128]; @@ -1057,9 +1219,6 @@ static inline int ff_get_fourcc(const char *s){ #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) -void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max); - - #ifdef ARCH_X86 #define MASK_ABS(mask, level)\ asm volatile(\ @@ -1105,21 +1264,23 @@ static inline long long rdtsc() } #define START_TIMER \ -static uint64_t tsum=0;\ -static int tcount=0;\ -static int tskip_count=0;\ uint64_t tend;\ uint64_t tstart= rdtsc();\ #define STOP_TIMER(id) \ tend= rdtsc();\ -if(tcount<2 || tend - tstart < 4*tsum/tcount){\ - tsum+= tend - tstart;\ - tcount++;\ -}else\ - tskip_count++;\ -if(256*256*256*64%(tcount+tskip_count)==0){\ - fprintf(stderr, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ +{\ + static uint64_t tsum=0;\ + static int tcount=0;\ + static int tskip_count=0;\ + if(tcount<2 || tend - tstart < 8*tsum/tcount){\ + tsum+= tend - tstart;\ + tcount++;\ + }else\ + tskip_count++;\ + if(256*256*256*64%(tcount+tskip_count)==0){\ + av_log(NULL, AV_LOG_DEBUG, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ + }\ } #endif @@ -1129,6 +1290,13 @@ if(256*256*256*64%(tcount+tskip_count)==0){\ #define malloc please_use_av_malloc #define free please_use_av_free #define realloc please_use_av_realloc +#define time time_is_forbidden_due_to_security_issues +#define rand rand_is_forbidden_due_to_state_trashing +#define srand srand_is_forbidden_due_to_state_trashing +#if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H)) +#define printf please_use_av_log +#define fprintf please_use_av_log +#endif #define CHECKED_ALLOCZ(p, size)\ {\ diff --git a/stepmania/src/ffmpeg/lib/avcodec.lib b/stepmania/src/ffmpeg/lib/avcodec.lib index 31d5740294..d301da43fb 100644 Binary files a/stepmania/src/ffmpeg/lib/avcodec.lib and b/stepmania/src/ffmpeg/lib/avcodec.lib differ diff --git a/stepmania/src/ffmpeg/lib/avformat.lib b/stepmania/src/ffmpeg/lib/avformat.lib index b683e11c29..0f90b4ffa5 100644 Binary files a/stepmania/src/ffmpeg/lib/avformat.lib and b/stepmania/src/ffmpeg/lib/avformat.lib differ