<commit_before>#include<gtest/gtest.h>
#include <time.h>
#include "cpu.h"
#include "cpu_core.h"
#include "get_intra_predictor.h"
#include "typedefs.h"
#include "ls_defines.h"
using namespace WelsDec;
#define GENERATE_4x4_UT(pred, ref, ASM, CPUFLAGS) \
  TEST(DecoderIntraPredictionTest, pred) { \
  const int32_t kiStride = 32; \
  int32_t iRunTimes = 1000; \
  uint8_t pPredBuffer[9 * kiStride]; \
  uint8_t pRefBuffer[9 * kiStride]; \
if (ASM) {\
  int32_t  iNumberofCPUCore = 1; \
  uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iNumberofCPUCore); \
  if ((uiCPUFlags & CPUFLAGS) == 0) {\
    return; \
  } \
}\
  srand((unsigned int)time(NULL)); \
  while(iRunTimes--) {\
  for (int i = 0; i < 9; i++) {\
    pRefBuffer[i] = pPredBuffer[i] = rand() & 255; \
    pRefBuffer[i * kiStride] = pPredBuffer[i * kiStride] = rand() & 255; \
  } \
  pred (&pPredBuffer[kiStride + 1], kiStride); \
  ref (&pRefBuffer[kiStride + 1], kiStride); \
  bool ok = true; \
  for (int i = 0; i < 4; i++) \
    for (int j = 0; j < 4; j++) \
      if (pPredBuffer[(i+1) * kiStride + j + 1] != pRefBuffer[(i+1) * kiStride + j + 1]) { \
        ok = false; \
        break; \
      } \
  EXPECT_EQ(ok, true);\
  } \
  }

#define PREDV(size) \
void LumaI##size##x##size##PredV(uint8_t *pPred, const int32_t kiStride) {\
  int i; \
  for (i = 0; i < size; i++) {\
    memcpy(pPred + i * kiStride, pPred - kiStride, size * sizeof(uint8_t)); \
  } \
}

#define PREDH(size) \
void LumaI##size##x##size##PredH(uint8_t *pPred, const int32_t kiStride) {\
  for (int i = 0; i < size; i++) { \
    memset(pPred + i * kiStride, pPred[i * kiStride - 1], size * sizeof(uint8_t));\
  }\
}

#define PREDDC(size, log) \
void LumaI##size##x##size##PredDC(uint8_t *pPred, const int32_t kiStride) {\
  int iSum = size; \<commit_msg>Prevent misaligned warning in UT<commit_after>#include<gtest/gtest.h>
#include <time.h>
#include "cpu.h"
#include "cpu_core.h"
#include "get_intra_predictor.h"
#include "typedefs.h"
#include "ls_defines.h"
#include "macros.h"

using namespace WelsDec;
#define GENERATE_4x4_UT(pred, ref, ASM, CPUFLAGS) \
  TEST(DecoderIntraPredictionTest, pred) { \
  const int32_t kiStride = 32; \
  int32_t iRunTimes = 1000; \
  ENFORCE_STACK_ALIGN_1D (uint8_t, pPredBuffer, 12 * kiStride, 4); \
  ENFORCE_STACK_ALIGN_1D (uint8_t, pRefBuffer, 12 * kiStride, 4); \
if (ASM) {\
  int32_t  iNumberofCPUCore = 1; \
  uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iNumberofCPUCore); \
  if ((uiCPUFlags & CPUFLAGS) == 0) {\
    return; \
  } \
}\
  srand((unsigned int)time(NULL)); \
  while(iRunTimes--) {\
  for (int i = 0; i < 12; i++) {\
    pRefBuffer[kiStride * 3 + i] = pPredBuffer[kiStride * 3 + i] = rand() & 255; \
    pRefBuffer[i * kiStride + 3] = pPredBuffer[i * kiStride + 3] = rand() & 255; \
  } \
  pred (&pPredBuffer[kiStride * 4 + 4], kiStride); \
  ref (&pRefBuffer[kiStride * 4 + 4], kiStride); \
  bool ok = true; \
  for (int i = 0; i < 4; i++) \
    for (int j = 0; j < 4; j++) \
      if (pPredBuffer[(i+4) * kiStride + j + 4] != pRefBuffer[(i+4) * kiStride + j + 4]) { \
        ok = false; \
        break; \
      } \
  EXPECT_EQ(ok, true);\
  } \
  }

#define PREDV(size) \
void LumaI##size##x##size##PredV(uint8_t *pPred, const int32_t kiStride) {\
  int i; \
  for (i = 0; i < size; i++) {\
    memcpy(pPred + i * kiStride, pPred - kiStride, size * sizeof(uint8_t)); \
  } \
}

#define PREDH(size) \
void LumaI##size##x##size##PredH(uint8_t *pPred, const int32_t kiStride) {\
  for (int i = 0; i < size; i++) { \
    memset(pPred + i * kiStride, pPred[i * kiStride - 1], size * sizeof(uint8_t));\
  }\
}

#define PREDDC(size, log) \
void LumaI##size##x##size##PredDC(uint8_t *pPred, const int32_t kiStride) {\
  int iSum = size; \
{'fraction_non_alphanumeric': 0.18055183498526653, 'fraction_numerical': 0.0324136083578891, 'mean_word_length': 3.190796857463524, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3384845', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1595, 'n_words': 354}