libcamera: pipeline: simple: converter: Decouple input and output completion

The SimpleConverter API signals completion of input and output buffer
pairs. This unnecessarily delays requeueing the input buffer to the
video capture queue until the output buffer completes, and also delays
signalling request completion until the input buffer completes. While
this shouldn't cause large delays in practice, it will also not scale
when multi-stream support will be added to the converter class.

To address the current issue and prepare for the future, decouple
signalling of input and output buffers completion.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
Laurent Pinchart
2020-12-26 23:45:04 +02:00
parent fb8c63d69c
commit be50270b7d
3 changed files with 26 additions and 35 deletions
+6 -18
View File
@@ -45,8 +45,8 @@ SimpleConverter::SimpleConverter(MediaDevice *media)
return;
}
m2m_->output()->bufferReady.connect(this, &SimpleConverter::outputBufferReady);
m2m_->capture()->bufferReady.connect(this, &SimpleConverter::captureBufferReady);
m2m_->output()->bufferReady.connect(this, &SimpleConverter::m2mInputBufferReady);
m2m_->capture()->bufferReady.connect(this, &SimpleConverter::m2mOutputBufferReady);
}
std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
@@ -247,26 +247,14 @@ int SimpleConverter::queueBuffers(FrameBuffer *input, FrameBuffer *output)
return 0;
}
void SimpleConverter::captureBufferReady(FrameBuffer *buffer)
void SimpleConverter::m2mInputBufferReady(FrameBuffer *buffer)
{
if (!outputDoneQueue_.empty()) {
FrameBuffer *other = outputDoneQueue_.front();
outputDoneQueue_.pop();
bufferReady.emit(other, buffer);
} else {
captureDoneQueue_.push(buffer);
}
inputBufferReady.emit(buffer);
}
void SimpleConverter::outputBufferReady(FrameBuffer *buffer)
void SimpleConverter::m2mOutputBufferReady(FrameBuffer *buffer)
{
if (!captureDoneQueue_.empty()) {
FrameBuffer *other = captureDoneQueue_.front();
captureDoneQueue_.pop();
bufferReady.emit(buffer, other);
} else {
outputDoneQueue_.push(buffer);
}
outputBufferReady.emit(buffer);
}
} /* namespace libcamera */