# HG changeset patch # User michaelni # Date 1017355822 0 # Node ID a1234c032636b5c9972271bcf4d06d9870eecb38 # Parent c1a8a1b4a24b50817b6842bfb9697a59644f0ef2 force frame type for 2-pass encoding diff -r c1a8a1b4a24b -r a1234c032636 avcodec.h --- a/avcodec.h Thu Mar 28 13:41:04 2002 +0000 +++ b/avcodec.h Thu Mar 28 22:50:22 2002 +0000 @@ -120,6 +120,8 @@ int qmin; /* min qscale */ int qmax; /* max qscale */ int max_qdiff; /* max qscale difference between frames */ + + int force_type; /* 0= no force, otherwise I_TYPE, P_TYPE, ... */ struct AVCodec *codec; void *priv_data; diff -r c1a8a1b4a24b -r a1234c032636 mpegvideo.c --- a/mpegvideo.c Thu Mar 28 13:41:04 2002 +0000 +++ b/mpegvideo.c Thu Mar 28 22:50:22 2002 +0000 @@ -514,9 +514,10 @@ init_put_bits(&s->pb, buf, buf_size, NULL, NULL); + s->force_type= avctx->force_type; if (!s->intra_only) { /* first picture of GOP is intra */ - if (s->picture_in_gop_number % s->gop_size==0){ + if (s->picture_in_gop_number % s->gop_size==0 || s->force_type==I_TYPE){ s->picture_in_gop_number=0; s->pict_type = I_TYPE; }else @@ -1313,7 +1314,7 @@ memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height); } - if(s->avg_mb_var < s->mc_mb_var && s->pict_type != B_TYPE){ //FIXME subtract MV bits + if(s->avg_mb_var < s->mc_mb_var && s->pict_type != B_TYPE && (!s->force_type)){ //FIXME subtract MV bits s->pict_type= I_TYPE; s->picture_in_gop_number=0; memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height); @@ -1955,7 +1956,7 @@ double fps; INT64 wanted_bits; emms_c(); - + fps= (double)s->frame_rate / FRAME_RATE_BASE; wanted_bits= s->bit_rate*(double)s->picture_number/fps; diff -r c1a8a1b4a24b -r a1234c032636 mpegvideo.h --- a/mpegvideo.h Thu Mar 28 13:41:04 2002 +0000 +++ b/mpegvideo.h Thu Mar 28 22:50:22 2002 +0000 @@ -66,6 +66,7 @@ int max_qdiff; /* max qscale difference between frames */ int encoding; /* true if we are encoding (vs decoding) */ int flags; /* AVCodecContext.flags (HQ, MV4, ...) */ + int force_type; /* 0= no force, otherwise I_TYPE, P_TYPE, ... */ /* the following fields are managed internally by the encoder */ /* bit output */