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.15 2003-05-29 11:37:20 edgomez Exp $ |
* $Id: plugin_2pass2.c,v 1.1.2.16 2003-05-29 12:38:44 edgomez Exp $ |
29 |
* |
* |
30 |
*****************************************************************************/ |
*****************************************************************************/ |
31 |
|
|
873 |
int64_t pass1_length = rc->tot_length[0] + rc->tot_length[1] + rc->tot_length[2] - rc->tot_quant; |
int64_t pass1_length = rc->tot_length[0] + rc->tot_length[1] + rc->tot_length[2] - rc->tot_quant; |
874 |
double scaler; |
double scaler; |
875 |
int i, num_MBs; |
int i, num_MBs; |
|
int min_size[3]; |
|
876 |
|
|
877 |
/* Let's compute a linear scaler in order to perform curve scaling */ |
/* Let's compute a linear scaler in order to perform curve scaling */ |
878 |
scaler = (double)target / (double)pass1_length; |
scaler = (double)target / (double)pass1_length; |
890 |
* Compute min frame lengths (for each frame type) according to the number |
* Compute min frame lengths (for each frame type) according to the number |
891 |
* of MBs. We sum all blocks count from frame 0 (should be an IFrame, so |
* of MBs. We sum all blocks count from frame 0 (should be an IFrame, so |
892 |
* blocks[0] should be enough) to know how many MBs there are. |
* blocks[0] should be enough) to know how many MBs there are. |
893 |
|
* |
894 |
|
* We compare these hardcoded values with observed values in first pass |
895 |
|
* (determined in pre_process0).Then we keep the real minimum. |
896 |
*/ |
*/ |
897 |
num_MBs = rc->stats[0].blks[0] + rc->stats[0].blks[1] + rc->stats[0].blks[2]; |
num_MBs = rc->stats[0].blks[0] + rc->stats[0].blks[1] + rc->stats[0].blks[2]; |
898 |
min_size[0] = ((num_MBs*22) + 240) / 8; |
|
899 |
min_size[1] = ((num_MBs) + 88) / 8; |
if(rc->min_length[0] > ((num_MBs*22) + 240) / 8) |
900 |
min_size[2] = 8; |
rc->min_length[0] = ((num_MBs*22) + 240) / 8; |
901 |
|
|
902 |
|
if(rc->min_length[1] > ((num_MBs) + 88) / 8) |
903 |
|
rc->min_length[1] = ((num_MBs) + 88) / 8; |
904 |
|
|
905 |
|
if(rc->min_length[2] > 8) |
906 |
|
rc->min_length[2] = 8; |
907 |
|
|
908 |
/* |
/* |
909 |
* Perform an initial scale pass. |
* Perform an initial scale pass. |
924 |
len = (int)((double)s->length * scaler * s->weight / rc->avg_weight); |
len = (int)((double)s->length * scaler * s->weight / rc->avg_weight); |
925 |
|
|
926 |
/* Compare with the computed minimum */ |
/* Compare with the computed minimum */ |
927 |
if (len < min_size[s->type-1]) { |
if (len < rc->min_length[s->type-1]) { |
928 |
/* force frame size to our computed minimum */ |
/* force frame size to our computed minimum */ |
929 |
s->scaled_length = min_size[s->type-1]; |
s->scaled_length = rc->min_length[s->type-1]; |
930 |
target -= s->scaled_length; |
target -= s->scaled_length; |
931 |
pass1_length -= s->length; |
pass1_length -= s->length; |
932 |
} else { |
} else { |