[x265-commits] [x265] rdcost: explicit cast of return value, to prevent MSVC wa...

Steve Borho steve at borho.org
Sat May 3 22:09:05 CEST 2014


details:   http://hg.videolan.org/x265/rev/04e91f38854f
branches:  stable
changeset: 6804:04e91f38854f
user:      Steve Borho <steve at borho.org>
date:      Sat May 03 15:07:48 2014 -0500
description:
rdcost: explicit cast of return value, to prevent MSVC warnings
Subject: [x265] use fseekg() to skip frames for 64bit builds

details:   http://hg.videolan.org/x265/rev/61ad93af167c
branches:  
changeset: 6805:61ad93af167c
user:      Steve Borho <steve at borho.org>
date:      Thu May 01 15:58:19 2014 -0500
description:
use fseekg() to skip frames for 64bit builds

This is orders of magnitude faster, at least on Windows, than repeated calls to
ignore(framesize)
Subject: [x265] cmake: add a clean-generated Makefile rule

details:   http://hg.videolan.org/x265/rev/d72770a77ff8
branches:  
changeset: 6806:d72770a77ff8
user:      Steve Borho <steve at borho.org>
date:      Thu May 01 17:41:42 2014 -0500
description:
cmake: add a clean-generated Makefile rule

'make clean-generated' will remove all the machine generated files in the build
folder so that they will be re-generated with more up-to-date version info the
next time you run 'make'

The "easy" workaround for this problem is to just nuke the build folder and
start a new one.
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/dcf74ea39e31
branches:  
changeset: 6807:dcf74ea39e31
user:      Steve Borho <steve at borho.org>
date:      Sat May 03 15:08:24 2014 -0500
description:
Merge with stable

diffstat:

 source/CMakeLists.txt              |   4 +
 source/Lib/TLibCommon/TComRdCost.h |   4 +-
 source/cmake/clean-generated.cmake |  10 ++++
 source/encoder/slicetype.cpp       |  84 ++++++++++---------------------------
 source/input/y4m.cpp               |   4 +
 source/input/yuv.cpp               |   4 +
 6 files changed, 48 insertions(+), 62 deletions(-)

diffs (219 lines):

diff -r d3d47e3ef9c2 -r dcf74ea39e31 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Fri May 02 14:19:10 2014 -0500
+++ b/source/CMakeLists.txt	Sat May 03 15:08:24 2014 -0500
@@ -250,6 +250,10 @@ if(CMAKE_RC_COMPILER)
     configure_file("${CMAKE_CURRENT_SOURCE_DIR}/x265.rc.in" "${X265_RC_FILE}" @ONLY)
 endif()
 
+if(NOT (MSVC_IDE OR XCODE))
+    add_custom_target(clean-generated COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/clean-generated.cmake)
+endif()
+
 option(ENABLE_SHARED "Build shared library" ON)
 if(ENABLE_SHARED)
     add_library(x265-shared SHARED "${PROJECT_BINARY_DIR}/x265.def" ${YASM_OBJS}
diff -r d3d47e3ef9c2 -r dcf74ea39e31 source/Lib/TLibCommon/TComRdCost.h
--- a/source/Lib/TLibCommon/TComRdCost.h	Fri May 02 14:19:10 2014 -0500
+++ b/source/Lib/TLibCommon/TComRdCost.h	Sat May 03 15:08:24 2014 -0500
@@ -86,9 +86,9 @@ public:
 
     inline uint32_t getCost(uint32_t bits)                     { return (uint32_t)((bits * m_lambdaMotionSAD + 128) >> 8); }
 
-    inline uint32_t scaleChromaDistCb(uint32_t dist)           { return ((dist * m_cbDistortionWeight) + 128) >> 8; }
+    inline uint32_t scaleChromaDistCb(uint32_t dist)           { return (uint32_t)(((dist * m_cbDistortionWeight) + 128) >> 8); }
 
-    inline uint32_t scaleChromaDistCr(uint32_t dist)           { return ((dist * m_crDistortionWeight) + 128) >> 8; }
+    inline uint32_t scaleChromaDistCr(uint32_t dist)           { return (uint32_t)(((dist * m_crDistortionWeight) + 128) >> 8); }
 };
 }
 //! \}
diff -r d3d47e3ef9c2 -r dcf74ea39e31 source/cmake/clean-generated.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/cmake/clean-generated.cmake	Sat May 03 15:08:24 2014 -0500
@@ -0,0 +1,10 @@
+set(generated "${CMAKE_CURRENT_BINARY_DIR}/x265.rc"
+              "${CMAKE_CURRENT_BINARY_DIR}/x265.pc"
+              "${CMAKE_CURRENT_BINARY_DIR}/x265.def"
+              "${CMAKE_CURRENT_BINARY_DIR}/x265_config.h")
+
+foreach(file ${generated})
+  if(EXISTS ${file})
+     file(REMOVE ${file})
+  endif()
+endforeach(file)
diff -r d3d47e3ef9c2 -r dcf74ea39e31 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Fri May 02 14:19:10 2014 -0500
+++ b/source/encoder/slicetype.cpp	Sat May 03 15:08:24 2014 -0500
@@ -208,7 +208,7 @@ int64_t Lookahead::getEstimatedPictureCo
     Lowres *frames[X265_LOOKAHEAD_MAX];
 
     // POC distances to each reference
-    int d0, d1, p0, p1, b;
+    int p0 = 0, p1, b;
     int poc = pic->getSlice()->getPOC();
     int l0poc = pic->getSlice()->getRefPOC(REF_PIC_LIST_0, 0);
     int l1poc = pic->getSlice()->getRefPOC(REF_PIC_LIST_1, 0);
@@ -216,58 +216,34 @@ int64_t Lookahead::getEstimatedPictureCo
     switch (pic->getSlice()->getSliceType())
     {
     case I_SLICE:
-        frames[0] = &pic->m_lowres;
-        p0 = p1 = b = 0;
+        frames[p0] = &pic->m_lowres;
+        b = p1 = 0;
         break;
 
     case P_SLICE:
-        d0 = poc - l0poc;
-        frames[0] = &pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->m_lowres;
-        frames[d0] = &pic->m_lowres;
-        p0 = 0;
-        p1 = d0;
-        b = d0;
+        b = p1 = poc - l0poc;
+        frames[p0] = &pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->m_lowres;
+        frames[b] = &pic->m_lowres;
         break;
 
     case B_SLICE:
-        d0 = poc - l0poc;
-        if (l1poc > poc)
-        {
-            // L1 reference is truly in the future
-            d1 = l1poc - poc;
-            frames[0] = &pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->m_lowres;
-            frames[d0] = &pic->m_lowres;
-            frames[d0 + d1] = &pic->getSlice()->getRefPic(REF_PIC_LIST_1, 0)->m_lowres;
-            p0 = 0;
-            p1 = d0 + d1;
-            b = d0;
-        }
-        else
-        {
-            frames[0] = &pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->m_lowres;
-            frames[d0] = &pic->m_lowres;
-            p0 = 0;
-            p1 = d0;
-            b = d0;
-        }
+        b = poc - l0poc;
+        p1 = b + l1poc - poc;
+        frames[p0] = &pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->m_lowres;
+        frames[b] = &pic->m_lowres;
+        frames[p1] = &pic->getSlice()->getRefPic(REF_PIC_LIST_1, 0)->m_lowres;
         break;
 
     default:
         return 0;
     }
 
-    if (pic->m_lowres.costEst[b - p0][p1 - b] < 0)
-    {
-        CostEstimate cost(ThreadPool::getThreadPool());
-        cost.init(param, pic);
-        cost.estimateFrameCost(frames, p0, p1, b, false);
-        cost.flush();
-    }
     if (param->rc.cuTree)
     {
-        /* update row satds */
+        /* update row satds based on cutree offsets */
         pic->m_lowres.satdCost = frameCostRecalculate(frames, p0, p1, b);
-        /* update intra row satds */
+
+        /* update intra row satds on P or B frames */
         if (b && param->rc.vbvBufferSize)
             frameCostRecalculate(frames, b, b, b);
     }
@@ -278,6 +254,7 @@ int64_t Lookahead::getEstimatedPictureCo
 
     if (param->rc.vbvBufferSize && param->rc.vbvMaxBitrate)
     {
+        /* aggregate lowres row satds to CTU resolution */
         pic->m_lowres.lowresCostForRc = pic->m_lowres.lowresCosts[b - p0][p1 - b];
         uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;
         uint32_t scale = param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);
@@ -438,38 +415,25 @@ void Lookahead::slicetypeDecide()
     if (param->rc.rateControlMode != X265_RC_CQP)
     {
         int p0, p1, b;
+
+        /* estimate new non-B cost */
         p1 = b = bframes + 1;
-
-        for (int i = 0; i <= bframes; i++)
-        {
-            frames[i + 1] = &list[i]->m_lowres;
-        }
-
-        if (IS_X265_TYPE_I(frames[bframes + 1]->sliceType))
-            p0 = bframes + 1;
-        else // P
-            p0 = 0;
-
+        p0 = (IS_X265_TYPE_I(frames[bframes + 1]->sliceType)) ? b : 0;
         est.estimateFrameCost(frames, p0, p1, b, 0);
 
-        if ((p0 != p1 || bframes) && param->rc.vbvBufferSize)
+        if (bframes)
         {
-            // We need the intra costs for row SATDs
-            est.estimateFrameCost(frames, b, b, b, 0);
-
-            // We need B-frame costs for row SATDs
-            p0 = 0;
+            p0 = 0; // last nonb
             for (b = 1; b <= bframes; b++)
             {
                 if (frames[b]->sliceType == X265_TYPE_B)
-                    for (p1 = b; frames[p1]->sliceType == X265_TYPE_B; )
-                    {
-                        p1++;
-                    }
-
+                    for (p1 = b; frames[p1]->sliceType == X265_TYPE_B; p1++)
+                        ; // find new nonb or bref
                 else
                     p1 = bframes + 1;
+
                 est.estimateFrameCost(frames, p0, p1, b, 0);
+
                 if (frames[b]->sliceType == X265_TYPE_BREF)
                     p0 = b;
             }
diff -r d3d47e3ef9c2 -r dcf74ea39e31 source/input/y4m.cpp
--- a/source/input/y4m.cpp	Fri May 02 14:19:10 2014 -0500
+++ b/source/input/y4m.cpp	Sat May 03 15:08:24 2014 -0500
@@ -137,10 +137,14 @@ Y4MInput::Y4MInput(InputFileInfo& info)
 
     if (info.skipFrames)
     {
+#if X86_64
+        ifs->seekg((uint64_t)frameSize * info.skipFrames, ios::cur);
+#else
         for (int i = 0; i < info.skipFrames; i++)
         {
             ifs->ignore(frameSize);
         }
+#endif
     }
 }
 
diff -r d3d47e3ef9c2 -r dcf74ea39e31 source/input/yuv.cpp
--- a/source/input/yuv.cpp	Fri May 02 14:19:10 2014 -0500
+++ b/source/input/yuv.cpp	Sat May 03 15:08:24 2014 -0500
@@ -136,10 +136,14 @@ YUVInput::YUVInput(InputFileInfo& info)
 
     if (info.skipFrames)
     {
+#if X86_64
+        ifs->seekg((uint64_t)framesize * info.skipFrames, ios::cur);
+#else
         for (int i = 0; i < info.skipFrames; i++)
         {
             ifs->ignore(framesize);
         }
+#endif
     }
 }
 


More information about the x265-commits mailing list