It is possible that TJ_SUBSAMPL could be greater than 7 in future.
This patch make ensure that it will works well even that value increased.
Change-Id: I3a7b1ce25cda3fb6717f3cb847bd0d4e744086e7
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
"DALI_ENABLE_DECODE_JPEG_TO_YUV_411",
"DALI_ENABLE_DECODE_JPEG_TO_YUV_441"};
"DALI_ENABLE_DECODE_JPEG_TO_YUV_411",
"DALI_ENABLE_DECODE_JPEG_TO_YUV_441"};
+const int CHROMINANCE_SUBSAMPLING_OPTIONS_ENV_COUNT = sizeof(CHROMINANCE_SUBSAMPLING_OPTIONS_ENV) / sizeof(CHROMINANCE_SUBSAMPLING_OPTIONS_ENV[0]);
+
static bool gSubsamplingFormatTable[TJ_NUMSAMP] = {
false,
};
static bool gSubsamplingFormatTable[TJ_NUMSAMP] = {
false,
};
{
for(int i = 0; i < TJ_NUMSAMP; i++)
{
{
for(int i = 0; i < TJ_NUMSAMP; i++)
{
- auto valueString = Dali::EnvironmentVariable::GetEnvironmentVariable(CHROMINANCE_SUBSAMPLING_OPTIONS_ENV[i]);
+ const char* envName = DALI_LIKELY(i < CHROMINANCE_SUBSAMPLING_OPTIONS_ENV_COUNT) ? CHROMINANCE_SUBSAMPLING_OPTIONS_ENV[i] : "";
+ auto valueString = Dali::EnvironmentVariable::GetEnvironmentVariable(envName);
gSubsamplingFormatTable[i] = valueString ? std::atoi(valueString) : false;
}
gIsSubsamplingFormatTableInitialized = true;
}
gSubsamplingFormatTable[i] = valueString ? std::atoi(valueString) : false;
}
gIsSubsamplingFormatTableInitialized = true;
}
- return gSubsamplingFormatTable[chrominanceSubsampling];
+ if(DALI_UNLIKELY(chrominanceSubsampling >= TJ_NUMSAMP))
+ {
+ DALI_LOG_WARNING("WARNING! Input subsampling value [%d] is bigger than turbojpeg library support [%d]\n", chrominanceSubsampling, TJ_NUMSAMP);
+ }
+
+ return chrominanceSubsampling < TJ_NUMSAMP ? gSubsamplingFormatTable[chrominanceSubsampling] : false;
}
/// @brief Pointer to Pointer cast operator
}
/// @brief Pointer to Pointer cast operator