av1/encoder/encoder.c
// Encode key frame with/without screen content tools to determine whether
// screen content tools should be enabled for this key frame group or not.
// The first encoding is without screen content tools.
// The second encoding is with screen content tools.
// We compare the psnr and frame size to make the decision.
Encode key frame with/without screen content tools to determine whether
screen content tools should be enabled for this key frame group or not.
The first encoding is without screen content tools.
The second encoding is with screen content tools.
We compare the psnr and frame size to make the decision.
Encode key frame with / without screen content tools to determine whether screen content tools should be enabled for this key frame group or not . The first encoding is without screen content tools . The second encoding is with screen content tools . We compare the psnr and frame size to make the decision .
static void screen_content_tools_determination(
    AV1_COMP *cpi, const int allow_screen_content_tools_orig_decision,
    const int allow_intrabc_orig_decision,
    const int is_screen_content_type_orig_decision, const int pass,
    int *projected_size_pass, PSNR_STATS *psnr) {
  AV1_COMMON *const cm = &cpi->common;
  projected_size_pass[pass] = cpi->rc.projected_frame_size;
#if CONFIG_AV1_HIGHBITDEPTH
  const uint32_t in_bit_depth = cpi->oxcf.input_bit_depth;
  const uint32_t bit_depth = cpi->td.mb.e_mbd.bd;
  aom_calc_highbd_psnr(cpi->source, &cpi->common.cur_frame->buf, &psnr[pass],
                       bit_depth, in_bit_depth);
#else
  aom_calc_psnr(cpi->source, &cpi->common.cur_frame->buf, &psnr[pass]);
#endif
  if (pass != 1) return;
  const double psnr_diff = psnr[1].psnr[0] - psnr[0].psnr[0];
  const int is_sc_encoding_much_better = psnr_diff > STRICT_PSNR_DIFF_THRESH;
  if (is_sc_encoding_much_better) {
    cm->allow_screen_content_tools = 1;
    cm->allow_intrabc = cpi->intrabc_used;
    cpi->is_screen_content_type = 1;
  } else {
    cm->allow_screen_content_tools = allow_screen_content_tools_orig_decision;
    cm->allow_intrabc = allow_intrabc_orig_decision;
    cpi->is_screen_content_type = is_screen_content_type_orig_decision;
  }
}
static void screen_content_tools_determination ( AV1_COMP * cpi , const int allow_screen_content_tools_orig_decision , const int allow_intrabc_orig_decision , const int is_screen_content_type_orig_decision , const int pass , int * projected_size_pass , PSNR_STATS * psnr ) { AV1_COMMON * const cm = & cpi -> common ; projected_size_pass [ pass ] = cpi -> rc . projected_frame_size ; #if CONFIG_AV1_HIGHBITDEPTH const uint32_t in_bit_depth = cpi -> oxcf . input_bit_depth ; const uint32_t bit_depth = cpi -> td . mb . e_mbd . bd ; aom_calc_highbd_psnr ( cpi -> source , & cpi -> common . cur_frame -> buf , & psnr [ pass ] , bit_depth , in_bit_depth ) ; #else aom_calc_psnr ( cpi -> source , & cpi -> common . cur_frame -> buf , & psnr [ pass ] ) ; #endif if ( pass != 1 ) return ; const double psnr_diff = psnr [ 1 ] . psnr [ 0 ] - psnr [ 0 ] . psnr [ 0 ] ; const int is_sc_encoding_much_better = psnr_diff > STRICT_PSNR_DIFF_THRESH ; if ( is_sc_encoding_much_better ) { cm -> allow_screen_content_tools = 1 ; cm -> allow_intrabc = cpi -> intrabc_used ; cpi -> is_screen_content_type = 1 ; } else { cm -> allow_screen_content_tools = allow_screen_content_tools_orig_decision ; cm -> allow_intrabc = allow_intrabc_orig_decision ; cpi -> is_screen_content_type = is_screen_content_type_orig_decision ; } }
Encode key frame with/without screen content tools to determine whether
screen content tools should be enabled for this key frame group or not.
Encode key frame with / without screen content tools to determine whether screen content tools should be enabled for this key frame group or not .
// Use screen content tools, if we get coding gain. // Use original screen content decision.