/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
((static_cast<unsigned long long>(w) * static_cast<unsigned long long>(h)) >= \
((1ULL << (29 * (sizeof(void*) / 4))) - 2048))
-#define PRINT_ERR_AND_EXIT(args...) \
- do \
- { \
- DALI_LOG_ERROR(args); \
- if(rows) \
- { \
- free(rows); \
- } \
- return ret; \
+#define PRINT_ERROR_AND_EXIT(errorFormat, ...) \
+ do \
+ { \
+ DALI_LOG_ERROR(errorFormat, ##__VA_ARGS__); \
+ if(rows) \
+ { \
+ free(rows); \
+ } \
+ return ret; \
} while(0)
namespace Dali
if(DALI_LIKELY(!fseek(fp, 0, SEEK_SET)))
{
- globalMap = reinterpret_cast<GifByteType*>(malloc(sizeof(GifByteType) * length));
- length = fread(globalMap, sizeof(GifByteType), length, fp);
+ globalMap = reinterpret_cast<GifByteType*>(malloc(sizeof(GifByteType) * static_cast<unsigned long long>(length)));
+ if(DALI_UNLIKELY(globalMap == nullptr))
+ {
+ DALI_LOG_ERROR("malloc is failed. request malloc size : %llu\n", sizeof(GifByteType) * static_cast<unsigned long long>(length));
+ return false;
+ }
+ length = fread(globalMap, sizeof(GifByteType), length, fp);
}
else
{
if(DALI_LIKELY(!fseek(fp, 0, SEEK_SET)))
{
globalMap = reinterpret_cast<GifByteType*>(malloc(sizeof(GifByteType) * blobSize));
- length = fread(globalMap, sizeof(GifByteType), blobSize, fp);
- succeeded = true;
+ if(DALI_UNLIKELY(globalMap == nullptr))
+ {
+ DALI_LOG_ERROR("malloc is failed. request malloc size : %zu\n", sizeof(GifByteType) * blobSize);
+ }
+ else
+ {
+ length = fread(globalMap, sizeof(GifByteType), blobSize, fp);
+ succeeded = true;
+ }
}
else
{
{
DALI_LOG_ERROR("gifW : %d, w : %d, gifH : %d, h : %d\n", gifW, w, gifH, h);
DALI_ASSERT_DEBUG(false && "Dimensions are bigger than the Gif image size");
- PRINT_ERR_AND_EXIT("GIF Loader: Dimensions are bigger than the Gif image size! gifW : %d, w : %d, gifH : %d, h : %d\n", gifW, w, gifH, h);
+ PRINT_ERROR_AND_EXIT("GIF Loader: Dimensions are bigger than the Gif image size! gifW : %d, w : %d, gifH : %d, h : %d\n", gifW, w, gifH, h);
}
// build a blob of memory to have pointers to rows of pixels
rows = static_cast<GifRowType*>(malloc((gifH * sizeof(GifRowType)) + (gifW * gifH * sizeof(GifPixelType))));
if(DALI_UNLIKELY(!rows))
{
- PRINT_ERR_AND_EXIT("GIF Loader: malloc failed! gifW : %d, w : %d, gifH : %d, h : %d\n", gifW, w, gifH, h);
+ PRINT_ERROR_AND_EXIT("GIF Loader: malloc failed! gifW : %d, w : %d, gifH : %d, h : %d\n", gifW, w, gifH, h);
}
// fill in the pointers at the start
{
if(DALI_UNLIKELY(DGifGetLine(gif, rows[yy], gifW) != GIF_OK))
{
- PRINT_ERR_AND_EXIT("GIF Loader: Decode failed at line %d! gifW : %d, gifH : %d, rows[yy] : %d, i : %d, intoffset[i] : %d, intjump[i] : %d\n", yy, gifW, gifH, rows[yy], i, intoffset[i], intjump[i]);
+ PRINT_ERROR_AND_EXIT("GIF Loader: Decode failed at line %d! gifW : %d, gifH : %d, rows[yy] : %d, i : %d, intoffset[i] : %d, intjump[i] : %d\n", yy, gifW, gifH, rows[yy], i, intoffset[i], intjump[i]);
}
}
}
{
if(DALI_UNLIKELY(DGifGetLine(gif, rows[yy], gifW) != GIF_OK))
{
- PRINT_ERR_AND_EXIT("GIF Loader: Decode failed at line %d! gifW : %d, gifH : %d, rows[yy] : %d\n", yy, gifW, gifH, rows[yy]);
+ PRINT_ERROR_AND_EXIT("GIF Loader: Decode failed at line %d! gifW : %d, gifH : %d, rows[yy] : %d\n", yy, gifW, gifH, rows[yy]);
}
}
}
delete mImpl;
}
-Dali::Devel::PixelBuffer GifLoading::LoadFrame(uint32_t frameIndex)
+Dali::Devel::PixelBuffer GifLoading::LoadFrame(uint32_t frameIndex, ImageDimensions desiredSize)
{
int error;
Dali::Devel::PixelBuffer pixelBuffer;