Add a API function to get the pixel size of nvnc_fb
parent
c7dd062498
commit
96886e21d5
|
@ -97,6 +97,7 @@ uint16_t nvnc_fb_get_width(const struct nvnc_fb* fb);
|
||||||
uint16_t nvnc_fb_get_height(const struct nvnc_fb* fb);
|
uint16_t nvnc_fb_get_height(const struct nvnc_fb* fb);
|
||||||
uint32_t nvnc_fb_get_fourcc_format(const struct nvnc_fb* fb);
|
uint32_t nvnc_fb_get_fourcc_format(const struct nvnc_fb* fb);
|
||||||
int32_t nvnc_fb_get_stride(const struct nvnc_fb* fb);
|
int32_t nvnc_fb_get_stride(const struct nvnc_fb* fb);
|
||||||
|
int nvnc_fb_get_pixel_size(const struct nvnc_fb* fb);
|
||||||
|
|
||||||
struct nvnc_fb_pool* nvnc_fb_pool_new(uint16_t width, uint16_t height,
|
struct nvnc_fb_pool* nvnc_fb_pool_new(uint16_t width, uint16_t height,
|
||||||
uint32_t fourcc_format, uint16_t stride);
|
uint32_t fourcc_format, uint16_t stride);
|
||||||
|
|
|
@ -29,3 +29,5 @@ void pixel32_to_cpixel(uint8_t* restrict dst,
|
||||||
|
|
||||||
int rfb_pixfmt_from_fourcc(struct rfb_pixel_format *dst, uint32_t src);
|
int rfb_pixfmt_from_fourcc(struct rfb_pixel_format *dst, uint32_t src);
|
||||||
uint32_t rfb_pixfmt_to_fourcc(const struct rfb_pixel_format* fmt);
|
uint32_t rfb_pixfmt_to_fourcc(const struct rfb_pixel_format* fmt);
|
||||||
|
|
||||||
|
int pixel_size_from_fourcc(uint32_t fourcc);
|
||||||
|
|
7
src/fb.c
7
src/fb.c
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fb.h"
|
#include "fb.h"
|
||||||
|
#include "pixels.h"
|
||||||
#include "neatvnc.h"
|
#include "neatvnc.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -99,6 +100,12 @@ int32_t nvnc_fb_get_stride(const struct nvnc_fb* fb)
|
||||||
return fb->stride;
|
return fb->stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT
|
||||||
|
int nvnc_fb_get_pixel_size(const struct nvnc_fb* fb)
|
||||||
|
{
|
||||||
|
return pixel_size_from_fourcc(fb->fourcc_format);
|
||||||
|
}
|
||||||
|
|
||||||
static void nvnc__fb_free(struct nvnc_fb* fb)
|
static void nvnc__fb_free(struct nvnc_fb* fb)
|
||||||
{
|
{
|
||||||
nvnc_cleanup_fn cleanup = fb->common.cleanup_fn;
|
nvnc_cleanup_fn cleanup = fb->common.cleanup_fn;
|
||||||
|
|
30
src/pixels.c
30
src/pixels.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 - 2020 Andri Yngvason
|
* Copyright (c) 2019 - 2021 Andri Yngvason
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -220,4 +220,30 @@ bpp_16:
|
||||||
dst->true_colour_flag = 1;
|
dst->true_colour_flag = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
int pixel_size_from_fourcc(uint32_t fourcc)
|
||||||
|
{
|
||||||
|
switch (fourcc & ~DRM_FORMAT_BIG_ENDIAN) {
|
||||||
|
case DRM_FORMAT_RGBA8888:
|
||||||
|
case DRM_FORMAT_RGBX8888:
|
||||||
|
case DRM_FORMAT_BGRA8888:
|
||||||
|
case DRM_FORMAT_BGRX8888:
|
||||||
|
case DRM_FORMAT_ARGB8888:
|
||||||
|
case DRM_FORMAT_XRGB8888:
|
||||||
|
case DRM_FORMAT_ABGR8888:
|
||||||
|
case DRM_FORMAT_XBGR8888:
|
||||||
|
return 4;
|
||||||
|
case DRM_FORMAT_RGBA4444:
|
||||||
|
case DRM_FORMAT_RGBX4444:
|
||||||
|
case DRM_FORMAT_BGRA4444:
|
||||||
|
case DRM_FORMAT_BGRX4444:
|
||||||
|
case DRM_FORMAT_ARGB4444:
|
||||||
|
case DRM_FORMAT_XRGB4444:
|
||||||
|
case DRM_FORMAT_ABGR4444:
|
||||||
|
case DRM_FORMAT_XBGR4444:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue