[x265-commits] [x265] getopt: remove double underscores from prototype argument...

Steve Borho steve at borho.org
Fri Aug 14 07:19:31 CEST 2015


details:   http://hg.videolan.org/x265/rev/567f9b1263a2
branches:  stable
changeset: 10887:567f9b1263a2
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 14 09:06:13 2015 +0530
description:
getopt: remove double underscores from prototype arguments (fixes #162)

It seems that the latest stdint.h from Microsoft defines a macro named __arg
which causes our compat getopt.h to mis-compile.
Subject: [x265] doc: fix typos and improve readability of threading chapter

details:   http://hg.videolan.org/x265/rev/1b8ff853ad41
branches:  stable
changeset: 10888:1b8ff853ad41
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 14 09:58:25 2015 +0530
description:
doc: fix typos and improve readability of threading chapter
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/a7746c2cd531
branches:  
changeset: 10889:a7746c2cd531
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 14 10:48:59 2015 +0530
description:
Merge with stable

diffstat:

 doc/reST/cli.rst                     |   10 +
 doc/reST/threading.rst               |   27 +-
 source/CMakeLists.txt                |    2 +-
 source/common/cudata.cpp             |    6 +-
 source/common/deblock.cpp            |    8 +-
 source/common/frame.cpp              |   14 +-
 source/common/frame.h                |    2 +
 source/common/framedata.cpp          |    8 +-
 source/common/framedata.h            |    6 +-
 source/common/param.cpp              |    4 +
 source/common/picyuv.cpp             |    6 +-
 source/common/picyuv.h               |    2 +-
 source/common/predict.cpp            |   42 +-
 source/common/slice.cpp              |   12 +-
 source/common/slice.h                |   37 +-
 source/common/x86/asm-primitives.cpp |    1 +
 source/common/x86/intrapred8.asm     |  932 ++++++++++++++++------------------
 source/compat/getopt/getopt.h        |   20 +-
 source/encoder/analysis.cpp          |   13 +-
 source/encoder/api.cpp               |    1 +
 source/encoder/dpb.cpp               |   20 +-
 source/encoder/dpb.h                 |    4 +-
 source/encoder/encoder.cpp           |   47 +-
 source/encoder/encoder.h             |    7 -
 source/encoder/frameencoder.cpp      |   11 +-
 source/encoder/framefilter.cpp       |    6 +-
 source/encoder/ratecontrol.cpp       |   18 +-
 source/encoder/sao.cpp               |   30 +-
 source/encoder/search.cpp            |   54 +-
 source/encoder/slicetype.cpp         |   28 +-
 source/encoder/weightPrediction.cpp  |    2 +-
 source/test/intrapredharness.cpp     |    2 +
 source/x265.h                        |   17 +
 source/x265cli.h                     |    4 +
 34 files changed, 721 insertions(+), 682 deletions(-)

diffs (truncated from 2395 to 300 lines):

diff -r a68dff2b203c -r a7746c2cd531 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Tue Aug 11 14:30:27 2015 +0530
+++ b/doc/reST/cli.rst	Fri Aug 14 10:48:59 2015 +0530
@@ -1638,6 +1638,16 @@ VUI fields must be manually specified.
 	Note that this string value will need to be escaped or quoted to
 	protect against shell expansion on many platforms. No default.
 
+.. option:: --min-luma <integer>
+
+	Minimum luma value allowed for input pictures. Any values below min-luma
+	are clipped. Experimental. No default.
+
+.. option:: --max-luma <integer>
+
+	Maximum luma value allowed for input pictures. Any values above max-luma
+	are clipped. Experimental. No default.
+
 Bitstream options
 =================
 
diff -r a68dff2b203c -r a7746c2cd531 doc/reST/threading.rst
--- a/doc/reST/threading.rst	Tue Aug 11 14:30:27 2015 +0530
+++ b/doc/reST/threading.rst	Fri Aug 14 10:48:59 2015 +0530
@@ -28,7 +28,7 @@ pool has a method to **poke** awake a bl
 providers are recommended to call this method when they make new jobs
 available.
 
-Worker jobs are not allowed to block except when abosultely necessary
+Worker jobs are not allowed to block except when absolutely necessary
 for data locking. If a job becomes blocked, the work function is
 expected to drop that job so the worker thread may go back to the pool
 and find more work.
@@ -94,10 +94,10 @@ Bonded Task Groups
 
 If a worker thread job has work which can be performed in parallel by
 many threads, it may allocate a bonded task group and enlist the help of
-other idle worker threads in the same pool. Those threads will cooperate
-to complete the work of the bonded task group and then return to their
-idle states. The larger and more uniform those tasks are, the better the
-bonded task group will perform.
+other idle worker threads from the same thread pool. Those threads will
+cooperate to complete the work of the bonded task group and then return
+to their idle states. The larger and more uniform those tasks are, the
+better the bonded task group will perform.
 
 Parallel Mode Analysis
 ~~~~~~~~~~~~~~~~~~~~~~
@@ -105,19 +105,20 @@ Parallel Mode Analysis
 When :option:`--pmode` is enabled, each CU (at all depths from 64x64 to
 8x8) will distribute its analysis work to the thread pool via a bonded
 task group. Each analysis job will measure the cost of one prediction
-for the CU: merge, skip, intra, inter (2Nx2N, Nx2N, 2NxN, and AMP). At
-slower presets, the amount of increased parallelism is often enough to
-be able to reduce frame parallelism while achieving the same overall CPU
-utilization. Reducing frame threads is often beneficial to ABR and VBV
-rate control.
+for the CU: merge, skip, intra, inter (2Nx2N, Nx2N, 2NxN, and AMP).
+
+At slower presets, the amount of increased parallelism from pmode is
+often enough to be able to reduce or disable frame parallelism while
+achieving the same overall CPU utilization. Reducing frame threads is
+often beneficial to ABR and VBV rate control.
 
 Parallel Motion Estimation
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 When :option:`--pme` is enabled all of the analysis functions which
 perform motion searches to reference frames will distribute those motion
-searches as jobs for worker threads via a bonded task group (if more
-than two motion searches are required).
+searches to other worker threads via a bonded task group (if more than
+two motion searches are required).
 
 Frame Threading
 ===============
@@ -241,7 +242,7 @@ to perform batches of frame cost estimat
 bonded task groups to measure single frame cost estimates using slices.
 (see :option:`--lookahead-slices`)
 
-The function slicetypeDecide() itself is also be performed by a worker
+The main slicetypeDecide() function itself is also performed by a worker
 thread if your encoder has a thread pool, else it runs within the
 context of the thread which calls the x265_encoder_encode().
 
diff -r a68dff2b203c -r a7746c2cd531 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/CMakeLists.txt	Fri Aug 14 10:48:59 2015 +0530
@@ -30,7 +30,7 @@ option(STATIC_LINK_CRT "Statically link 
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 68)
+set(X265_BUILD 70)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r a68dff2b203c -r a7746c2cd531 source/common/cudata.cpp
--- a/source/common/cudata.cpp	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/cudata.cpp	Fri Aug 14 10:48:59 2015 +0530
@@ -1676,7 +1676,7 @@ int CUData::getPMV(InterNeighbourMV *nei
         if (tempRefIdx != -1)
         {
             uint32_t cuAddr = neighbours[MD_COLLOCATED].cuAddr[picList];
-            const Frame* colPic = m_slice->m_refPicList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];
+            const Frame* colPic = m_slice->m_refFrameList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];
             const CUData* colCU = colPic->m_encData->getPicCTU(cuAddr);
 
             // Scale the vector
@@ -1857,7 +1857,7 @@ bool CUData::getIndirectPMV(MV& outMV, I
 
 bool CUData::getColMVP(MV& outMV, int& outRefIdx, int picList, int cuAddr, int partUnitIdx) const
 {
-    const Frame* colPic = m_slice->m_refPicList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];
+    const Frame* colPic = m_slice->m_refFrameList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];
     const CUData* colCU = colPic->m_encData->getPicCTU(cuAddr);
 
     uint32_t absPartAddr = partUnitIdx & TMVP_UNIT_MASK;
@@ -1892,7 +1892,7 @@ bool CUData::getColMVP(MV& outMV, int& o
 // Cache the collocated MV.
 bool CUData::getCollocatedMV(int cuAddr, int partUnitIdx, InterNeighbourMV *neighbour) const
 {
-    const Frame* colPic = m_slice->m_refPicList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];
+    const Frame* colPic = m_slice->m_refFrameList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];
     const CUData* colCU = colPic->m_encData->getPicCTU(cuAddr);
 
     uint32_t absPartAddr = partUnitIdx & TMVP_UNIT_MASK;
diff -r a68dff2b203c -r a7746c2cd531 source/common/deblock.cpp
--- a/source/common/deblock.cpp	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/deblock.cpp	Fri Aug 14 10:48:59 2015 +0530
@@ -209,8 +209,8 @@ uint8_t Deblock::getBoundaryStrength(con
     const Slice* const sliceQ = cuQ->m_slice;
     const Slice* const sliceP = cuP->m_slice;
 
-    const Frame* refP0 = sliceP->getRefPic(0, cuP->m_refIdx[0][partP]);
-    const Frame* refQ0 = sliceQ->getRefPic(0, cuQ->m_refIdx[0][partQ]);
+    const Frame* refP0 = sliceP->m_refFrameList[0][cuP->m_refIdx[0][partP]];
+    const Frame* refQ0 = sliceQ->m_refFrameList[0][cuQ->m_refIdx[0][partQ]];
     const MV& mvP0 = refP0 ? cuP->m_mv[0][partP] : zeroMv;
     const MV& mvQ0 = refQ0 ? cuQ->m_mv[0][partQ] : zeroMv;
 
@@ -221,8 +221,8 @@ uint8_t Deblock::getBoundaryStrength(con
     }
 
     // (sliceQ->isInterB() || sliceP->isInterB())
-    const Frame* refP1 = sliceP->getRefPic(1, cuP->m_refIdx[1][partP]);
-    const Frame* refQ1 = sliceQ->getRefPic(1, cuQ->m_refIdx[1][partQ]);
+    const Frame* refP1 = sliceP->m_refFrameList[1][cuP->m_refIdx[1][partP]];
+    const Frame* refQ1 = sliceQ->m_refFrameList[1][cuQ->m_refIdx[1][partQ]];
     const MV& mvP1 = refP1 ? cuP->m_mv[1][partP] : zeroMv;
     const MV& mvQ1 = refQ1 ? cuQ->m_mv[1][partQ] : zeroMv;
 
diff -r a68dff2b203c -r a7746c2cd531 source/common/frame.cpp
--- a/source/common/frame.cpp	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/frame.cpp	Fri Aug 14 10:48:59 2015 +0530
@@ -36,6 +36,7 @@ Frame::Frame()
     m_countRefEncoders = 0;
     m_encData = NULL;
     m_reconPic = NULL;
+    m_quantOffsets = NULL;
     m_next = NULL;
     m_prev = NULL;
     m_param = NULL;
@@ -56,7 +57,7 @@ bool Frame::allocEncodeData(x265_param *
     m_encData = new FrameData;
     m_reconPic = new PicYuv;
     m_encData->m_reconPic = m_reconPic;
-    bool ok = m_encData->create(param, sps) && m_reconPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp);
+    bool ok = m_encData->create(*param, sps) && m_reconPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp);
     if (ok)
     {
         /* initialize right border of m_reconpicYuv as SAO may read beyond the
@@ -65,6 +66,12 @@ bool Frame::allocEncodeData(x265_param *
         memset(m_reconPic->m_picOrg[0], 0, sizeof(pixel) * m_reconPic->m_stride * maxHeight);
         memset(m_reconPic->m_picOrg[1], 0, sizeof(pixel) * m_reconPic->m_strideC * (maxHeight >> m_reconPic->m_vChromaShift));
         memset(m_reconPic->m_picOrg[2], 0, sizeof(pixel) * m_reconPic->m_strideC * (maxHeight >> m_reconPic->m_vChromaShift));
+
+        /* use pre-calculated cu/pu offsets cached in the SPS structure */
+        m_reconPic->m_cuOffsetC = sps.cuOffsetC;
+        m_reconPic->m_cuOffsetY = sps.cuOffsetY;
+        m_reconPic->m_buOffsetC = sps.buOffsetC;
+        m_reconPic->m_buOffsetY = sps.buOffsetY;
     }
     return ok;
 }
@@ -100,5 +107,10 @@ void Frame::destroy()
         m_reconPic = NULL;
     }
 
+    if (m_quantOffsets)
+    {
+        delete[] m_quantOffsets;
+    }
+
     m_lowres.destroy();
 }
diff -r a68dff2b203c -r a7746c2cd531 source/common/frame.h
--- a/source/common/frame.h	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/frame.h	Fri Aug 14 10:48:59 2015 +0530
@@ -59,6 +59,8 @@ public:
     bool                   m_lowresInit;         // lowres init complete (pre-analysis)
     bool                   m_bChromaExtended;    // orig chroma planes motion extended for weight analysis
 
+    float*                 m_quantOffsets;       // points to quantOffsets in x265_picture
+
     /* Frame Parallelism - notification between FrameEncoders of available motion reference rows */
     ThreadSafeInteger      m_reconRowCount;      // count of CTU rows completely reconstructed and extended for motion reference
     volatile uint32_t      m_countRefEncoders;   // count of FrameEncoder threads monitoring m_reconRowCount
diff -r a68dff2b203c -r a7746c2cd531 source/common/framedata.cpp
--- a/source/common/framedata.cpp	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/framedata.cpp	Fri Aug 14 10:48:59 2015 +0530
@@ -31,15 +31,15 @@ FrameData::FrameData()
     memset(this, 0, sizeof(*this));
 }
 
-bool FrameData::create(x265_param *param, const SPS& sps)
+bool FrameData::create(const x265_param& param, const SPS& sps)
 {
-    m_param = param;
+    m_param = ¶m;
     m_slice  = new Slice;
     m_picCTU = new CUData[sps.numCUsInFrame];
 
-    m_cuMemPool.create(0, param->internalCsp, sps.numCUsInFrame);
+    m_cuMemPool.create(0, param.internalCsp, sps.numCUsInFrame);
     for (uint32_t ctuAddr = 0; ctuAddr < sps.numCUsInFrame; ctuAddr++)
-        m_picCTU[ctuAddr].initialize(m_cuMemPool, 0, param->internalCsp, ctuAddr);
+        m_picCTU[ctuAddr].initialize(m_cuMemPool, 0, param.internalCsp, ctuAddr);
 
     CHECKED_MALLOC(m_cuStat, RCStatCU, sps.numCUsInFrame);
     CHECKED_MALLOC(m_rowStat, RCStatRow, sps.numCuInHeight);
diff -r a68dff2b203c -r a7746c2cd531 source/common/framedata.h
--- a/source/common/framedata.h	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/framedata.h	Fri Aug 14 10:48:59 2015 +0530
@@ -96,7 +96,7 @@ public:
 
     Slice*         m_slice;
     SAOParam*      m_saoParam;
-    x265_param*    m_param;
+    const x265_param* m_param;
 
     FrameData*     m_freeListNext;
     PicYuv*        m_reconPic;
@@ -142,11 +142,11 @@ public:
 
     FrameData();
 
-    bool create(x265_param *param, const SPS& sps);
+    bool create(const x265_param& param, const SPS& sps);
     void reinit(const SPS& sps);
     void destroy();
 
-    CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }
+    inline CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }
 };
 }
 
diff -r a68dff2b203c -r a7746c2cd531 source/common/param.cpp
--- a/source/common/param.cpp	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/param.cpp	Fri Aug 14 10:48:59 2015 +0530
@@ -241,6 +241,8 @@ void x265_param_default(x265_param* para
     param->vui.defDispWinRightOffset = 0;
     param->vui.defDispWinTopOffset = 0;
     param->vui.defDispWinBottomOffset = 0;
+    param->minLuma = 0;
+    param->maxLuma = (1 << X265_DEPTH) - 1;
 }
 
 int x265_param_default_preset(x265_param* param, const char* preset, const char* tune)
@@ -855,6 +857,8 @@ int x265_param_parse(x265_param* p, cons
     OPT("qg-size") p->rc.qgSize = atoi(value);
     OPT("master-display") p->masteringDisplayColorVolume = strdup(value);
     OPT("max-cll") p->contentLightLevelInfo = strdup(value);
+    OPT("min-luma") p->minLuma = (uint16_t)atoi(value);
+    OPT("max-luma") p->maxLuma = (uint16_t)atoi(value);
     else
         return X265_PARAM_BAD_NAME;
 #undef OPT
diff -r a68dff2b203c -r a7746c2cd531 source/common/picyuv.cpp
--- a/source/common/picyuv.cpp	Tue Aug 11 14:30:27 2015 +0530
+++ b/source/common/picyuv.cpp	Fri Aug 14 10:48:59 2015 +0530
@@ -121,7 +121,7 @@ void PicYuv::destroy()
 
 /* Copy pixels from an x265_picture into internal PicYuv instance.
  * Shift pixels as necessary, mask off bits above X265_DEPTH for safety. */
-void PicYuv::copyFromPicture(const x265_picture& pic, int padx, int pady)
+void PicYuv::copyFromPicture(const x265_picture& pic, const x265_param& param, int padx, int pady)
 {
     /* m_picWidth is the width that is being encoded, padx indicates how many
      * of those pixels are padding to reach multiple of MinCU(4) size.
@@ -237,6 +237,10 @@ void PicYuv::copyFromPicture(const x265_
 
         for (int r = 0; r < height; r++)
         {
+            /* Clip luma of source picture to max and min values before extending edges of picYuv */
+            for (int c = 0; c < m_stride; c++)
+                Y[c] = x265_clip3((pixel)param.minLuma, (pixel)param.maxLuma, Y[c]);
+
             for (int x = 0; x < padx; x++)
                 Y[width + x] = Y[width - 1];
 


More information about the x265-commits mailing list