#if CONFIG_MULTI_RES_ENCODING
#include "mr_dissim.h"
#endif
+#include "encodeframe.h"
#include <math.h>
#include <stdio.h>
static void alloc_raw_frame_buffers(VP8_COMP *cpi)
{
+#if VP8_TEMPORAL_ALT_REF
int width = (cpi->oxcf.Width + 15) & ~15;
int height = (cpi->oxcf.Height + 15) & ~15;
+#endif
cpi->lookahead = vp8_lookahead_init(cpi->oxcf.Width, cpi->oxcf.Height,
cpi->oxcf.lag_in_frames);
#endif
}
-void update_layer_contexts (VP8_COMP *cpi)
+static void update_layer_contexts (VP8_COMP *cpi)
{
VP8_CONFIG *oxcf = &cpi->oxcf;
if (!oxcf)
return;
+#if CONFIG_MULTITHREAD
+ /* wait for the last picture loopfilter thread done */
+ if (cpi->b_lpf_running)
+ {
+ sem_wait(&cpi->h_event_end_lpf);
+ cpi->b_lpf_running = 0;
+ }
+#endif
+
if (cm->version != oxcf->Version)
{
cm->version = oxcf->Version;
vp8_setup_version(cm);
}
+ last_w = cpi->oxcf.Width;
+ last_h = cpi->oxcf.Height;
+
cpi->oxcf = *oxcf;
switch (cpi->oxcf.Mode)
cpi->target_bandwidth = cpi->oxcf.target_bandwidth;
- last_w = cm->Width;
- last_h = cm->Height;
-
cm->Width = cpi->oxcf.Width;
cm->Height = cpi->oxcf.Height;
- cm->horiz_scale = cpi->horiz_scale;
- cm->vert_scale = cpi->vert_scale;
+ /* TODO(jkoleszar): if an internal spatial resampling is active,
+ * and we downsize the input image, maybe we should clear the
+ * internal scale immediately rather than waiting for it to
+ * correct.
+ */
// VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
if (cpi->oxcf.Sharpness > 7)
cm->Height = (vs - 1 + cpi->oxcf.Height * vr) / vs;
}
- if (last_w != cm->Width || last_h != cm->Height)
+ if (last_w != cpi->oxcf.Width || last_h != cpi->oxcf.Height)
cpi->force_next_frame_intra = 1;
if (((cm->Width + 15) & 0xfffffff0) !=
return force_recode;
}
-void update_reference_frames(VP8_COMMON *cm)
+static void update_reference_frames(VP8_COMMON *cm)
{
YV12_BUFFER_CONFIG *yv12_fb = cm->yv12_fb;
int Loop = 0;
int loop_count;
- int this_q;
- int last_zbin_oq;
+ VP8_COMMON *cm = &cpi->common;
+ int active_worst_qchanged = 0;
+
+#if !(CONFIG_REALTIME_ONLY)
int q_low;
int q_high;
int zbin_oq_high;
int zbin_oq_low = 0;
int top_index;
int bottom_index;
- VP8_COMMON *cm = &cpi->common;
- int active_worst_qchanged = 0;
-
int overshoot_seen = 0;
int undershoot_seen = 0;
+#endif
+
int drop_mark = cpi->oxcf.drop_frames_water_mark * cpi->oxcf.optimal_buffer_level / 100;
int drop_mark75 = drop_mark * 2 / 3;
int drop_mark50 = drop_mark / 4;
// Clear down mmx registers to allow floating point in what follows
vp8_clear_system_state();
+#if CONFIG_MULTITHREAD
+ /* wait for the last picture loopfilter thread done */
+ if (cpi->b_lpf_running)
+ {
+ sem_wait(&cpi->h_event_end_lpf);
+ cpi->b_lpf_running = 0;
+ }
+#endif
+
// Test code for segmentation of gf/arf (0,0)
//segmentation_test_function( cpi);
{
cpi->decimation_factor = 1;
}
-
//vpx_log("Encoder: Decimation Factor: %d \n",cpi->decimation_factor);
}
// Determine initial Q to try
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
- last_zbin_oq = cpi->zbin_over_quant;
+
+#if !(CONFIG_REALTIME_ONLY)
// Set highest allowed value for Zbin over quant
if (cm->frame_type == KEY_FRAME)
}
else
zbin_oq_high = ZBIN_OQ_MAX;
+#endif
// Setup background Q adjustment for error resilient mode.
// For multi-layer encodes only enable this for the base layer.
vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &frame_over_shoot_limit);
+#if !(CONFIG_REALTIME_ONLY)
// Limit Q range for the adaptive loop.
bottom_index = cpi->active_best_quality;
top_index = cpi->active_worst_quality;
q_low = cpi->active_best_quality;
q_high = cpi->active_worst_quality;
+#endif
vp8_save_coding_context(cpi);
loop_count = 0;
-
scale_and_extend_source(cpi->un_scaled_source, cpi);
+
#if !(CONFIG_REALTIME_ONLY) && CONFIG_POSTPROC && !(CONFIG_TEMPORAL_DENOISING)
if (cpi->oxcf.noise_sensitivity > 0)
*/
vp8_set_quantizer(cpi, Q);
- this_q = Q;
// setup skip prob for costing in mode/mv decision
if (cpi->common.mb_no_coeff_skip)
vp8_setup_key_frame(cpi);
}
-#if CONFIG_MULTITHREAD
- /* wait for the last picture loopfilter thread done */
- if (cpi->b_lpf_running)
- {
- sem_wait(&cpi->h_event_end_lpf);
- cpi->b_lpf_running = 0;
- }
-#endif
+
#if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING
{
if (cpi->compressor_speed == 2)
{
/* we don't do re-encoding in realtime mode
- * if key frame is decided than we force it on next frame */
+ * if key frame is decided then we force it on next frame */
cpi->force_next_frame_intra = key_frame_decision;
}
+#if !(CONFIG_REALTIME_ONLY)
else if (key_frame_decision)
{
// Reset all our sizing numbers and recode
continue;
}
+#endif
}
vp8_clear_system_state();
while ((cpi->active_worst_quality < cpi->worst_quality) && (over_size_percent > 0))
{
cpi->active_worst_quality++;
- top_index = cpi->active_worst_quality;
+
over_size_percent = (int)(over_size_percent * 0.96); // Assume 1 qstep = about 4% on frame size.
}
-
+#if !(CONFIG_REALTIME_ONLY)
+ top_index = cpi->active_worst_quality;
+#endif
// If we have updated the active max Q do not call vp8_update_rate_correction_factors() this loop.
active_worst_qchanged = 1;
}
// Clamp cpi->zbin_over_quant
cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ? zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ? zbin_oq_high : cpi->zbin_over_quant;
- //Loop = (Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant);
Loop = Q != last_q;
- last_zbin_oq = cpi->zbin_over_quant;
}
else
#endif
}
// adjust frame rates based on timestamps given
- if (!cm->refresh_alt_ref_frame || (cpi->oxcf.number_of_layers > 1))
+ if (cm->show_frame)
{
int64_t this_duration;
int step = 0;