bundle.rd_plot_from_bundle
Author: Leonardo de Sousa Marques Affiliation: Embedded Computing Lab (ECL), Federal University of Santa Catarina (UFSC)
- Description:
This module decodes and generates RD plots from a bundle of encoded Light Field files.
- Observation:
It is crucial to have the repository cloned beforehand in the correct path so that the encoded file can be decoded. The bundle follows a hierarchical structure: bundle -> codec name -> lf name -> encoded files. RD report files follow the naming convention: {lf_name}_{codec_name}_rd_reports.json
- get_codec_wrapper(codec_name, configuration, codec_configuration)[source]
Instantiate a codec wrapper, cloning and building the repository if needed.
- Parameters:
codec_name (str) – Name of the codec
configuration (ConfigurationReader) – Configuration reader
codec_configuration (Dict) – Codec-specific configuration dictionary
- Returns:
Instantiated codec wrapper
- Return type:
CodecWrapper
- get_codec_configuration(configuration, codec_name)[source]
Get codec configuration with inheritance resolution.
- Parameters:
configuration (ConfigurationReader) – Configuration reader instance
codec_name (str) – Name of the codec
- Returns:
Codec configuration dictionary
- Raises:
ValueError – If codec not found in configuration
- Return type:
Dict
- compute_metrics(original_lf, decoded_lf, wrapper_instances)[source]
Compute quality metrics between original and decoded light fields.
- Parameters:
original_lf (RAWLightFieldData) – Reference light field
decoded_lf (RAWLightFieldData) – Decoded light field
wrapper_instances (Dict) – Pre-instantiated quality tool wrappers
- Returns:
Quality metric reports keyed by tool short-name
- Return type:
Dict[str, Dict]
- compute_metrics_from_encoded_and_decoded(codecs, configuration, encoded_files_dir, results_path)[source]
For each codec: decode all encoded files across all light fields, then compute quality metrics per light field and generate RD plots and JSON reports immediately after each light field is fully processed.
- Parameters:
codecs (List[str]) – Codec names to process; empty list means all found
configuration (ConfigurationReader) – Configuration reader
encoded_files_dir (Path) – Root directory containing per-codec encoded files
results_path (Path) – Root directory where plots and reports will be saved
- Returns:
Data organised as {codec: {lf_name: [(bpp, reports_by_wrapper)]}}
- Return type:
Dict[str, Dict[str, List[Tuple[float, Dict[str, Dict]]]]]
- load_bundle_data_from_rd_reports(rd_reports_dir, allowed_codecs, configuration)[source]
Build bundle data from pre-computed RD report JSON files.
Expects files named
{lf_name}_{codec_name}_rd_reports.jsoncontaining aresultsdict keyed by target bitrate label, each entry having aratefield and per-metric dicts with ameanvalue.The returned structure mirrors
compute_metrics_from_encoded_and_decoded()so thatgenerate_rd_plots_from_encoded()can consume both paths.- Parameters:
rd_reports_dir (Path) – Directory containing RD report JSON files
allowed_codecs (List[str]) – Codec names to include; empty list means all
configuration (ConfigurationReader) – Configuration reader
- Returns:
Data organised as {codec: {lf_name: [(bpp, reports_by_wrapper)]}}
- Raises:
ValueError – If rd_reports_dir does not exist
- Return type:
Dict[str, Dict[str, List[Tuple[float, Dict[str, Dict]]]]]
- generate_rd_plots_from_encoded(all_data, results_path, configuration, from_rd_reports=False)[source]
Generate R-D plots from bundle data for all configured light fields and metrics.
When from_rd_reports is True, metrics are taken from the report data itself and rd_plots config is used only for plot styling (a single pass).
- Parameters:
all_data (Dict[str, Dict[str, List[Tuple[float, Dict[str, Dict]]]]]) – Bundle data organised as {codec: {lf_name: [(bpp, reports)]}}
results_path (Path) – Root directory where plots will be saved
configuration (ConfigurationReader) – Configuration reader
from_rd_reports (bool) – If True, derive metrics from report data instead of rd_plots config
- Return type:
None
- create_json_from_bundle(all_data, results_path, configuration, from_rd_reports=False)[source]
Generate JSON reports from bundle data containing rate-distortion information.
Creates detailed JSON files containing R-D values, metadata, and codec information organized by target bitrate and quality metric, mirroring the structure produced by the original create_json function.
- Parameters:
all_data (Dict[str, Dict[str, List[Tuple[float, Dict[str, Dict]]]]]) – Bundle data organised as {codec: {lf_name: [(bpp, reports)]}}
results_path (Path) – Root directory where JSON reports will be saved
configuration (ConfigurationReader) – Configuration reader
from_rd_reports (bool) – If True, data comes from pre-computed RD reports
- Return type:
None
- main()[source]
Decode and generate R-D plots from an encoded light field bundle.
Reads configuration from command-line arguments, then either decodes encoded files and computes quality metrics, or loads pre-computed RD report JSON files, before generating rate-distortion plots.
Usage: python rd_plots_from_bundle.py <configuration.json>
- Raises:
SystemExit – If configuration or required paths are invalid
- Return type:
None