cpi->cq_target_quality = cpi->oxcf.cq_level;
- // Only allow dropped frames in buffered mode
- cpi->drop_frames_allowed = cpi->oxcf.allow_df && cpi->buffered_mode;
-
if (!cm->use_bilinear_mc_filter)
cm->mcomp_filter_type = SIXTAP;
else
cpi->avg_q = vp8_convert_qindex_to_q( cpi->oxcf.worst_allowed_q );
cpi->total_byte_count = 0;
- cpi->drop_frame = 0;
- cpi->drop_count = 0;
- cpi->max_drop_count = 0;
- cpi->max_consec_dropped_frames = 4;
-
cpi->rate_correction_factor = 1.0;
cpi->key_frame_rate_correction_factor = 1.0;
cpi->gf_rate_correction_factor = 1.0;
fclose(yframe);
}
#endif
-// return of 0 means drop frame
// Function to test for conditions that indeicate we should loop
// back and recode a frame.
int overshoot_seen = FALSE;
int undershoot_seen = FALSE;
- 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;
- int drop_mark25 = drop_mark / 8;
// Clear down mmx registers to allow floating point in what follows
vp8_clear_system_state();
// Test code for new segment features
init_seg_features( cpi );
- if (cpi->drop_frames_allowed)
- {
- // The reset to decimation 0 is only done here for one pass.
- // Once it is set two pass leaves decimation on till the next kf.
- if ((cpi->buffer_level > drop_mark) && (cpi->decimation_factor > 0))
- cpi->decimation_factor --;
-
- if (cpi->buffer_level > drop_mark75 && cpi->decimation_factor > 0)
- cpi->decimation_factor = 1;
-
- else if (cpi->buffer_level < drop_mark25 && (cpi->decimation_factor == 2 || cpi->decimation_factor == 3))
- {
- cpi->decimation_factor = 3;
- }
- else if (cpi->buffer_level < drop_mark50 && (cpi->decimation_factor == 1 || cpi->decimation_factor == 2))
- {
- cpi->decimation_factor = 2;
- }
- else if (cpi->buffer_level < drop_mark75 && (cpi->decimation_factor == 0 || cpi->decimation_factor == 1))
- {
- cpi->decimation_factor = 1;
- }
-
- //vpx_log("Encoder: Decimation Factor: %d \n",cpi->decimation_factor);
- }
-
- // The following decimates the frame rate according to a regular pattern (i.e. to 1/2 or 2/3 frame rate)
- // This can be used to help prevent buffer under-run in CBR mode. Alternatively it might be desirable in
- // some situations to drop frame rate but throw more bits at each frame.
- //
- // Note that dropping a key frame can be problematic if spatial resampling is also active
- if (cpi->decimation_factor > 0)
- {
- switch (cpi->decimation_factor)
- {
- case 1:
- cpi->per_frame_bandwidth = cpi->per_frame_bandwidth * 3 / 2;
- break;
- case 2:
- cpi->per_frame_bandwidth = cpi->per_frame_bandwidth * 5 / 4;
- break;
- case 3:
- cpi->per_frame_bandwidth = cpi->per_frame_bandwidth * 5 / 4;
- break;
- }
-
- // Note that we should not throw out a key frame (especially when spatial resampling is enabled).
- if ((cm->frame_type == KEY_FRAME))
- {
- cpi->decimation_count = cpi->decimation_factor;
- }
- else if (cpi->decimation_count > 0)
- {
- cpi->decimation_count --;
- cpi->bits_off_target += cpi->av_per_frame_bandwidth;
-
- // Clip the buffer level at the maximum buffer size
- if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
- cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
-
- cm->current_video_frame++;
- cpi->frames_since_key++;
-
-#if CONFIG_INTERNAL_STATS
- cpi->count ++;
-#endif
-
- cpi->buffer_level = cpi->bits_off_target;
-
- return;
- }
- else
- cpi->decimation_count = cpi->decimation_factor;
- }
-
// Decide how big to make the frame
if (!vp8_pick_frame_size(cpi))
{
cpi->ni_av_qi = (cpi->ni_tot_qi / cpi->ni_frames);
}
- // Set the count for maximum consequative dropped frames based upon the ratio of
- // this frame size to the target average per frame bandwidth.
- // (cpi->av_per_frame_bandwidth > 0) is just a sanity check to prevent / 0.
- if (cpi->drop_frames_allowed && (cpi->av_per_frame_bandwidth > 0))
- {
- cpi->max_drop_count = cpi->projected_frame_size / cpi->av_per_frame_bandwidth;
-
- if (cpi->max_drop_count > cpi->max_consec_dropped_frames)
- cpi->max_drop_count = cpi->max_consec_dropped_frames;
- }
-
// Update the buffer level variable.
// Non-viewable frames are a special case and are treated as pure overhead.
if ( !cm->show_frame )
oxcf->lag_in_frames = cfg.g_lag_in_frames;
}
- oxcf->allow_df = (cfg.rc_dropframe_thresh > 0);
- oxcf->drop_frames_water_mark = cfg.rc_dropframe_thresh;
-
// VBR only supported for now.
// CBR code has been deprectated for experimental phase.
// CQ mode not yet tested
printf("fixed_q: %d\n", oxcf->fixed_q);
printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q);
printf("best_allowed_q: %d\n", oxcf->best_allowed_q);
- printf("allow_df: %d\n", oxcf->allow_df);
- printf("drop_frames_water_mark: %d\n", oxcf->drop_frames_water_mark);
printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias);
printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section);
printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section);