Calculate subsampled shape for a given format and channel * * @param[in] shape Shape of the tensor to calculate the extracted channel. * @param[in] format Format of the tensor. * @param[in] channel Channel to create tensor shape to be extracted. * * @return The subsampled tensor shape. */
| 404 | * @return The subsampled tensor shape. |
| 405 | */ |
| 406 | inline TensorShape |
| 407 | calculate_subsampled_shape(const TensorShape &shape, Format format, Channel channel = Channel::UNKNOWN) |
| 408 | { |
| 409 | TensorShape output{shape}; |
| 410 | |
| 411 | // Subsample shape only for U or V channel |
| 412 | if (Channel::U == channel || Channel::V == channel || Channel::UNKNOWN == channel) |
| 413 | { |
| 414 | // Subsample width for the tensor shape when channel is U or V |
| 415 | if (has_format_horizontal_subsampling(format)) |
| 416 | { |
| 417 | output.set(0, output.x() / 2U); |
| 418 | } |
| 419 | |
| 420 | // Subsample height for the tensor shape when channel is U or V |
| 421 | if (has_format_vertical_subsampling(format)) |
| 422 | { |
| 423 | output.set(1, output.y() / 2U); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | return output; |
| 428 | } |
| 429 | |
| 430 | /** Return an error if the passed tensor objects are not sub-sampled. |
| 431 | * |
no test coverage detected