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.18 2003-05-29 14:18:18 edgomez Exp $ |
* $Id: plugin_2pass2.c,v 1.1.2.23 2003-10-01 23:23:01 edgomez Exp $ |
29 |
* |
* |
30 |
*****************************************************************************/ |
*****************************************************************************/ |
31 |
|
|
96 |
double movie_curve; |
double movie_curve; |
97 |
|
|
98 |
/* dynamic */ |
/* dynamic */ |
|
|
|
99 |
int * keyframe_locations; |
int * keyframe_locations; |
100 |
stat_t * stats; |
stat_t * stats; |
101 |
|
|
243 |
} |
} |
244 |
|
|
245 |
/* Compute the target filesize */ |
/* Compute the target filesize */ |
246 |
if (rc->num_frames < create->fbase/create->fincr) { |
if (rc->param.bitrate<0) { |
247 |
|
/* if negative, bitrate equals the target (in kbytes) */ |
248 |
|
rc->target = (-rc->param.bitrate) * 1024; |
249 |
|
} else if (rc->num_frames < create->fbase/create->fincr) { |
250 |
/* Source sequence is less than 1s long, we do as if it was 1s long */ |
/* Source sequence is less than 1s long, we do as if it was 1s long */ |
251 |
rc->target = rc->param.bitrate / 8; |
rc->target = rc->param.bitrate / 8; |
252 |
} else { |
} else { |
411 |
rc->curve_comp_error += dbytes - (int)dbytes; |
rc->curve_comp_error += dbytes - (int)dbytes; |
412 |
} |
} |
413 |
|
|
|
|
|
414 |
/* |
/* |
415 |
* We can't do bigger frames than first pass, this would be stupid as first |
* We can't do bigger frames than first pass, this would be stupid as first |
416 |
* pass is quant=2 and that reaching quant=1 is not worth it. We would lose |
* pass is quant=2 and that reaching quant=1 is not worth it. We would lose |
601 |
rc->overflow += rc->KFoverflow; |
rc->overflow += rc->KFoverflow; |
602 |
rc->KFoverflow = s->desired_length - data->length; |
rc->KFoverflow = s->desired_length - data->length; |
603 |
|
|
604 |
if (kfdiff > 1) { // non-consecutive keyframes |
if (kfdiff > 1) { /* non-consecutive keyframes */ |
605 |
rc->KFoverflow_partial = rc->KFoverflow / (kfdiff - 1); |
rc->KFoverflow_partial = rc->KFoverflow / (kfdiff - 1); |
606 |
}else{ // consecutive keyframes |
}else{ /* consecutive keyframes */ |
607 |
rc->overflow += rc->KFoverflow; |
rc->overflow += rc->KFoverflow; |
608 |
rc->KFoverflow = 0; |
rc->KFoverflow = 0; |
609 |
rc->KFoverflow_partial = 0; |
rc->KFoverflow_partial = 0; |
610 |
} |
} |
611 |
rc->KF_idx++; |
rc->KF_idx++; |
612 |
} else { |
} else { |
613 |
// distribute part of the keyframe overflow |
/* distribute part of the keyframe overflow */ |
614 |
rc->overflow += s->desired_length - data->length + rc->KFoverflow_partial; |
rc->overflow += s->desired_length - data->length + rc->KFoverflow_partial; |
615 |
rc->KFoverflow -= rc->KFoverflow_partial; |
rc->KFoverflow -= rc->KFoverflow_partial; |
616 |
} |
} |
827 |
next -= create->zones[i].frame; |
next -= create->zones[i].frame; |
828 |
rc->avg_weight += (double)(next * create->zones[i].increment) / (double)create->zones[i].base; |
rc->avg_weight += (double)(next * create->zones[i].increment) / (double)create->zones[i].base; |
829 |
n += next; |
n += next; |
830 |
}else{ // XVID_ZONE_QUANT |
}else{ /* XVID_ZONE_QUANT */ |
831 |
for (j = create->zones[i].frame; j < next && j < rc->num_frames; j++ ) { |
for (j = create->zones[i].frame; j < next && j < rc->num_frames; j++ ) { |
832 |
rc->stats[j].zone_mode = XVID_ZONE_QUANT; |
rc->stats[j].zone_mode = XVID_ZONE_QUANT; |
833 |
rc->stats[j].weight = (double)create->zones[i].increment / (double)create->zones[i].base; |
rc->stats[j].weight = (double)create->zones[i].increment / (double)create->zones[i].base; |