From 70ac76c0eb13d74d2001e83d7803f3dc0299f86a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 3 Jan 2003 23:21:52 +0000 Subject: [PATCH] mpeg4 header encoding bugfix Originally committed as revision 1392 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/avcodec.h | 21 ++++++++++++++++++--- libavcodec/h263.c | 4 +--- libavcodec/mpegvideo.h | 1 - tests/ffmpeg.regression.ref | 8 ++++---- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7833741268..08dd8c99f0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5,8 +5,8 @@ #define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION "0.4.6" -#define LIBAVCODEC_BUILD 4650 -#define LIBAVCODEC_BUILD_STR "4650" +#define LIBAVCODEC_BUILD 4651 +#define LIBAVCODEC_BUILD_STR "4651" enum CodecID { CODEC_ID_NONE, @@ -147,6 +147,7 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, #define CODEC_FLAG_LOW_DELAY 0x00080000 /* force low delay / will fail on b frames */ #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 */ /* codec capabilities */ @@ -894,7 +895,7 @@ typedef struct AVCodecContext { * decoding: unused */ int last_predictor_count; - + /** * pre pass for motion estimation * encoding: set by user. @@ -902,6 +903,20 @@ typedef struct AVCodecContext { */ int pre_me; + /** + * motion estimation pre pass compare function + * encoding: set by user. + * decoding: unused + */ + int me_pre_cmp; + + /** + * ME pre pass diamond size & shape + * encoding: set by user. + * decoding: unused + */ + int pre_dia_size; + } AVCodecContext; typedef struct AVCodec { diff --git a/libavcodec/h263.c b/libavcodec/h263.c index c1bfbaf64d..bc21e0cd86 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -1727,11 +1727,9 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number) int time_div, time_mod; if(s->pict_type==I_TYPE){ - if(picture_number - s->last_vo_picture_number >= 300 || picture_number==0){ + if(!(s->flags&CODEC_FLAG_GLOBAL_HEADER)){ mpeg4_encode_visual_object_header(s); mpeg4_encode_vol_header(s, 0, 0); - - s->last_vo_picture_number= picture_number; } mpeg4_encode_gop_header(s); } diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 983e42dce5..1bd9bf6628 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -443,7 +443,6 @@ typedef struct MpegEncContext { INT8 (*field_select_table)[2]; /* wtf, no really another table for interlaced b frames */ int t_frame; /* time distance of first I -> B, used for interlaced b frames */ int padding_bug_score; /* used to detect the VERY common padding bug in MPEG4 */ - int last_vo_picture_number; /* last picture number for which we added a VOS/VO/VOL header */ /* divx specific, used to workaround (many) bugs in divx5 */ int divx_version; diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 812112c2cc..56d1bc489d 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -11,12 +11,12 @@ a6527e93fe0e2e5942934efbde59f78b *./data/a-h263.avi f3bc40b0a09eb06504fa5b51eb9135ee *./data/out.yuv a11e0b741fa3c7fc491fb58ab8f7ca8d *./data/a-h263p.avi 615e3db2bdc535ca5b17996b29cabf24 *./data/out.yuv -466e2365c9027dea8695cf205adf3b9d *./data/a-odivx.avi +67a4922527e2341d11d6a61c79b497e5 *./data/a-odivx.avi 3ede54eadc97f43b4ab260faeb5e8674 *./data/out.yuv -5811f89254bc1f59528247f3daf11c1f *./data/a-mpeg4-rc.avi +4fdf373ede0785cc381687b8f1b207d4 *./data/a-mpeg4-rc.avi d34057ff0806320c8be54fe34210c937 *./data/out.yuv -d0c2e8f437f0a08470764e1f12dd1ec6 *./data/a-mpeg4-adv.avi -1a2795985b820b4ed5064abf4187fd9a *./data/out.yuv +2abefdb7650d076021ad455cc5ef040e *./data/a-mpeg4-adv.avi +a26abb66bf9c5f5df3ab971dfdf1189d *./data/out.yuv 2846c8e3d97d7395eb746bfce44e0443 *./data/a-mjpeg.avi 278033451d7a6bfeb8339abbe4228499 *./data/out.yuv b5f5efce96150d5cc8f5af8024ae3688 *./data/a-rv10.rm