Skip to contentSkip to conversation

libv4lconvert: fix RGB32 conversion

PATCH Hans Verkuil 2 participants 4 messages Jul 19, 2014 – Jul 20, 2014 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

The RGB32 formats start with an alpha byte in memory. So before calling the v4lconvert_rgb32_to_rgb24 or v4lconvert_rgb24_to_yuv420 function skip that initial alpha byte so the src pointer is aligned with the first color component, since that is what those functions expect.

lib/libv4lconvert/libv4lconvert.c +1 -0
index cea65aa..e4aa54a 100644
@@ -1132,6 +1132,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
 			errno = EPIPE;
 			result = -1;
 		}
+		src++;
 		switch (dest_pix_fmt) {
 		case V4L2_PIX_FMT_RGB24:
 			v4lconvert_rgb32_to_rgb24(src, dest, width, height, 0);
#1 lore raw

Hi,

Quoted 12 lines · Hans Verkuil

The RGB32 formats start with an alpha byte in memory. So before calling the v4lconvert_rgb32_to_rgb24 or v4lconvert_rgb24_to_yuv420 function skip that initial alpha byte so the src pointer is aligned with the first color component, since that is what those functions expect.

lib/libv4lconvert/libv4lconvert.c +0 -0
index cea65aa..e4aa54a 100644

lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1135

Quoted 4 lines
lib/libv4lconvert/libv4lconvert.c +1 -0
@@ -1132,6 +1132,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
  			errno = EPIPE;
  			result = -1;
  		}
+		src++;

Hmm what about bgr versus rgb, since those are mirrored, maybe the location of the alpha byte is mirrored to, and we should only do the src++ for one of them ?

lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1138

Quoted 4 lines
lib/libv4lconvert/libv4lconvert.c +0 -0
  		switch (dest_pix_fmt) {
  		case V4L2_PIX_FMT_RGB24:
  			v4lconvert_rgb32_to_rgb24(src, dest, width, height, 0);

Regards,

Hans

#2 lore raw
Quoted 10 lines · Hans de Goede

Hi,

Quoted 7 lines · Hans Verkuil

The RGB32 formats start with an alpha byte in memory. So before calling the v4lconvert_rgb32_to_rgb24 or v4lconvert_rgb24_to_yuv420 function skip that initial alpha byte so the src pointer is aligned with the first color component, since that is what those functions expect.

Quoted 12 lines

lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1135

Quoted 9 lines
lib/libv4lconvert/libv4lconvert.c +1 -0
index cea65aa..e4aa54a 100644
@@ -1132,6 +1132,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
  			errno = EPIPE;
  			result = -1;
  		}
+		src++;

Hmm what about bgr versus rgb, since those are mirrored, maybe the location of the alpha byte is mirrored to, and we should only do the src++ for one of them ?

Uh, that's what I do. Only for the RGB32 pixformats does the src have to be increased by one. The BGR32 pixformats have the alpha at the end, so there is no need to increment src.

Regards,

Hans

Quoted 14 lines

lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1138

Quoted 5 lines
lib/libv4lconvert/libv4lconvert.c +0 -0
  		switch (dest_pix_fmt) {
  		case V4L2_PIX_FMT_RGB24:
  			v4lconvert_rgb32_to_rgb24(src, dest, width, height, 0);

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#3 lore raw

Hi,

Quoted 24 lines · Hans Verkuil
Quoted 10 lines · Hans de Goede

Hi,

Quoted 7 lines · Hans Verkuil

The RGB32 formats start with an alpha byte in memory. So before calling the v4lconvert_rgb32_to_rgb24 or v4lconvert_rgb24_to_yuv420 function skip that initial alpha byte so the src pointer is aligned with the first color component, since that is what those functions expect.

Quoted 12 lines

lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1135

Quoted 9 lines
lib/libv4lconvert/libv4lconvert.c +1 -0
index cea65aa..e4aa54a 100644
@@ -1132,6 +1132,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
  			errno = EPIPE;
  			result = -1;
  		}
+		src++;

Hmm what about bgr versus rgb, since those are mirrored, maybe the location of the alpha byte is mirrored to, and we should only do the src++ for one of them ?

Quoted 3 lines

Uh, that's what I do. Only for the RGB32 pixformats does the src have to be increased by one. The BGR32 pixformats have the alpha at the end, so there is no need to increment src.

Duh, I did not look closely enough, so the original patch is:

Feel free to push it.

Regards,

Hans