| 242 | }; |
| 243 | |
| 244 | nvcv::ImageFormat GetOutputFormat(nvcv::DataType in, NVCVColorConversionCode code) |
| 245 | { |
| 246 | auto outFormatIt = kOutputFormat.find(code); |
| 247 | if (outFormatIt == kOutputFormat.end()) |
| 248 | { |
| 249 | throw std::runtime_error("Invalid color conversion code"); |
| 250 | } |
| 251 | nvcv::ImageFormat outFormat{outFormatIt->second}; |
| 252 | |
| 253 | auto inPackingParams = nvcv::GetParams(in.packing()); |
| 254 | int inNumBits = 0; |
| 255 | for (const auto &numBits : inPackingParams.bits) |
| 256 | { |
| 257 | if (numBits > 0) |
| 258 | { |
| 259 | inNumBits = (inNumBits == 0) ? numBits : inNumBits; |
| 260 | if (numBits != inNumBits) |
| 261 | { |
| 262 | throw std::runtime_error("Invalid input format, all channels must have the same bit-depth"); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | auto outPackingParams = nvcv::GetParams(outFormat.planePacking(0)); |
| 267 | for (auto &numBits : outPackingParams.bits) |
| 268 | { |
| 269 | numBits = (numBits > 0) ? inNumBits : numBits; |
| 270 | } |
| 271 | auto outPacking = nvcv::MakePacking(outPackingParams); |
| 272 | outFormat = outFormat.swizzleAndPacking(outFormat.swizzle(), outPacking, nvcv::Packing::NONE, nvcv::Packing::NONE, |
| 273 | nvcv::Packing::NONE); |
| 274 | |
| 275 | return outFormat; |
| 276 | } |
| 277 | |
| 278 | int64_t GetOutputHeight(int64_t height, NVCVColorConversionCode code) |
| 279 | { |
no test coverage detected