av1/encoder/encode_strategy.c
// Update reference frame stack info.
Update reference frame stack info.
Update reference frame stack info .
void av1_update_ref_frame_map(AV1_COMP *cpi,
                              FRAME_UPDATE_TYPE frame_update_type,
                              int show_existing_frame, int ref_map_index,
                              RefBufferStack *ref_buffer_stack) {
  AV1_COMMON *const cm = &cpi->common;
  if (frame_is_sframe(cm)) frame_update_type = KEY_FRAME;
  if (is_frame_droppable(cpi)) return;
  switch (frame_update_type) {
    case KEY_FRAME:
      if (show_existing_frame)
        ref_map_index = stack_pop(ref_buffer_stack->arf_stack,
                                  &ref_buffer_stack->arf_stack_size);
      stack_reset(ref_buffer_stack->lst_stack,
                  &ref_buffer_stack->lst_stack_size);
      stack_reset(ref_buffer_stack->gld_stack,
                  &ref_buffer_stack->gld_stack_size);
      stack_reset(ref_buffer_stack->arf_stack,
                  &ref_buffer_stack->arf_stack_size);
      stack_push(ref_buffer_stack->gld_stack, &ref_buffer_stack->gld_stack_size,
                 ref_map_index);
      break;
    case GF_UPDATE:
      update_arf_stack(ref_map_index, ref_buffer_stack);
      stack_push(ref_buffer_stack->gld_stack, &ref_buffer_stack->gld_stack_size,
                 ref_map_index);
      if (cpi->sf.rt_sf.use_nonrd_pick_mode)
        stack_push(ref_buffer_stack->lst_stack,
                   &ref_buffer_stack->lst_stack_size, ref_map_index);
      break;
    case LF_UPDATE:
      update_arf_stack(ref_map_index, ref_buffer_stack);
      stack_push(ref_buffer_stack->lst_stack, &ref_buffer_stack->lst_stack_size,
                 ref_map_index);
      break;
    case ARF_UPDATE:
    case INTNL_ARF_UPDATE:
      update_arf_stack(ref_map_index, ref_buffer_stack);
      stack_push(ref_buffer_stack->arf_stack, &ref_buffer_stack->arf_stack_size,
                 ref_map_index);
      break;
    case OVERLAY_UPDATE:
      ref_map_index = stack_pop(ref_buffer_stack->arf_stack,
                                &ref_buffer_stack->arf_stack_size);
      stack_push(ref_buffer_stack->gld_stack, &ref_buffer_stack->gld_stack_size,
                 ref_map_index);
      break;
    case INTNL_OVERLAY_UPDATE:
      ref_map_index = stack_pop(ref_buffer_stack->arf_stack,
                                &ref_buffer_stack->arf_stack_size);
      stack_push(ref_buffer_stack->lst_stack, &ref_buffer_stack->lst_stack_size,
                 ref_map_index);
      break;
    default: assert(0 && "unknown type");
  }
  return;
}
void av1_update_ref_frame_map ( AV1_COMP * cpi , FRAME_UPDATE_TYPE frame_update_type , int show_existing_frame , int ref_map_index , RefBufferStack * ref_buffer_stack ) { AV1_COMMON * const cm = & cpi -> common ; if ( frame_is_sframe ( cm ) ) frame_update_type = KEY_FRAME ; if ( is_frame_droppable ( cpi ) ) return ; switch ( frame_update_type ) { case KEY_FRAME : if ( show_existing_frame ) ref_map_index = stack_pop ( ref_buffer_stack -> arf_stack , & ref_buffer_stack -> arf_stack_size ) ; stack_reset ( ref_buffer_stack -> lst_stack , & ref_buffer_stack -> lst_stack_size ) ; stack_reset ( ref_buffer_stack -> gld_stack , & ref_buffer_stack -> gld_stack_size ) ; stack_reset ( ref_buffer_stack -> arf_stack , & ref_buffer_stack -> arf_stack_size ) ; stack_push ( ref_buffer_stack -> gld_stack , & ref_buffer_stack -> gld_stack_size , ref_map_index ) ; break ; case GF_UPDATE : update_arf_stack ( ref_map_index , ref_buffer_stack ) ; stack_push ( ref_buffer_stack -> gld_stack , & ref_buffer_stack -> gld_stack_size , ref_map_index ) ; if ( cpi -> sf . rt_sf . use_nonrd_pick_mode ) stack_push ( ref_buffer_stack -> lst_stack , & ref_buffer_stack -> lst_stack_size , ref_map_index ) ; break ; case LF_UPDATE : update_arf_stack ( ref_map_index , ref_buffer_stack ) ; stack_push ( ref_buffer_stack -> lst_stack , & ref_buffer_stack -> lst_stack_size , ref_map_index ) ; break ; case ARF_UPDATE : case INTNL_ARF_UPDATE : update_arf_stack ( ref_map_index , ref_buffer_stack ) ; stack_push ( ref_buffer_stack -> arf_stack , & ref_buffer_stack -> arf_stack_size , ref_map_index ) ; break ; case OVERLAY_UPDATE : ref_map_index = stack_pop ( ref_buffer_stack -> arf_stack , & ref_buffer_stack -> arf_stack_size ) ; stack_push ( ref_buffer_stack -> gld_stack , & ref_buffer_stack -> gld_stack_size , ref_map_index ) ; break ; case INTNL_OVERLAY_UPDATE : ref_map_index = stack_pop ( ref_buffer_stack -> arf_stack , & ref_buffer_stack -> arf_stack_size ) ; stack_push ( ref_buffer_stack -> lst_stack , & ref_buffer_stack -> lst_stack_size , ref_map_index ) ; break ; default : assert ( 0 && " " ) ; } return ; }
Update reference frame stack info.
Update reference frame stack info .
// TODO(jingning): Consider the S-frame same as key frame for the // reference frame tracking purpose. The logic might be better // expressed than converting the frame update type. // For nonrd_mode: update LAST as well on GF_UPDATE frame.