[cvs] / xvidcore / src / plugins / plugin_2pass2.c Repository:
ViewVC logotype

Diff of /xvidcore/src/plugins/plugin_2pass2.c

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

revision 1.5, Sat Jun 12 13:53:19 2004 UTC revision 1.9, Tue Mar 9 10:00:14 2010 UTC
# Line 1  Line 1 
1  /******************************************************************************  /******************************************************************************
2   *   *
3   *  XviD Bit Rate Controller Library   *  Xvid Bit Rate Controller Library
4   *  - VBR 2 pass bitrate controller implementation -   *  - VBR 2 pass bitrate controller implementation -
5   *   *
6   *  Copyright (C)      2002 Foxer <email?>   *  Copyright (C)      2002 Benjamin Lambert <foxer@hotmail.com>
7   *                     2002 Dirk Knop <dknop@gwdg.de>   *                     2002 Dirk Knop <dknop@gwdg.de>
8   *                2002-2003 Edouard Gomez <ed.gomez@free.fr>   *                2002-2003 Edouard Gomez <ed.gomez@free.fr>
9   *                     2003 Pete Ross <pross@xvid.org>   *                     2003 Pete Ross <pross@xvid.org>
10   *   *
11   *  This curve treatment algorithm is the one originally implemented by Foxer   *  This curve treatment algorithm is the one originally implemented by Foxer
12   *  and tuned by Dirk Knop for the XviD vfw frontend.   *  and tuned by Dirk Knop for the Xvid vfw frontend.
13   *   *
14   *  This program is free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
15   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 219  Line 219 
219           *--------------------------------*/           *--------------------------------*/
220          double desired_total;          double desired_total;
221          double real_total;          double real_total;
222    
223            int scaled_frames;
224  } rc_2pass2_t;  } rc_2pass2_t;
225    
226    
# Line 344  Line 346 
346    
347          rc->fq_error = 0;          rc->fq_error = 0;
348          rc->min_quant = 1;          rc->min_quant = 1;
349            rc->scaled_frames = 0;
350    
351          /* 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
352           * the rc structure */           * the rc structure */
# Line 457  Line 460 
460          if (rc->param.vbv_size==0) {          if (rc->param.vbv_size==0) {
461                  rc->param.vbv_size      =  3145728;                  rc->param.vbv_size      =  3145728;
462                  rc->param.vbv_initial   =  2359296;                  rc->param.vbv_initial   =  2359296;
463                  rc->param.vbv_maxrate  =  4000000;                  rc->param.vbv_maxrate   =  4854000;
464                  rc->param.vbv_peakrate = 10000000;                  rc->param.vbv_peakrate  =  8000000;
465          }          }
466  #endif  #endif
467    
# Line 794  Line 797 
797                  rc->last_quant[s->type-1] = data->quant;                  rc->last_quant[s->type-1] = data->quant;
798    
799          /* Don't forget to force 1st pass frame type ;-) */          /* Don't forget to force 1st pass frame type ;-) */
800            if (rc->scaled_frames)
801          data->type = s->type;          data->type = s->type;
802    
803            rc->scaled_frames++;
804          return 0;          return 0;
805  }  }
806    
# Line 857  Line 862 
862                  rc->KFoverflow -= rc->KFoverflow_partial;                  rc->KFoverflow -= rc->KFoverflow_partial;
863          }          }
864    
865          rc->overflow += (s->error = s->desired_length - data->length);          s->error = s->desired_length - data->length;
866          rc->real_total += data->length;          rc->real_total += data->length;
867    
868          DPRINTF(XVID_DEBUG_RC, "[xvid rc] -- frame:%d type:%c quant:%d stats:%d scaled:%d desired:%d actual:%d error:%d overflow:%.2f\n",          DPRINTF(XVID_DEBUG_RC, "[xvid rc] -- frame:%d type:%c quant:%d stats:%d scaled:%d desired:%d actual:%d error:%d overflow:%.2f\n",
# Line 954  Line 959 
959          /* We are done with the file */          /* We are done with the file */
960          fclose(f);          fclose(f);
961    
962          return(0);          if (!rc->num_keyframes) return (-1); /* No keyframes? Then something is wrong */
963            else return(0);
964  }  }
965    
966  /* open stats file(s) and read into rc->stats array */  /* open stats file(s) and read into rc->stats array */
# Line 1461  Line 1467 
1467           * typical values from DivX Home Theater profile:           * typical values from DivX Home Theater profile:
1468           *  vbv_size= 384*1024 (384kB)           *  vbv_size= 384*1024 (384kB)
1469           *  vbv_initial= 288*1024 (75% fill)           *  vbv_initial= 288*1024 (75% fill)
1470           *  maxrate= 4000000 (4MBps)           *  maxrate= 4854000 (4.854MBps)
1471           *  peakrate= 10000000 (10MBps)           *  peakrate= 8000000 (8MBps)
1472           *           *
1473           *  PAL: offset3s = 75 (3 seconds of 25fps)           *  PAL: offset3s = 75 (3 seconds of 25fps)
1474           *  NTSC: offset3s = 90 (3 seconds of 29.97fps) or 72 (3 seconds of 23.976fps)           *  NTSC: offset3s = 90 (3 seconds of 29.97fps) or 72 (3 seconds of 23.976fps)
# Line 1490  Line 1496 
1496                  if (i>=offset3s)                  if (i>=offset3s)
1497                          bytes3s -= rc->stats[i-offset3s].scaled_length;                          bytes3s -= rc->stats[i-offset3s].scaled_length;
1498    
1499                  if (8.f*bytes3s > 3*peakrate)      /* ignore peakrate constraint if peakrate is <= 0.f */
1500                    if (peakrate>0.f && 8.f*bytes3s > 3*peakrate)
1501                          return(VBV_PEAKRATE);                          return(VBV_PEAKRATE);
1502    
1503                  /* update vbv fill level */                  /* update vbv fill level */

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

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