[x265-commits] [x265] cmake: add ENABLE_SHARED cmake option, default to ON

Steve Borho steve at borho.org
Fri Dec 6 06:40:21 CET 2013


details:   http://hg.videolan.org/x265/rev/3e6be1e11720
branches:  
changeset: 5552:3e6be1e11720
user:      Steve Borho <steve at borho.org>
date:      Thu Dec 05 22:37:33 2013 -0600
description:
cmake: add ENABLE_SHARED cmake option, default to ON

Allow MSVC users to opt-out; to roughly halve the compile time.  Clean up a few
nits in the process.
Subject: [x265] cmake: drop pool test; not seriously used since May

details:   http://hg.videolan.org/x265/rev/d5dc48e6cd16
branches:  
changeset: 5553:d5dc48e6cd16
user:      Steve Borho <steve at borho.org>
date:      Thu Dec 05 22:46:25 2013 -0600
description:
cmake: drop pool test; not seriously used since May

diffstat:

 source/CMakeLists.txt      |   74 ++++++------
 source/test/CMakeLists.txt |    3 -
 source/test/testpool.cpp   |  241 ---------------------------------------------
 3 files changed, 37 insertions(+), 281 deletions(-)

diffs (truncated from 363 to 300 lines):

diff -r 97e917c4a923 -r d5dc48e6cd16 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Dec 05 20:13:39 2013 -0600
+++ b/source/CMakeLists.txt	Thu Dec 05 22:46:25 2013 -0600
@@ -189,43 +189,43 @@ if((MSVC_IDE OR XCODE) AND ENABLE_ASSEMB
 endif()
 
 add_library(x265-static STATIC $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
-add_library(x265-shared SHARED dllmain.cpp "${PROJECT_BINARY_DIR}/x265.def" ${YASM_OBJS}
-                               $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common>)
-target_link_libraries(x265-shared ${PLATFORM_LIBS})
-set_target_properties(x265-shared PROPERTIES OUTPUT_NAME x265)
 if(NOT MSVC)
     set_target_properties(x265-static PROPERTIES OUTPUT_NAME x265)
 endif()
-if(UNIX AND NOT APPLE)
-    set_target_properties(x265-shared PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
-endif()
-# WIN32 builds static: x265-static.lib  shared: x265.dll + x265.lib (shim loader)
-# MINGW builds static: libx265-static.a shared: libx265.dll + libx265.dll.a
-# *NIX  builds static: libx265.a        shared: libx265.so
-
-if(X265_LATEST_TAG)
-    # shared library is not installed if a tag is not found
-    set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG} SOVERSION ${X265_BUILD})
-    install(TARGETS x265-shared
-            RUNTIME DESTINATION bin
-            LIBRARY DESTINATION lib
-            ARCHIVE DESTINATION lib)
-
-    # convert lists of link libraries into -lstdc++ -lm etc..
-    foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS})
-        set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
-    endforeach()
-    # Produce a pkg-config file for linking against the shared lib
-    configure_file("x265.pc.in" "x265.pc" @ONLY)
-    install(FILES       "${CMAKE_CURRENT_BINARY_DIR}/x265.pc"
-            DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
-endif()
 install(TARGETS x265-static
         RUNTIME DESTINATION bin
         LIBRARY DESTINATION lib
         ARCHIVE DESTINATION lib)
 install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include)
 
+option(ENABLE_SHARED "Build shared library" ON)
+if(ENABLE_SHARED)
+    add_library(x265-shared SHARED dllmain.cpp "${PROJECT_BINARY_DIR}/x265.def" ${YASM_OBJS}
+                                   $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common>)
+    target_link_libraries(x265-shared ${PLATFORM_LIBS})
+    set_target_properties(x265-shared PROPERTIES OUTPUT_NAME x265)
+    if(UNIX AND NOT APPLE)
+        set_target_properties(x265-shared PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
+    endif()
+    if(X265_LATEST_TAG)
+        # shared library is not installed if a tag is not found
+        set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG} SOVERSION ${X265_BUILD})
+        install(TARGETS x265-shared
+                RUNTIME DESTINATION bin
+                LIBRARY DESTINATION lib
+                ARCHIVE DESTINATION lib)
+
+        # convert lists of link libraries into -lstdc++ -lm etc..
+        foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS})
+            set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
+        endforeach()
+        # Produce a pkg-config file for linking against the shared lib
+        configure_file("x265.pc.in" "x265.pc" @ONLY)
+        install(FILES       "${CMAKE_CURRENT_BINARY_DIR}/x265.pc"
+                DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
+    endif()
+endif()
+
 if(NOT WIN32)
     configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
                    "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
@@ -251,13 +251,13 @@ if(ENABLE_CLI)
         set(GETOPT compat/getopt/getopt.c compat/getopt/getopt.h)
     endif(NOT HAVE_GETOPT_H)
 
-if(XCODE)
-    add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${GETOPT} x265.cpp x265.h
-                       $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
-else()
-    add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${GETOPT} x265.cpp x265.h)
-    target_link_libraries(cli x265-static ${PLATFORM_LIBS})
-endif()
+    if(XCODE)
+        add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${GETOPT} x265.cpp x265.h
+                           $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
+    else()
+        add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${GETOPT} x265.cpp x265.h)
+        target_link_libraries(cli x265-static ${PLATFORM_LIBS})
+    endif()
     set_target_properties(cli PROPERTIES OUTPUT_NAME x265)
 
     install(TARGETS cli DESTINATION bin)
@@ -265,9 +265,9 @@ endif(ENABLE_CLI)
 
 # Test applications
 option(ENABLE_TESTS "Enable Unit Tests" OFF)
-if(ENABLE_TESTS)
+if(ENABLE_TESTS AND NOT XCODE)
     if(ENABLE_ASSEMBLY)
         add_definitions(-DENABLE_ASSEMBLY=1)
     endif(ENABLE_ASSEMBLY)
     add_subdirectory(test)
-endif(ENABLE_TESTS)
+endif()
diff -r 97e917c4a923 -r d5dc48e6cd16 source/test/CMakeLists.txt
--- a/source/test/CMakeLists.txt	Thu Dec 05 20:13:39 2013 -0600
+++ b/source/test/CMakeLists.txt	Thu Dec 05 22:46:25 2013 -0600
@@ -5,6 +5,3 @@ add_executable(TestBench
     ipfilterharness.cpp ipfilterharness.h
     intrapredharness.cpp intrapredharness.h)
 target_link_libraries(TestBench x265-static ${PLATFORM_LIBS})
-
-add_executable(PoolTest testpool.cpp)
-target_link_libraries(PoolTest x265-static ${PLATFORM_LIBS})
diff -r 97e917c4a923 -r d5dc48e6cd16 source/test/testpool.cpp
--- a/source/test/testpool.cpp	Thu Dec 05 20:13:39 2013 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,241 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve at borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing at multicorewareinc.com
- *****************************************************************************/
-
-#include "threadpool.h"
-#include "wavefront.h"
-#include "threading.h"
-#include "md5.h"
-#include "PPA/ppa.h"
-
-#include <time.h>
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <sstream>
-#include <iostream>
-
-using namespace x265;
-
-struct CUData
-{
-    CUData()
-    {
-        memset(digest, 0, sizeof(digest));
-    }
-
-    unsigned char digest[16];
-};
-
-struct RowData
-{
-    RowData() : active(false), curCol(0) {}
-
-    Lock          lock;
-    volatile bool active;
-    volatile int  curCol;
-};
-
-// Create a fake frame class with manufactured data in each CU block.  We
-// need to create an MD5 hash such that each CU's hash includes the hashes
-// of the blocks that would have HEVC data dependencies (left, top-left,
-// top, top-right).  This will give us one deterministic output hash.  We
-// then generate the same hash using the thread pool and wave-front parallelism
-// to verify the thread-pool behavior and the wave-front schedule data
-// structures.
-class MD5Frame : public WaveFront
-{
-private:
-
-    CUData  *cu;
-    RowData *row;
-    int      numrows;
-    int      numcols;
-    Event    complete;
-
-public:
-
-    MD5Frame(ThreadPool *pool) : WaveFront(pool), cu(0), row(0) {}
-
-    virtual ~MD5Frame()
-    {
-        // ensure no threads are lingering on FindJob() before allowing
-        // this object's vtable to be destroyed
-        JobProvider::flush();
-
-        delete[] this->cu;
-        delete[] this->row;
-    }
-
-    void initialize(int cols, int rows);
-
-    void encode();
-
-    void processRow(int row);
-};
-
-void MD5Frame::initialize(int cols, int rows)
-{
-    this->cu = new CUData[rows * cols];
-    this->row = new RowData[rows];
-    this->numrows = rows;
-    this->numcols = cols;
-
-    if (!this->WaveFront::init(rows))
-    {
-        assert(!"Unable to initialize job queue");
-    }
-}
-
-void MD5Frame::encode()
-{
-    this->JobProvider::enqueue();
-
-    this->WaveFront::enqueueRow(0);
-
-    // NOTE: When EnableRow after enqueueRow at first row, we'd better call pokeIdleThread, it will release a thread to do job
-    this->WaveFront::enableRow(0);
-    this->m_pool->pokeIdleThread();
-
-    this->complete.wait();
-
-    this->JobProvider::dequeue();
-
-    unsigned int *outdigest = (unsigned int*)this->cu[this->numrows * this->numcols - 1].digest;
-
-    std::stringstream ss;
-
-    for (int i = 0; i < 4; i++)
-    {
-        ss << std::hex << outdigest[i];
-    }
-
-    if (ss.str().compare("da667b741a7a9d0ee862158da2dd1882"))
-        std::cout << "Bad hash: " << ss.str() << std::endl;
-}
-
-void MD5Frame::processRow(int rownum)
-{
-    // Called by worker thread
-    RowData &curRow = this->row[rownum];
-
-    assert(rownum < this->numrows && rownum >= 0);
-    assert(curRow.curCol < this->numcols);
-
-    while (curRow.curCol < this->numcols)
-    {
-        int id = rownum * this->numcols + curRow.curCol;
-        CUData  &curCTU = this->cu[id];
-        MD5 hash;
-
-        // * Fake CTU processing *
-        PPAStartCpuEventFunc(encode_block);
-        memset(curCTU.digest, id, sizeof(curCTU.digest));
-        hash.update(curCTU.digest, sizeof(curCTU.digest));
-        if (curRow.curCol > 0)
-            hash.update(this->cu[id - 1].digest, sizeof(curCTU.digest));
-
-        if (rownum > 0)
-        {
-            if (curRow.curCol > 0)
-                hash.update(this->cu[id - this->numcols - 1].digest, sizeof(curCTU.digest));
-
-            hash.update(this->cu[id - this->numcols].digest, sizeof(curCTU.digest));
-            if (curRow.curCol < this->numcols - 1)
-                hash.update(this->cu[id - this->numcols + 1].digest, sizeof(curCTU.digest));
-        }
-
-        hash.finalize(curCTU.digest);
-        PPAStopCpuEventFunc(encode_block);
-
-        curRow.curCol++;
-
-        if (curRow.curCol >= 2 && rownum < this->numrows - 1)
-        {
-            ScopedLock below(this->row[rownum + 1].lock);
-
-            if (this->row[rownum + 1].active == false &&
-                this->row[rownum + 1].curCol + 2 <= curRow.curCol)
-            {


More information about the x265-commits mailing list