MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / EncoderBase

Class EncoderBase

Test/testlib/encoder.py:43–258  ·  view source on GitHub ↗

A wrapper around the astcenc binary, abstracting the command line so that the rest of the test suite does not need to worry about changes to the command line interface over versions. This is an abstract base class providing some generic helper functionality used by concrete ins

Source from the content-addressed store, hash-verified

41
42
43class EncoderBase:
44 '''
45 A wrapper around the astcenc binary, abstracting the command line so that
46 the rest of the test suite does not need to worry about changes to the
47 command line interface over versions.
48
49 This is an abstract base class providing some generic helper functionality
50 used by concrete instantiations of subclasses.
51
52 Attributes:
53 name: The encoder name to use in reports.
54 variant: The encoder SIMD variant being tested.
55 binary_path: The encoder binary path.
56
57 Class attributes:
58 version: Encoder version or branch.
59 remap_color_switches: Dict of color format to profile switches.
60 remap_output_types: Dict of color format to output file extensions.
61 '''
62
63 # Subclasses override these if they need them
64 version = ''
65 remap_color_switches: dict[str, str] = {}
66 remap_output_types: dict[str, str] = {}
67
68 def __init__(self, name: str, variant: str, binary_path: Path):
69 '''
70 Create a new encoder instance.
71
72 Args:
73 name: The name of the encoder.
74 variant: The SIMD variant of the encoder.
75 binary: The path to the binary on the file system.
76 '''
77 self.name = name
78 self.variant = variant
79 self.binary_path = binary_path
80
81 def build_cli(self, image: TestImage, block_size: str = '6x6',
82 preset: str = '-thorough', keep_output: bool = True,
83 threads: Optional[int] = None) -> list[str]:
84 '''
85 Build the command line needed for the given test.
86
87 Args:
88 image: The test image to compress.
89 block_size: The block size to use.
90 preset: The quality preset to use.
91 keep_output: Should the test preserve output images? This is a hint
92 and may be ignored if astcenc version used can't do it.
93 threads: The thread count to use.
94
95 Return:
96 The command line arguments for this encoder version.
97 '''
98 # pylint: disable=unused-argument,redundant-returns-doc
99 assert False, 'Missing subclass implementation'
100

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected