Adjust tensor shape size if width or height are odd for a given multi-planar format. No modification is done for other formats. * * @note Adding here a few links discussing the issue of odd size and sharing the same solution: * Android Source * <a
| 343 | * @return The adjusted tensor shape. |
| 344 | */ |
| 345 | inline TensorShape adjust_odd_shape(const TensorShape &shape, Format format) |
| 346 | { |
| 347 | TensorShape output{shape}; |
| 348 | |
| 349 | // Force width to be even for formats which require subsampling of the U and V channels |
| 350 | if (has_format_horizontal_subsampling(format)) |
| 351 | { |
| 352 | output.set(0, (output.x() + 1) & ~1U); |
| 353 | } |
| 354 | |
| 355 | // Force height to be even for formats which require subsampling of the U and V channels |
| 356 | if (has_format_vertical_subsampling(format)) |
| 357 | { |
| 358 | output.set(1, (output.y() + 1) & ~1U); |
| 359 | } |
| 360 | |
| 361 | return output; |
| 362 | } |
| 363 | |
| 364 | /** Return an error if the passed tensor objects are not even. |
| 365 | * |
no test coverage detected