Fix error in frame variance calculation. Chroma channels were not added to variance

This commit is contained in:
siivonek 2020-03-26 14:33:00 +02:00
parent 5986e71535
commit be7d9ddec5

View file

@ -1268,7 +1268,12 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
// Calculate frame pixel variance // Calculate frame pixel variance
uint32_t len = state->tile->frame->width * state->tile->frame->height; uint32_t len = state->tile->frame->width * state->tile->frame->height;
uint32_t c_len = len / 4;
double frame_var = pixel_var(state->tile->frame->source->y, len); double frame_var = pixel_var(state->tile->frame->source->y, len);
if (has_chroma) {
frame_var += pixel_var(state->tile->frame->source->u, c_len);
frame_var += pixel_var(state->tile->frame->source->v, c_len);
}
// Loop through LCUs // Loop through LCUs
// For each LCU calculate: D * (log(LCU pixel variance) - log(frame pixel variance)) // For each LCU calculate: D * (log(LCU pixel variance) - log(frame pixel variance))