V4L2CaptureInterface::FramePair V4L2CaptureInterface::getFrameRGB24() { CaptureStatistics stats; PreciseTimer start = PreciseTimer::currentTime(); protectFrame.lock(); FramePair result; RGB24Buffer **results[MAX_INPUTS_NUMBER] = { &result.buffers[LEFT_FRAME ].rgbBuffer, &result.buffers[RIGHT_FRAME ].rgbBuffer, &result.buffers[THIRD_FRAME ].rgbBuffer, &result.buffers[FOURTH_FRAME].rgbBuffer }; for (int i = 0; i < MAX_INPUTS_NUMBER; i++) { decodeDataRGB24(&camera[i], ¤tFrame[i], results[i]); if ((*results[i]) == NULL) { printf("V4L2CaptureInterface::getFrameRGB24(): Precrash condition at %d (%s)\n", i, getFrameSourceName((FrameSourceId)i)); } } if (result.rgbBufferLeft() != NULL) { result.setBufferLeft ( result.rgbBufferLeft() ->toG12Buffer() ); // FIXME } if (result.rgbBufferRight() != NULL) { result.setBufferRight ( result.rgbBufferRight()->toG12Buffer() ); } if (currentFrame[LEFT_FRAME].isFilled) result.setTimeStampLeft (currentFrame[LEFT_FRAME].usecsTimeStamp()); if (currentFrame[RIGHT_FRAME].isFilled) result.setTimeStampRight (currentFrame[RIGHT_FRAME].usecsTimeStamp()); if (skippedCount == 0) { // SYNC_PRINT(("Warning: Requested same frames twice. Is this by design?\n")); } stats.framesSkipped = skippedCount > 0 ? skippedCount - 1 : 0; skippedCount = 0; protectFrame.unlock(); stats.values[CaptureStatistics::DECODING_TIME] = start.usecsToNow(); stats.values[CaptureStatistics::INTERFRAME_DELAY] = frameDelay; int64_t desync = currentFrame[LEFT_FRAME ].usecsTimeStamp() - currentFrame[RIGHT_FRAME].usecsTimeStamp(); stats.values[CaptureStatistics::DESYNC_TIME] = CORE_ABS(desync); stats.values[CaptureStatistics::DATA_SIZE] = currentFrame[LEFT_FRAME].bytesused; if (imageInterfaceReceiver != NULL) { imageInterfaceReceiver->newStatisticsReadyCallback(stats); } else { SYNC_PRINT(("Warning: V4L2CaptureInterface::getFrameRGB24(): imageInterfaceReceiver is NULL\n")); } return result; }
V4L2CaptureInterface::FramePair V4L2CaptureInterface::getFrame() { // SYNC_PRINT(("V4L2CaptureInterface::getFrame(): called\n")); CaptureStatistics stats; PreciseTimer start = PreciseTimer::currentTime(); FramePair result; protectFrame.lock(); G12Buffer **results[MAX_INPUTS_NUMBER] = { &result.buffers[LEFT_FRAME ].g12Buffer, &result.buffers[RIGHT_FRAME].g12Buffer, &result.buffers[LEFT_FRAME ].g12Buffer, &result.buffers[RIGHT_FRAME].g12Buffer, }; result.setRgbBufferRight(NULL); result.setRgbBufferLeft (NULL); //SYNC_PRINT(("LF:%s RF:%s\n", // currentFrame[Frames::LEFT_FRAME ].isFilled ? "filled" : "empty" , // currentFrame[Frames::RIGHT_FRAME].isFilled ? "filled" : "empty")); for (int i = 0; i < MAX_INPUTS_NUMBER; i++) { decodeData(&camera[i], ¤tFrame[i], results[i]); if ((*results[i]) == NULL) { SYNC_PRINT(("V4L2CaptureInterface::getFrame(): Precrash condition\n")); } } if (currentFrame[LEFT_FRAME].isFilled) result.setTimeStampLeft (currentFrame[LEFT_FRAME].usecsTimeStamp()); if (currentFrame[RIGHT_FRAME].isFilled) result.setTimeStampRight (currentFrame[RIGHT_FRAME].usecsTimeStamp()); if (skippedCount == 0) { //SYNC_PRINT(("Warning: Requested same frames twice. Is this by design?\n")); } stats.framesSkipped = skippedCount > 0 ? skippedCount - 1 : 0; skippedCount = 0; protectFrame.unlock(); stats.values[CaptureStatistics::DECODING_TIME] = start.usecsToNow(); stats.values[CaptureStatistics::INTERFRAME_DELAY] = frameDelay; int64_t desync = currentFrame[LEFT_FRAME].usecsTimeStamp() - currentFrame[RIGHT_FRAME].usecsTimeStamp(); stats.values[CaptureStatistics::DESYNC_TIME] = desync > 0 ? desync : -desync; stats.values[CaptureStatistics::DATA_SIZE] = currentFrame[LEFT_FRAME].bytesused; if (imageInterfaceReceiver != NULL) { imageInterfaceReceiver->newStatisticsReadyCallback(stats); } return result; }