codecwrappers.x265_wrapper

Author: Ismael Seidel (ismael.seidel@ufsc.br) Affiliation: Embedded Computing Lab (ECL), Federal University of Santa Catarina (UFSC)

Description:

This module contains the x265Wrapper class, which extends the CodecWrapper class to provide specific encoding and decoding functionality for the x265 codec.

class x265Wrapper(codec, codec_path, results_path, encoded_extension, bpp_to_actual_kbps_map_path, clear_log=False, repetitions=1, force_encoding=False, num_cores=None, fps=30, tune_metric='psnr', repository=None)[source]

Bases: CodecWrapper

Parameters:
  • codec (str)

  • codec_path (str | Path)

  • results_path (str | Path)

  • encoded_extension (str)

  • bpp_to_actual_kbps_map_path (str | Path)

  • clear_log (bool)

  • repetitions (int)

  • force_encoding (bool)

  • num_cores (int)

  • fps (int)

  • tune_metric (str)

__init__(codec, codec_path, results_path, encoded_extension, bpp_to_actual_kbps_map_path, clear_log=False, repetitions=1, force_encoding=False, num_cores=None, fps=30, tune_metric='psnr', repository=None)[source]

Initializes the x265Wrapper instance with the given parameters.

Parameters:
  • codec (str) – Name of the codec

  • codec_path (Union[str, Path]) – Path to the codec binary

  • results_path (Union[str, Path]) – Path to store results

  • encoded_extension (str) – File extension for encoded files

  • bpp_to_actual_kbps_map_path (Union[str, Path]) – Path to the bpp-to-kbps mapping file

  • 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

  • num_cores (int, optional) – Number of cores to use for encoding/decoding, defaults to None

  • fps (int, optional) – Frames per second, defaults to 30

  • tune_metric (str, optional) – Metric to tune for encoding, defaults to “psnr”

  • repository (optional) – Repository object for managing codec source, defaults to None

get_target_bitrate_kbps_from_bpp(bpp, raw_lightfield)[source]

Calculates the target bitrate in kbps for the given bpp value.

Parameters:
  • bpp (float) – Target bits per pixel value

  • raw_lightfield (RAWLightFieldData) – The raw light field data

Returns:

Target bitrate in kbps

Return type:

int

get_stats_path(raw_lightfield)[source]

Gets the path for storing x265 statistics files.

Parameters:

raw_lightfield (RAWLightFieldData) – The raw light field data

Returns:

Path to the stats directory

Return type:

Path

get_csv_path(raw_lightfield)[source]

Gets the path for storing x265 CSV output files.

Parameters:

raw_lightfield (RAWLightFieldData) – The raw light field data

Returns:

Path to the CSV directory

Return type:

Path

create_required_paths(raw_lightfield)[source]

Creates the required directories for storing stats, encoded, and CSV data.

Parameters:

raw_lightfield (RAWLightFieldData) – The raw light field data

Returns:

None

Return type:

None

encode_lightfield_for_target_bpps(raw_lightfield, bpps)[source]

Encodes the light field for the specified target bits per pixel (bpp) values.

Parameters:
  • raw_lightfield (RAWLightFieldData) – The raw light field data

  • bpps (List[float]) – List of target bpp values

Returns:

List of encoded light fields

Return type:

List[EncodedLightField]

combine_measurements(pass1_measurements, pass2_measurements)[source]

Combines first-pass and second-pass measurements into a single ExecutionMeasurements object.

Parameters:
Returns:

Combined execution measurements with summed durations

Return type:

ExecutionMeasurements

decode(encoded_lightfield)[source]

Decodes an encoded light field using ffmpeg to decompress HEVC to YUV.

Parameters:

encoded_lightfield (EncodedLightField) – The encoded light field to decode

Returns:

Decoded raw light field data in YUV format

Return type:

RAWLightFieldData