MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / processQImage

Method processQImage

sources/utils/FrameDecoder.cpp:493–847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493void FrameDecoder::processQImage(
494 const uint8_t* data, const uint8_t* dataUV, int width, int height, int lineLength,
495 const PixelFormat pixelFormat, const uint8_t* lutBuffer, Image<ColorRgb>& outputImage, bool toneMapping, AutomaticToneMapping* automaticToneMapping)
496{
497 uint32_t ind_lutd;
498 uint8_t buffer[8];
499
500 // validate format
501 if (pixelFormat != PixelFormat::YUYV && pixelFormat != PixelFormat::UYVY &&
502 pixelFormat != PixelFormat::XRGB && pixelFormat != PixelFormat::RGB24 &&
503 pixelFormat != PixelFormat::I420 && pixelFormat != PixelFormat::NV12 && pixelFormat != PixelFormat::P010)
504 {
505 Error(Logger::getInstance("FrameDecoder"), "Invalid pixel format given");
506 return;
507 }
508
509 // validate format LUT
510 if ((pixelFormat == PixelFormat::YUYV || pixelFormat == PixelFormat::UYVY || pixelFormat == PixelFormat::I420 ||
511 pixelFormat == PixelFormat::NV12 || pixelFormat == PixelFormat::P010) && lutBuffer == NULL)
512 {
513 Error(Logger::getInstance("FrameDecoder"), "Missing LUT table for YUV colorspace");
514 return;
515 }
516
517 // calculate the output size
518 int outputWidth = (width) >> 1;
519 int outputHeight = (height) >> 1;
520
521 outputImage.resize(outputWidth, outputHeight);
522
523 uint8_t* destMemory = outputImage.rawMem();
524 int destLineSize = outputImage.width() * 3;
525
526
527 if (pixelFormat == PixelFormat::YUYV && automaticToneMapping == nullptr)
528 {
529 for (int yDest = 0, ySource = 0; yDest < outputHeight; ySource += 2, ++yDest)
530 {
531 uint8_t* currentDest = destMemory + ((uint64_t)destLineSize) * yDest;
532 uint8_t* endDest = currentDest + destLineSize;
533 uint8_t* currentSource = (uint8_t*)data + (((uint64_t)lineLength * ySource));
534
535 while (currentDest < endDest)
536 {
537 *((uint32_t*)&buffer) = *((uint32_t*)currentSource);
538
539 ind_lutd = LUT_INDEX(buffer[0], buffer[1], buffer[3]);
540
541 *((uint32_t*)currentDest) = *((uint32_t*)(&lutBuffer[ind_lutd]));
542 currentDest += 3;
543 currentSource += 4;
544 }
545 }
546 return;
547 }
548 if (pixelFormat == PixelFormat::YUYV && automaticToneMapping != nullptr)
549 {
550 for (int yDest = 0, ySource = 0; yDest < outputHeight; ySource += 2, ++yDest)

Callers

nothing calls this directly

Calls 8

initP010Function · 0.85
checkYMethod · 0.80
checkUMethod · 0.80
checkVMethod · 0.80
finilizeMethod · 0.80
resizeMethod · 0.45
rawMemMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected