Hi Ankit, ... > - if (bpp <= 8) { > + if (bpp <= 8) > range_bpg_offset = ofs_und4[buf_i]; > - } else if (bpp <= 10) { > - res = DIV_ROUND_UP(((bpp - 8) * > - (ofs_und5[buf_i] - ofs_und4[buf_i])), 2); > - range_bpg_offset = ofs_und4[buf_i] + res; > - } else if (bpp <= 12) { > - res = DIV_ROUND_UP(((bpp - 10) * > - (ofs_und6[buf_i] - ofs_und5[buf_i])), 2); > - range_bpg_offset = ofs_und5[buf_i] + res; > - } else if (bpp <= 16) { > - res = DIV_ROUND_UP(((bpp - 12) * > - (ofs_und8[buf_i] - ofs_und6[buf_i])), 4); > - range_bpg_offset = ofs_und6[buf_i] + res; > - } else { > + else if (bpp <= 10) > + range_bpg_offset = get_range_bpg_offset(8, ofs_und4[buf_i], > + 10, ofs_und5[buf_i], bpp); > + else if (bpp <= 12) > + range_bpg_offset = get_range_bpg_offset(10, ofs_und5[buf_i], > + 12, ofs_und6[buf_i], bpp); > + else if (bpp <= 16) > + range_bpg_offset = get_range_bpg_offset(12, ofs_und6[buf_i], > + 16, ofs_und8[buf_i], bpp); > + else > range_bpg_offset = ofs_und8[buf_i]; > - } I tried to get these ifs out of the for loop, because the bpp value doesn't change during the execution here, but I don't think it is worth it due to offset buffers changing depending on bpp value and I believe your solution is good for what we could do here: Reviewed-by: Krzysztof Karas <krzysztof.karas@xxxxxxxxx> Krzysztof > > vdsc_cfg->rc_range_params[buf_i].range_bpg_offset = > range_bpg_offset & DSC_RANGE_BPG_OFFSET_MASK; > @@ -215,21 +218,19 @@ calculate_rc_params(struct drm_dsc_config *vdsc_cfg) > intel_vdsc_set_min_max_qp(vdsc_cfg, buf_i, bpp_i); > > /* Calculate range_bpg_offset */ > - if (bpp <= 6) { > + if (bpp <= 6) > range_bpg_offset = ofs_und6[buf_i]; > - } else if (bpp <= 8) { > - res = DIV_ROUND_UP(((bpp - 6) * > - (ofs_und8[buf_i] - ofs_und6[buf_i])), 2); > - range_bpg_offset = ofs_und6[buf_i] + res; > - } else if (bpp <= 12) { > - range_bpg_offset = ofs_und8[buf_i]; > - } else if (bpp <= 15) { > - res = DIV_ROUND_UP(((bpp - 12) * > - (ofs_und15[buf_i] - ofs_und12[buf_i])), 3); > - range_bpg_offset = ofs_und12[buf_i] + res; > - } else { > + else if (bpp <= 8) > + range_bpg_offset = get_range_bpg_offset(6, ofs_und6[buf_i], > + 8, ofs_und8[buf_i], bpp); > + else if (bpp <= 12) > + range_bpg_offset = get_range_bpg_offset(8, ofs_und8[buf_i], > + 12, ofs_und12[buf_i], bpp); > + else if (bpp <= 15) > + range_bpg_offset = get_range_bpg_offset(12, ofs_und12[buf_i], > + 15, ofs_und15[buf_i], bpp); > + else > range_bpg_offset = ofs_und15[buf_i]; > - } > > vdsc_cfg->rc_range_params[buf_i].range_bpg_offset = > range_bpg_offset & DSC_RANGE_BPG_OFFSET_MASK; > -- > 2.45.2 >