From f4299fbb0d459fc6bba1780b549b44107e5b63c4 Mon Sep 17 00:00:00 2001 From: Thomas Guillem Date: Thu, 16 Nov 2017 12:09:49 +0100 Subject: [PATCH] chroma: copy: add asserts --- modules/video_chroma/copy.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c index d2ce2bc517..6b5629196f 100644 --- a/modules/video_chroma/copy.c +++ b/modules/video_chroma/copy.c @@ -33,6 +33,18 @@ #include "copy.h" +#define ASSERT_PLANE(i) assert(src[i]); \ + assert(src_pitch[i]) + +#define ASSERT_2PLANES \ + assert(dst); \ + ASSERT_PLANE(0); \ + ASSERT_PLANE(1); \ + assert(height) + +#define ASSERT_3PLANES ASSERT_2PLANES; \ + ASSERT_PLANE(2) + int CopyInitCache(copy_cache_t *cache, unsigned width) { #ifdef CAN_COMPILE_SSE2 @@ -556,6 +568,7 @@ void Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2], const size_t src_pitch[static 2], unsigned height, const copy_cache_t *cache) { + ASSERT_2PLANES; #ifdef CAN_COMPILE_SSE2 unsigned cpu = vlc_CPU(); if (vlc_CPU_SSE2()) @@ -575,6 +588,7 @@ void Copy420_SP_to_P(picture_t *dst, const uint8_t *src[static 2], const size_t src_pitch[static 2], unsigned height, const copy_cache_t *cache) { + ASSERT_2PLANES; #ifdef CAN_COMPILE_SSE2 unsigned cpu = vlc_CPU(); @@ -595,6 +609,7 @@ void Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3], const size_t src_pitch[static 3], unsigned height, const copy_cache_t *cache) { + ASSERT_3PLANES; #ifdef CAN_COMPILE_SSE2 unsigned cpu = vlc_CPU(); if (vlc_CPU_SSE2()) @@ -674,6 +689,7 @@ void Copy420_P_to_P(picture_t *dst, const uint8_t *src[static 3], const size_t src_pitch[static 3], unsigned height, const copy_cache_t *cache) { + ASSERT_3PLANES; #ifdef CAN_COMPILE_SSE2 unsigned cpu = vlc_CPU(); if (vlc_CPU_SSE2()) -- GitLab