[x265-commits] [x265] param: enforce a minimum picture size

Steve Borho steve at borho.org
Fri Apr 4 19:37:20 CEST 2014


details:   http://hg.videolan.org/x265/rev/343414c96b01
branches:  
changeset: 6663:343414c96b01
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 17:04:15 2014 -0500
description:
param: enforce a minimum picture size

Do not allow the user to configure a picture smaller than at least one CTU
Subject: [x265] param: nit reorder of RC mode checks to avoid uncrustify problems

details:   http://hg.videolan.org/x265/rev/2e376af3a467
branches:  
changeset: 6664:2e376af3a467
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 17:06:37 2014 -0500
description:
param: nit reorder of RC mode checks to avoid uncrustify problems

uncrustify was seeing FOO(bar < x || bar > y) and assuming this was a template
instantiation and changing it to FOO(bar<x || bar> y).  Reordering the two
comparisons avoids this problem
Subject: [x265] rest: nit

details:   http://hg.videolan.org/x265/rev/d73898ae3e47
branches:  
changeset: 6665:d73898ae3e47
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 20:32:13 2014 -0500
description:
rest: nit
Subject: [x265] TEncEntropy: nit

details:   http://hg.videolan.org/x265/rev/1d2ab46f13d2
branches:  
changeset: 6666:1d2ab46f13d2
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 20:32:24 2014 -0500
description:
TEncEntropy: nit
Subject: [x265] cli: add missing --no-dither option to getopt list

details:   http://hg.videolan.org/x265/rev/8273932bc5b7
branches:  
changeset: 6667:8273932bc5b7
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 20:32:49 2014 -0500
description:
cli: add missing --no-dither option to getopt list
Subject: [x265] api: add support for access unit delimiters (--aud)

details:   http://hg.videolan.org/x265/rev/6327400944ee
branches:  
changeset: 6668:6327400944ee
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 19:46:21 2014 -0500
description:
api: add support for access unit delimiters (--aud)
Subject: [x265] testbench: prevent 0 height in plane copy tests

details:   http://hg.videolan.org/x265/rev/ac9e57296fa8
branches:  
changeset: 6669:ac9e57296fa8
user:      Steve Borho <steve at borho.org>
date:      Thu Apr 03 21:14:24 2014 -0500
description:
testbench: prevent 0 height in plane copy tests

The ASM functions handle the last row specially and cannot handle height of 0,
it causes testbench crashes when rand() rolls the wrong dice.

diffstat:

 doc/reST/cli.rst                       |  13 ++++++++++++-
 source/CMakeLists.txt                  |   2 +-
 source/Lib/TLibEncoder/TEncEntropy.cpp |   5 +++++
 source/Lib/TLibEncoder/TEncEntropy.h   |   4 +++-
 source/Lib/TLibEncoder/TEncSbac.cpp    |  22 ++++++++++++++++++++++
 source/Lib/TLibEncoder/TEncSbac.h      |   1 +
 source/common/param.cpp                |   7 +++++--
 source/encoder/frameencoder.cpp        |  23 ++++++++++++++++++++---
 source/test/pixelharness.cpp           |   4 ++--
 source/x265.cpp                        |   5 +++++
 source/x265.h                          |   4 ++++
 11 files changed, 80 insertions(+), 10 deletions(-)

diffs (242 lines):

diff -r 8c946aca5824 -r ac9e57296fa8 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Thu Apr 03 14:49:57 2014 -0500
+++ b/doc/reST/cli.rst	Thu Apr 03 21:14:24 2014 -0500
@@ -746,8 +746,19 @@ implicitly enabled.
 	info reported in the PPS header but is sometimes required.  Default
 	disabled
 
+Bitstream options
+=================
+
+.. option:: --aud, --no-aud
+
+	Emit an access unit delimiter NAL at the start of each slice access
+	unit. If option:`--repeat-headers` is not enabled (indicating the
+	user will be writing headers manually at the start of the stream)
+	the very first AUD will be skipped since it cannot be placed at the
+	start of the access unit, where it belongs. Default disabled
+
 Debugging options
-=======================================
+=================
 
 .. option:: --hash <integer>
 
diff -r 8c946aca5824 -r ac9e57296fa8 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/CMakeLists.txt	Thu Apr 03 21:14:24 2014 -0500
@@ -19,7 +19,7 @@ include(CheckSymbolExists)
 include(CheckCXXCompilerFlag)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 13)
+set(X265_BUILD 14)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 8c946aca5824 -r ac9e57296fa8 source/Lib/TLibEncoder/TEncEntropy.cpp
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp	Thu Apr 03 21:14:24 2014 -0500
@@ -89,6 +89,11 @@ void TEncEntropy::encodeSPS(TComSPS* sps
     m_entropyCoderIf->codeSPS(sps);
 }
 
+void TEncEntropy::encodeAUD(TComSlice* slice)
+{
+    m_entropyCoderIf->codeAUD(slice);
+}
+
 void TEncEntropy::encodeCUTransquantBypassFlag(TComDataCU* cu, uint32_t absPartIdx, bool bRD)
 {
     if (bRD)
diff -r 8c946aca5824 -r ac9e57296fa8 source/Lib/TLibEncoder/TEncEntropy.h
--- a/source/Lib/TLibEncoder/TEncEntropy.h	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.h	Thu Apr 03 21:14:24 2014 -0500
@@ -71,6 +71,7 @@ public:
     virtual void codeVPS(TComVPS* vps) = 0;
     virtual void codeSPS(TComSPS* sps) = 0;
     virtual void codePPS(TComPPS* pps) = 0;
+    virtual void codeAUD(TComSlice* slice) = 0;
     virtual void codeSliceHeader(TComSlice* slice) = 0;
 
     virtual void codeTilesWPPEntryPoint(TComSlice* slice) = 0;
@@ -131,7 +132,7 @@ public:
 
     void    resetBits() { m_entropyCoderIf->resetBits();      }
 
-    uint32_t    getNumberOfWrittenBits() { return m_entropyCoderIf->getNumberOfWrittenBits(); }
+    uint32_t getNumberOfWrittenBits() { return m_entropyCoderIf->getNumberOfWrittenBits(); }
 
     void    resetEntropy() { m_entropyCoderIf->resetEntropy();  }
 
@@ -149,6 +150,7 @@ public:
     // SPS
     void encodeSPS(TComSPS* sps);
     void encodePPS(TComPPS* pps);
+    void encodeAUD(TComSlice* pps);
     void encodeSplitFlag(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool bRD = false);
     void encodeCUTransquantBypassFlag(TComDataCU* cu, uint32_t absPartIdx, bool bRD = false);
     void encodeSkipFlag(TComDataCU* cu, uint32_t absPartIdx, bool bRD = false);
diff -r 8c946aca5824 -r ac9e57296fa8 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Thu Apr 03 21:14:24 2014 -0500
@@ -649,6 +649,28 @@ void TEncSbac::codeVUI(TComVUI *vui, TCo
     }
 }
 
+void TEncSbac::codeAUD(TComSlice* slice)
+{
+    int picType;
+
+    switch (slice->getSliceType())
+    {
+    case I_SLICE:
+        picType = 0;
+        break;
+    case P_SLICE:
+        picType = 1;
+        break;
+    case B_SLICE:
+        picType = 2;
+        break;
+    default:
+        picType = 7;
+        break;
+    }
+    WRITE_CODE(picType, 3, "pic_type");
+}
+
 void TEncSbac::codeHrdParameters(TComHRD *hrd, bool commonInfPresentFlag, uint32_t maxNumSubLayersMinus1)
 {
     if (commonInfPresentFlag)
diff -r 8c946aca5824 -r ac9e57296fa8 source/Lib/TLibEncoder/TEncSbac.h
--- a/source/Lib/TLibEncoder/TEncSbac.h	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSbac.h	Thu Apr 03 21:14:24 2014 -0500
@@ -88,6 +88,7 @@ public:
     void codeSPS(TComSPS* sps);
     void codePPS(TComPPS* pps);
     void codeVUI(TComVUI* vui, TComSPS* sps);
+    void codeAUD(TComSlice *slice);
     void codeSliceHeader(TComSlice* slice);
     void codePTL(TComPTL* ptl, bool profilePresentFlag, int maxNumSubLayersMinus1);
     void codeProfileTier(ProfileTierLevel* ptl);
diff -r 8c946aca5824 -r ac9e57296fa8 source/common/param.cpp
--- a/source/common/param.cpp	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/common/param.cpp	Thu Apr 03 21:14:24 2014 -0500
@@ -595,6 +595,7 @@ int x265_param_parse(x265_param *p, cons
     OPT("ssim") p->bEnableSsim = atobool(value);
     OPT("psnr") p->bEnablePsnr = atobool(value);
     OPT("hash") p->decodedPictureHashSEI = atoi(value);
+    OPT("aud") p->bEnableAccessUnitDelimiters = atobool(value);
     OPT("b-pyramid") p->bBPyramid = atobool(value);
     OPT("aq-mode") p->rc.aqMode = atoi(value);
     OPT("aq-strength") p->rc.aqStrength = atof(value);
@@ -916,12 +917,14 @@ int x265_check_params(x265_param *param)
     CHECK(param->maxNumReferences < 1, "maxNumReferences must be 1 or greater.");
     CHECK(param->maxNumReferences > MAX_NUM_REF, "maxNumReferences must be 16 or smaller.");
 
-    CHECK(param->sourceWidth  % TComSPS::getWinUnitX(param->internalCsp) != 0,
+    CHECK(param->sourceWidth < (int)param->maxCUSize || param->sourceWidth < (int)param->maxCUSize,
+          "Picture size must be at least one CTU");
+    CHECK(param->sourceWidth % TComSPS::getWinUnitX(param->internalCsp) != 0,
           "Picture width must be an integer multiple of the specified chroma subsampling");
     CHECK(param->sourceHeight % TComSPS::getWinUnitY(param->internalCsp) != 0,
           "Picture height must be an integer multiple of the specified chroma subsampling");
 
-    CHECK(param->rc.rateControlMode<X265_RC_ABR || param->rc.rateControlMode> X265_RC_CRF,
+    CHECK(param->rc.rateControlMode > X265_RC_CRF || param->rc.rateControlMode < X265_RC_ABR,
           "Rate control mode is out of range");
     CHECK(param->rdLevel < 0 || param->rdLevel > 6,
           "RD Level is out of range");
diff -r 8c946aca5824 -r ac9e57296fa8 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Thu Apr 03 21:14:24 2014 -0500
@@ -369,10 +369,27 @@ void FrameEncoder::compressFrame()
     TComSlice*   slice             = m_pic->getSlice();
     int          chFmt             = slice->getSPS()->getChromaFormatIdc();
 
+    m_nalCount = 0;
+    entropyCoder->setEntropyCoder(&m_sbacCoder, NULL);
+
+    /* Emit access unit delimiter unless this is the first frame and the user is
+     * not repeating headers (since AUD is supposed to be the first NAL in the access
+     * unit) */
+    if (m_cfg->param->bEnableAccessUnitDelimiters && (m_pic->getPOC() || m_cfg->param->bRepeatHeaders))
+    {
+        OutputNALUnit nalu(NAL_UNIT_ACCESS_UNIT_DELIMITER);
+        entropyCoder->setBitstream(&nalu.m_bitstream);
+        entropyCoder->encodeAUD(slice);
+        writeRBSPTrailingBits(nalu.m_bitstream);
+        m_nalList[m_nalCount] = X265_MALLOC(NALUnitEBSP, 1);
+        if (m_nalList[m_nalCount])
+        {
+            m_nalList[m_nalCount]->init(nalu);
+            m_nalCount++;
+        }
+    }
     if (m_cfg->param->bRepeatHeaders && m_pic->m_lowres.bKeyframe)
-        m_nalCount = getStreamHeaders(m_nalList);
-    else
-        m_nalCount = 0;
+        m_nalCount += getStreamHeaders(m_nalList + m_nalCount);
 
     int qp = slice->getSliceQp();
     double lambda = 0;
diff -r 8c946aca5824 -r ac9e57296fa8 source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/test/pixelharness.cpp	Thu Apr 03 21:14:24 2014 -0500
@@ -939,7 +939,7 @@ bool PixelHarness::check_planecopy_sp(pl
 
     int srcStride = 64;
     int width = rand() % 64;
-    int height = rand() % 64;
+    int height = 1 + rand() % 63;
     int dstStride = width;
     int j = 0;
 
@@ -968,7 +968,7 @@ bool PixelHarness::check_planecopy_cp(pl
 
     int srcStride = 64;
     int width = rand() % 64;
-    int height = rand() % 64;
+    int height = 1 + rand() % 63;
     int dstStride = width;
     int j = 0;
 
diff -r 8c946aca5824 -r ac9e57296fa8 source/x265.cpp
--- a/source/x265.cpp	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/x265.cpp	Thu Apr 03 21:14:24 2014 -0500
@@ -169,7 +169,10 @@ static const struct option long_options[
     { "crop-rect",      required_argument, NULL, 0 },
     { "timinginfo",           no_argument, NULL, 0 },
     { "no-timinginfo",        no_argument, NULL, 0 },
+    { "no-dither",            no_argument, NULL, 0 },
     { "dither",               no_argument, NULL, 0 },
+    { "aud",                  no_argument, NULL, 0 },
+    { "no-aud",               no_argument, NULL, 0 },
     { 0, 0, 0, 0 }
 };
 
@@ -390,6 +393,8 @@ void CLIOptions::showHelp(x265_param *pa
     H0("                                 smpte240m, GBR, YCgCo, bt2020nc, bt2020c. Default undef\n");
     H0("   --chromaloc <integer>         Specify chroma sample location (0 to 5). Default of %d\n", param->vui.chromaSampleLocTypeTopField);
     H0("   --[no-]timinginfo             Add timing information to the VUI. Defaut %s\n", OPT(param->vui.bEnableVuiTimingInfoPresentFlag));
+    H0("\nBitstream options:\n");
+    H0("   --[no-]aud                    Emit access unit delimiters at the start of each access unit. Default %s\n", OPT(param->bEnableAccessUnitDelimiters));
     H0("\nReconstructed video options (debugging):\n");
     H0("-r/--recon <filename>            Reconstructed raw image YUV or Y4M output file name\n");
     H0("   --recon-depth <integer>       Bit-depth of reconstructed raw image file. Defaults to input bit depth, or 8 if Y4M\n");
diff -r 8c946aca5824 -r ac9e57296fa8 source/x265.h
--- a/source/x265.h	Thu Apr 03 14:49:57 2014 -0500
+++ b/source/x265.h	Thu Apr 03 21:14:24 2014 -0500
@@ -392,6 +392,10 @@ typedef struct x265_param
      * each keyframe. Default false */
     int       bRepeatHeaders;
 
+    /* Flag indicating whether the encoder should emit an Access Unit Delimiter
+     * NAL at the start of every access unit. Default false */
+    int       bEnableAccessUnitDelimiters;
+
     /*== Coding Unit (CU) definitions ==*/
 
     /* Maxiumum CU width and height in pixels.  The size must be 64, 32, or 16.


More information about the x265-commits mailing list