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)
| 143 | }) |
| 144 | |
| 145 | def to_dict(self) -> Dict[str, Any]: |
| 146 | """ |
| 147 | Convert the CompressionConfig instance to a dictionary. |
| 148 | If attribute_codec_registry is not None, it will be converted to a dictionary using its to_dict method. |
| 149 | """ |
| 150 | # Get only attributes defined in VideoCompressionConfig |
| 151 | video_compression_attrs = [ |
| 152 | "use_sort", "verbose", "qp", "n_clusters", |
| 153 | "use_all_intra", "debug", "transform_attributes", |
| 154 | "chroma_subsampling", "use_chroma_qp_offset" |
| 155 | ] |
| 156 | |
| 157 | result = {attr: getattr(self, attr) for attr in video_compression_attrs} |
| 158 | |
| 159 | # handle attribute_codec_registry |
| 160 | if self.attribute_codec_registry is not None: |
| 161 | result["attribute_codec_registry"] = self.attribute_codec_registry.to_dict() |
| 162 | |
| 163 | return result |
| 164 | |
| 165 | @dataclass |
| 166 | class Config: |