[x265] [PATCH 2 of 4] api: add x265_alloc_inter_intra_data and x265_free_inter_intra_data methods to allocate and free analysis info

sagar at multicorewareinc.com sagar at multicorewareinc.com
Tue Sep 9 11:23:00 CEST 2014


# HG changeset patch
# User Sagar Kotecha <sagar at multicorewareinc.com>
# Date 1410245000 -19800
#      Tue Sep 09 12:13:20 2014 +0530
# Node ID 2f993103d6b6cd35cbe52bd624c8eef0d1b85be4
# Parent  a6d18c4bfccdb31af03b1c21cb9e15cf20ed34fe
api: add x265_alloc_inter_intra_data and x265_free_inter_intra_data methods to allocate and free analysis info

diff -r a6d18c4bfccd -r 2f993103d6b6 source/encoder/api.cpp
--- a/source/encoder/api.cpp	Tue Sep 09 12:00:10 2014 +0530
+++ b/source/encoder/api.cpp	Tue Sep 09 12:13:20 2014 +0530
@@ -196,3 +196,52 @@
 {
     return x265_free(p);
 }
+
+int x265_alloc_inter_intra_data(x265_picture* pic, x265_param* param)
+{
+    uint32_t numPartitions   = 1 << g_maxFullDepth * 2;
+    uint32_t widthInCU       = (param->sourceWidth  + g_maxCUSize - 1) >> g_maxLog2CUSize;
+    uint32_t heightInCU      = (param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;
+
+    uint32_t numCUsInFrame   = widthInCU * heightInCU;
+    pic->intraInterData.numCUsInFrame = numCUsInFrame;
+    pic->intraInterData.numPartitions = numPartitions;
+
+    CHECKED_MALLOC(pic->intraInterData.interData, x265_inter_data, numCUsInFrame * 85);
+    CHECKED_MALLOC(pic->intraInterData.intraData, x265_intra_data, 1);
+    pic->intraInterData.intraData->cuAddr     = NULL;
+    pic->intraInterData.intraData->depth      = NULL;
+    pic->intraInterData.intraData->modes      = NULL;
+    pic->intraInterData.intraData->partSizes  = NULL;
+    pic->intraInterData.intraData->poc        = NULL;
+    CHECKED_MALLOC(pic->intraInterData.intraData->depth, uint8_t, numPartitions * numCUsInFrame);
+    CHECKED_MALLOC(pic->intraInterData.intraData->modes, uint8_t, numPartitions * numCUsInFrame);
+    CHECKED_MALLOC(pic->intraInterData.intraData->partSizes, char, numPartitions * numCUsInFrame);
+    CHECKED_MALLOC(pic->intraInterData.intraData->cuAddr, uint32_t, numCUsInFrame);
+    CHECKED_MALLOC(pic->intraInterData.intraData->poc, int, numCUsInFrame);
+    return 1;
+
+fail:
+    x265_log(NULL, X265_LOG_WARNING, "unable to allocate memory for intra-inter analysis");
+    x265_free_inter_intra_data(pic);
+    return 0;
+}
+
+void x265_free_inter_intra_data(x265_picture* pic)
+{
+    if (pic->intraInterData.interData)
+        X265_FREE(pic->intraInterData.interData);
+
+    if (pic->intraInterData.intraData)
+    {
+        X265_FREE(pic->intraInterData.intraData->depth);
+        X265_FREE(pic->intraInterData.intraData->modes);
+        X265_FREE(pic->intraInterData.intraData->partSizes);
+        X265_FREE(pic->intraInterData.intraData->cuAddr);
+        X265_FREE(pic->intraInterData.intraData->poc);
+        X265_FREE(pic->intraInterData.intraData);
+    }
+
+    pic->intraInterData.interData = NULL;
+    pic->intraInterData.intraData = NULL;
+}
diff -r a6d18c4bfccd -r 2f993103d6b6 source/x265.h
--- a/source/x265.h	Tue Sep 09 12:00:10 2014 +0530
+++ b/source/x265.h	Tue Sep 09 12:13:20 2014 +0530
@@ -1028,6 +1028,15 @@
  *  allocated by x265_picture_alloc() */
 void x265_picture_free(x265_picture *);
 
+/* x265_alloc_inter_intra_data:
+ *  Allocate memory to hold inter-intra meta data, returns 1 on success else 0 */
+int x265_alloc_inter_intra_data(x265_picture*, x265_param*);
+
+/* x265_free_inter_intra_data:
+ *  Use x265_free_inter_intra_data to release storage of x265_interIntraData
+    members allocated by x265_alloc_inter_intra_data */
+void x265_free_inter_intra_data(x265_picture*);
+
 /***
  * Initialize an x265_picture structure to default values. It sets the pixel
  * depth and color space to the encoder's internal values and sets the slice


More information about the x265-devel mailing list