[x265] [PATCH] api: 'x265_get_slicetype_poc_and_scenecut' to fetch slicetype, poc and scenecut information

praveen at multicorewareinc.com praveen at multicorewareinc.com
Fri Nov 3 11:49:07 CET 2017


# HG changeset patch
# User Praveen Tiwari <praveen at multicorewareinc.com>
# Date 1509438457 -19800
#      Tue Oct 31 13:57:37 2017 +0530
# Node ID de91aae2db5353e4e548d002e2dce530a6c8078d
# Parent  6a310b24c6a2d831ef08bbda1bdcf9d929daa308
api: 'x265_get_slicetype_poc_and_scenecut' to fetch slicetype, poc and scenecut information

diff -r 6a310b24c6a2 -r de91aae2db53 doc/reST/api.rst
--- a/doc/reST/api.rst	Thu Nov 02 12:17:29 2017 +0530
+++ b/doc/reST/api.rst	Tue Oct 31 13:57:37 2017 +0530
@@ -192,6 +192,15 @@
 	 *      presets is not recommended without a more fine-grained breakdown of
 	 *      parameters to take this into account. */
 	int x265_encoder_reconfig(x265_encoder *, x265_param *);
+
+**x265_get_slicetype_poc_and_scenecut()** may be used to fetch slice type, poc and scene cut information mid-encode::
+
+    /* x265_get_slicetype_poc_and_scenecut:
+     *     get the slice type, poc and scene cut information for the current frame,
+     *     returns negative on error, 0 on success.
+     *     This API must be called after(poc >= lookaheadDepth + bframes + 2) condition check. */
+     int x265_get_slicetype_poc_and_scenecut(x265_encoder *encoder, int *slicetype, int *poc, int* sceneCut);
+
 **x265_encoder_ctu_info**
        /* x265_encoder_ctu_info:
         *    Copy CTU information such as ctu address and ctu partition structure of all
diff -r 6a310b24c6a2 -r de91aae2db53 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/CMakeLists.txt	Tue Oct 31 13:57:37 2017 +0530
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 136)
+set(X265_BUILD 137)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 6a310b24c6a2 -r de91aae2db53 source/common/piclist.cpp
--- a/source/common/piclist.cpp	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/common/piclist.cpp	Tue Oct 31 13:57:37 2017 +0530
@@ -117,6 +117,15 @@
         return NULL;
 }
 
+Frame* PicList::getCurFrame(void)
+{
+    Frame *curFrame = m_start;
+    if (curFrame != NULL)
+        return curFrame;
+    else
+        return NULL;
+}
+
 void PicList::remove(Frame& curFrame)
 {
 #if _DEBUG
diff -r 6a310b24c6a2 -r de91aae2db53 source/common/piclist.h
--- a/source/common/piclist.h	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/common/piclist.h	Tue Oct 31 13:57:37 2017 +0530
@@ -62,6 +62,9 @@
     /** Find frame with specified POC */
     Frame* getPOC(int poc);
 
+    /** Get the current Frame from the list **/
+    Frame* getCurFrame(void);
+
     /** Remove picture from list */
     void remove(Frame& pic);
 
diff -r 6a310b24c6a2 -r de91aae2db53 source/encoder/api.cpp
--- a/source/encoder/api.cpp	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/encoder/api.cpp	Tue Oct 31 13:57:37 2017 +0530
@@ -340,6 +340,16 @@
     return 0;
 }
 
+int x265_get_slicetype_poc_and_scenecut(x265_encoder *enc, int *slicetype, int *poc, int *sceneCut)
+{
+    if (!enc)
+        return -1;
+    Encoder *encoder = static_cast<Encoder*>(enc);
+    if (!encoder->copySlicetypePocAndSceneCut(slicetype, poc, sceneCut))
+        return 0;
+    return -1;
+}
+
 void x265_cleanup(void)
 {
     BitCost::destroy();
@@ -413,6 +423,7 @@
     sizeof(x265_frame_stats),
     &x265_encoder_intra_refresh,
     &x265_encoder_ctu_info,
+    &x265_get_slicetype_poc_and_scenecut,
 };
 
 typedef const x265_api* (*api_get_func)(int bitDepth);
diff -r 6a310b24c6a2 -r de91aae2db53 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/encoder/encoder.cpp	Tue Oct 31 13:57:37 2017 +0530
@@ -429,6 +429,23 @@
     }
 }
 
+int Encoder::copySlicetypePocAndSceneCut(int *slicetype, int *poc, int *sceneCut)
+{
+    Frame *FramePtr = m_dpb->m_picList.getCurFrame();
+    if (FramePtr != NULL)
+    {
+        *slicetype = FramePtr->m_lowres.sliceType;
+        *poc = FramePtr->m_encData->m_slice->m_poc;
+        *sceneCut = FramePtr->m_lowres.bScenecut;
+    }
+    else
+    {
+        x265_log(NULL, X265_LOG_WARNING, "Frame is still in lookahead pipeline, this API must be called after (poc >= lookaheadDepth + bframes + 2) condition check\n");
+        return -1;
+    }
+    return 0;
+}
+
 void Encoder::destroy()
 {
 #if ENABLE_HDR10_PLUS
diff -r 6a310b24c6a2 -r de91aae2db53 source/encoder/encoder.h
--- a/source/encoder/encoder.h	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/encoder/encoder.h	Tue Oct 31 13:57:37 2017 +0530
@@ -205,6 +205,8 @@
 
     void copyCtuInfo(x265_ctu_info_t** frameCtuInfo, int poc);
 
+    int copySlicetypePocAndSceneCut(int *slicetype, int *poc, int *sceneCut);
+
     void getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream& bs);
 
     void fetchStats(x265_stats* stats, size_t statsSizeBytes);
diff -r 6a310b24c6a2 -r de91aae2db53 source/x265.h
--- a/source/x265.h	Thu Nov 02 12:17:29 2017 +0530
+++ b/source/x265.h	Tue Oct 31 13:57:37 2017 +0530
@@ -1705,6 +1705,13 @@
 int x265_encoder_ctu_info(x265_encoder *, int poc, x265_ctu_info_t** ctu);
 /* x265_cleanup:
  *       release library static allocations, reset configured CTU size */
+
+/* x265_get_slicetype_poc_and_scenecut:
+ *     get the slice type, poc and scene cut information for the current frame,
+ *     returns negative on error, 0 when access unit were output.
+ *     This API must be called after(poc >= lookaheadDepth + bframes + 2) condition check */
+int x265_get_slicetype_poc_and_scenecut(x265_encoder *encoder, int *slicetype, int *poc, int* sceneCut);
+
 void x265_cleanup(void);
 
 #define X265_MAJOR_VERSION 1
@@ -1752,6 +1759,7 @@
     int           sizeof_frame_stats;   /* sizeof(x265_frame_stats) */
     int           (*encoder_intra_refresh)(x265_encoder*);
     int           (*encoder_ctu_info)(x265_encoder*, int, x265_ctu_info_t**);
+    int           (*x265_get_slicetype_poc_and_scenecut)(x265_encoder*, int*, int*, int*);
     /* add new pointers to the end, or increment X265_MAJOR_VERSION */
 } x265_api;
 


More information about the x265-devel mailing list