Fix assertion failure with drop frames In this CL, the update of 'cm->current_frame->frame_number' and 'cpi->frame_index_set.show_frame_count' is handled correctly when a frame is dropped. This fixes the assertion failure in init_gop_frames_for_tpl() while encoding with --drop-frame=1. The update of relevant frame counters is also abstracted in to a new function 'update_counters_for_show_frame'. STATS_CHANGED expected with --drop-frame=1 BUG=aomedia:3372 Change-Id: I9d01375d026d3a8d74acbe9cf12cbf8116390ec3
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index 2b93c1e..4f74772 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -952,11 +952,10 @@ frame_index_set->show_frame_count = 0; } -static INLINE void update_frame_index_set(FRAME_INDEX_SET *frame_index_set, - int is_show_frame) { - if (is_show_frame) { - frame_index_set->show_frame_count++; - } +static INLINE void update_counters_for_show_frame(AV1_COMP *const cpi) { + assert(cpi->common.show_frame); + cpi->frame_index_set.show_frame_count++; + cpi->common.current_frame.frame_number++; } AV1_PRIMARY *av1_create_primary_compressor( @@ -3674,8 +3673,7 @@ } #endif // !CONFIG_REALTIME_ONLY - ++current_frame->frame_number; - update_frame_index_set(&cpi->frame_index_set, cm->show_frame); + update_counters_for_show_frame(cpi); return AOM_CODEC_OK; } @@ -3736,6 +3734,12 @@ av1_rc_postencode_update_drop_frame(cpi); release_scaled_references(cpi); cpi->is_dropped_frame = true; + // A dropped frame might not be shown but it always takes a slot in the gf + // group. Therefore, even when it is not shown, we still need to update + // the relevant frame counters. + if (cm->show_frame) { + update_counters_for_show_frame(cpi); + } return AOM_CODEC_OK; } } @@ -3950,12 +3954,8 @@ cm->seg.update_data = 0; cm->lf.mode_ref_delta_update = 0; - // A droppable frame might not be shown but it always - // takes a space in the gf group. Therefore, even when - // it is not shown, we still need update the count down. if (cm->show_frame) { - update_frame_index_set(&cpi->frame_index_set, cm->show_frame); - ++current_frame->frame_number; + update_counters_for_show_frame(cpi); } #if CONFIG_COLLECT_COMPONENT_TIMING