[libcamera-devel,v2,2/2] android: Log stream types using PixelFormat::toString()
diff mbox series

Message ID 20211125131224.927640-3-umang.jain@ideasonboard.com
State Rejected
Headers show
Series
  • Improve stream type logging
Related show

Commit Message

Umang Jain Nov. 25, 2021, 1:12 p.m. UTC
Log stream types using PixelFormat::toString() instead of hex values,
since that is more human readable.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/android/camera_capabilities.cpp | 5 +++--
 src/android/camera_device.cpp       | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Hirokazu Honda Nov. 25, 2021, 1:15 p.m. UTC | #1
Hi Umang, thank you for the patch.

On Thu, Nov 25, 2021 at 10:12 PM Umang Jain <umang.jain@ideasonboard.com> wrote:
>
> Log stream types using PixelFormat::toString() instead of hex values,
> since that is more human readable.
>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> ---
>  src/android/camera_capabilities.cpp | 5 +++--
>  src/android/camera_device.cpp       | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index f357902e..71f302c4 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
>         LOG(HAL, Debug) << "Collected stream configuration map: ";
>         for (const auto &entry : streamConfigurations_)
>                 LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
> -                               << utils::hex(entry.androidFormat) << " }";
> +                               << toPixelFormat(entry.androidFormat).toString()
> +                               << " }";
>
>         return 0;
>  }
> @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
>                 minFrameDurations.push_back(entry.minFrameDurationNsec);
>
>                 LOG(HAL, Debug)
> -                       << "Output Stream: " << utils::hex(entry.androidFormat)
> +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
>                         << " (" << entry.resolution.toString() << ")["
>                         << entry.minFrameDurationNsec << "]"
>                         << "@" << fps;
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index ad4bf07c..cc6dccc1 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>                                << ", direction: " << directionToString(stream->stream_type)
>                                << ", width: " << stream->width
>                                << ", height: " << stream->height
> -                              << ", format: " << utils::hex(stream->format)
> +                              << ", format: " << format.toString()
>                                << ", rotation: " << rotationToString(stream->rotation)
>  #if defined(OS_CHROMEOS)
>                                << ", crop_rotate_scale_degrees: "
> --
> 2.31.0
>
Kieran Bingham Nov. 25, 2021, 1:28 p.m. UTC | #2
Quoting Umang Jain (2021-11-25 13:12:24)
> Log stream types using PixelFormat::toString() instead of hex values,
> since that is more human readable.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/android/camera_capabilities.cpp | 5 +++--
>  src/android/camera_device.cpp       | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index f357902e..71f302c4 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
>         LOG(HAL, Debug) << "Collected stream configuration map: ";
>         for (const auto &entry : streamConfigurations_)
>                 LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
> -                               << utils::hex(entry.androidFormat) << " }";
> +                               << toPixelFormat(entry.androidFormat).toString()

Do all androidFormats get correctly converted to libcamera formats
currently?

This might still need to print the Android format, or have an android
specific string function... (Or print both the android hex string, and
our representation of it?)


> +                               << " }";
>  
>         return 0;
>  }
> @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
>                 minFrameDurations.push_back(entry.minFrameDurationNsec);
>  
>                 LOG(HAL, Debug)
> -                       << "Output Stream: " << utils::hex(entry.androidFormat)
> +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
>                         << " (" << entry.resolution.toString() << ")["
>                         << entry.minFrameDurationNsec << "]"
>                         << "@" << fps;
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index ad4bf07c..cc6dccc1 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>                                << ", direction: " << directionToString(stream->stream_type)
>                                << ", width: " << stream->width
>                                << ", height: " << stream->height
> -                              << ", format: " << utils::hex(stream->format)
> +                              << ", format: " << format.toString()
>                                << ", rotation: " << rotationToString(stream->rotation)
>  #if defined(OS_CHROMEOS)
>                                << ", crop_rotate_scale_degrees: "
> -- 
> 2.31.0
>
Umang Jain Nov. 25, 2021, 1:45 p.m. UTC | #3
Hi Kieran,

On 11/25/21 6:58 PM, Kieran Bingham wrote:
> Quoting Umang Jain (2021-11-25 13:12:24)
>> Log stream types using PixelFormat::toString() instead of hex values,
>> since that is more human readable.
>>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>> ---
>>   src/android/camera_capabilities.cpp | 5 +++--
>>   src/android/camera_device.cpp       | 2 +-
>>   2 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
>> index f357902e..71f302c4 100644
>> --- a/src/android/camera_capabilities.cpp
>> +++ b/src/android/camera_capabilities.cpp
>> @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
>>          LOG(HAL, Debug) << "Collected stream configuration map: ";
>>          for (const auto &entry : streamConfigurations_)
>>                  LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
>> -                               << utils::hex(entry.androidFormat) << " }";
>> +                               << toPixelFormat(entry.androidFormat).toString()
> Do all androidFormats get correctly converted to libcamera formats
> currently?


Yes, that's my interpretation of toPixelFormat()

>
> This might still need to print the Android format, or have an android
> specific string function... (Or print both the android hex string, and
> our representation of it?)


If the format is not supported, toPixelFormat shall print an Error about 
the unsupported format (along with it's hex string)

         if (it == formatsMap_.end()) {
             LOG(HAL, Error) << "Requested format " << utils::hex(format)
                     << " not supported";

>
>
>> +                               << " }";
>>   
>>          return 0;
>>   }
>> @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
>>                  minFrameDurations.push_back(entry.minFrameDurationNsec);
>>   
>>                  LOG(HAL, Debug)
>> -                       << "Output Stream: " << utils::hex(entry.androidFormat)
>> +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
>>                          << " (" << entry.resolution.toString() << ")["
>>                          << entry.minFrameDurationNsec << "]"
>>                          << "@" << fps;
>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
>> index ad4bf07c..cc6dccc1 100644
>> --- a/src/android/camera_device.cpp
>> +++ b/src/android/camera_device.cpp
>> @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>>                                 << ", direction: " << directionToString(stream->stream_type)
>>                                 << ", width: " << stream->width
>>                                 << ", height: " << stream->height
>> -                              << ", format: " << utils::hex(stream->format)
>> +                              << ", format: " << format.toString()
>>                                 << ", rotation: " << rotationToString(stream->rotation)
>>   #if defined(OS_CHROMEOS)
>>                                 << ", crop_rotate_scale_degrees: "
>> -- 
>> 2.31.0
>>
Laurent Pinchart Nov. 25, 2021, 1:49 p.m. UTC | #4
On Thu, Nov 25, 2021 at 01:28:11PM +0000, Kieran Bingham wrote:
> Quoting Umang Jain (2021-11-25 13:12:24)
> > Log stream types using PixelFormat::toString() instead of hex values,
> > since that is more human readable.
> > 
> > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> > ---
> >  src/android/camera_capabilities.cpp | 5 +++--
> >  src/android/camera_device.cpp       | 2 +-
> >  2 files changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> > index f357902e..71f302c4 100644
> > --- a/src/android/camera_capabilities.cpp
> > +++ b/src/android/camera_capabilities.cpp
> > @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
> >         LOG(HAL, Debug) << "Collected stream configuration map: ";
> >         for (const auto &entry : streamConfigurations_)
> >                 LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
> > -                               << utils::hex(entry.androidFormat) << " }";
> > +                               << toPixelFormat(entry.androidFormat).toString()
> 
> Do all androidFormats get correctly converted to libcamera formats
> currently?
> 
> This might still need to print the Android format, or have an android
> specific string function... (Or print both the android hex string, and
> our representation of it?)

That's also my concern. If we receive from the camera service a format
we don't support, printing an "unknown" or similar name hinders
debugging. I'd rather keep the android format in hex in the locations
before we validate it.

> > +                               << " }";
> >  
> >         return 0;
> >  }
> > @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
> >                 minFrameDurations.push_back(entry.minFrameDurationNsec);
> >  
> >                 LOG(HAL, Debug)
> > -                       << "Output Stream: " << utils::hex(entry.androidFormat)
> > +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
> >                         << " (" << entry.resolution.toString() << ")["
> >                         << entry.minFrameDurationNsec << "]"
> >                         << "@" << fps;
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index ad4bf07c..cc6dccc1 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >                                << ", direction: " << directionToString(stream->stream_type)
> >                                << ", width: " << stream->width
> >                                << ", height: " << stream->height
> > -                              << ", format: " << utils::hex(stream->format)
> > +                              << ", format: " << format.toString()
> >                                << ", rotation: " << rotationToString(stream->rotation)
> >  #if defined(OS_CHROMEOS)
> >                                << ", crop_rotate_scale_degrees: "
Kieran Bingham Nov. 25, 2021, 2:16 p.m. UTC | #5
Quoting Laurent Pinchart (2021-11-25 13:49:48)
> On Thu, Nov 25, 2021 at 01:28:11PM +0000, Kieran Bingham wrote:
> > Quoting Umang Jain (2021-11-25 13:12:24)
> > > Log stream types using PixelFormat::toString() instead of hex values,
> > > since that is more human readable.
> > > 
> > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> > > ---
> > >  src/android/camera_capabilities.cpp | 5 +++--
> > >  src/android/camera_device.cpp       | 2 +-
> > >  2 files changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> > > index f357902e..71f302c4 100644
> > > --- a/src/android/camera_capabilities.cpp
> > > +++ b/src/android/camera_capabilities.cpp
> > > @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
> > >         LOG(HAL, Debug) << "Collected stream configuration map: ";
> > >         for (const auto &entry : streamConfigurations_)
> > >                 LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
> > > -                               << utils::hex(entry.androidFormat) << " }";
> > > +                               << toPixelFormat(entry.androidFormat).toString()
> > 
> > Do all androidFormats get correctly converted to libcamera formats
> > currently?
> > 
> > This might still need to print the Android format, or have an android
> > specific string function... (Or print both the android hex string, and
> > our representation of it?)
> 
> That's also my concern. If we receive from the camera service a format
> we don't support, printing an "unknown" or similar name hinders
> debugging. I'd rather keep the android format in hex in the locations
> before we validate it.

I think we should have both. Or only print the hex if it's unknown ...

--
Kieran


> 
> > > +                               << " }";
> > >  
> > >         return 0;
> > >  }
> > > @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
> > >                 minFrameDurations.push_back(entry.minFrameDurationNsec);
> > >  
> > >                 LOG(HAL, Debug)
> > > -                       << "Output Stream: " << utils::hex(entry.androidFormat)
> > > +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
> > >                         << " (" << entry.resolution.toString() << ")["
> > >                         << entry.minFrameDurationNsec << "]"
> > >                         << "@" << fps;
> > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > > index ad4bf07c..cc6dccc1 100644
> > > --- a/src/android/camera_device.cpp
> > > +++ b/src/android/camera_device.cpp
> > > @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> > >                                << ", direction: " << directionToString(stream->stream_type)
> > >                                << ", width: " << stream->width
> > >                                << ", height: " << stream->height
> > > -                              << ", format: " << utils::hex(stream->format)
> > > +                              << ", format: " << format.toString()
> > >                                << ", rotation: " << rotationToString(stream->rotation)
> > >  #if defined(OS_CHROMEOS)
> > >                                << ", crop_rotate_scale_degrees: "
> 
> -- 
> Regards,
> 
> Laurent Pinchart
Umang Jain Nov. 25, 2021, 2:25 p.m. UTC | #6
Hi

On 11/25/21 7:46 PM, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2021-11-25 13:49:48)
>> On Thu, Nov 25, 2021 at 01:28:11PM +0000, Kieran Bingham wrote:
>>> Quoting Umang Jain (2021-11-25 13:12:24)
>>>> Log stream types using PixelFormat::toString() instead of hex values,
>>>> since that is more human readable.
>>>>
>>>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>>>> ---
>>>>   src/android/camera_capabilities.cpp | 5 +++--
>>>>   src/android/camera_device.cpp       | 2 +-
>>>>   2 files changed, 4 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
>>>> index f357902e..71f302c4 100644
>>>> --- a/src/android/camera_capabilities.cpp
>>>> +++ b/src/android/camera_capabilities.cpp
>>>> @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
>>>>          LOG(HAL, Debug) << "Collected stream configuration map: ";
>>>>          for (const auto &entry : streamConfigurations_)
>>>>                  LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
>>>> -                               << utils::hex(entry.androidFormat) << " }";
>>>> +                               << toPixelFormat(entry.androidFormat).toString()
>>> Do all androidFormats get correctly converted to libcamera formats
>>> currently?
>>>
>>> This might still need to print the Android format, or have an android
>>> specific string function... (Or print both the android hex string, and
>>> our representation of it?)
>> That's also my concern. If we receive from the camera service a format
>> we don't support, printing an "unknown" or similar name hinders
>> debugging. I'd rather keep the android format in hex in the locations
>> before we validate it.
> I think we should have both. Or only print the hex if it's unknown ...


In that case, the hex is printed if the format is unknown as part of 
Error logging. It is done through CameraCapabilites::toPixelFormat()

>
> --
> Kieran
>
>
>>>> +                               << " }";
>>>>   
>>>>          return 0;
>>>>   }
>>>> @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
>>>>                  minFrameDurations.push_back(entry.minFrameDurationNsec);
>>>>   
>>>>                  LOG(HAL, Debug)
>>>> -                       << "Output Stream: " << utils::hex(entry.androidFormat)
>>>> +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
>>>>                          << " (" << entry.resolution.toString() << ")["
>>>>                          << entry.minFrameDurationNsec << "]"
>>>>                          << "@" << fps;
>>>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
>>>> index ad4bf07c..cc6dccc1 100644
>>>> --- a/src/android/camera_device.cpp
>>>> +++ b/src/android/camera_device.cpp
>>>> @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>>>>                                 << ", direction: " << directionToString(stream->stream_type)
>>>>                                 << ", width: " << stream->width
>>>>                                 << ", height: " << stream->height
>>>> -                              << ", format: " << utils::hex(stream->format)
>>>> +                              << ", format: " << format.toString()


Also, the 'format' here comes from

         PixelFormat format = capabilities_.toPixelFormat(stream->format);

a few lines above.

>>>>                                 << ", rotation: " << rotationToString(stream->rotation)
>>>>   #if defined(OS_CHROMEOS)
>>>>                                 << ", crop_rotate_scale_degrees: "
>> -- 
>> Regards,
>>
>> Laurent Pinchart
Kieran Bingham Nov. 25, 2021, 9:53 p.m. UTC | #7
Quoting Umang Jain (2021-11-25 14:25:01)
> Hi
> 
> On 11/25/21 7:46 PM, Kieran Bingham wrote:
> > Quoting Laurent Pinchart (2021-11-25 13:49:48)
> >> On Thu, Nov 25, 2021 at 01:28:11PM +0000, Kieran Bingham wrote:
> >>> Quoting Umang Jain (2021-11-25 13:12:24)
> >>>> Log stream types using PixelFormat::toString() instead of hex values,
> >>>> since that is more human readable.
> >>>>
> >>>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> >>>> ---
> >>>>   src/android/camera_capabilities.cpp | 5 +++--
> >>>>   src/android/camera_device.cpp       | 2 +-
> >>>>   2 files changed, 4 insertions(+), 3 deletions(-)
> >>>>
> >>>> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> >>>> index f357902e..71f302c4 100644
> >>>> --- a/src/android/camera_capabilities.cpp
> >>>> +++ b/src/android/camera_capabilities.cpp
> >>>> @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
> >>>>          LOG(HAL, Debug) << "Collected stream configuration map: ";
> >>>>          for (const auto &entry : streamConfigurations_)
> >>>>                  LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
> >>>> -                               << utils::hex(entry.androidFormat) << " }";
> >>>> +                               << toPixelFormat(entry.androidFormat).toString()
> >>> Do all androidFormats get correctly converted to libcamera formats
> >>> currently?
> >>>
> >>> This might still need to print the Android format, or have an android
> >>> specific string function... (Or print both the android hex string, and
> >>> our representation of it?)
> >> That's also my concern. If we receive from the camera service a format
> >> we don't support, printing an "unknown" or similar name hinders
> >> debugging. I'd rather keep the android format in hex in the locations
> >> before we validate it.
> > I think we should have both. Or only print the hex if it's unknown ...
> 
> 
> In that case, the hex is printed if the format is unknown as part of 
> Error logging. It is done through CameraCapabilites::toPixelFormat()

In which case, I'd be content with this.

Laurent?


> >
> > --
> > Kieran
> >
> >
> >>>> +                               << " }";
> >>>>   
> >>>>          return 0;
> >>>>   }
> >>>> @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
> >>>>                  minFrameDurations.push_back(entry.minFrameDurationNsec);
> >>>>   
> >>>>                  LOG(HAL, Debug)
> >>>> -                       << "Output Stream: " << utils::hex(entry.androidFormat)
> >>>> +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
> >>>>                          << " (" << entry.resolution.toString() << ")["
> >>>>                          << entry.minFrameDurationNsec << "]"
> >>>>                          << "@" << fps;
> >>>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> >>>> index ad4bf07c..cc6dccc1 100644
> >>>> --- a/src/android/camera_device.cpp
> >>>> +++ b/src/android/camera_device.cpp
> >>>> @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >>>>                                 << ", direction: " << directionToString(stream->stream_type)
> >>>>                                 << ", width: " << stream->width
> >>>>                                 << ", height: " << stream->height
> >>>> -                              << ", format: " << utils::hex(stream->format)
> >>>> +                              << ", format: " << format.toString()
> 
> 
> Also, the 'format' here comes from
> 
>          PixelFormat format = capabilities_.toPixelFormat(stream->format);
> 
> a few lines above.
> 
> >>>>                                 << ", rotation: " << rotationToString(stream->rotation)
> >>>>   #if defined(OS_CHROMEOS)
> >>>>                                 << ", crop_rotate_scale_degrees: "
> >> -- 
> >> Regards,
> >>
> >> Laurent Pinchart
Laurent Pinchart Nov. 25, 2021, 10:46 p.m. UTC | #8
On Thu, Nov 25, 2021 at 09:53:24PM +0000, Kieran Bingham wrote:
> Quoting Umang Jain (2021-11-25 14:25:01)
> > On 11/25/21 7:46 PM, Kieran Bingham wrote:
> > > Quoting Laurent Pinchart (2021-11-25 13:49:48)
> > >> On Thu, Nov 25, 2021 at 01:28:11PM +0000, Kieran Bingham wrote:
> > >>> Quoting Umang Jain (2021-11-25 13:12:24)
> > >>>> Log stream types using PixelFormat::toString() instead of hex values,
> > >>>> since that is more human readable.
> > >>>>
> > >>>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> > >>>> ---
> > >>>>   src/android/camera_capabilities.cpp | 5 +++--
> > >>>>   src/android/camera_device.cpp       | 2 +-
> > >>>>   2 files changed, 4 insertions(+), 3 deletions(-)
> > >>>>
> > >>>> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> > >>>> index f357902e..71f302c4 100644
> > >>>> --- a/src/android/camera_capabilities.cpp
> > >>>> +++ b/src/android/camera_capabilities.cpp
> > >>>> @@ -713,7 +713,8 @@ int CameraCapabilities::initializeStreamConfigurations()
> > >>>>          LOG(HAL, Debug) << "Collected stream configuration map: ";
> > >>>>          for (const auto &entry : streamConfigurations_)
> > >>>>                  LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
> > >>>> -                               << utils::hex(entry.androidFormat) << " }";
> > >>>> +                               << toPixelFormat(entry.androidFormat).toString()
> > >>>
> > >>> Do all androidFormats get correctly converted to libcamera formats
> > >>> currently?
> > >>>
> > >>> This might still need to print the Android format, or have an android
> > >>> specific string function... (Or print both the android hex string, and
> > >>> our representation of it?)
> > >>
> > >> That's also my concern. If we receive from the camera service a format
> > >> we don't support, printing an "unknown" or similar name hinders
> > >> debugging. I'd rather keep the android format in hex in the locations
> > >> before we validate it.
> > >
> > > I think we should have both. Or only print the hex if it's unknown ...
> > 
> > In that case, the hex is printed if the format is unknown as part of 
> > Error logging. It is done through CameraCapabilites::toPixelFormat()
> 
> In which case, I'd be content with this.
> 
> Laurent?

I'm sorry, but it still bothers me a bit :-S The mapping between Android
formats and libcamera formats isn't 1:1, we map multiple Android formats
to NV21 for instance. With this patch we lose the ability to tell the
different Android formats apart.

The Camera3Format structure contains a name member. If we want to print
a name instead of the hex value, we should add a function that will use
the camera3FormatsMap to lookup the name and return something like
"Unknown (0x....)" when the format isn't known.

> > >>>> +                               << " }";
> > >>>>   
> > >>>>          return 0;
> > >>>>   }
> > >>>> @@ -1303,7 +1304,7 @@ int CameraCapabilities::initializeStaticMetadata()
> > >>>>                  minFrameDurations.push_back(entry.minFrameDurationNsec);
> > >>>>   
> > >>>>                  LOG(HAL, Debug)
> > >>>> -                       << "Output Stream: " << utils::hex(entry.androidFormat)
> > >>>> +                       << "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
> > >>>>                          << " (" << entry.resolution.toString() << ")["
> > >>>>                          << entry.minFrameDurationNsec << "]"
> > >>>>                          << "@" << fps;
> > >>>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > >>>> index ad4bf07c..cc6dccc1 100644
> > >>>> --- a/src/android/camera_device.cpp
> > >>>> +++ b/src/android/camera_device.cpp
> > >>>> @@ -566,7 +566,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> > >>>>                                 << ", direction: " << directionToString(stream->stream_type)
> > >>>>                                 << ", width: " << stream->width
> > >>>>                                 << ", height: " << stream->height
> > >>>> -                              << ", format: " << utils::hex(stream->format)
> > >>>> +                              << ", format: " << format.toString()
> > 
> > Also, the 'format' here comes from
> > 
> >          PixelFormat format = capabilities_.toPixelFormat(stream->format);
> > 
> > a few lines above.
> > 
> > >>>>                                 << ", rotation: " << rotationToString(stream->rotation)
> > >>>>   #if defined(OS_CHROMEOS)
> > >>>>                                 << ", crop_rotate_scale_degrees: "

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index f357902e..71f302c4 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -713,7 +713,8 @@  int CameraCapabilities::initializeStreamConfigurations()
 	LOG(HAL, Debug) << "Collected stream configuration map: ";
 	for (const auto &entry : streamConfigurations_)
 		LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
-				<< utils::hex(entry.androidFormat) << " }";
+				<< toPixelFormat(entry.androidFormat).toString()
+				<< " }";
 
 	return 0;
 }
@@ -1303,7 +1304,7 @@  int CameraCapabilities::initializeStaticMetadata()
 		minFrameDurations.push_back(entry.minFrameDurationNsec);
 
 		LOG(HAL, Debug)
-			<< "Output Stream: " << utils::hex(entry.androidFormat)
+			<< "Output Stream: " << toPixelFormat(entry.androidFormat).toString()
 			<< " (" << entry.resolution.toString() << ")["
 			<< entry.minFrameDurationNsec << "]"
 			<< "@" << fps;
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ad4bf07c..cc6dccc1 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -566,7 +566,7 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 			       << ", direction: " << directionToString(stream->stream_type)
 			       << ", width: " << stream->width
 			       << ", height: " << stream->height
-			       << ", format: " << utils::hex(stream->format)
+			       << ", format: " << format.toString()
 			       << ", rotation: " << rotationToString(stream->rotation)
 #if defined(OS_CHROMEOS)
 			       << ", crop_rotate_scale_degrees: "