codecwrappers.codec_wrapper
Author: Ismael Seidel (ismael.seidel@ufsc.br) Affiliation: Embedded Computing Lab (ECL), Federal University of Santa Catarina (UFSC)
- Description:
This module contains the CodecWrapper class, which provides a base implementation for encoding and decoding light fields using various codecs.
- class CodecWrapper(codec_path, results_path, encoded_extension, clear_log=False, repetitions=1, force_encoding=False, codec=None, num_cores=None, repository=None)[source]
Bases:
object- Parameters:
codec_path (Path)
results_path (Path)
encoded_extension (str)
clear_log (bool)
repetitions (int)
force_encoding (bool)
codec (str)
num_cores (int)
- __init__(codec_path, results_path, encoded_extension, clear_log=False, repetitions=1, force_encoding=False, codec=None, num_cores=None, repository=None)[source]
Initializes the CodecWrapper instance with the given parameters.
- Parameters:
codec_path (Path) – Path to the codec binary
results_path (Path) – Path to store results
encoded_extension (str) – File extension for encoded files
clear_log (bool, optional) – Whether to clear logs after execution, defaults to False
repetitions (int, optional) – Number of repetitions for encoding/decoding, defaults to 1
force_encoding (bool, optional) – Whether to force encoding even if results exist, defaults to False
codec (str, optional) – Name of the codec, defaults to None
num_cores (int, optional) – Number of cores to use for encoding/decoding, defaults to None
repository (optional) – Repository object for managing codec source, defaults to None
- get_encoded_path(raw_lightfield)[source]
Gets the path for storing encoded light field data.
- Parameters:
raw_lightfield (RAWLightFieldData) – The raw light field data
- Returns:
Path to the encoded data
- Return type:
Path
- get_logs_path(raw_lightfield)[source]
Gets the path for storing logs.
- Parameters:
raw_lightfield (RAWLightFieldData) – The raw light field data
- Returns:
Path to the logs
- Return type:
Path
- get_decoded_path(raw_lightfield)[source]
Gets the path for storing decoded light field data.
- Parameters:
raw_lightfield (RAWLightFieldData) – The raw light field data
- Returns:
Path to the decoded data
- Return type:
Path
- compute_bytes_and_bpp(encoded_filename, raw_lightfield)[source]
Computes the number of bytes and bits per pixel (bpp) for the encoded file.
- Parameters:
encoded_filename (Union[str, Path]) – Path to the encoded file
raw_lightfield (RAWLightFieldData) – The raw light field data
- Returns:
Tuple containing the number of bytes and bpp
- Return type:
Tuple[int, float]
- add_decoded_conversion(decoded_conversion)[source]
Adds a decoded conversion to the results.
- Parameters:
decoded_conversion (RAWLightFieldData) – The decoded conversion data
- Returns:
None
- Return type:
None
- extract_data_from_log(log_filename)[source]
Extracts data from the log file.
- Parameters:
log_filename (Union[str, Path]) – Path to the log file
- Returns:
Dictionary containing the extracted data
- Return type:
Dict
- create_execution_log(output_log_filename)[source]
Creates a new execution log entry.
- Parameters:
output_log_filename (Path) – Path to the output log file
- Returns:
None
- Return type:
None
- verify_lightfield_consistency(bpp, lightfield)[source]
Verifies if the light field file has changed between repetitions by comparing MD5 hashes.
- Parameters:
bpp (float) – Target bits per pixel value
lightfield (LightField) – The light field data
- Returns:
True if the light field is consistent, False otherwise
- Return type:
bool
- execute_perf_command(command, cwd=None)[source]
Executes a command and captures its execution profile (duration, stdout, stderr).
- Parameters:
command (List[str]) – Command to execute as a list of arguments
cwd (Optional[str], optional) – Current working directory for the command, defaults to None
- Returns:
Run profile with duration, success status, stdout and stderr
- Return type:
- execute_command(bpp, command, log_filename, cwd=None, lightfield=None)[source]
Executes a command for encoding or decoding light fields, allowing multiple repetitions.
- Parameters:
bpp (float) – Target bits per pixel value
command (List[str]) – Command to execute
log_filename (Path) – Path to the log file
cwd (Optional[Path], optional) – Current working directory, defaults to None
lightfield (Optional[LightField], optional) – The light field data, defaults to None
- Returns:
Execution measurements for the command
- Return type: