[libcamera-devel] [PATCH v2 4/6] fixup! android: camera_device: Compute frame durations
Jacopo Mondi
jacopo at jmondi.org
Tue Mar 9 08:30:54 CET 2021
Hi Laurent,
On Tue, Mar 09, 2021 at 01:47:01AM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> On Tue, Feb 09, 2021 at 03:50:55AM +0200, Laurent Pinchart wrote:
> > On Tue, Jan 26, 2021 at 06:30:06PM +0100, Jacopo Mondi wrote:
> > > ---
> > > src/android/camera_device.cpp | 20 ++++++++++++++++++++
> > > 1 file changed, 20 insertions(+)
> > >
> > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > > index e3d43bea4700..5a8072a8a007 100644
> > > --- a/src/android/camera_device.cpp
> > > +++ b/src/android/camera_device.cpp
> > > @@ -768,6 +768,26 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
> > > minFrameDurationUsec = frameDurationsInfo->second.min().get<int64_t>();
> > > maxFrameDurationUsec = frameDurationsInfo->second.max().get<int64_t>();
> > >
> > > + /*
> > > + * Adjust the minimum frame duration to comply with Android
> > > + * requirements. The camera service mandates all preview/record
> > > + * streams to have a minimum frame duration < 33,366 milliseconds
> > > + * (see MAX_PREVIEW_RECORD_DURATION_NS in the camera service
> > > + * implementation).
> > > + *
> > > + * If we're close enough (+- 500 useconds) to that value round
> > > + * the minimum frame duration of the camera to an accepted
> > > + * value.
> > > + */
> > > + static constexpr double MIN_PREVIEW_RECORD_FPS = 29.97;
> > > + static constexpr int64_t MAX_PREVIEW_RECORD_DURATION_US = 1e6 / MIN_PREVIEW_RECORD_FPS;
> >
> > You could write
> >
> > static constexpr int64_t MAX_PREVIEW_RECORD_DURATION_US = 1e6 / 29.97;
> >
> > as MIN_PREVIEW_RECORD_FPS is only used here.
> >
> > > + if (minFrameDurationUsec > MAX_PREVIEW_RECORD_DURATION_US) {
> > > + double frameDurationDelta = minFrameDurationUsec -
> > > + MAX_PREVIEW_RECORD_DURATION_US;
> > > + if (frameDurationDelta < 500)
> > > + minFrameDurationUsec = MAX_PREVIEW_RECORD_DURATION_US - 1;
> > > + }
> >
> > Is the following more readable ?
> >
> > if (minFrameDurationUsec > MAX_PREVIEW_RECORD_DURATION_US &&
> > minFrameDurationUsec < MAX_PREVIEW_RECORD_DURATION_US + 500) {
> > minFrameDurationUsec = MAX_PREVIEW_RECORD_DURATION_US - 1;
> >
> > This is of course a horrible hack, but if we have no choice...
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> >
> > What's the maximum FPS we otherwise report ? Is it really that the
> > sensor can't reach 30fps, or is there an issue somewhere else ?
>
> Do you have any data regarding this question, why can't we achieve 30fps
I thought I reported it already, sorry about that. The sensor can
achieve 29.94 FPS while android wants 29.97
> without cheating ? I'm also curious, how does the Intel IPU3 HAL handle
> this issue ?
>
Afaict from looking at the static metadata they report a fram duration
of 33.33 milliseconds unconditionally (30.00.. FPS)
> > > /*
> > > * The AE routine frame rate limits are computed using the frame
> > > * duration limits, as libcamera clips the AE routine to the
>
> --
> Regards,
>
> Laurent Pinchart
More information about the libcamera-devel
mailing list