[svn] / branches / dev-api-4 / xvidcore / src / plugins / plugin_2pass2.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/plugins/plugin_2pass2.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1241, Fri Dec 5 14:23:02 2003 UTC revision 1242, Fri Dec 5 14:44:35 2003 UTC
# Line 25  Line 25 
25   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
26   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27   *   *
28   * $Id: plugin_2pass2.c,v 1.1.2.27 2003-11-19 15:59:41 edgomez Exp $   * $Id: plugin_2pass2.c,v 1.1.2.28 2003-12-05 14:44:35 edgomez Exp $
29   *   *
30   *****************************************************************************/   *****************************************************************************/
31    
# Line 51  Line 51 
51    
52  /* Keyframe settings */  /* Keyframe settings */
53  #define DEFAULT_KFREDUCTION 20  #define DEFAULT_KFREDUCTION 20
54  #define DEFAULT_MIN_KEY_INTERVAL 1  #define DEFAULT_KFTHRESHOLD 1
55    
56  /*****************************************************************************  /*****************************************************************************
57   * Structures   * Structures
# Line 282  Line 282 
282    
283          /* Keyframe settings */          /* Keyframe settings */
284          _INIT(rc->param.kfreduction, DEFAULT_KFREDUCTION);          _INIT(rc->param.kfreduction, DEFAULT_KFREDUCTION);
285          _INIT(rc->param.min_key_interval, DEFAULT_MIN_KEY_INTERVAL);          _INIT(rc->param.kfthreshold, DEFAULT_KFTHRESHOLD);
286  #undef _INIT  #undef _INIT
287    
288          /* Initialize some stuff to zero */          /* Initialize some stuff to zero */
# Line 467  Line 467 
467    
468          /* IFrame user settings*/          /* IFrame user settings*/
469          if (s->type == XVID_TYPE_IVOP) {          if (s->type == XVID_TYPE_IVOP) {
   
470                  /* Keyframe boosting -- All keyframes benefit from it */                  /* Keyframe boosting -- All keyframes benefit from it */
471                  dbytes += dbytes*rc->param.keyframe_boost / 100;                  dbytes += dbytes*rc->param.keyframe_boost / 100;
472    
473                  /* Applies keyframe penalties, but not the first frame */  #if 0 /* ToDo: decide how to apply kfthresholding */
474                  if (rc->KF_idx) {  #endif
                         int penalty_distance;  
   
                         /* Minimum keyframe distance penalties */  
                         penalty_distance  = rc->param.min_key_interval;  
                         penalty_distance -= rc->keyframe_locations[rc->KF_idx];  
                         penalty_distance += rc->keyframe_locations[rc->KF_idx-1];  
   
                         /* Ah ah ! guilty keyframe, you're under arrest ! */  
                         if (penalty_distance > 0)  
                                 dbytes -= dbytes*penalty_distance*rc->param.kfreduction/100;  
                 }  
475          } else {          } else {
476    
477                  /* P/S/B frames must reserve some bits for iframe boosting */                  /* P/S/B frames must reserve some bits for iframe boosting */
# Line 1191  Line 1179 
1179  scaled_curve_apply_advanced_parameters(rc_2pass2_t * rc)  scaled_curve_apply_advanced_parameters(rc_2pass2_t * rc)
1180  {  {
1181          int i;          int i;
1182          uint64_t ivop_boost_total;          int64_t ivop_boost_total;
1183    
1184          /* Reset the rate controller (per frame type) total byte counters */          /* Reset the rate controller (per frame type) total byte counters */
1185          for (i=0; i<3; i++) rc->tot_scaled_length[i] = 0;          for (i=0; i<3; i++) rc->tot_scaled_length[i] = 0;
# Line 1214  Line 1202 
1202    
1203                  /* Some more work is needed for I frames */                  /* Some more work is needed for I frames */
1204                  if (s->type == XVID_TYPE_IVOP) {                  if (s->type == XVID_TYPE_IVOP) {
                         int penalty_distance;  
1205                          int ivop_boost;                          int ivop_boost;
1206    
1207                          /* Accumulate bytes needed for keyframe boosting */                          /* Accumulate bytes needed for keyframe boosting */
1208                          ivop_boost = s->scaled_length*rc->param.keyframe_boost/100;                          ivop_boost = s->scaled_length*rc->param.keyframe_boost/100;
1209    
1210                          if (rc->KF_idx) {  #if 0 /* ToDo: decide how to apply kfthresholding */
1211                                  /* Minimum keyframe distance penalties */  #endif
                                 penalty_distance  = rc->param.min_key_interval;  
                                 penalty_distance -= rc->keyframe_locations[rc->KF_idx];  
                                 penalty_distance += rc->keyframe_locations[rc->KF_idx-1];  
   
                                 /* Ah ah ! guilty keyframe, you're under arrest ! */  
                                 if (penalty_distance > 0)  
                                          ivop_boost -= (s->scaled_length + ivop_boost)*penalty_distance*rc->param.kfreduction/100;  
                         }  
   
1212                          /* If the frame size drops under the minimum length, then cap ivop_boost */                          /* If the frame size drops under the minimum length, then cap ivop_boost */
1213                          if (ivop_boost + s->scaled_length < rc->min_length[XVID_TYPE_IVOP-1])                          if (ivop_boost + s->scaled_length < rc->min_length[XVID_TYPE_IVOP-1])
1214                                  ivop_boost = rc->min_length[XVID_TYPE_IVOP-1] - s->scaled_length;                                  ivop_boost = rc->min_length[XVID_TYPE_IVOP-1] - s->scaled_length;
# Line 1260  Line 1238 
1238    
1239          /* Compute the ratio described above          /* Compute the ratio described above
1240           *     taxed_total = sum(0, n, tax*scaled_length)           *     taxed_total = sum(0, n, tax*scaled_length)
1241           * <=> taxed_total = tax.sum(0, n, tax*scaled_length)           * <=> taxed_total = tax.sum(0, n, scaled_length)
1242           * <=> tax = taxed_total / original_total */           * <=> tax = taxed_total / original_total */
1243          rc->pb_iboost_tax_ratio =          rc->pb_iboost_tax_ratio =
1244                  (rc->pb_iboost_tax_ratio - ivop_boost_total) /                  (rc->pb_iboost_tax_ratio - ivop_boost_total) /

Legend:
Removed from v.1241  
changed lines
  Added in v.1242

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4