| 183 | |
| 184 | |
| 185 | void FrameDecoder::processImage( |
| 186 | int _cropLeft, int _cropRight, int _cropTop, int _cropBottom, |
| 187 | const uint8_t* data, const uint8_t* dataUV, int width, int height, int lineLength, |
| 188 | const PixelFormat pixelFormat, const uint8_t* lutBuffer, Image<ColorRgb>& outputImage, bool toneMapping) |
| 189 | { |
| 190 | uint32_t ind_lutd, ind_lutd2; |
| 191 | uint8_t buffer[8]; |
| 192 | |
| 193 | // validate format |
| 194 | if (pixelFormat != PixelFormat::YUYV && pixelFormat != PixelFormat::UYVY && |
| 195 | pixelFormat != PixelFormat::XRGB && pixelFormat != PixelFormat::RGB24 && |
| 196 | pixelFormat != PixelFormat::I420 && pixelFormat != PixelFormat::NV12 && pixelFormat != PixelFormat::P010 && pixelFormat != PixelFormat::MJPEG) |
| 197 | { |
| 198 | Error(Logger::getInstance("FrameDecoder"), "Invalid pixel format given"); |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | // validate format LUT |
| 203 | if ((pixelFormat == PixelFormat::YUYV || pixelFormat == PixelFormat::UYVY || pixelFormat == PixelFormat::I420 || pixelFormat == PixelFormat::MJPEG || |
| 204 | pixelFormat == PixelFormat::NV12 || pixelFormat == PixelFormat::P010) && lutBuffer == NULL) |
| 205 | { |
| 206 | Error(Logger::getInstance("FrameDecoder"), "Missing LUT table for YUV colorspace"); |
| 207 | return; |
| 208 | } |
| 209 | |
| 210 | // sanity check, odd values doesnt work for yuv either way |
| 211 | _cropLeft = (_cropLeft >> 1) << 1; |
| 212 | _cropRight = (_cropRight >> 1) << 1; |
| 213 | |
| 214 | // calculate the output size |
| 215 | int outputWidth = (width - _cropLeft - _cropRight); |
| 216 | int outputHeight = (height - _cropTop - _cropBottom); |
| 217 | |
| 218 | outputImage.resize(outputWidth, outputHeight); |
| 219 | outputImage.setOriginFormat(pixelFormat); |
| 220 | |
| 221 | uint8_t* destMemory = outputImage.rawMem(); |
| 222 | int destLineSize = outputImage.width() * 3; |
| 223 | |
| 224 | |
| 225 | if (pixelFormat == PixelFormat::YUYV) |
| 226 | { |
| 227 | for (int yDest = 0, ySource = _cropTop; yDest < outputHeight; ++ySource, ++yDest) |
| 228 | { |
| 229 | uint8_t* currentDest = destMemory + ((uint64_t)destLineSize) * yDest; |
| 230 | uint8_t* endDest = currentDest + destLineSize; |
| 231 | uint8_t* currentSource = (uint8_t*)data + (((uint64_t)lineLength * ySource) + (((uint64_t)_cropLeft) << 1)); |
| 232 | |
| 233 | while (currentDest < endDest) |
| 234 | { |
| 235 | *((uint32_t*)&buffer) = *((uint32_t*)currentSource); |
| 236 | |
| 237 | ind_lutd = LUT_INDEX(buffer[0], buffer[1], buffer[3]); |
| 238 | ind_lutd2 = LUT_INDEX(buffer[2], buffer[1], buffer[3]); |
| 239 | |
| 240 | *((uint32_t*)currentDest) = *((uint32_t*)(&lutBuffer[ind_lutd])); |
| 241 | currentDest += 3; |
| 242 | *((uint32_t*)currentDest) = *((uint32_t*)(&lutBuffer[ind_lutd2])); |
nothing calls this directly
no test coverage detected