Message ID | 20250710144316.601640-1-barnabas.pocze@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Barnabás, On Thu, 10 Jul 2025 at 15:43, Barnabás Pőcze <barnabas.pocze@ideasonboard.com> wrote: > > `SensorTimestamp` and `FrameWallClock` should always be available. However, > if that ever changes or they are not available for some unforeseen reason, > setting them to 0 is not ideal. That makes it more complicated for the > application to detect these cases (since they have to check the existence > either way), and if an application blindly assumes e.g. that `SensorTimestamp` > is monotonically increasing, then receiving a timestamp of 0 will likely > cause issues. > > So simply omit them from the request metadata if they are not available. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Looks good to me. Reviewed-by: Naushir Patuck <naush@raspberrypi.com> > --- > src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp > index eafe94427..563df198e 100644 > --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp > +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp > @@ -1487,10 +1487,10 @@ void CameraData::checkRequestCompleted() > > void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request *request) > { > - request->metadata().set(controls::SensorTimestamp, > - bufferControls.get(controls::SensorTimestamp).value_or(0)); > - request->metadata().set(controls::FrameWallClock, > - bufferControls.get(controls::FrameWallClock).value_or(0)); > + if (auto x = bufferControls.get(controls::SensorTimestamp)) > + request->metadata().set(controls::SensorTimestamp, *x); > + if (auto x = bufferControls.get(controls::FrameWallClock)) > + request->metadata().set(controls::FrameWallClock, *x); > > if (cropParams_.size()) { > std::vector<Rectangle> crops; > -- > 2.50.0 >
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index eafe94427..563df198e 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1487,10 +1487,10 @@ void CameraData::checkRequestCompleted() void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request *request) { - request->metadata().set(controls::SensorTimestamp, - bufferControls.get(controls::SensorTimestamp).value_or(0)); - request->metadata().set(controls::FrameWallClock, - bufferControls.get(controls::FrameWallClock).value_or(0)); + if (auto x = bufferControls.get(controls::SensorTimestamp)) + request->metadata().set(controls::SensorTimestamp, *x); + if (auto x = bufferControls.get(controls::FrameWallClock)) + request->metadata().set(controls::FrameWallClock, *x); if (cropParams_.size()) { std::vector<Rectangle> crops;
`SensorTimestamp` and `FrameWallClock` should always be available. However, if that ever changes or they are not available for some unforeseen reason, setting them to 0 is not ideal. That makes it more complicated for the application to detect these cases (since they have to check the existence either way), and if an application blindly assumes e.g. that `SensorTimestamp` is monotonically increasing, then receiving a timestamp of 0 will likely cause issues. So simply omit them from the request metadata if they are not available. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)