[libcamera-devel,v3,19/30] android: jpeg: Use stride instead of image width for line address
diff mbox series

Message ID 20210906225636.14683-19-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: Handle fallout of FrameBuffer offset support
Related show

Commit Message

Laurent Pinchart Sept. 6, 2021, 10:56 p.m. UTC
When calculating the luma line address, the image width is used instead
of the stride. Without padding at the end of the line the the values
should be identical, but this is conceptually incorrect in any case. Fix
it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/android/jpeg/encoder_libjpeg.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Sept. 7, 2021, midnight UTC | #1
On 06/09/2021 23:56, Laurent Pinchart wrote:
> When calculating the luma line address, the image width is used instead
> of the stride. Without padding at the end of the line the the values
> should be identical, but this is conceptually incorrect in any case. Fix
> it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/android/jpeg/encoder_libjpeg.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp
> index b8b01e20a001..807a0949a8fc 100644
> --- a/src/android/jpeg/encoder_libjpeg.cpp
> +++ b/src/android/jpeg/encoder_libjpeg.cpp
> @@ -152,7 +152,7 @@ void EncoderLibJpeg::compressNV(Span<const uint8_t> frame)
>  	for (unsigned int y = 0; y < compress_.image_height; y++) {
>  		unsigned char *dst = &tmprowbuf[0];
>  
> -		const unsigned char *src_y = src + y * compress_.image_width;
> +		const unsigned char *src_y = src + y * y_stride;
>  		const unsigned char *src_cb = src_c + (y / vertSubSample) * c_stride + cb_pos;
>  		const unsigned char *src_cr = src_c + (y / vertSubSample) * c_stride + cr_pos;
>  
>
Jean-Michel Hautbois Sept. 7, 2021, 2:22 p.m. UTC | #2
Hi Laurent,

On 07/09/2021 02:00, Kieran Bingham wrote:
> On 06/09/2021 23:56, Laurent Pinchart wrote:
>> When calculating the luma line address, the image width is used instead
>> of the stride. Without padding at the end of the line the the values
>> should be identical, but this is conceptually incorrect in any case. Fix
>> it.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> 
>> ---
>>  src/android/jpeg/encoder_libjpeg.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp
>> index b8b01e20a001..807a0949a8fc 100644
>> --- a/src/android/jpeg/encoder_libjpeg.cpp
>> +++ b/src/android/jpeg/encoder_libjpeg.cpp
>> @@ -152,7 +152,7 @@ void EncoderLibJpeg::compressNV(Span<const uint8_t> frame)
>>  	for (unsigned int y = 0; y < compress_.image_height; y++) {
>>  		unsigned char *dst = &tmprowbuf[0];
>>  
>> -		const unsigned char *src_y = src + y * compress_.image_width;
>> +		const unsigned char *src_y = src + y * y_stride;
>>  		const unsigned char *src_cb = src_c + (y / vertSubSample) * c_stride + cb_pos;
>>  		const unsigned char *src_cr = src_c + (y / vertSubSample) * c_stride + cr_pos;
>>  
>>

Patch
diff mbox series

diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp
index b8b01e20a001..807a0949a8fc 100644
--- a/src/android/jpeg/encoder_libjpeg.cpp
+++ b/src/android/jpeg/encoder_libjpeg.cpp
@@ -152,7 +152,7 @@  void EncoderLibJpeg::compressNV(Span<const uint8_t> frame)
 	for (unsigned int y = 0; y < compress_.image_height; y++) {
 		unsigned char *dst = &tmprowbuf[0];
 
-		const unsigned char *src_y = src + y * compress_.image_width;
+		const unsigned char *src_y = src + y * y_stride;
 		const unsigned char *src_cb = src_c + (y / vertSubSample) * c_stride + cb_pos;
 		const unsigned char *src_cr = src_c + (y / vertSubSample) * c_stride + cr_pos;