Convert the CompressionConfig instance to a dictionary. If attribute_codec_registry is not None, it will be converted to a dictionary using its to_dict method.
(self)
| 223 | }) |
| 224 | |
| 225 | def to_dict(self) -> Dict[str, Any]: |
| 226 | """ |
| 227 | Convert the CompressionConfig instance to a dictionary. |
| 228 | If attribute_codec_registry is not None, it will be converted to a dictionary using its to_dict method. |
| 229 | """ |
| 230 | # Get only attributes defined in VideoCompressionConfig |
| 231 | video_compression_attrs = [ |
| 232 | "use_sort", "verbose", "qp", "n_clusters", |
| 233 | "use_all_intra", "debug", "transform_attributes", |
| 234 | "chroma_subsampling", "use_chroma_qp_offset" |
| 235 | ] |
| 236 | |
| 237 | result = {attr: getattr(self, attr) for attr in video_compression_attrs} |
| 238 | |
| 239 | # handle attribute_codec_registry |
| 240 | if self.attribute_codec_registry is not None: |
| 241 | result["attribute_codec_registry"] = self.attribute_codec_registry.to_dict() |
| 242 | |
| 243 | return result |
| 244 | |
| 245 | @dataclass |
| 246 | class Config: |