Home | History | Annotate | Download | only in encoder

Lines Matching refs:twopass

83     cpi->twopass.stats_in = Position;
88 if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
91 *next_frame = *cpi->twopass.stats_in;
100 FIRSTPASS_STATS * fps_ptr = cpi->twopass.stats_in;
105 if ( &fps_ptr[offset] >= cpi->twopass.stats_in_end )
110 if ( &fps_ptr[offset] < cpi->twopass.stats_in_start )
120 if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
123 *fps = *cpi->twopass.stats_in;
124 cpi->twopass.stats_in =
125 (void*)((char *)cpi->twopass.stats_in + sizeof(FIRSTPASS_STATS));
265 double av_err = ( cpi->twopass.total_stats.ssim_weighted_pred_err /
266 cpi->twopass.total_stats.count );
384 max_bits = (int)(((double)cpi->twopass.bits_left / (cpi->twopass.total_stats.count - (double)cpi->common.current_video_frame)) * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0));
396 zero_stats(&cpi->twopass.total_stats);
401 output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.total_stats);
848 memcpy(&cpi->twopass.this_frame_stats,
851 output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.this_frame_stats);
852 accumulate_stats(&cpi->twopass.total_stats, &fps);
859 (cpi->twopass.this_frame_stats.pcnt_inter > 0.20) &&
860 ((cpi->twopass.this_frame_stats.intra_error / cpi->twopass.this_frame_stats.coded_error) > 2.0))
989 return cpi->twopass.maxq_max_limit; /* Highest value allowed */
1008 cpi->twopass.est_max_qcorrection_factor -= 0.005;
1010 cpi->twopass.est_max_qcorrection_factor += 0.005;
1012 cpi->twopass.est_max_qcorrection_factor =
1013 (cpi->twopass.est_max_qcorrection_factor < 0.1)
1015 : (cpi->twopass.est_max_qcorrection_factor > 10.0)
1016 ? 10.0 : cpi->twopass.est_max_qcorrection_factor;
1034 pow( 0.98, (double)cpi->twopass.maxq_min_limit ));
1039 for (Q = cpi->twopass.maxq_min_limit; Q < cpi->twopass.maxq_max_limit; Q++)
1051 * speed_correction * cpi->twopass.est_max_qcorrection_factor
1052 * cpi->twopass.section_max_qfactor
1077 ((int)cpi->twopass.total_stats.count >> 8)) &&
1080 cpi->twopass.maxq_max_limit = ((cpi->ni_av_qi + 32) < cpi->worst_quality)
1082 cpi->twopass.maxq_min_limit = ((cpi->ni_av_qi - 32) > cpi->best_quality)
1135 clip_iiratio = cpi->twopass.total_stats.intra_error /
1136 DOUBLE_DIVIDE_CHECK(cpi->twopass.total_stats.coded_error);
1214 cpi->twopass.est_max_qcorrection_factor *
1334 zero_stats(&cpi->twopass.total_stats);
1335 zero_stats(&cpi->twopass.total_left_stats);
1337 if (!cpi->twopass.stats_in_end)
1340 cpi->twopass.total_stats = *cpi->twopass.stats_in_end;
1341 cpi->twopass.total_left_stats = cpi->twopass.total_stats;
1349 vp8_new_frame_rate(cpi, 10000000.0 * cpi->twopass.total_stats.count / cpi->twopass.total_stats.duration);
1352 cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats.duration * cpi->oxcf.target_bandwidth / 10000000.0) ;
1353 cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats.duration * two_pass_min_rate / 10000000.0);
1360 cpi->twopass.kf_intra_err_min = KF_MB_INTRA_MIN * cpi->common.MBs;
1361 cpi->twopass.gf_intra_err_min = GF_MB_INTRA_MIN * cpi->common.MBs;
1370 start_pos = cpi->twopass.stats_in; /* Note starting "file" position */
1379 cpi->twopass.avg_iiratio = sum_iiratio / DOUBLE_DIVIDE_CHECK((double)cpi->twopass.total_stats.count);
1389 start_pos = cpi->twopass.stats_in; /* Note starting "file" position */
1391 cpi->twopass.modified_error_total = 0.0;
1392 cpi->twopass.modified_error_used = 0.0;
1396 cpi->twopass.modified_error_total += calculate_modified_err(cpi, &this_frame);
1398 cpi->twopass.modified_error_left = cpi->twopass.modified_error_total;
1468 FIRSTPASS_STATS * position = cpi->twopass.stats_in;
1588 if (this_frame->intra_error > cpi->twopass.gf_intra_err_min)
1592 frame_boost = (IIFACTOR * cpi->twopass.gf_intra_err_min /
1765 cpi->twopass.gf_group_bits = 0;
1766 cpi->twopass.gf_decay_rate = 0;
1770 start_pos = cpi->twopass.stats_in;
1795 while (((i < cpi->twopass.static_scene_max_gf_interval) ||
1796 ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)) &&
1797 (i < cpi->twopass.frames_to_key))
1855 ((cpi->twopass.frames_to_key - i) >= MIN_GF_INTERVAL) &&
1873 cpi->twopass.gf_decay_rate =
1906 if ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)
1908 while (i < cpi->twopass.frames_to_key)
1915 if (i < cpi->twopass.frames_to_key)
1934 (i <= (cpi->twopass.frames_to_key - MIN_GF_INTERVAL)) &&
1947 (cpi->twopass.gf_decay_rate <=
1964 if ((cpi->twopass.kf_group_bits > 0) &&
1965 (cpi->twopass.kf_group_error_left > 0))
1967 group_bits = (int)((double)cpi->twopass.kf_group_bits *
1968 (gf_group_err / (double)cpi->twopass.kf_group_error_left));
2047 frames_after_arf = (int)(cpi->twopass.total_stats.count -
2102 * where cpi->twopass.kf_group_bits is tied to cpi->twopass.bits_left.
2106 if (cpi->twopass.frames_to_key >= (int)(cpi->twopass.total_stats.count -
2109 cpi->twopass.kf_group_bits =
2110 (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0;
2114 if ((cpi->twopass.kf_group_bits > 0) &&
2115 (cpi->twopass.kf_group_error_left > 0))
2117 cpi->twopass.gf_group_bits =
2118 (int)((double)cpi->twopass.kf_group_bits *
2119 (gf_group_err / (double)cpi->twopass.kf_group_error_left));
2122 cpi->twopass.gf_group_bits = 0;
2124 cpi->twopass.gf_group_bits = (int)(
2125 (cpi->twopass.gf_group_bits < 0)
2127 : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits)
2128 ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits);
2130 /* Clip cpi->twopass.gf_group_bits based on user supplied data rate
2133 if (cpi->twopass.gf_group_bits > max_bits * cpi->baseline_gf_interval)
2134 cpi->twopass.gf_group_bits = max_bits * cpi->baseline_gf_interval;
2140 cpi->twopass.modified_error_used += gf_group_err;
2195 (cpi->twopass.gf_group_bits /
2208 (double)cpi->twopass.kf_group_bits *
2210 DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left);
2227 (int)((double)cpi->twopass.kf_group_bits *
2229 DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left));
2240 if (cpi->twopass.gf_bits > (int)(cpi->buffer_level >> 1))
2241 cpi->twopass.gf_bits = (int)(cpi->buffer_level >> 1);
2253 cpi->twopass.gf_bits = gf_bits;
2264 cpi->twopass.kf_group_error_left -= (int64_t)gf_group_err;
2265 cpi->twopass.kf_group_bits -= cpi->twopass.gf_group_bits;
2267 if (cpi->twopass.kf_group_bits < 0)
2268 cpi->twopass.kf_group_bits = 0;
2276 cpi->twopass.gf_group_error_left = (int)(gf_group_err -
2279 cpi->twopass.gf_group_error_left = (int) gf_group_err;
2281 cpi->twopass.gf_group_bits -= cpi->twopass.gf_bits - cpi->min_frame_bandwidth;
2283 if (cpi->twopass.gf_group_bits < 0)
2284 cpi->twopass.gf_group_bits = 0;
2288 * calculation of cpi->twopass.alt_extra_bits.
2305 cpi->twopass.alt_extra_bits =
2306 (cpi->twopass.gf_group_bits * pct_extra) / 100;
2307 cpi->twopasstwopass.alt_extra_bits;
2308 cpi->twopass.alt_extra_bits /=
2312 cpi->twopass.alt_extra_bits = 0;
2315 cpi->twopass.alt_extra_bits = 0;
2335 cpi->twopass.section_intra_rating = (unsigned int)
2340 cpi->twopass.section_max_qfactor = 1.0 - ((Ratio - 10.0) * 0.025);
2342 if (cpi->twopass.section_max_qfactor < 0.80)
2343 cpi->twopass.section_max_qfactor = 0.80;
2363 if (cpi->twopass.gf_group_error_left > 0)
2364 err_fraction = modified_err / cpi->twopass.gf_group_error_left;
2369 target_frame_size = (int)((double)cpi->twopass.gf_group_bits * err_fraction);
2371 /* Clip to target size to 0 - max_bits (or cpi->twopass.gf_group_bits)
2381 if (target_frame_size > cpi->twopass.gf_group_bits)
2382 target_frame_size = cpi->twopass.gf_group_bits;
2386 cpi->twopass.gf_group_error_left -= (int)modified_err;
2387 cpi->twopass.gf_group_bits -= target_frame_size;
2389 if (cpi->twopass.gf_group_bits < 0)
2390 cpi->twopass.gf_group_bits = 0;
2399 target_frame_size += cpi->twopass.alt_extra_bits;
2409 int frames_left = (int)(cpi->twopass.total_stats.count - cpi->common.current_video_frame);
2419 if (!cpi->twopass.stats_in)
2433 if (cpi->twopass.frames_to_key == 0)
2448 cpi->twopass.gf_group_bits = (int)cpi->twopass.kf_group_bits;
2449 cpi->twopass.gf_group_error_left =
2450 (int)cpi->twopass.kf_group_error_left;
2451 cpi->baseline_gf_interval = cpi->twopass.frames_to_key;
2496 cpi->frames_till_gf_update_due = cpi->twopass.frames_to_key;
2514 cpi->twopass.this_iiratio = (unsigned int)(this_frame_intra_error /
2520 cpi->twopass.next_iiratio = (unsigned int)(next_frame.intra_error /
2534 cpi, &cpi->twopass.total_left_stats );
2539 cpi->twopass.est_max_qcorrection_factor = 1.0;
2548 &cpi->twopass.total_left_stats,
2549 (int)(cpi->twopass.bits_left / frames_left),
2558 cpi->twopass.maxq_max_limit = cpi->worst_quality;
2559 cpi->twopass.maxq_min_limit = cpi->best_quality;
2563 &cpi->twopass.total_left_stats,
2564 (int)(cpi->twopass.bits_left / frames_left),
2573 cpi->twopass.maxq_max_limit = ((tmp_q + 32) < cpi->worst_quality)
2575 cpi->twopass.maxq_min_limit = ((tmp_q - 32) > cpi->best_quality)
2588 (((unsigned int)cpi->twopass.total_stats.count * 255)>>8)) &&
2590 (unsigned int)cpi->twopass.total_stats.count) )
2597 &cpi->twopass.total_left_stats,
2598 (int)(cpi->twopass.bits_left / frames_left),
2611 cpi->twopass.frames_to_key --;
2614 subtract_stats(&cpi->twopass.total_left_stats, &this_frame );
2652 start_pos = cpi->twopass.stats_in;
2729 start_position = cpi->twopass.stats_in;
2744 cpi->twopass.frames_to_key = 1;
2749 cpi->twopass.kf_group_bits = 0;
2750 cpi->twopass.kf_group_error_left = 0;
2756 while (cpi->twopass.stats_in < cpi->twopass.stats_in_end)
2811 cpi->twopass.frames_to_key ++;
2816 if (cpi->twopass.frames_to_key >= 2 *(int)cpi->key_frame_frequency)
2819 cpi->twopass.frames_to_key ++;
2830 && cpi->twopass.frames_to_key > (int)cpi->key_frame_frequency )
2832 FIRSTPASS_STATS *current_pos = cpi->twopass.stats_in;
2835 cpi->twopass.frames_to_key /= 2;
2848 for( i = 0; i < cpi->twopass.frames_to_key; i++ )
2868 if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end)
2883 if ((cpi->twopass.bits_left > 0) && (cpi->twopass.modified_error_left > 0.0))
2894 cpi->twopass.kf_group_bits = (int64_t)( cpi->twopass.bits_left *
2896 cpi->twopass.modified_error_left ));
2899 max_grp_bits = (int64_t)max_bits * (int64_t)cpi->twopass.frames_to_key;
2900 if (cpi->twopass.kf_group_bits > max_grp_bits)
2901 cpi->twopass.kf_group_bits = max_grp_bits;
2921 (int64_t)cpi->twopass.frames_to_key;
2932 if (cpi->twopass.kf_group_bits < min_group_bits)
2933 cpi->twopass.kf_group_bits = min_group_bits;
2936 else if (cpi->twopass.kf_group_bits < av_group_bits)
2939 cpi->twopass.kf_group_bits;
2941 cpi->twopass.kf_group_bits +=
2950 cpi->twopass.kf_group_bits = 0;
2962 for (i = 0 ; i < cpi->twopass.frames_to_key ; i++)
2969 if (next_frame.intra_error > cpi->twopass.kf_intra_err_min)
2973 r = (IIKFACTOR2 * cpi->twopass.kf_intra_err_min /
3004 for (i = 0 ; i < cpi->twopass.frames_to_key ; i++)
3012 cpi->twopass.section_intra_rating = (unsigned int)
3017 cpi->twopass.section_max_qfactor = 1.0 - ((Ratio - 10.0) * 0.025);
3019 if (cpi->twopass.section_max_qfactor < 0.80)
3020 cpi->twopass.section_max_qfactor = 0.80;
3059 int Counter = cpi->twopass.frames_to_key;
3104 * cpi->twopass.frames_to_key-1 because key frame itself is taken
3110 ((cpi->twopass.frames_to_key - 1) * 10) + kf_boost;
3115 ((cpi->twopass.frames_to_key - 1) * 100) + kf_boost;
3125 cpi->twopass.kf_group_bits = (cpi->twopass.kf_group_bits < 0) ? 0 : cpi->twopass.kf_group_bits;
3128 cpi->twopass.kf_bits = (int)((double)kf_boost * ((double)cpi->twopass.kf_group_bits / (double)allocation_chunks));
3133 if (cpi->twopass.kf_bits > (int)((3 * cpi->buffer_level) >> 2))
3134 cpi->twopass.kf_bits = (int)((3 * cpi->buffer_level) >> 2);
3142 if (kf_mod_err < kf_group_err / cpi->twopass.frames_to_key)
3145 ((double)cpi->twopass.bits_left *
3146 (kf_mod_err * (double)cpi->twopass.frames_to_key) /
3147 DOUBLE_DIVIDE_CHECK(cpi->twopass.modified_error_left));
3152 if (cpi->twopass.kf_bits > alt_kf_bits)
3154 cpi->twopass.kf_bits = alt_kf_bits;
3164 (int)((double)cpi->twopass.bits_left *
3166 DOUBLE_DIVIDE_CHECK(cpi->twopass.modified_error_left)));
3168 if (alt_kf_bits > cpi->twopass.kf_bits)
3170 cpi->twopass.kf_bits = alt_kf_bits;
3174 cpi->twopass.kf_group_bits -= cpi->twopass.kf_bits;
3176 cpi->twopass.kf_bits += cpi->min_frame_bandwidth;
3179 cpi->per_frame_bandwidth = cpi->twopass.kf_bits;
3182 cpi->target_bandwidth = (int)(cpi->twopass.kf_bits *
3187 cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err);
3192 cpi->twopass.modified_error_left -= kf_group_err;
3209 double err_per_frame = kf_group_err / cpi->twopass.frames_to_key;
3238 (cpi->twopass.kf_group_bits / cpi->twopass.frames_to_key);
3271 cpi->twopass.frames_to_key));
3276 fprintf(f, " %8d %8d %8d %8d %12.0f %8d %8d %8d\n", cpi->common.current_video_frame, kf_q, cpi->common.horiz_scale, cpi->common.vert_scale, kf_group_err / cpi->twopass.frames_to_key, (int)(cpi->twopass.kf_group_bits / cpi->twopass.frames_to_key), new_height, new_width);
3297 int64_t clip_bits = (int64_t)(cpi->twopass.total_stats.count * cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->frame_rate));
3347 fprintf(f, "******** %8d %8d %8d %12.0f %8d %8d %8d\n", kf_q, cpi->common.horiz_scale, cpi->common.vert_scale, kf_group_err / cpi->twopass.frames_to_key, (int)(cpi->twopass.kf_group_bits / cpi->twopass.frames_to_key), new_height, new_width);