/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2021-2023. All rights reserved. * Description: Common defs * Author: Hisilicon * Created: 2021.04.16 */ #ifndef IMAGEKIT_MAGIC_IMAGE_H #define IMAGEKIT_MAGIC_IMAGE_H #include extern "C" { const static uint8_t MAX_COLOR_PLANES = 3; const static int32_t MAX_BUF_SLOTS = 24; enum ImageColorspace { IMAGE_COLORSPACE_SRGB, IMAGE_COLORSPACE_BT709, IMAGE_COLORSPACE_BT2020_LINEAR, IMAGE_COLORSPACE_BT2020_PQ, IMAGE_COLORSPACE_DISPLAY_P3, IMAGE_COLORSPACE_DISPLAY_P3_LINEAR }; enum ImageLayout { IMAGE_LAYOUT_LINEAR, IMAGE_LAYOUT_TILE, IMAGE_LAYOUT_AFBC, IMAGE_LAYOUT_HFBC, }; struct ImagePoint2D { int32_t x; int32_t y; }; struct ImagePoint3D { int32_t x; int32_t y; int32_t z; }; struct ImageRect { int32_t x; int32_t y; uint32_t width; uint32_t height; }; struct AFBCAttr { uint32_t headerSize; uint32_t headerStride; uint32_t useYuvTransform; uint32_t useSparseAlloc; uint32_t dispWidth; /* display width for yuv format */ uint32_t dispHeight; /* display height for yuv format */ } __attribute__((packed)); struct PFBCAttr { uint32_t alignWidth; uint32_t alignHeight; uint32_t bitDepth; uint32_t lumaStride; uint32_t lumaHeaderOffset; uint32_t lumaDataOffset; uint32_t chromaHeaderOffset; uint32_t chromaDataOffset; uint32_t lumaData2Offset; /* for 10bit, luma data address for part2 if exist */ uint32_t chromaData2Offset; /* for 10bit, chroma data address for part2 if exist */ } __attribute__((packed)); struct ImageColorPlane { int32_t handle; uint32_t stride; uint32_t size; uint32_t offset; }; struct ImageColorBuffer { int32_t width; /* real width */ int32_t height; /* real height */ int32_t drmFormat; bool isProtected; ImageColorspace colorSpace; int32_t colorRange; ImageLayout layout; ImageColorPlane planes[MAX_COLOR_PLANES]; /* Linear */ union { struct AFBCAttr afbc; /* afbc */ struct PFBCAttr pfbc; /* pfbc or tile */ }; }; /* range from -100 to 100, 30% */ struct KeystoneAttr { ImagePoint2D topLeft; /* destination top_left coordinates, 2: x y */ ImagePoint2D topRight; /* destination top_right coordinates, 2: x y */ ImagePoint2D bottomLeft; /* destination bottom_left coordinates, 2: x y */ ImagePoint2D bottomRight; /* destination bottom_right coordinates, 2: x y */ ImageRect originRect; ImageRect cropRect; }; } // end extern #endif