h->i_nal_type = i_nal_type;
h->i_nal_ref_idc = i_nal_ref_idc;
- if( h->param.b_intra_refresh && h->fenc->i_type == X264_TYPE_P )
+ if( h->param.b_intra_refresh )
{
- int pocdiff = (h->fdec->i_poc - h->fref0[0]->i_poc)/2;
- float increment = X264_MAX( ((float)h->sps->i_mb_width-1) / h->param.i_keyint_max, 1 );
- int max_position = (int)(increment * h->param.i_keyint_max);
- if( IS_X264_TYPE_I( h->fref0[0]->i_type ) )
- h->fdec->f_pir_position = 0;
- else
+ if( IS_X264_TYPE_I( h->fenc->i_type ) )
+ {
+ h->fdec->i_frames_since_pir = 0;
+ /* PIR is currently only supported with ref == 1, so any intra frame effectively refreshes
+ * the whole frame and counts as an intra refresh. */
+ h->fdec->f_pir_position = h->sps->i_mb_width;
+ }
+ else if( h->fenc->i_type == X264_TYPE_P )
{
+ int pocdiff = (h->fdec->i_poc - h->fref0[0]->i_poc)/2;
+ float increment = X264_MAX( ((float)h->sps->i_mb_width-1) / h->param.i_keyint_max, 1 );
h->fdec->f_pir_position = h->fref0[0]->f_pir_position;
- if( h->fdec->f_pir_position+0.5 >= max_position )
+ h->fdec->i_frames_since_pir = h->fref0[0]->i_frames_since_pir + pocdiff;
+ if( h->fdec->i_frames_since_pir >= h->param.i_keyint_max )
{
h->fdec->f_pir_position = 0;
+ h->fdec->i_frames_since_pir = 0;
h->fenc->b_keyframe = 1;
}
+ h->fdec->i_pir_start_col = h->fdec->f_pir_position+0.5;
+ h->fdec->f_pir_position += increment * pocdiff;
+ h->fdec->i_pir_end_col = h->fdec->f_pir_position+0.5;
}
- h->fdec->i_pir_start_col = h->fdec->f_pir_position+0.5;
- h->fdec->f_pir_position += increment * pocdiff;
- h->fdec->i_pir_end_col = h->fdec->f_pir_position+0.5;
}
if( h->fenc->b_keyframe )