* [PATCH 1/2] libv4lconvert: add support for BAYER10
@ 2019-02-27 14:47 Daniel Gomez
2019-02-27 14:47 ` [PATCH 2/2] libv4lconvert: add support for BAYER16 Daniel Gomez
2019-02-27 15:15 ` [PATCH 1/2] libv4lconvert: add support for BAYER10 Ricardo Ribalda Delgado
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Gomez @ 2019-02-27 14:47 UTC (permalink / raw)
To: linux-media; +Cc: ricardo, daniel
Add support for 10 bit Bayer formats:
-V4L2_PIX_FMT_SBGGR10
-V4L2_PIX_FMT_SGBRG10
-V4L2_PIX_FMT_SRGGB10
Previous BAYER10 format declared (V4L2_PIX_FMT_SGRBG10) now is grouped
with the new list without the need of tmp buffer.
Update v4lconvert_10to8 function:
- Renaming function name to keep naming convention with the
other bayer10p conversion function:
v4lconvert_10to8 -> v4lconvert_bayer10_to_bayer8
Tested using vivid included in linux v5.0-rc8.
Signed-off-by: Daniel Gomez <daniel@qtec.com>
---
lib/libv4lconvert/bayer.c | 10 ++++
lib/libv4lconvert/libv4lconvert-priv.h | 2 +
lib/libv4lconvert/libv4lconvert.c | 65 +++++++++++++++++++-------
3 files changed, 59 insertions(+), 18 deletions(-)
diff --git a/lib/libv4lconvert/bayer.c b/lib/libv4lconvert/bayer.c
index 11af6543..96d26cce 100644
--- a/lib/libv4lconvert/bayer.c
+++ b/lib/libv4lconvert/bayer.c
@@ -632,6 +632,16 @@ void v4lconvert_bayer_to_yuv420(const unsigned char *bayer, unsigned char *yuv,
!start_with_green, !blue_line);
}
+void v4lconvert_bayer10_to_bayer8(void *bayer10,
+ unsigned char *bayer8, int width, int height)
+{
+ int i;
+ uint16_t *src = bayer10;
+
+ for (i = 0; i < width * height; i++)
+ bayer8[i] = src[i] >> 2;
+}
+
void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
unsigned char *bayer8, int width, int height)
{
diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h
index 3020a39e..44d2d32e 100644
--- a/lib/libv4lconvert/libv4lconvert-priv.h
+++ b/lib/libv4lconvert/libv4lconvert-priv.h
@@ -264,6 +264,8 @@ void v4lconvert_bayer_to_bgr24(const unsigned char *bayer,
void v4lconvert_bayer_to_yuv420(const unsigned char *bayer, unsigned char *yuv,
int width, int height, const unsigned int stride, unsigned int src_pixfmt, int yvu);
+void v4lconvert_bayer10_to_bayer8(void *bayer10,
+ unsigned char *bayer8, int width, int height);
void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
unsigned char *bayer8, int width, int height);
diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c
index 6a4c66a8..a8cf856a 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -132,11 +132,14 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = {
{ V4L2_PIX_FMT_SGRBG8, 8, 8, 8, 0 },
{ V4L2_PIX_FMT_SRGGB8, 8, 8, 8, 0 },
{ V4L2_PIX_FMT_STV0680, 8, 8, 8, 1 },
- { V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 },
{ V4L2_PIX_FMT_SBGGR10P, 10, 8, 8, 1 },
{ V4L2_PIX_FMT_SGBRG10P, 10, 8, 8, 1 },
{ V4L2_PIX_FMT_SGRBG10P, 10, 8, 8, 1 },
{ V4L2_PIX_FMT_SRGGB10P, 10, 8, 8, 1 },
+ { V4L2_PIX_FMT_SBGGR10, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SGBRG10, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SRGGB10, 16, 8, 8, 1 },
/* compressed bayer */
{ V4L2_PIX_FMT_SPCA561, 0, 9, 9, 1 },
{ V4L2_PIX_FMT_SN9C10X, 0, 9, 9, 1 },
@@ -695,6 +698,10 @@ static int v4lconvert_processing_needs_double_conversion(
case V4L2_PIX_FMT_SGBRG10P:
case V4L2_PIX_FMT_SGRBG10P:
case V4L2_PIX_FMT_SRGGB10P:
+ case V4L2_PIX_FMT_SBGGR10:
+ case V4L2_PIX_FMT_SGBRG10:
+ case V4L2_PIX_FMT_SGRBG10:
+ case V4L2_PIX_FMT_SRGGB10:
case V4L2_PIX_FMT_STV0680:
return 0;
}
@@ -722,16 +729,6 @@ unsigned char *v4lconvert_alloc_buffer(int needed,
return *buf;
}
-static void v4lconvert_10to8(void *_src, unsigned char *dst, int width, int height)
-{
- int i;
- uint16_t *src = _src;
-
- for (i = 0; i < width * height; i++) {
- dst[i] = src[i] >> 2;
- }
-}
-
int v4lconvert_oom_error(struct v4lconvert_data *data)
{
V4LCONVERT_ERR("could not allocate memory\n");
@@ -907,8 +904,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
#endif
case V4L2_PIX_FMT_SN9C2028:
case V4L2_PIX_FMT_SQ905C:
- case V4L2_PIX_FMT_STV0680:
- case V4L2_PIX_FMT_SGRBG10: { /* Not compressed but needs some shuffling */
+ case V4L2_PIX_FMT_STV0680: { /* Not compressed but needs some shuffling */
unsigned char *tmpbuf;
struct v4l2_format tmpfmt = *fmt;
@@ -918,11 +914,6 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
return v4lconvert_oom_error(data);
switch (src_pix_fmt) {
- case V4L2_PIX_FMT_SGRBG10:
- v4lconvert_10to8(src, tmpbuf, width, height);
- tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG8;
- bytesperline = width;
- break;
case V4L2_PIX_FMT_SPCA561:
v4lconvert_decode_spca561(src, tmpbuf, width, height);
tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8;
@@ -1023,6 +1014,44 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
bytesperline = width;
}
}
+
+ case V4L2_PIX_FMT_SBGGR10:
+ case V4L2_PIX_FMT_SGBRG10:
+ case V4L2_PIX_FMT_SGRBG10:
+ case V4L2_PIX_FMT_SRGGB10: {
+ int b10format = 1;
+
+ switch (src_pix_fmt) {
+ case V4L2_PIX_FMT_SBGGR10:
+ src_pix_fmt = V4L2_PIX_FMT_SBGGR8;
+ break;
+ case V4L2_PIX_FMT_SGBRG10:
+ src_pix_fmt = V4L2_PIX_FMT_SGBRG8;
+ break;
+ case V4L2_PIX_FMT_SGRBG10:
+ src_pix_fmt = V4L2_PIX_FMT_SGRBG8;
+ break;
+ case V4L2_PIX_FMT_SRGGB10:
+ src_pix_fmt = V4L2_PIX_FMT_SRGGB8;
+ break;
+ default:
+ b10format = 0;
+ break;
+ }
+
+ if (b10format) {
+ if (src_size < (width * height * 2)) {
+ V4LCONVERT_ERR
+ ("short raw bayer10 data frame\n");
+ errno = EPIPE;
+ result = -1;
+ break;
+ }
+ v4lconvert_bayer10_to_bayer8(src, src, width, height);
+ bytesperline = width;
+ }
+ }
+
/* Fall-through*/
case V4L2_PIX_FMT_SBGGR8:
case V4L2_PIX_FMT_SGBRG8:
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] libv4lconvert: add support for BAYER16
2019-02-27 14:47 [PATCH 1/2] libv4lconvert: add support for BAYER10 Daniel Gomez
@ 2019-02-27 14:47 ` Daniel Gomez
2019-02-27 15:15 ` Ricardo Ribalda Delgado
2019-02-27 15:15 ` [PATCH 1/2] libv4lconvert: add support for BAYER10 Ricardo Ribalda Delgado
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Gomez @ 2019-02-27 14:47 UTC (permalink / raw)
To: linux-media; +Cc: ricardo, daniel
Add support for 16 bit Bayer formats:
-V4L2_PIX_FMT_SBGGR16
-V4L2_PIX_FMT_SGBRG16
-V4L2_PIX_FMT_SGRBG16
-V4L2_PIX_FMT_SRGGB16
Tested using vivid included in linux v5.0-rc8.
Signed-off-by: Daniel Gomez <daniel@qtec.com>
---
lib/libv4lconvert/bayer.c | 9 ++++++
lib/libv4lconvert/libv4lconvert-priv.h | 3 ++
lib/libv4lconvert/libv4lconvert.c | 45 ++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/lib/libv4lconvert/bayer.c b/lib/libv4lconvert/bayer.c
index 96d26cce..7748e68d 100644
--- a/lib/libv4lconvert/bayer.c
+++ b/lib/libv4lconvert/bayer.c
@@ -662,3 +662,12 @@ void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
bayer8 += 4;
}
}
+
+void v4lconvert_bayer16_to_bayer8(unsigned char *bayer16,
+ unsigned char *bayer8, int width, int height)
+{
+ int i;
+
+ for (i = 0; i < width * height; i++)
+ bayer8[i] = bayer16[2*i+1];
+}
diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h
index 44d2d32e..a8046ce2 100644
--- a/lib/libv4lconvert/libv4lconvert-priv.h
+++ b/lib/libv4lconvert/libv4lconvert-priv.h
@@ -270,6 +270,9 @@ void v4lconvert_bayer10_to_bayer8(void *bayer10,
void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
unsigned char *bayer8, int width, int height);
+void v4lconvert_bayer16_to_bayer8(unsigned char *bayer16,
+ unsigned char *bayer8, int width, int height);
+
void v4lconvert_hm12_to_rgb24(const unsigned char *src,
unsigned char *dst, int width, int height);
diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c
index a8cf856a..7dc409f2 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -140,6 +140,10 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = {
{ V4L2_PIX_FMT_SGBRG10, 16, 8, 8, 1 },
{ V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 },
{ V4L2_PIX_FMT_SRGGB10, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SBGGR16, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SGBRG16, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SGRBG16, 16, 8, 8, 1 },
+ { V4L2_PIX_FMT_SRGGB16, 16, 8, 8, 1 },
/* compressed bayer */
{ V4L2_PIX_FMT_SPCA561, 0, 9, 9, 1 },
{ V4L2_PIX_FMT_SN9C10X, 0, 9, 9, 1 },
@@ -702,6 +706,10 @@ static int v4lconvert_processing_needs_double_conversion(
case V4L2_PIX_FMT_SGBRG10:
case V4L2_PIX_FMT_SGRBG10:
case V4L2_PIX_FMT_SRGGB10:
+ case V4L2_PIX_FMT_SBGGR16:
+ case V4L2_PIX_FMT_SGBRG16:
+ case V4L2_PIX_FMT_SGRBG16:
+ case V4L2_PIX_FMT_SRGGB16:
case V4L2_PIX_FMT_STV0680:
return 0;
}
@@ -1052,6 +1060,43 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
}
}
+ case V4L2_PIX_FMT_SBGGR16:
+ case V4L2_PIX_FMT_SGBRG16:
+ case V4L2_PIX_FMT_SGRBG16:
+ case V4L2_PIX_FMT_SRGGB16: {
+ int b16format = 1;
+
+ switch (src_pix_fmt) {
+ case V4L2_PIX_FMT_SBGGR16:
+ src_pix_fmt = V4L2_PIX_FMT_SBGGR8;
+ break;
+ case V4L2_PIX_FMT_SGBRG16:
+ src_pix_fmt = V4L2_PIX_FMT_SGBRG8;
+ break;
+ case V4L2_PIX_FMT_SGRBG16:
+ src_pix_fmt = V4L2_PIX_FMT_SGRBG8;
+ break;
+ case V4L2_PIX_FMT_SRGGB16:
+ src_pix_fmt = V4L2_PIX_FMT_SRGGB8;
+ break;
+ default:
+ b16format = 0;
+ break;
+ }
+
+ if (b16format) {
+ if (src_size < ((width * height * 2))) {
+ V4LCONVERT_ERR
+ ("short raw bayer16 data frame\n");
+ errno = EPIPE;
+ result = -1;
+ break;
+ }
+ v4lconvert_bayer16_to_bayer8(src, src, width, height);
+ bytesperline = width;
+ }
+ }
+
/* Fall-through*/
case V4L2_PIX_FMT_SBGGR8:
case V4L2_PIX_FMT_SGBRG8:
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] libv4lconvert: add support for BAYER16
2019-02-27 14:47 ` [PATCH 2/2] libv4lconvert: add support for BAYER16 Daniel Gomez
@ 2019-02-27 15:15 ` Ricardo Ribalda Delgado
0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2019-02-27 15:15 UTC (permalink / raw)
To: Daniel Gomez; +Cc: linux-media
Hi Daniel,
On Wed, Feb 27, 2019 at 3:47 PM Daniel Gomez <daniel@qtec.com> wrote:
>
> Add support for 16 bit Bayer formats:
> -V4L2_PIX_FMT_SBGGR16
> -V4L2_PIX_FMT_SGBRG16
> -V4L2_PIX_FMT_SGRBG16
> -V4L2_PIX_FMT_SRGGB16
>
> Tested using vivid included in linux v5.0-rc8.
>
> Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
> ---
> lib/libv4lconvert/bayer.c | 9 ++++++
> lib/libv4lconvert/libv4lconvert-priv.h | 3 ++
> lib/libv4lconvert/libv4lconvert.c | 45 ++++++++++++++++++++++++++
> 3 files changed, 57 insertions(+)
>
> diff --git a/lib/libv4lconvert/bayer.c b/lib/libv4lconvert/bayer.c
> index 96d26cce..7748e68d 100644
> --- a/lib/libv4lconvert/bayer.c
> +++ b/lib/libv4lconvert/bayer.c
> @@ -662,3 +662,12 @@ void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
> bayer8 += 4;
> }
> }
> +
> +void v4lconvert_bayer16_to_bayer8(unsigned char *bayer16,
> + unsigned char *bayer8, int width, int height)
> +{
> + int i;
> +
> + for (i = 0; i < width * height; i++)
> + bayer8[i] = bayer16[2*i+1];
> +}
> diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h
> index 44d2d32e..a8046ce2 100644
> --- a/lib/libv4lconvert/libv4lconvert-priv.h
> +++ b/lib/libv4lconvert/libv4lconvert-priv.h
> @@ -270,6 +270,9 @@ void v4lconvert_bayer10_to_bayer8(void *bayer10,
> void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
> unsigned char *bayer8, int width, int height);
>
> +void v4lconvert_bayer16_to_bayer8(unsigned char *bayer16,
> + unsigned char *bayer8, int width, int height);
> +
> void v4lconvert_hm12_to_rgb24(const unsigned char *src,
> unsigned char *dst, int width, int height);
>
> diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c
> index a8cf856a..7dc409f2 100644
> --- a/lib/libv4lconvert/libv4lconvert.c
> +++ b/lib/libv4lconvert/libv4lconvert.c
> @@ -140,6 +140,10 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = {
> { V4L2_PIX_FMT_SGBRG10, 16, 8, 8, 1 },
> { V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 },
> { V4L2_PIX_FMT_SRGGB10, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SBGGR16, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SGBRG16, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SGRBG16, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SRGGB16, 16, 8, 8, 1 },
> /* compressed bayer */
> { V4L2_PIX_FMT_SPCA561, 0, 9, 9, 1 },
> { V4L2_PIX_FMT_SN9C10X, 0, 9, 9, 1 },
> @@ -702,6 +706,10 @@ static int v4lconvert_processing_needs_double_conversion(
> case V4L2_PIX_FMT_SGBRG10:
> case V4L2_PIX_FMT_SGRBG10:
> case V4L2_PIX_FMT_SRGGB10:
> + case V4L2_PIX_FMT_SBGGR16:
> + case V4L2_PIX_FMT_SGBRG16:
> + case V4L2_PIX_FMT_SGRBG16:
> + case V4L2_PIX_FMT_SRGGB16:
> case V4L2_PIX_FMT_STV0680:
> return 0;
> }
> @@ -1052,6 +1060,43 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
> }
> }
>
> + case V4L2_PIX_FMT_SBGGR16:
> + case V4L2_PIX_FMT_SGBRG16:
> + case V4L2_PIX_FMT_SGRBG16:
> + case V4L2_PIX_FMT_SRGGB16: {
> + int b16format = 1;
> +
> + switch (src_pix_fmt) {
> + case V4L2_PIX_FMT_SBGGR16:
> + src_pix_fmt = V4L2_PIX_FMT_SBGGR8;
> + break;
> + case V4L2_PIX_FMT_SGBRG16:
> + src_pix_fmt = V4L2_PIX_FMT_SGBRG8;
> + break;
> + case V4L2_PIX_FMT_SGRBG16:
> + src_pix_fmt = V4L2_PIX_FMT_SGRBG8;
> + break;
> + case V4L2_PIX_FMT_SRGGB16:
> + src_pix_fmt = V4L2_PIX_FMT_SRGGB8;
> + break;
> + default:
> + b16format = 0;
> + break;
> + }
> +
> + if (b16format) {
> + if (src_size < ((width * height * 2))) {
> + V4LCONVERT_ERR
> + ("short raw bayer16 data frame\n");
> + errno = EPIPE;
> + result = -1;
> + break;
> + }
> + v4lconvert_bayer16_to_bayer8(src, src, width, height);
> + bytesperline = width;
> + }
> + }
> +
> /* Fall-through*/
> case V4L2_PIX_FMT_SBGGR8:
> case V4L2_PIX_FMT_SGBRG8:
> --
> 2.20.1
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] libv4lconvert: add support for BAYER10
2019-02-27 14:47 [PATCH 1/2] libv4lconvert: add support for BAYER10 Daniel Gomez
2019-02-27 14:47 ` [PATCH 2/2] libv4lconvert: add support for BAYER16 Daniel Gomez
@ 2019-02-27 15:15 ` Ricardo Ribalda Delgado
1 sibling, 0 replies; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2019-02-27 15:15 UTC (permalink / raw)
To: Daniel Gomez; +Cc: linux-media
Hi Daniel,
Thanks for both patches
On Wed, Feb 27, 2019 at 3:47 PM Daniel Gomez <daniel@qtec.com> wrote:
>
> Add support for 10 bit Bayer formats:
> -V4L2_PIX_FMT_SBGGR10
> -V4L2_PIX_FMT_SGBRG10
> -V4L2_PIX_FMT_SRGGB10
>
> Previous BAYER10 format declared (V4L2_PIX_FMT_SGRBG10) now is grouped
> with the new list without the need of tmp buffer.
>
> Update v4lconvert_10to8 function:
> - Renaming function name to keep naming convention with the
> other bayer10p conversion function:
> v4lconvert_10to8 -> v4lconvert_bayer10_to_bayer8
>
> Tested using vivid included in linux v5.0-rc8.
>
> Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
> ---
> lib/libv4lconvert/bayer.c | 10 ++++
> lib/libv4lconvert/libv4lconvert-priv.h | 2 +
> lib/libv4lconvert/libv4lconvert.c | 65 +++++++++++++++++++-------
> 3 files changed, 59 insertions(+), 18 deletions(-)
>
> diff --git a/lib/libv4lconvert/bayer.c b/lib/libv4lconvert/bayer.c
> index 11af6543..96d26cce 100644
> --- a/lib/libv4lconvert/bayer.c
> +++ b/lib/libv4lconvert/bayer.c
> @@ -632,6 +632,16 @@ void v4lconvert_bayer_to_yuv420(const unsigned char *bayer, unsigned char *yuv,
> !start_with_green, !blue_line);
> }
>
> +void v4lconvert_bayer10_to_bayer8(void *bayer10,
> + unsigned char *bayer8, int width, int height)
> +{
> + int i;
> + uint16_t *src = bayer10;
> +
> + for (i = 0; i < width * height; i++)
> + bayer8[i] = src[i] >> 2;
> +}
> +
> void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
> unsigned char *bayer8, int width, int height)
> {
> diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h
> index 3020a39e..44d2d32e 100644
> --- a/lib/libv4lconvert/libv4lconvert-priv.h
> +++ b/lib/libv4lconvert/libv4lconvert-priv.h
> @@ -264,6 +264,8 @@ void v4lconvert_bayer_to_bgr24(const unsigned char *bayer,
> void v4lconvert_bayer_to_yuv420(const unsigned char *bayer, unsigned char *yuv,
> int width, int height, const unsigned int stride, unsigned int src_pixfmt, int yvu);
>
> +void v4lconvert_bayer10_to_bayer8(void *bayer10,
> + unsigned char *bayer8, int width, int height);
>
> void v4lconvert_bayer10p_to_bayer8(unsigned char *bayer10p,
> unsigned char *bayer8, int width, int height);
> diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c
> index 6a4c66a8..a8cf856a 100644
> --- a/lib/libv4lconvert/libv4lconvert.c
> +++ b/lib/libv4lconvert/libv4lconvert.c
> @@ -132,11 +132,14 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = {
> { V4L2_PIX_FMT_SGRBG8, 8, 8, 8, 0 },
> { V4L2_PIX_FMT_SRGGB8, 8, 8, 8, 0 },
> { V4L2_PIX_FMT_STV0680, 8, 8, 8, 1 },
> - { V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 },
> { V4L2_PIX_FMT_SBGGR10P, 10, 8, 8, 1 },
> { V4L2_PIX_FMT_SGBRG10P, 10, 8, 8, 1 },
> { V4L2_PIX_FMT_SGRBG10P, 10, 8, 8, 1 },
> { V4L2_PIX_FMT_SRGGB10P, 10, 8, 8, 1 },
> + { V4L2_PIX_FMT_SBGGR10, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SGBRG10, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 },
> + { V4L2_PIX_FMT_SRGGB10, 16, 8, 8, 1 },
> /* compressed bayer */
> { V4L2_PIX_FMT_SPCA561, 0, 9, 9, 1 },
> { V4L2_PIX_FMT_SN9C10X, 0, 9, 9, 1 },
> @@ -695,6 +698,10 @@ static int v4lconvert_processing_needs_double_conversion(
> case V4L2_PIX_FMT_SGBRG10P:
> case V4L2_PIX_FMT_SGRBG10P:
> case V4L2_PIX_FMT_SRGGB10P:
> + case V4L2_PIX_FMT_SBGGR10:
> + case V4L2_PIX_FMT_SGBRG10:
> + case V4L2_PIX_FMT_SGRBG10:
> + case V4L2_PIX_FMT_SRGGB10:
> case V4L2_PIX_FMT_STV0680:
> return 0;
> }
> @@ -722,16 +729,6 @@ unsigned char *v4lconvert_alloc_buffer(int needed,
> return *buf;
> }
>
> -static void v4lconvert_10to8(void *_src, unsigned char *dst, int width, int height)
> -{
> - int i;
> - uint16_t *src = _src;
> -
> - for (i = 0; i < width * height; i++) {
> - dst[i] = src[i] >> 2;
> - }
> -}
> -
> int v4lconvert_oom_error(struct v4lconvert_data *data)
> {
> V4LCONVERT_ERR("could not allocate memory\n");
> @@ -907,8 +904,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
> #endif
> case V4L2_PIX_FMT_SN9C2028:
> case V4L2_PIX_FMT_SQ905C:
> - case V4L2_PIX_FMT_STV0680:
> - case V4L2_PIX_FMT_SGRBG10: { /* Not compressed but needs some shuffling */
> + case V4L2_PIX_FMT_STV0680: { /* Not compressed but needs some shuffling */
> unsigned char *tmpbuf;
> struct v4l2_format tmpfmt = *fmt;
>
> @@ -918,11 +914,6 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
> return v4lconvert_oom_error(data);
>
> switch (src_pix_fmt) {
> - case V4L2_PIX_FMT_SGRBG10:
> - v4lconvert_10to8(src, tmpbuf, width, height);
> - tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG8;
> - bytesperline = width;
> - break;
> case V4L2_PIX_FMT_SPCA561:
> v4lconvert_decode_spca561(src, tmpbuf, width, height);
> tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8;
> @@ -1023,6 +1014,44 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
> bytesperline = width;
> }
> }
> +
> + case V4L2_PIX_FMT_SBGGR10:
> + case V4L2_PIX_FMT_SGBRG10:
> + case V4L2_PIX_FMT_SGRBG10:
> + case V4L2_PIX_FMT_SRGGB10: {
> + int b10format = 1;
> +
> + switch (src_pix_fmt) {
> + case V4L2_PIX_FMT_SBGGR10:
> + src_pix_fmt = V4L2_PIX_FMT_SBGGR8;
> + break;
> + case V4L2_PIX_FMT_SGBRG10:
> + src_pix_fmt = V4L2_PIX_FMT_SGBRG8;
> + break;
> + case V4L2_PIX_FMT_SGRBG10:
> + src_pix_fmt = V4L2_PIX_FMT_SGRBG8;
> + break;
> + case V4L2_PIX_FMT_SRGGB10:
> + src_pix_fmt = V4L2_PIX_FMT_SRGGB8;
> + break;
> + default:
> + b10format = 0;
> + break;
> + }
> +
> + if (b10format) {
> + if (src_size < (width * height * 2)) {
> + V4LCONVERT_ERR
> + ("short raw bayer10 data frame\n");
> + errno = EPIPE;
> + result = -1;
> + break;
> + }
> + v4lconvert_bayer10_to_bayer8(src, src, width, height);
> + bytesperline = width;
> + }
> + }
> +
> /* Fall-through*/
> case V4L2_PIX_FMT_SBGGR8:
> case V4L2_PIX_FMT_SGBRG8:
> --
> 2.20.1
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-27 15:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 14:47 [PATCH 1/2] libv4lconvert: add support for BAYER10 Daniel Gomez
2019-02-27 14:47 ` [PATCH 2/2] libv4lconvert: add support for BAYER16 Daniel Gomez
2019-02-27 15:15 ` Ricardo Ribalda Delgado
2019-02-27 15:15 ` [PATCH 1/2] libv4lconvert: add support for BAYER10 Ricardo Ribalda Delgado
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).