[libcamera-devel,v3,1/2] android: camera_capabilities: Clarify CameraMetadata allocation
diff mbox series

Message ID 20210923072453.130346-2-umang.jain@ideasonboard.com
State Superseded
Delegated to: Umang Jain
Headers show
Series
  • android: Fix generation of thumbnail for EXIF data
Related show

Commit Message

Umang Jain Sept. 23, 2021, 7:24 a.m. UTC
CameraMetadata's constructor take in number of entries and number of
bytes to be allocated for those entries. However, CameraMetadata is
already capable of resizing its container on the fly, in case more
entries are added to it. Hence, the numbers passed in during the
construction acts as hint values for initialization.

Clarify this in CameraCapabilities::requestTemplatePreview() and
remove the \todo, as the arguments and the \todo gives the perspective
that we need to be quite accurate with the numbers of entries / bytes,
which is not the case.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/android/camera_capabilities.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Paul Elder Sept. 23, 2021, 7:33 a.m. UTC | #1
Hi Umang,

On Thu, Sep 23, 2021 at 12:54:52PM +0530, Umang Jain wrote:
> CameraMetadata's constructor take in number of entries and number of
> bytes to be allocated for those entries. However, CameraMetadata is
> already capable of resizing its container on the fly, in case more
> entries are added to it. Hence, the numbers passed in during the
> construction acts as hint values for initialization.
> 
> Clarify this in CameraCapabilities::requestTemplatePreview() and
> remove the \todo, as the arguments and the \todo gives the perspective
> that we need to be quite accurate with the numbers of entries / bytes,
> which is not the case.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/android/camera_capabilities.cpp | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index e92bca42..238b44db 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -1340,8 +1340,12 @@ std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateManual() cons
>  std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplatePreview() const
>  {
>  	/*
> -	 * \todo Keep this in sync with the actual number of entries.
> -	 * Currently: 20 entries, 35 bytes
> +	 * Give initial hint of entries and number of bytes to be allocated.
> +	 * It is deliberate that the hint is slightly larger than required, to
> +	 * avoid resizing the container.
> +	 *
> +	 * CameraMetadata is capable to resize the container on the fly, if the

s/to resize/of resizing/

s/the$/adding a new entry will exceed its capacity./


Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> +	 * number of entries get exceeded.
>  	 */
>  	auto requestTemplate = std::make_unique<CameraMetadata>(21, 36);
>  	if (!requestTemplate->isValid()) {
> -- 
> 2.31.0
>
Laurent Pinchart Sept. 23, 2021, 10:11 a.m. UTC | #2
On Thu, Sep 23, 2021 at 04:33:26PM +0900, paul.elder@ideasonboard.com wrote:
> On Thu, Sep 23, 2021 at 12:54:52PM +0530, Umang Jain wrote:
> > CameraMetadata's constructor take in number of entries and number of

s/take/takes/

> > bytes to be allocated for those entries. However, CameraMetadata is
> > already capable of resizing its container on the fly, in case more
> > entries are added to it. Hence, the numbers passed in during the
> > construction acts as hint values for initialization.

s/acts/act/

> > Clarify this in CameraCapabilities::requestTemplatePreview() and
> > remove the \todo, as the arguments and the \todo gives the perspective
> > that we need to be quite accurate with the numbers of entries / bytes,
> > which is not the case.
> > 
> > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> > ---
> >  src/android/camera_capabilities.cpp | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> > index e92bca42..238b44db 100644
> > --- a/src/android/camera_capabilities.cpp
> > +++ b/src/android/camera_capabilities.cpp
> > @@ -1340,8 +1340,12 @@ std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateManual() cons
> >  std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplatePreview() const
> >  {
> >  	/*
> > -	 * \todo Keep this in sync with the actual number of entries.
> > -	 * Currently: 20 entries, 35 bytes
> > +	 * Give initial hint of entries and number of bytes to be allocated.
> > +	 * It is deliberate that the hint is slightly larger than required, to
> > +	 * avoid resizing the container.
> > +	 *
> > +	 * CameraMetadata is capable to resize the container on the fly, if the
> 
> s/to resize/of resizing/
> 
> s/the$/adding a new entry will exceed its capacity./
> 
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

With this,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> > +	 * number of entries get exceeded.
> >  	 */
> >  	auto requestTemplate = std::make_unique<CameraMetadata>(21, 36);
> >  	if (!requestTemplate->isValid()) {

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index e92bca42..238b44db 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -1340,8 +1340,12 @@  std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateManual() cons
 std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplatePreview() const
 {
 	/*
-	 * \todo Keep this in sync with the actual number of entries.
-	 * Currently: 20 entries, 35 bytes
+	 * Give initial hint of entries and number of bytes to be allocated.
+	 * It is deliberate that the hint is slightly larger than required, to
+	 * avoid resizing the container.
+	 *
+	 * CameraMetadata is capable to resize the container on the fly, if the
+	 * number of entries get exceeded.
 	 */
 	auto requestTemplate = std::make_unique<CameraMetadata>(21, 36);
 	if (!requestTemplate->isValid()) {