[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 1324, Thu Jan 22 20:54:31 2004 UTC revision 1347, Sat Jan 31 14:51:56 2004 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.36 2004-01-22 20:54:31 edgomez Exp $   * $Id: plugin_2pass2.c,v 1.1.2.37 2004-01-31 14:51:56 syskin Exp $
29   *   *
30   *****************************************************************************/   *****************************************************************************/
31    
# Line 35  Line 35 
35  /* forces second pass not to be bigger than first */  /* forces second pass not to be bigger than first */
36  #undef PASS_SMALLER  #undef PASS_SMALLER
37    
38    /* automtically alters overflow controls (strength and improvement/degradation)
39            to fight most common problems without user's knowladge */
40    #define SMART_OVERFLOW_SETTING
41    
42  #include <stdio.h>  #include <stdio.h>
43  #include <math.h>  #include <math.h>
44  #include <limits.h>  #include <limits.h>
# Line 208  Line 212 
212           * ToDo: description */           * ToDo: description */
213          double fq_error;          double fq_error;
214    
215            int min_quant; /* internal minimal quant, prevents wrong quants from being used */
216    
217          /*----------------------------------          /*----------------------------------
218           * Debug           * Debug
219           *--------------------------------*/           *--------------------------------*/
# Line 311  Line 317 
317          for (i=0; i<3; i++) rc->last_quant[i] = 0;          for (i=0; i<3; i++) rc->last_quant[i] = 0;
318    
319          rc->fq_error = 0;          rc->fq_error = 0;
320            rc->min_quant = 1;
321    
322          /* Count frames (and intra frames) in the stats file, store the result into          /* Count frames (and intra frames) in the stats file, store the result into
323           * the rc structure */           * the rc structure */
# Line 707  Line 714 
714                  data->quant = data->max_quant[s->type-1];                  data->quant = data->max_quant[s->type-1];
715          }          }
716    
717            if (data->quant < rc->min_quant) data->quant = rc->min_quant;
718    
719          /* To avoid big quality jumps from frame to frame, we apply a "security"          /* To avoid big quality jumps from frame to frame, we apply a "security"
720           * rule that makes |last_quant - new_quant| <= 2. This rule only applies           * rule that makes |last_quant - new_quant| <= 2. This rule only applies
721           * to predicted frames (P and B) */           * to predicted frames (P and B) */
# Line 1119  Line 1128 
1128          /* Let's compute a linear scaler in order to perform curve scaling */          /* Let's compute a linear scaler in order to perform curve scaling */
1129          scaler = (double)(target - total_invariant) / (double)(rc->tot_weighted);          scaler = (double)(target - total_invariant) / (double)(rc->tot_weighted);
1130    
1131    #ifdef SMART_OVERFLOW_SETTING
1132            if (scaler > 0.9) {
1133                    rc->param.max_overflow_degradation *= 5;
1134                    rc->param.max_overflow_improvement *= 5;
1135                    rc->param.overflow_control_strength *= 3;
1136            } else if (scaler > 0.6) {
1137                    rc->param.max_overflow_degradation *= 2;
1138                    rc->param.max_overflow_improvement *= 2;
1139                    rc->param.overflow_control_strength *= 2;
1140            } else {
1141                    rc->min_quant = 2;
1142            }
1143    #endif
1144    
1145          /* Compute min frame lengths (for each frame type) according to the number          /* Compute min frame lengths (for each frame type) according to the number
1146           * of MBs. We sum all block type counters of frame 0, this gives us the           * of MBs. We sum all block type counters of frame 0, this gives us the
1147           * number of MBs.           * number of MBs.

Legend:
Removed from v.1324  
changed lines
  Added in v.1347

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