public void captureSetup(iVideoTrack videoTrack, int decodedBuffersCount, sDecodedVideoSize decodedSize) { this.decodedSize = decodedSize; if (pendingFrames.capacity != decodedBuffersCount) { pendingFrames = new PendingFrames(decodedBuffersCount); } // Set decoded format. Pi4 Linux failed to implement V4L2 stateful decoder setup workflow, instead computing everything manually, from parsed SPS. sPixelFormatMP sdf = computeDecodedFormat(ref decodedSize); device.setDataFormat(eBufferType.VideoCaptureMPlane, ref sdf); // Apparently, Pi4 hardware or drivers is unable to process S_SELECTION request and crop the video. Cropping it later while rendering NV12 into RGB. /* sSelection selection = default; * selection.type = eBufferType.VideoCaptureMPlane; * selection.target = eSelectionTarget.Compose; * selection.flags = eSelectionFlags.LesserOrEqual; * selection.rect = decodedSize.cropRect; * device.file.call( eControlCode.S_SELECTION, ref selection ); * device.file.call( eControlCode.G_SELECTION, ref selection ); * CRect selectedRect = selection.rect; * if( selectedRect == decodedSize.cropRect ) * Logger.logVerbose( "Video cropping: decoded size {0}, cropped to {1}", decodedSize.size, selectedRect ); * else * Logger.logInfo( "Video cropping: decoded size {0}, asked to crop to {1}, GPU driver replaced with {2}", decodedSize.size, decodedSize.cropRect, selectedRect ); */ sdf = device.getDataFormat(eBufferType.VideoCaptureMPlane); decoded = new DecodedQueue(device, decodedBuffersCount); // decoded.exportTextures( renderDev, device, ref sdf ); // Start streaming of the output queue device.startStreaming(eBufferType.VideoCaptureMPlane); }