summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-26 23:45:04 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-03 00:59:05 +0200
commitbe50270b7dedd596d5cca34ca66dce82fc92fe73 (patch)
tree0a1144b1afcfcbe5aa3bd530e5f109483084f644 /src
parentfb8c63d69cbb7a4a32b6b9c81a92af1baf6c78fa (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/simple/converter.cpp24
-rw-r--r--src/libcamera/pipeline/simple/converter.h11
-rw-r--r--src/libcamera/pipeline/simple/simple.cpp24
3 files changed, 25 insertions, 34 deletions
diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
index f782fbc6..8324baed 100644
--- a/src/libcamera/pipeline/simple/converter.cpp
+++ b/src/libcamera/pipeline/simple/converter.cpp
@@ -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 */
diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h
index 6e3df553..be6844ca 100644
--- a/src/libcamera/pipeline/simple/converter.h
+++ b/src/libcamera/pipeline/simple/converter.h
@@ -9,7 +9,6 @@
#define __LIBCAMERA_PIPELINE_SIMPLE_CONVERTER_H__
#include <memory>
-#include <queue>
#include <tuple>
#include <vector>
@@ -48,17 +47,15 @@ public:
int queueBuffers(FrameBuffer *input, FrameBuffer *output);
- Signal<FrameBuffer *, FrameBuffer *> bufferReady;
+ Signal<FrameBuffer *> inputBufferReady;
+ Signal<FrameBuffer *> outputBufferReady;
private:
- void captureBufferReady(FrameBuffer *buffer);
- void outputBufferReady(FrameBuffer *buffer);
+ void m2mInputBufferReady(FrameBuffer *buffer);
+ void m2mOutputBufferReady(FrameBuffer *buffer);
std::unique_ptr<V4L2M2MDevice> m2m_;
- std::queue<FrameBuffer *> captureDoneQueue_;
- std::queue<FrameBuffer *> outputDoneQueue_;
-
unsigned int inputBufferCount_;
unsigned int outputBufferCount_;
};
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 9ad3aa62..a5089dba 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -144,7 +144,8 @@ private:
}
void bufferReady(FrameBuffer *buffer);
- void converterDone(FrameBuffer *input, FrameBuffer *output);
+ void converterInputDone(FrameBuffer *buffer);
+ void converterOutputDone(FrameBuffer *buffer);
MediaDevice *media_;
std::map<const MediaEntity *, std::unique_ptr<V4L2VideoDevice>> videos_;
@@ -768,7 +769,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
<< "Failed to create converter, disabling format conversion";
converter_.reset();
} else {
- converter_->bufferReady.connect(this, &SimplePipelineHandler::converterDone);
+ converter_->inputBufferReady.connect(this, &SimplePipelineHandler::converterInputDone);
+ converter_->outputBufferReady.connect(this, &SimplePipelineHandler::converterOutputDone);
}
}
@@ -925,19 +927,23 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
completeRequest(request);
}
-void SimplePipelineHandler::converterDone(FrameBuffer *input,
- FrameBuffer *output)
+void SimplePipelineHandler::converterInputDone(FrameBuffer *buffer)
{
ASSERT(activeCamera_);
SimpleCameraData *data = cameraData(activeCamera_);
+ /* Queue the input buffer back for capture. */
+ data->video_->queueBuffer(buffer);
+}
+
+void SimplePipelineHandler::converterOutputDone(FrameBuffer *buffer)
+{
+ ASSERT(activeCamera_);
+
/* Complete the request. */
- Request *request = output->request();
- completeBuffer(request, output);
+ Request *request = buffer->request();
+ completeBuffer(request, buffer);
completeRequest(request);
-
- /* Queue the input buffer back for capture. */
- data->video_->queueBuffer(input);
}
REGISTER_PIPELINE_HANDLER(SimplePipelineHandler)