From ca51f660d5ee8793bfe27fb392804c028b8684d0 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 5 Mar 2014 16:18:47 +0200 Subject: [PATCH] Fix fluctuation of coefficients on identical frames when RDOQ is on. Moves CABAC context initialization to take place before search. This fixes an issue with RDOQ returning different coefficients for identical adjacent frames. - This actually probably worsens BD-rate a little for all frames except the first one because we were using last frames final CABAC context for every LCU and now we are using initialized CABAC contexts. The fix is to encode the LCU before we start compressing the next LCU so we can update CABAC contexts. --- src/encoder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/encoder.c b/src/encoder.c index e209be1a..97bcd142 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -450,6 +450,8 @@ void encode_one_frame(encoder_control* encoder) // First slice is IDR cabac_start(&cabac); + init_contexts(encoder, encoder->in.cur_pic->slicetype); + scalinglist_process(); search_slice_data(encoder); @@ -472,6 +474,7 @@ void encode_one_frame(encoder_control* encoder) write_aud(encoder); cabac_start(&cabac); + init_contexts(encoder, encoder->in.cur_pic->slicetype); scalinglist_process(); search_slice_data(encoder); @@ -1255,8 +1258,6 @@ void encode_slice_data(encoder_control* encoder) free(new_v_data); } - init_contexts(encoder,encoder->in.cur_pic->slicetype); - // Loop through every LCU in the slice for (y_ctb = 0; y_ctb < encoder->in.height_in_lcu; y_ctb++) { uint8_t last_cu_y = (y_ctb == (encoder->in.height_in_lcu - 1)) ? 1 : 0;