av1/encoder/tune_vmaf.c
// Calculates the new qindex from the VMAF motion score. This is based on the
// observation: when the motion score becomes higher, the VMAF score of the
// same source and distorted frames would become higher.
Calculates the new qindex from the VMAF motion score. This is based on the
observation: when the motion score becomes higher, the VMAF score of the
same source and distorted frames would become higher.
Calculates the new qindex from the VMAF motion score . This is based on the observation : when the motion score becomes higher the VMAF score of the same source and distorted frames would become higher .
int av1_get_vmaf_base_qindex(const AV1_COMP *const cpi, int current_qindex) {
  const AV1_COMMON *const cm = &cpi->common;
  if (cm->current_frame.frame_number == 0 || cpi->oxcf.pass == 1) {
    return current_qindex;
  }
  const int bit_depth = cpi->td.mb.e_mbd.bd;
  const double approx_sse =
      cpi->last_frame_ysse /
      (double)((1 << (bit_depth - 8)) * (1 << (bit_depth - 8)));
  const double approx_dvmaf = kBaselineVmaf - cpi->last_frame_vmaf;
  const double sse_threshold =
      0.01 * cpi->source->y_width * cpi->source->y_height;
  const double vmaf_threshold = 0.01;
  if (approx_sse < sse_threshold || approx_dvmaf < vmaf_threshold) {
    return current_qindex;
  }
  aom_clear_system_state();
  const GF_GROUP *gf_group = &cpi->gf_group;
  YV12_BUFFER_CONFIG *cur_buf = cpi->source;
  int src_index = 0;
  if (cm->show_frame == 0) {
    src_index = gf_group->arf_src_offset[gf_group->index];
    struct lookahead_entry *cur_entry =
        av1_lookahead_peek(cpi->lookahead, src_index, cpi->compressor_stage);
    cur_buf = &cur_entry->img;
  }
  assert(cur_buf);
  const struct lookahead_entry *last_entry =
      av1_lookahead_peek(cpi->lookahead, src_index - 1, cpi->compressor_stage);
  const struct lookahead_entry *next_entry =
      av1_lookahead_peek(cpi->lookahead, src_index + 1, cpi->compressor_stage);
  const YV12_BUFFER_CONFIG *next_buf = &next_entry->img;
  const YV12_BUFFER_CONFIG *last_buf =
      cm->show_frame ? cpi->last_source : &last_entry->img;
  assert(last_buf);
  const double motion =
      calc_vmaf_motion_score(cpi, cm, cur_buf, last_buf, next_buf);
  const double dvmaf = 26.11 * (1.0 - exp(-0.06 * motion));
  const double dsse = dvmaf * approx_sse / approx_dvmaf;
  const double beta = approx_sse / (dsse + approx_sse);
  const int offset = av1_get_deltaq_offset(cpi, current_qindex, beta);
  int qindex = current_qindex + offset;
  qindex = AOMMIN(qindex, MAXQ);
  qindex = AOMMAX(qindex, MINQ);
  aom_clear_system_state();
  return qindex;
}
int av1_get_vmaf_base_qindex ( const AV1_COMP * const cpi , int current_qindex ) { const AV1_COMMON * const cm = & cpi -> common ; if ( cm -> current_frame . frame_number == 0 || cpi -> oxcf . pass == 1 ) { return current_qindex ; } const int bit_depth = cpi -> td . mb . e_mbd . bd ; const double approx_sse = cpi -> last_frame_ysse / ( double ) ( ( 1 << ( bit_depth - 8 ) ) * ( 1 << ( bit_depth - 8 ) ) ) ; const double approx_dvmaf = kBaselineVmaf - cpi -> last_frame_vmaf ; const double sse_threshold = 0.01 * cpi -> source -> y_width * cpi -> source -> y_height ; const double vmaf_threshold = 0.01 ; if ( approx_sse < sse_threshold || approx_dvmaf < vmaf_threshold ) { return current_qindex ; } aom_clear_system_state ( ) ; const GF_GROUP * gf_group = & cpi -> gf_group ; YV12_BUFFER_CONFIG * cur_buf = cpi -> source ; int src_index = 0 ; if ( cm -> show_frame == 0 ) { src_index = gf_group -> arf_src_offset [ gf_group -> index ] ; struct lookahead_entry * cur_entry = av1_lookahead_peek ( cpi -> lookahead , src_index , cpi -> compressor_stage ) ; cur_buf = & cur_entry -> img ; } assert ( cur_buf ) ; const struct lookahead_entry * last_entry = av1_lookahead_peek ( cpi -> lookahead , src_index - 1 , cpi -> compressor_stage ) ; const struct lookahead_entry * next_entry = av1_lookahead_peek ( cpi -> lookahead , src_index + 1 , cpi -> compressor_stage ) ; const YV12_BUFFER_CONFIG * next_buf = & next_entry -> img ; const YV12_BUFFER_CONFIG * last_buf = cm -> show_frame ? cpi -> last_source : & last_entry -> img ; assert ( last_buf ) ; const double motion = calc_vmaf_motion_score ( cpi , cm , cur_buf , last_buf , next_buf ) ; const double dvmaf = 26.11 * ( 1.0 - exp ( -0.06 * motion ) ) ; const double dsse = dvmaf * approx_sse / approx_dvmaf ; const double beta = approx_sse / ( dsse + approx_sse ) ; const int offset = av1_get_deltaq_offset ( cpi , current_qindex , beta ) ; int qindex = current_qindex + offset ; qindex = AOMMIN ( qindex , MAXQ ) ; qindex = AOMMAX ( qindex , MINQ ) ; aom_clear_system_state ( ) ; return qindex ; }
Calculates the new qindex from the VMAF motion score.
Calculates the new qindex from the VMAF motion score .
// Get dVMAF through a data fitted model.