sw_engine: optimization++
authorHermet Park <chuneon.park@samsung.com>
Sun, 19 Apr 2020 02:13:28 +0000 (11:13 +0900)
committerHermet Park <chuneon.park@samsung.com>
Sun, 19 Apr 2020 02:13:28 +0000 (11:13 +0900)
Adjust rle span generation size to reduce memory allocation.
This span growing is experimentally increased, undeterministic.
Thus We need too increase them every requests, if we increase their
size x 4, we can avoid a lot of memory copy in advance.

Change-Id: Idd24024204a69fa3b6857728b95aa63a3ac26c5e

src/lib/sw_engine/tvgSwRle.cpp

index 25b9c03..1d3d498 100644 (file)
@@ -145,9 +145,9 @@ static void _genSpan(SwRleData* rle, SwSpan* spans, size_t count)
     /* alloc is required to prevent free and reallocation */
     /* when the rle needs to be regenerated because of attribute change. */
     if (rle->alloc < newSize) {
-        rle->spans = static_cast<SwSpan*>(realloc(rle->spans, newSize * sizeof(SwSpan)));
+        rle->spans = static_cast<SwSpan*>(realloc(rle->spans, (count + rle->size) << 2 * sizeof(SwSpan)));
         assert(rle->spans);
-        rle->alloc = newSize;
+        rle->alloc = rle->size + (count << 2);
     }
 
     //copy the new spans to the allocated memory