Skip to content

Commit

Permalink
Add abgr2101010 format
Browse files Browse the repository at this point in the history
Signed-off-by: Kyuwon Kim <[email protected]>
  • Loading branch information
chammoru committed Apr 10, 2021
1 parent 3f90a52 commit 169627a
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
58 changes: 54 additions & 4 deletions QVisionCore/qimage_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,11 @@ void qimage_rgba1010102_to_bgr888(qu8* bgr, qu8* src_rgb, qu8* n1, qu8* n2,
{
for (j = 0; j < w; j++)
{
qu32 rgb1010102 = ((qu32 *)src_rgb)[0];
qu32 rgba1010102 = ((qu32 *)src_rgb)[0];

int R10 = (rgb1010102 >> 22) & 0x3ff;
int G10 = (rgb1010102 >> 12) & 0x3ff;
int B10 = (rgb1010102 >> 2) & 0x3ff;
int R10 = (rgba1010102 >> 22) & 0x3ff;
int G10 = (rgba1010102 >> 12) & 0x3ff;
int B10 = (rgba1010102 >> 2) & 0x3ff;

R10 = ((R10 - RGB101010RangeMin) * UCHAR_MAX + range10_half) / range10;
G10 = ((G10 - RGB101010RangeMin) * UCHAR_MAX + range10_half) / range10;
Expand All @@ -429,6 +429,56 @@ void qimage_rgba1010102_to_bgr888(qu8* bgr, qu8* src_rgb, qu8* n1, qu8* n2,
}
}

int qimage_abgr2101010_load_info(int w, int h, int* bufoff2, int* bufoff3)
{
int scene_size = w * h * 4;

if (bufoff2)
*bufoff2 = 0;

if (bufoff3)
*bufoff3 = 0;

return scene_size;
}

void qimage_abgr2101010_to_bgr888(qu8* bgr, qu8* src_rgb, qu8* n1, qu8* n2,
int s_bgr, int w, int h)
{
int i, j;
int gap;

gap = (s_bgr - w) * 3;
const int RGB101010RangeMin = 0;
const int RGB101010RangeMax = 0x3ff; // 1023
const int range10 = RGB101010RangeMax - RGB101010RangeMin;
const int range10_half = range10 >> 1;

for (i = 0; i < h; i++)
{
for (j = 0; j < w; j++)
{
qu32 abgr2101010 = ((qu32*)src_rgb)[0];

int B10 = (abgr2101010 >> 20) & 0x3ff;
int G10 = (abgr2101010 >> 10) & 0x3ff;
int R10 = (abgr2101010 >> 0) & 0x3ff;

B10 = ((B10 - RGB101010RangeMin) * UCHAR_MAX + range10_half) / range10;
G10 = ((G10 - RGB101010RangeMin) * UCHAR_MAX + range10_half) / range10;
R10 = ((R10 - RGB101010RangeMin) * UCHAR_MAX + range10_half) / range10;

*bgr++ = SAT_S32_TO_U8(B10);
*bgr++ = SAT_S32_TO_U8(G10);
*bgr++ = SAT_S32_TO_U8(R10);

src_rgb += 4;
}

bgr += gap;
}
}

int qimage_rgb16u_load_info(int w, int h, int* bufoff2, int* bufoff3)
{
int scene_size = w * h * 6;
Expand Down
11 changes: 11 additions & 0 deletions QVisionCore/qimage_cs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef enum _QIMAGE_CS
QIMAGE_CS_BGR888,
QIMAGE_CS_BGR565,
QIMAGE_CS_RGBA1010102,
QIMAGE_CS_ABGR2101010,
QIMAGE_CS_RGB16U,
} QIMAGE_CS;

Expand Down Expand Up @@ -55,6 +56,7 @@ int qimage_rgba8888_load_info(int w, int h, int *bufoff2, int *bufoff3);
int qimage_bgr888_load_info(int w, int h, int *bufoff2, int *bufoff3);
int qimage_bgr565_load_info(int w, int h, int *bufoff2, int *bufoff3);
int qimage_rgba1010102_load_info(int w, int h, int* bufoff2, int* bufoff3);
int qimage_abgr2101010_load_info(int w, int h, int* bufoff2, int* bufoff3);
int qimage_rgb16u_load_info(int w, int h, int* bufoff2, int* bufoff3);
int qimage_t256x16_load_info(int w, int h, int *bufoff2, int *bufoff3);
int qimage_grayscale_load_info(int w, int h, int *bufoff2, int *bufoff3);
Expand All @@ -75,6 +77,8 @@ void qimage_bgr888_to_bgr888(qu8 *bgr, qu8 *src_rgb, qu8 *n1, qu8 *n2,
int s_bgr, int w, int h);
void qimage_rgba1010102_to_bgr888(qu8* bgr, qu8* src_rgb, qu8* n1, qu8* n2,
int s_bgr, int w, int h);
void qimage_abgr2101010_to_bgr888(qu8* bgr, qu8* src_rgb, qu8* n1, qu8* n2,
int s_bgr, int w, int h);
void qimage_rgb16u_to_bgr888(qu8* bgr, qu8* src_rgb, qu8* n1, qu8* n2,
int s_bgr, int w, int h);
void qimage_bgr565_to_bgr888(qu8 *bgr, qu8 *src_rgb, qu8 *n1, qu8 *n2,
Expand Down Expand Up @@ -187,6 +191,13 @@ static const struct qcsc_info qcsc_info_table[] =
qimage_rgba1010102_to_bgr888,
NULL,
},
{
QIMAGE_CS_ABGR2101010,
"abgr2101010",
qimage_abgr2101010_load_info,
qimage_abgr2101010_to_bgr888,
NULL,
},
{
QIMAGE_CS_RGB16U,
"rgb16u",
Expand Down

0 comments on commit 169627a

Please sign in to comment.