[codec,yuv] use restrict keyword

This commit is contained in:
akallabeth 2024-05-29 23:44:47 +02:00
parent cbd2f5e65f
commit 4899cf5c0f
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
2 changed files with 87 additions and 67 deletions

View File

@ -31,27 +31,32 @@ extern "C"
typedef struct S_YUV_CONTEXT YUV_CONTEXT; typedef struct S_YUV_CONTEXT YUV_CONTEXT;
FREERDP_API BOOL yuv420_context_decode(YUV_CONTEXT* context, const BYTE* pYUVData[3], FREERDP_API BOOL yuv420_context_decode(
const UINT32 iStride[3], UINT32 yuvHeight, YUV_CONTEXT* WINPR_RESTRICT context, const BYTE* WINPR_RESTRICT pYUVData[3],
DWORD DstFormat, BYTE* dest, UINT32 nDstStep, const UINT32 iStride[3], UINT32 yuvHeight, DWORD DstFormat, BYTE* WINPR_RESTRICT dest,
const RECTANGLE_16* regionRects, UINT32 numRegionRects); UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects);
FREERDP_API BOOL yuv420_context_encode(YUV_CONTEXT* context, const BYTE* rgbData, FREERDP_API BOOL yuv420_context_encode(YUV_CONTEXT* WINPR_RESTRICT context,
UINT32 srcStep, UINT32 srcFormat, const BYTE* WINPR_RESTRICT rgbData, UINT32 srcStep,
const UINT32 iStride[3], BYTE* yuvData[3], UINT32 srcFormat, const UINT32 iStride[3],
const RECTANGLE_16* regionRects, UINT32 numRegionRects); BYTE* WINPR_RESTRICT yuvData[3],
const RECTANGLE_16* WINPR_RESTRICT regionRects,
FREERDP_API BOOL yuv444_context_decode(YUV_CONTEXT* context, BYTE type, const BYTE* pYUVData[3],
const UINT32 iStride[3], UINT32 srcYuvHeight,
BYTE* pYUVDstData[3], const UINT32 iDstStride[3],
DWORD DstFormat, BYTE* dest, UINT32 nDstStep,
const RECTANGLE_16* regionRects, UINT32 numRegionRects);
FREERDP_API BOOL yuv444_context_encode(YUV_CONTEXT* context, BYTE version, const BYTE* pSrcData,
UINT32 nSrcStep, UINT32 SrcFormat,
const UINT32 iStride[3], BYTE* pYUVLumaData[3],
BYTE* pYUVChromaData[3], const RECTANGLE_16* regionRects,
UINT32 numRegionRects); UINT32 numRegionRects);
FREERDP_API BOOL yuv_context_reset(YUV_CONTEXT* context, UINT32 width, UINT32 height); FREERDP_API BOOL yuv444_context_decode(
YUV_CONTEXT* WINPR_RESTRICT context, BYTE type, const BYTE* WINPR_RESTRICT pYUVData[3],
const UINT32 iStride[3], UINT32 srcYuvHeight, BYTE* WINPR_RESTRICT pYUVDstData[3],
const UINT32 iDstStride[3], DWORD DstFormat, BYTE* WINPR_RESTRICT dest, UINT32 nDstStep,
const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects);
FREERDP_API BOOL yuv444_context_encode(YUV_CONTEXT* WINPR_RESTRICT context, BYTE version,
const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep,
UINT32 SrcFormat, const UINT32 iStride[3],
BYTE* WINPR_RESTRICT pYUVLumaData[3],
BYTE* WINPR_RESTRICT pYUVChromaData[3],
const RECTANGLE_16* WINPR_RESTRICT regionRects,
UINT32 numRegionRects);
FREERDP_API BOOL yuv_context_reset(YUV_CONTEXT* WINPR_RESTRICT context, UINT32 width,
UINT32 height);
FREERDP_API void yuv_context_free(YUV_CONTEXT* context); FREERDP_API void yuv_context_free(YUV_CONTEXT* context);

View File

@ -67,9 +67,10 @@ struct S_YUV_CONTEXT
YUV_COMBINE_WORK_PARAM* work_combined_params; YUV_COMBINE_WORK_PARAM* work_combined_params;
}; };
static INLINE BOOL avc420_yuv_to_rgb(const BYTE* pYUVData[3], const UINT32 iStride[3], static INLINE BOOL avc420_yuv_to_rgb(const BYTE* WINPR_RESTRICT pYUVData[3],
const RECTANGLE_16* rect, UINT32 nDstStep, BYTE* pDstData, const UINT32 iStride[3],
DWORD DstFormat) const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 nDstStep,
BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat)
{ {
primitives_t* prims = primitives_get(); primitives_t* prims = primitives_get();
prim_size_t roi; prim_size_t roi;
@ -99,9 +100,10 @@ static INLINE BOOL avc420_yuv_to_rgb(const BYTE* pYUVData[3], const UINT32 iStri
return TRUE; return TRUE;
} }
static INLINE BOOL avc444_yuv_to_rgb(const BYTE* pYUVData[3], const UINT32 iStride[3], static INLINE BOOL avc444_yuv_to_rgb(const BYTE* WINPR_RESTRICT pYUVData[3],
const RECTANGLE_16* rect, UINT32 nDstStep, BYTE* pDstData, const UINT32 iStride[3],
DWORD DstFormat) const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 nDstStep,
BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat)
{ {
primitives_t* prims = primitives_get(); primitives_t* prims = primitives_get();
prim_size_t roi; prim_size_t roi;
@ -157,7 +159,7 @@ static void CALLBACK yuv444_process_work_callback(PTP_CALLBACK_INSTANCE instance
WLog_WARN(TAG, "avc444_yuv_to_rgb failed"); WLog_WARN(TAG, "avc444_yuv_to_rgb failed");
} }
BOOL yuv_context_reset(YUV_CONTEXT* context, UINT32 width, UINT32 height) BOOL yuv_context_reset(YUV_CONTEXT* WINPR_RESTRICT context, UINT32 width, UINT32 height)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
WINPR_ASSERT(context); WINPR_ASSERT(context);
@ -275,11 +277,11 @@ void yuv_context_free(YUV_CONTEXT* context)
winpr_aligned_free(context); winpr_aligned_free(context);
} }
static INLINE YUV_PROCESS_WORK_PARAM pool_decode_param(const RECTANGLE_16* rect, static INLINE YUV_PROCESS_WORK_PARAM pool_decode_param(const RECTANGLE_16* WINPR_RESTRICT rect,
YUV_CONTEXT* context, YUV_CONTEXT* WINPR_RESTRICT context,
const BYTE* pYUVData[3], const BYTE* WINPR_RESTRICT pYUVData[3],
const UINT32 iStride[3], UINT32 DstFormat, const UINT32 iStride[3], UINT32 DstFormat,
BYTE* dest, UINT32 nDstStep) BYTE* WINPR_RESTRICT dest, UINT32 nDstStep)
{ {
YUV_PROCESS_WORK_PARAM current = { 0 }; YUV_PROCESS_WORK_PARAM current = { 0 };
@ -303,8 +305,8 @@ static INLINE YUV_PROCESS_WORK_PARAM pool_decode_param(const RECTANGLE_16* rect,
return current; return current;
} }
static BOOL submit_object(PTP_WORK* work_object, PTP_WORK_CALLBACK cb, const void* param, static BOOL submit_object(PTP_WORK* WINPR_RESTRICT work_object, PTP_WORK_CALLBACK cb,
YUV_CONTEXT* context) const void* WINPR_RESTRICT param, YUV_CONTEXT* WINPR_RESTRICT context)
{ {
union union
{ {
@ -347,7 +349,8 @@ static void free_objects(PTP_WORK* work_objects, UINT32 waitCount)
} }
} }
static BOOL intersects(UINT32 pos, const RECTANGLE_16* regionRects, UINT32 numRegionRects) static BOOL intersects(UINT32 pos, const RECTANGLE_16* WINPR_RESTRICT regionRects,
UINT32 numRegionRects)
{ {
WINPR_ASSERT(regionRects || (numRegionRects == 0)); WINPR_ASSERT(regionRects || (numRegionRects == 0));
@ -366,7 +369,8 @@ static BOOL intersects(UINT32 pos, const RECTANGLE_16* regionRects, UINT32 numRe
return FALSE; return FALSE;
} }
static RECTANGLE_16 clamp(YUV_CONTEXT* context, const RECTANGLE_16* rect, UINT32 srcHeight) static RECTANGLE_16 clamp(YUV_CONTEXT* WINPR_RESTRICT context,
const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 srcHeight)
{ {
WINPR_ASSERT(context); WINPR_ASSERT(context);
WINPR_ASSERT(rect); WINPR_ASSERT(rect);
@ -380,9 +384,11 @@ static RECTANGLE_16 clamp(YUV_CONTEXT* context, const RECTANGLE_16* rect, UINT32
return c; return c;
} }
static BOOL pool_decode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* pYUVData[3], static BOOL pool_decode(YUV_CONTEXT* WINPR_RESTRICT context, PTP_WORK_CALLBACK cb,
const UINT32 iStride[3], UINT32 yuvHeight, UINT32 DstFormat, BYTE* dest, const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3],
UINT32 nDstStep, const RECTANGLE_16* regionRects, UINT32 numRegionRects) UINT32 yuvHeight, UINT32 DstFormat, BYTE* WINPR_RESTRICT dest,
UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects,
UINT32 numRegionRects)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
UINT32 waitCount = 0; UINT32 waitCount = 0;
@ -459,7 +465,8 @@ fail:
return rc; return rc;
} }
static INLINE BOOL check_rect(const YUV_CONTEXT* yuv, const RECTANGLE_16* rect, UINT32 nDstWidth, static INLINE BOOL check_rect(const YUV_CONTEXT* WINPR_RESTRICT yuv,
const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 nDstWidth,
UINT32 nDstHeight) UINT32 nDstHeight)
{ {
WINPR_ASSERT(yuv); WINPR_ASSERT(yuv);
@ -511,9 +518,10 @@ static void CALLBACK yuv444_combine_work_callback(PTP_CALLBACK_INSTANCE instance
WLog_WARN(TAG, "YUV420CombineToYUV444 failed"); WLog_WARN(TAG, "YUV420CombineToYUV444 failed");
} }
static INLINE YUV_COMBINE_WORK_PARAM pool_decode_rect_param( static INLINE YUV_COMBINE_WORK_PARAM
const RECTANGLE_16* rect, YUV_CONTEXT* context, BYTE type, const BYTE* pYUVData[3], pool_decode_rect_param(const RECTANGLE_16* WINPR_RESTRICT rect, YUV_CONTEXT* WINPR_RESTRICT context,
const UINT32 iStride[3], BYTE* pYUVDstData[3], const UINT32 iDstStride[3]) BYTE type, const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3],
BYTE* WINPR_RESTRICT pYUVDstData[3], const UINT32 iDstStride[3])
{ {
YUV_COMBINE_WORK_PARAM current = { 0 }; YUV_COMBINE_WORK_PARAM current = { 0 };
@ -542,10 +550,10 @@ static INLINE YUV_COMBINE_WORK_PARAM pool_decode_rect_param(
return current; return current;
} }
static BOOL pool_decode_rect(YUV_CONTEXT* context, BYTE type, const BYTE* pYUVData[3], static BOOL pool_decode_rect(YUV_CONTEXT* WINPR_RESTRICT context, BYTE type,
const UINT32 iStride[3], BYTE* pYUVDstData[3], const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3],
const UINT32 iDstStride[3], const RECTANGLE_16* regionRects, BYTE* WINPR_RESTRICT pYUVDstData[3], const UINT32 iDstStride[3],
UINT32 numRegionRects) const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
UINT32 waitCount = 0; UINT32 waitCount = 0;
@ -597,10 +605,12 @@ fail:
return rc; return rc;
} }
BOOL yuv444_context_decode(YUV_CONTEXT* context, BYTE type, const BYTE* pYUVData[3], BOOL yuv444_context_decode(YUV_CONTEXT* WINPR_RESTRICT context, BYTE type,
const UINT32 iStride[3], UINT32 srcYuvHeight, BYTE* pYUVDstData[3], const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3],
const UINT32 iDstStride[3], DWORD DstFormat, BYTE* dest, UINT32 nDstStep, UINT32 srcYuvHeight, BYTE* WINPR_RESTRICT pYUVDstData[3],
const RECTANGLE_16* regionRects, UINT32 numRegionRects) const UINT32 iDstStride[3], DWORD DstFormat, BYTE* WINPR_RESTRICT dest,
UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects,
UINT32 numRegionRects)
{ {
const BYTE* pYUVCDstData[3]; const BYTE* pYUVCDstData[3];
@ -628,9 +638,11 @@ BOOL yuv444_context_decode(YUV_CONTEXT* context, BYTE type, const BYTE* pYUVData
srcYuvHeight, DstFormat, dest, nDstStep, regionRects, numRegionRects); srcYuvHeight, DstFormat, dest, nDstStep, regionRects, numRegionRects);
} }
BOOL yuv420_context_decode(YUV_CONTEXT* context, const BYTE* pYUVData[3], const UINT32 iStride[3], BOOL yuv420_context_decode(YUV_CONTEXT* WINPR_RESTRICT context,
UINT32 yuvHeight, DWORD DstFormat, BYTE* dest, UINT32 nDstStep, const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3],
const RECTANGLE_16* regionRects, UINT32 numRegionRects) UINT32 yuvHeight, DWORD DstFormat, BYTE* WINPR_RESTRICT dest,
UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects,
UINT32 numRegionRects)
{ {
return pool_decode(context, yuv420_process_work_callback, pYUVData, iStride, yuvHeight, return pool_decode(context, yuv420_process_work_callback, pYUVData, iStride, yuvHeight,
DstFormat, dest, nDstStep, regionRects, numRegionRects); DstFormat, dest, nDstStep, regionRects, numRegionRects);
@ -741,10 +753,10 @@ static void CALLBACK yuv444v2_encode_work_callback(PTP_CALLBACK_INSTANCE instanc
} }
} }
static INLINE YUV_ENCODE_WORK_PARAM pool_encode_fill(const RECTANGLE_16* rect, YUV_CONTEXT* context, static INLINE YUV_ENCODE_WORK_PARAM pool_encode_fill(
const BYTE* pSrcData, UINT32 nSrcStep, const RECTANGLE_16* WINPR_RESTRICT rect, YUV_CONTEXT* WINPR_RESTRICT context,
UINT32 SrcFormat, const UINT32 iStride[], const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep, UINT32 SrcFormat, const UINT32 iStride[],
BYTE* pYUVLumaData[], BYTE* pYUVChromaData[]) BYTE* WINPR_RESTRICT pYUVLumaData[], BYTE* WINPR_RESTRICT pYUVChromaData[])
{ {
YUV_ENCODE_WORK_PARAM current = { 0 }; YUV_ENCODE_WORK_PARAM current = { 0 };
@ -776,10 +788,11 @@ static INLINE YUV_ENCODE_WORK_PARAM pool_encode_fill(const RECTANGLE_16* rect, Y
return current; return current;
} }
static BOOL pool_encode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* pSrcData, static BOOL pool_encode(YUV_CONTEXT* WINPR_RESTRICT context, PTP_WORK_CALLBACK cb,
UINT32 nSrcStep, UINT32 SrcFormat, const UINT32 iStride[], const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep, UINT32 SrcFormat,
BYTE* pYUVLumaData[], BYTE* pYUVChromaData[], const UINT32 iStride[], BYTE* WINPR_RESTRICT pYUVLumaData[],
const RECTANGLE_16* regionRects, UINT32 numRegionRects) BYTE* WINPR_RESTRICT pYUVChromaData[],
const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
primitives_t* prims = primitives_get(); primitives_t* prims = primitives_get();
@ -856,9 +869,10 @@ fail:
return rc; return rc;
} }
BOOL yuv420_context_encode(YUV_CONTEXT* context, const BYTE* pSrcData, UINT32 nSrcStep, BOOL yuv420_context_encode(YUV_CONTEXT* WINPR_RESTRICT context, const BYTE* WINPR_RESTRICT pSrcData,
UINT32 SrcFormat, const UINT32 iStride[3], BYTE* pYUVData[3], UINT32 nSrcStep, UINT32 SrcFormat, const UINT32 iStride[3],
const RECTANGLE_16* regionRects, UINT32 numRegionRects) BYTE* WINPR_RESTRICT pYUVData[3],
const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects)
{ {
if (!context || !pSrcData || !iStride || !pYUVData || !regionRects) if (!context || !pSrcData || !iStride || !pYUVData || !regionRects)
return FALSE; return FALSE;
@ -867,10 +881,11 @@ BOOL yuv420_context_encode(YUV_CONTEXT* context, const BYTE* pSrcData, UINT32 nS
pYUVData, NULL, regionRects, numRegionRects); pYUVData, NULL, regionRects, numRegionRects);
} }
BOOL yuv444_context_encode(YUV_CONTEXT* context, BYTE version, const BYTE* pSrcData, BOOL yuv444_context_encode(YUV_CONTEXT* WINPR_RESTRICT context, BYTE version,
UINT32 nSrcStep, UINT32 SrcFormat, const UINT32 iStride[3], const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep, UINT32 SrcFormat,
BYTE* pYUVLumaData[3], BYTE* pYUVChromaData[3], const UINT32 iStride[3], BYTE* WINPR_RESTRICT pYUVLumaData[3],
const RECTANGLE_16* regionRects, UINT32 numRegionRects) BYTE* WINPR_RESTRICT pYUVChromaData[3],
const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects)
{ {
PTP_WORK_CALLBACK cb = NULL; PTP_WORK_CALLBACK cb = NULL;
switch (version) switch (version)