quality.compound_metrics

adjust_bd_metric(configuration, metric, value)[source]

Applies BD adjustment to a metric value using the configured adjustment module.

Parameters:
  • configuration (Any) – Configuration reader or dict with quality metrics

  • metric (str) – Metric name

  • value (float) – Raw metric value to adjust

Returns:

BD-adjusted value

Return type:

float

resolve_bd_adjusted_metric(bpp, frame_metrics, distortion_name, configuration)[source]

Resolves BD-adjusted metric from frame metrics, applying pooling-first or per-frame adjustment.

Parameters:
  • bpp (float) – Bits per pixel

  • frame_metrics (List[Dict[str, Any]]) – List of frame metric dictionaries

  • distortion_name (str) – Name of the distortion metric

  • configuration (ConfigurationReader) – Configuration reader

Returns:

RDResult with adjusted min, max, mean, stddev

Return type:

RDResult

resolve_derived_metric(frame_metrics, distortion_name, configuration)[source]

Resolves a derived (weighted) metric value from frame metrics.

Parameters:
  • frame_metrics (Dict[str, float]) – Frame metrics dictionary

  • distortion_name (str) – Name of the derived metric

  • configuration (ConfigurationReader) – Configuration reader

Returns:

Resolved metric value

Return type:

float

class CompoundMetrics[source]

Bases: object

static is_weighted_metric(metric, configuration)[source]

Checks if the metric is a weighted/derived metric.

Parameters:
Returns:

True if metric is weighted

Return type:

bool

static is_bd_adjusted_metric(metric, configuration)[source]

Checks if the metric is a BD-adjusted metric.

Parameters:
Returns:

True if metric is BD-adjusted

Return type:

bool

static calculate_weighted_metric_value(metrics_dict, weights)[source]

Calculates weighted average of metrics using the given weights.

Parameters:
  • metrics_dict (Dict[str, float]) – Dictionary of metric names to values

  • weights (Dict[str, float]) – Dictionary of metric names to weights

Returns:

Weighted metric value

Return type:

float

static resolve_metric_value(frame_metrics, distortion_name, configuration, generating_heatmap=False)[source]

Resolves the metric value from frame metrics, handling direct, BD-adjusted, and weighted metrics.

Parameters:
  • frame_metrics (Dict[str, Any]) – Frame metrics dictionary

  • distortion_name (str) – Name of the distortion metric

  • configuration (ConfigurationReader) – Configuration reader

  • generating_heatmap (bool, optional) – Whether resolving for heatmap (affects BD-adjusted), defaults to False

Returns:

Resolved metric value (float) or RDResult for BD-adjusted

Return type:

Union[float, RDResult]

static get_list_frames(all_frame_metrics, distortion_name, configuration)[source]

Extracts list of metric values from all frame metrics.

Parameters:
  • all_frame_metrics (List[Dict[str, Any]]) – List of frame metric dictionaries

  • distortion_name (str) – Name of the distortion metric

  • configuration (ConfigurationReader) – Configuration reader

Returns:

List of resolved metric values per frame

Return type:

List[float]