Dequantize CbCr channel
| 270 | |
| 271 | |
| 272 | class CDequantize(nn.Module): |
| 273 | """Dequantize CbCr channel |
| 274 | """ |
| 275 | |
| 276 | def __init__(self): |
| 277 | super(CDequantize, self).__init__() |
| 278 | self.c_table = c_table |
| 279 | |
| 280 | def forward(self, image, factor=1): |
| 281 | """ |
| 282 | Args: |
| 283 | image(tensor): batch x height x width |
| 284 | |
| 285 | Returns: |
| 286 | Tensor: batch x height x width |
| 287 | """ |
| 288 | if isinstance(factor, (int, float)): |
| 289 | out = image * (self.c_table * factor) |
| 290 | else: |
| 291 | b = factor.size(0) |
| 292 | table = self.c_table.expand(b, 1, 8, 8) * factor.view(b, 1, 1, 1) |
| 293 | out = image * table |
| 294 | return out |
| 295 | |
| 296 | |
| 297 | class iDCT8x8(nn.Module): |