From 14187ea720ffb2fc55895d29d07a28073e6781ca Mon Sep 17 00:00:00 2001 From: Harish Mahendrakar Date: Sat, 29 Apr 2017 16:00:02 +0530 Subject: [PATCH] Encoder: Update scene cut detection logic Encoder detects scene cut based on number of Intra MBs in the current frame. For frames which contain plane areas which are different from reference frames, encoder might encode these MBs as intra because of lower SAD when compared with inter SAD. Such cases were detected as scene cuts and RC model was being reset. To fix this, scene cut is rejected if the current picture did not consume all the bits that were allocated to it. In an actual scene cut where RC needs to be reset, current frame consumes more than what is allocated to it. Bug: 36814430 Change-Id: Ifa904fbaf28481f4762a23bb63e013fd37ec8942 --- encoder/irc_rate_control_api.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/encoder/irc_rate_control_api.c b/encoder/irc_rate_control_api.c index 95befce..4a64645 100644 --- a/encoder/irc_rate_control_api.c +++ b/encoder/irc_rate_control_api.c @@ -756,6 +756,16 @@ void irc_update_frame_level_info(rate_control_api_t *ps_rate_control_api, { u1_is_scd = 0; } + /* For frames that contain plane areas that differ from reference frames, encoder + * might generate more INTRA MBs because of lower SAD compared with INTER MBs. + * Such cases should not be treated as scene change. + * For such frames bits consumed will be lesser than the allocated bits. + */ + if(i4_total_frame_bits < ps_rate_control_api->i4_prev_frm_est_bits) + { + u1_is_scd = 0; + } + trace_printf((const WORD8*)"i4_total_frame_bits %d\n", i4_total_frame_bits); if(!i4_is_it_a_skip && !i4_is_pic_handling_done)