710 |
int overflow; |
int overflow; |
711 |
int credits_pos; |
int credits_pos; |
712 |
int capped_to_max_framesize = 0; |
int capped_to_max_framesize = 0; |
713 |
|
int KFdistance, KF_min_size; |
714 |
|
|
715 |
if (codec->framenum == 0) |
if (codec->framenum == 0) |
716 |
{ |
{ |
930 |
|
|
931 |
twopass->desired_bytes2 = bytes2; |
twopass->desired_bytes2 = bytes2; |
932 |
|
|
933 |
|
if (frame->intra) |
934 |
|
{ |
935 |
|
KFdistance = codec->twopass.keyframe_locations[codec->twopass.KF_idx] - |
936 |
|
codec->twopass.keyframe_locations[codec->twopass.KF_idx - 1]; |
937 |
|
|
938 |
|
if (KFdistance < codec->config.kftreshold) |
939 |
|
{ |
940 |
|
KFdistance = KFdistance - codec->config.min_key_interval; |
941 |
|
|
942 |
|
if (KFdistance >= 0) |
943 |
|
{ |
944 |
|
KF_min_size = bytes2 * (100 - codec->config.kfreduction) / 100; |
945 |
|
if (KF_min_size < 1) |
946 |
|
KF_min_size = 1; |
947 |
|
|
948 |
|
bytes2 = KF_min_size + (bytes2 - KF_min_size) * KFdistance / |
949 |
|
(codec->config.kftreshold - codec->config.min_key_interval); |
950 |
|
|
951 |
|
if (bytes2 < 1) |
952 |
|
bytes2 = 1; |
953 |
|
} |
954 |
|
} |
955 |
|
} |
956 |
|
|
957 |
// Foxer: scale overflow in relation to average size, so smaller frames don't get |
// Foxer: scale overflow in relation to average size, so smaller frames don't get |
958 |
// too much/little bitrate |
// too much/little bitrate |
959 |
overflow = (int)((double)overflow * bytes2 / twopass->average_frame); |
overflow = (int)((double)overflow * bytes2 / twopass->average_frame); |