<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 19, 2014 at 12:01 PM,  <span dir="ltr"><<a href="mailto:dtyx265@gmail.com" target="_blank">dtyx265@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User David T Yuen <<a href="mailto:dtyx265@gmail.com">dtyx265@gmail.com</a>><br>
# Date 1392832822 28800<br>
# Node ID 8ef0c14054879a7a0ba7720ecb3a640e6b3767d1<br>
# Parent  1c78bd13a14f3d5227c4b961664af97f86a8810d<br>
Added command line options to generate a VUI and add it to the coded bitstream<br></blockquote><div><br></div><div>Hello,  Thanks for working through these details.</div><div><br></div><div>I had some review comments for this patch but unfortunately didn't get around to responding to this patch yesterday.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
diff -r 1c78bd13a14f -r 8ef0c1405487 source/Lib/TLibCommon/TComSlice.h<br>
--- a/source/Lib/TLibCommon/TComSlice.h Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/Lib/TLibCommon/TComSlice.h Wed Feb 19 10:00:22 2014 -0800<br>
@@ -604,6 +604,7 @@<br>
     bool m_frameFieldInfoPresentFlag;<br>
     bool m_hrdParametersPresentFlag;<br>
     bool m_bitstreamRestrictionFlag;<br>
+    bool m_tilesFixedStructureFlag;<br>
     bool m_motionVectorsOverPicBoundariesFlag;<br>
     bool m_restrictedRefPicListsFlag;<br>
     int  m_minSpatialSegmentationIdc;<br>
@@ -638,6 +639,7 @@<br>
         , m_frameFieldInfoPresentFlag(false)<br>
         , m_hrdParametersPresentFlag(false)<br>
         , m_bitstreamRestrictionFlag(false)<br>
+        , m_tilesFixedStructureFlag(false)<br></blockquote><div><br></div><div>We don't support tiles, so it is ok to leave this hard-coded to zero</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

         , m_motionVectorsOverPicBoundariesFlag(true)<br>
         , m_restrictedRefPicListsFlag(1)<br>
         , m_minSpatialSegmentationIdc(0)<br>
@@ -737,6 +739,10 @@<br>
<br>
     void setBitstreamRestrictionFlag(bool i) { m_bitstreamRestrictionFlag = i; }<br>
<br>
+    bool getTilesFixedStructureFlag() { return m_tilesFixedStructureFlag; }<br>
+<br>
+    void setTilesFixedStructureFlag(bool i) { m_tilesFixedStructureFlag = i; }<br></blockquote><div><br></div><div><br></div><div>We're trying to remove these C++ style get/set methods.  Just set/get these variables directly.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     bool getMotionVectorsOverPicBoundariesFlag() { return m_motionVectorsOverPicBoundariesFlag; }<br>
<br>
     void setMotionVectorsOverPicBoundariesFlag(bool i) { m_motionVectorsOverPicBoundariesFlag = i; }<br>
diff -r 1c78bd13a14f -r 8ef0c1405487 source/Lib/TLibEncoder/TEncCfg.h<br>
--- a/source/Lib/TLibEncoder/TEncCfg.h  Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/Lib/TLibEncoder/TEncCfg.h  Wed Feb 19 10:00:22 2014 -0800<br>
@@ -151,6 +151,14 @@<br>
     int       m_maxBitsPerMinCuDenom;                         ///< Indicates an upper bound for the number of bits of coding_unit() data<br>
     int       m_log2MaxMvLengthHorizontal;                    ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units<br>
     int       m_log2MaxMvLengthVertical;                      ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units<br></blockquote><div><br></div><div><br></div><div>there's no need to add these flags to TEncCfg since TEncCfg itself has an x265_param structure built into it.  These are redundant.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    bool      m_fieldSeqFlag;                                 ///< Indicates that each picture is a field and has its own SEI timing message<br>
+    bool      m_vuiTimingInfoPresentFlag;                     ///< Indicates that timing info is added to the VUI<br>
+    int       m_vuiNumUnitsInTick;                            ///< The number of system ticks in an h265 tick where an h265 tick is in units of system ticks per frame<br>
+    int       m_vuiTimeScale;                                 ///< The number of system ticks per second<br>
+    bool      m_vuiHrdParametersPresentFlag;                  ///< Indicates HRD parameters are to be added to the VUI<br>
+    bool      m_subPicHrdParamsPresentFlag;                   ///< Indicates that sub pic parameters should be added to the HRD<br>
+    bool      m_restrictedRefPicListsFlag;                    ///< Indicates all P and B slices have the same reference pic list 0 and all B slices have the same reference pic list 1<br>
+    bool      m_tilesFixedStructureFlag;                      ///< Indicates each PPS in the CVS have the same tile structure fields<br>
<br>
 public:<br>
<br>
@@ -305,6 +313,22 @@<br>
     bool getNonPackedConstraintFlag() const { return m_nonPackedConstraintFlag; }<br>
<br>
     bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }<br></blockquote><div><br></div><div>ditto here, these should go away</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+<br>
+    bool getFieldSeqFlag() const { return m_fieldSeqFlag; }<br>
+<br>
+    bool getVuiTimingInfoPresentFlag() const { return m_vuiTimingInfoPresentFlag; }<br>
+<br>
+    int getVuiNumUnitsInTick() const { return m_vuiNumUnitsInTick; }<br>
+<br>
+    int getVuiTimeScale() const { return m_vuiTimeScale; }<br>
+<br>
+    bool getVuiHrdParametersPresentFlag() const { return m_vuiHrdParametersPresentFlag; }<br>
+<br>
+    bool getSubPicHrdParamsPresentFlag() const { return m_subPicHrdParamsPresentFlag; }<br>
+<br>
+    bool getRestrictedRefPicListsFlag() const { return m_restrictedRefPicListsFlag; }<br>
+<br>
+    bool getTilesFixedStructureFlag() const { return m_tilesFixedStructureFlag; }<br>
 };<br>
 }<br>
 //! \}<br>
diff -r 1c78bd13a14f -r 8ef0c1405487 source/Lib/TLibEncoder/TEncSbac.cpp<br>
--- a/source/Lib/TLibEncoder/TEncSbac.cpp       Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp       Wed Feb 19 10:00:22 2014 -0800<br>
@@ -665,7 +665,7 @@<br>
     WRITE_FLAG(vui->getBitstreamRestrictionFlag(),              "bitstream_restriction_flag");<br>
     if (vui->getBitstreamRestrictionFlag())<br>
     {<br>
-        WRITE_FLAG(0,                                                "tiles_fixed_structure_flag");<br>
+        WRITE_FLAG(vui->getTilesFixedStructureFlag(),             "tiles_fixed_structure_flag");<br></blockquote><div> </div><div>this one can be backed out</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

         WRITE_FLAG(vui->getMotionVectorsOverPicBoundariesFlag(),  "motion_vectors_over_pic_boundaries_flag");<br>
         WRITE_FLAG(vui->getRestrictedRefPicListsFlag(),           "restricted_ref_pic_lists_flag");<br>
         WRITE_UVLC(vui->getMinSpatialSegmentationIdc(),           "min_spatial_segmentation_idc");<br>
diff -r 1c78bd13a14f -r 8ef0c1405487 source/common/common.cpp<br>
--- a/source/common/common.cpp  Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/common/common.cpp  Wed Feb 19 10:00:22 2014 -0800<br>
@@ -221,6 +221,35 @@<br>
     /* Quality Measurement Metrics */<br>
     param->bEnablePsnr = 0;<br>
     param->bEnableSsim = 0;<br>
+<br>
+    /* Video Usability Information (VUI) */<br>
+    param->bEnableVuiParametersPresentFlag = 0;<br>
+    param->bEnableAspectRatioIdc = 0;<br>
+    param->aspectRatioIdc = 0;<br>
+    param->sarWidth = 0;<br>
+    param->sarHeight = 0;<br>
+    param->bEnableOverscanAppropriateFlag = 0;<br>
+    param->bEnableVideoSignalTypePresentFlag = 0;<br>
+    param->videoFormat = 5;<br>
+    param->bEnableVideoFullRangeFlag = 0;<br>
+    param->bEnableColorDescriptionPresentFlag = 0;<br>
+    param->colorPrimaries = 2;<br>
+    param->transferCharacteristics = 2;<br>
+    param->matrixCoeffs = 2;<br>
+    param->bEnableChromaLocInfoPresentFlag = 0;<br>
+    param->chromaSampleLocTypeTopField = 0;<br>
+    param->chromaSampleLocTypeBottomField = 0;<br>
+    param->bEnableFieldSeqFlag = 0;<br>
+    param->bEnableFrameFieldInfoPresentFlag = 0;<br>
+    param->bEnableDefaultDisplayWindowFlag = 0;<br>
+    param->defDispWinLeftOffset = 0;<br>
+    param->defDispWinRightOffset = 0;<br>
+    param->defDispWinTopOffset = 0;<br>
+    param->defDispWinBottomOffset = 0;<br>
+    param->bEnableVuiTimingInfoPresentFlag = 0;<br>
+    param->bEnableVuiHrdParametersPresentFlag = 0;<br>
+    param->bEnableBitstreamRestrictionFlag = 0;<br>
+    param->bEnableSubPicHrdParamsPresentFlag = 0;<br>
 }<br>
<br>
 extern "C"<br>
@@ -764,6 +793,200 @@<br>
     OPT("me")        p->searchMethod = parseName(value, x265_motion_est_names, berror);<br>
     OPT("cutree")    p->rc.cuTree = bvalue;<br>
     OPT("no-cutree") p->rc.cuTree = bvalue;<br>
+    OPT("vui")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = bvalue;<br>
+        p->bEnableAspectRatioIdc = bvalue;<br>
+        p->bEnableOverscanInfoPresentFlag = bvalue;<br>
+        p->bEnableVideoSignalTypePresentFlag = bvalue;<br>
+        p->bEnableColorDescriptionPresentFlag = bvalue;<br>
+        p->bEnableChromaLocInfoPresentFlag = bvalue;<br>
+        p->bEnableFieldSeqFlag = bvalue;<br>
+        p->bEnableFrameFieldInfoPresentFlag = bvalue;<br>
+        p->bEnableDefaultDisplayWindowFlag = bvalue;<br>
+        p->bEnableVuiTimingInfoPresentFlag = bvalue;<br>
+        p->bEnableVuiHrdParametersPresentFlag = bvalue;<br>
+        p->bEnableBitstreamRestrictionFlag = bvalue;<br>
+        p->bEnableSubPicHrdParamsPresentFlag = bvalue;<br>
+    }<br>
+    OPT("sar")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableAspectRatioIdc = bvalue;<br>
+        p->aspectRatioIdc = atoi(value);<br>
+    }<br>
+    OPT("extended-sar")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableAspectRatioIdc = bvalue;<br>
+        p->aspectRatioIdc = 255;<br>
+        sscanf(value, "%dx%d", &p->sarWidth, &p->sarHeight);<br>
+    }<br>
+    OPT("overscan")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        if (!strcmp(value, "show"))<br>
+            p->bEnableOverscanInfoPresentFlag = bvalue;<br>
+        else if (!strcmp(value, "crop"))<br>
+        {<br>
+            p->bEnableOverscanInfoPresentFlag = bvalue;<br>
+            p->bEnableOverscanAppropriateFlag = bvalue;<br>
+        }<br>
+    }<br>
+    OPT("videoformat")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVideoSignalTypePresentFlag = bvalue;<br>
+        if (!strcmp(value, "component"))<br>
+            p->videoFormat = 0;<br>
+        else if (!strcmp(value, "pal"))<br>
+            p->videoFormat = 1;<br>
+        else if (!strcmp(value, "ntsc"))<br>
+            p->videoFormat = 2;<br>
+        else if (!strcmp(value, "secam"))<br>
+            p->videoFormat = 3;<br>
+        else if (!strcmp(value, "mac"))<br>
+            p->videoFormat = 4;<br>
+        else if (!strcmp(value, "undef"))<br>
+            p->videoFormat = 5;<br>
+    }<br>
+    OPT("range")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVideoSignalTypePresentFlag = bvalue;<br>
+        p->bEnableVideoFullRangeFlag = bvalue;<br>
+    }<br>
+    OPT("colorprim")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVideoSignalTypePresentFlag = bvalue;<br>
+        p->bEnableColorDescriptionPresentFlag = bvalue;<br>
+        if (!strcmp(value, "bt709"))<br>
+            p->colorPrimaries = 1;<br>
+        else if (!strcmp(value, "undef"))<br>
+            p->colorPrimaries = 2;<br>
+        else if (!strcmp(value, "bt470m"))<br>
+            p->colorPrimaries = 4;<br>
+        else if (!strcmp(value, "bt470bg"))<br>
+            p->colorPrimaries = 5;<br>
+        else if (!strcmp(value, "smpte170m"))<br>
+            p->colorPrimaries = 6;<br>
+        else if (!strcmp(value, "smpte240m"))<br>
+            p->colorPrimaries = 7;<br>
+        else if (!strcmp(value, "film"))<br>
+            p->colorPrimaries = 8;<br>
+        else if (!strcmp(value, "bt2020"))<br>
+            p->colorPrimaries = 9;<br>
+    }<br>
+    OPT("transfer")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVideoSignalTypePresentFlag = bvalue;<br>
+        p->bEnableColorDescriptionPresentFlag = bvalue;<br>
+        if (!strcmp(value, "bt709"))<br>
+            p->transferCharacteristics = 1;<br>
+        else if (!strcmp(value, "undef"))<br>
+            p->transferCharacteristics = 2;<br>
+        else if (!strcmp(value, "bt470m"))<br>
+            p->transferCharacteristics = 4;<br>
+        else if (!strcmp(value, "bt470bg"))<br>
+            p->transferCharacteristics = 5;<br>
+        else if (!strcmp(value, "smpte170m"))<br>
+            p->transferCharacteristics = 6;<br>
+        else if (!strcmp(value, "smpte240m"))<br>
+            p->transferCharacteristics = 7;<br>
+        else if (!strcmp(value, "linear"))<br>
+            p->transferCharacteristics = 8;<br>
+        else if (!strcmp(value, "log100"))<br>
+            p->transferCharacteristics = 9;<br>
+        else if (!strcmp(value, "log316"))<br>
+            p->transferCharacteristics = 10;<br>
+        else if (!strcmp(value, "iec61966-2-4"))<br>
+            p->transferCharacteristics = 11;<br>
+        else if (!strcmp(value, "bt1361e"))<br>
+            p->transferCharacteristics = 12;<br>
+        else if (!strcmp(value, "iec61966-2-1"))<br>
+            p->transferCharacteristics = 13;<br>
+        else if (!strcmp(value, "bt2020-10"))<br>
+            p->transferCharacteristics = 14;<br>
+        else if (!strcmp(value, "bt2020-12"))<br>
+            p->transferCharacteristics = 15;<br>
+    }<br>
+    OPT("colormatrix")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVideoSignalTypePresentFlag = bvalue;<br>
+        p->bEnableColorDescriptionPresentFlag = bvalue;<br>
+        if (!strcmp(value, "GBR"))<br>
+            p->matrixCoeffs = 0;<br>
+        else if (!strcmp(value, "bt709"))<br>
+            p->matrixCoeffs = 1;<br>
+        else if (!strcmp(value, "undef"))<br>
+            p->matrixCoeffs = 2;<br>
+        else if (!strcmp(value, "fcc"))<br>
+            p->matrixCoeffs = 4;<br>
+        else if (!strcmp(value, "bt470bg"))<br>
+            p->matrixCoeffs = 5;<br>
+        else if (!strcmp(value, "smpte170m"))<br>
+            p->matrixCoeffs = 6;<br>
+        else if (!strcmp(value, "smpte240m"))<br>
+            p->matrixCoeffs = 7;<br>
+        else if (!strcmp(value, "YCgCo"))<br>
+            p->matrixCoeffs = 8;<br>
+        else if (!strcmp(value, "bt2020nc"))<br>
+            p->matrixCoeffs = 9;<br>
+        else if (!strcmp(value, "bt2020c"))<br>
+            p->matrixCoeffs = 10;<br>
+    }<br>
+    OPT("chromaloc")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableChromaLocInfoPresentFlag = bvalue;<br>
+        p->chromaSampleLocTypeTopField = atoi(value);<br>
+        p->chromaSampleLocTypeBottomField = p->chromaSampleLocTypeTopField;<br>
+    }<br>
+    OPT("fieldseq")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableFieldSeqFlag = bvalue;<br>
+    }<br>
+    OPT("framefieldinfo")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableFrameFieldInfoPresentFlag = bvalue;<br>
+    }<br>
+    OPT("crop-rect")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableDefaultDisplayWindowFlag = bvalue;<br>
+        sscanf(value,"%d,%d,%d,%d",<br>
+            &p->defDispWinLeftOffset,<br>
+            &p->defDispWinTopOffset,<br>
+            &p->defDispWinRightOffset,<br>
+            &p->defDispWinBottomOffset);<br>
+    }<br>
+    OPT("timinginfo")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVuiTimingInfoPresentFlag = bvalue;<br>
+    }<br>
+    OPT("nal-hrd")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVuiTimingInfoPresentFlag = bvalue;<br>
+        p->bEnableVuiHrdParametersPresentFlag = bvalue;<br>
+    }<br>
+    OPT("bitstreamrestriction")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableBitstreamRestrictionFlag = bvalue;<br>
+    }<br>
+    OPT("subpichrd")<br>
+    {<br>
+        p->bEnableVuiParametersPresentFlag = 1;<br>
+        p->bEnableVuiHrdParametersPresentFlag = bvalue;<br>
+        p->bEnableSubPicHrdParamsPresentFlag = bvalue;<br>
+    }<br>
<br>
     else<br>
         return X265_PARAM_BAD_NAME;<br>
diff -r 1c78bd13a14f -r 8ef0c1405487 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/encoder/encoder.cpp        Wed Feb 19 10:00:22 2014 -0800<br>
@@ -1043,7 +1043,7 @@<br>
     if (sps->getVuiParametersPresentFlag())<br>
     {<br>
         TComVUI* vui = sps->getVuiParameters();<br>
-        vui->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1);<br></blockquote><div><br></div><div>you can use param.* here</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+        vui->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());<br>
         vui->setAspectRatioIdc(getAspectRatioIdc());<br>
         vui->setSarWidth(getSarWidth());<br>
         vui->setSarHeight(getSarHeight());<br>
@@ -1062,12 +1062,17 @@<br>
         vui->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag());<br>
         vui->setDefaultDisplayWindow(getDefaultDisplayWindow());<br>
         vui->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag());<br>
-        vui->setFieldSeqFlag(false);<br>
-        vui->setHrdParametersPresentFlag(false);<br>
+        vui->setFieldSeqFlag(getFieldSeqFlag());<br>
+        vui->setHrdParametersPresentFlag(getVuiHrdParametersPresentFlag());<br>
+        vui->getTimingInfo()->setTimingInfoPresentFlag(getVuiTimingInfoPresentFlag());<br>
+        vui->getTimingInfo()->setNumUnitsInTick(getVuiNumUnitsInTick());<br>
+        vui->getTimingInfo()->setTimeScale(getVuiTimeScale());<br>
         vui->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());<br>
         vui->getTimingInfo()->setNumTicksPocDiffOneMinus1(getNumTicksPocDiffOneMinus1());<br>
         vui->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag());<br>
+        vui->setTilesFixedStructureFlag(getTilesFixedStructureFlag());<br>
         vui->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag());<br>
+        vui->setRestrictedRefPicListsFlag(getRestrictedRefPicListsFlag());<br>
         vui->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc());<br>
         vui->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom());<br>
         vui->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom());<br>
@@ -1390,11 +1395,11 @@<br>
     m_quadtreeTULog2MinSize = tuQTMinLog2Size;<br>
<br>
     //========= set default display window ==================================<br>
-    m_defaultDisplayWindow.m_enabledFlag = true;<br>
-    m_defaultDisplayWindow.m_winRightOffset = 0;<br>
-    m_defaultDisplayWindow.m_winTopOffset = 0;<br>
-    m_defaultDisplayWindow.m_winBottomOffset = 0;<br>
-    m_defaultDisplayWindow.m_winLeftOffset = 0;<br>
+    m_defaultDisplayWindow.m_enabledFlag = _param->bEnableDefaultDisplayWindowFlag;<br>
+    m_defaultDisplayWindow.m_winRightOffset = _param->defDispWinRightOffset;<br>
+    m_defaultDisplayWindow.m_winTopOffset = _param->defDispWinTopOffset;<br>
+    m_defaultDisplayWindow.m_winBottomOffset = _param->defDispWinBottomOffset;<br>
+    m_defaultDisplayWindow.m_winLeftOffset = _param->defDispWinLeftOffset;<br>
     m_pad[0] = m_pad[1] = 0;<br>
<br>
     //======== set pad size if width is not multiple of the minimum CU size =========<br>
@@ -1465,25 +1470,26 @@<br>
     m_decodingUnitInfoSEIEnabled = 0;<br>
     m_useScalingListId = 0;<br>
     m_activeParameterSetsSEIEnabled = 0;<br></blockquote><div><br></div><div>All the sets to fields redundant with x265_param should go away</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

-    m_vuiParametersPresentFlag = false;<br>
+    m_vuiParametersPresentFlag = _param->bEnableVuiParametersPresentFlag;<br>
     m_minSpatialSegmentationIdc = 0;<br>
-    m_aspectRatioIdc = 0;<br>
-    m_sarWidth = 0;<br>
-    m_sarHeight = 0;<br>
-    m_overscanInfoPresentFlag = false;<br>
-    m_overscanAppropriateFlag = false;<br>
-    m_videoSignalTypePresentFlag = false;<br>
-    m_videoFormat = 5;<br>
-    m_videoFullRangeFlag = false;<br>
-    m_colourDescriptionPresentFlag = false;<br>
-    m_colourPrimaries = 2;<br>
-    m_transferCharacteristics = 2;<br>
-    m_matrixCoefficients = 2;<br>
-    m_chromaLocInfoPresentFlag = false;<br>
-    m_chromaSampleLocTypeTopField = 0;<br>
-    m_chromaSampleLocTypeBottomField = 0;<br>
+    m_aspectRatioInfoPresentFlag = _param->bEnableAspectRatioIdc;<br>
+    m_aspectRatioIdc = _param->aspectRatioIdc;<br>
+    m_sarWidth = _param->sarWidth;<br>
+    m_sarHeight = _param->sarHeight;<br>
+    m_overscanInfoPresentFlag = _param->bEnableOverscanInfoPresentFlag;<br>
+    m_overscanAppropriateFlag = _param->bEnableOverscanAppropriateFlag;<br>
+    m_videoSignalTypePresentFlag = _param->bEnableVideoSignalTypePresentFlag;<br>
+    m_videoFormat = _param->videoFormat;<br>
+    m_videoFullRangeFlag = _param->bEnableVideoFullRangeFlag;<br>
+    m_colourDescriptionPresentFlag = _param->bEnableColorDescriptionPresentFlag;<br>
+    m_colourPrimaries = _param->colorPrimaries;<br>
+    m_transferCharacteristics = _param->transferCharacteristics;<br>
+    m_matrixCoefficients = _param->matrixCoeffs;<br>
+    m_chromaLocInfoPresentFlag = _param->bEnableChromaLocInfoPresentFlag;<br>
+    m_chromaSampleLocTypeTopField = _param->chromaSampleLocTypeTopField;<br>
+    m_chromaSampleLocTypeBottomField = _param->chromaSampleLocTypeBottomField;<br>
     m_neutralChromaIndicationFlag = false;<br>
-    m_frameFieldInfoPresentFlag = false;<br>
+    m_frameFieldInfoPresentFlag = _param->bEnableFrameFieldInfoPresentFlag;<br>
     m_pocProportionalToTimingFlag = false;<br>
     m_numTicksPocDiffOneMinus1 = 0;<br>
     m_bitstreamRestrictionFlag = false;<br>
@@ -1501,6 +1507,11 @@<br>
     m_useLossless = false;  // x264 configures this via --qp=0<br>
     m_TransquantBypassEnableFlag = false;<br>
     m_CUTransquantBypassFlagValue = false;<br>
+    m_fieldSeqFlag = _param->bEnableFieldSeqFlag;<br>
+    m_vuiTimingInfoPresentFlag = _param->bEnableVuiTimingInfoPresentFlag;<br>
+    m_vuiHrdParametersPresentFlag = _param->bEnableVuiHrdParametersPresentFlag;<br>
+    m_bitstreamRestrictionFlag = _param->bEnableBitstreamRestrictionFlag;<br>
+    m_subPicHrdParamsPresentFlag = _param->bEnableSubPicHrdParamsPresentFlag;<br>
 }<br>
<br>
 int Encoder::extractNalData(NALUnitEBSP **nalunits)<br>
diff -r 1c78bd13a14f -r 8ef0c1405487 source/x265.cpp<br>
--- a/source/x265.cpp   Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/x265.cpp   Wed Feb 19 10:00:22 2014 -0800<br>
@@ -154,6 +154,26 @@<br>
     { "strong-intra-smoothing",    no_argument, NULL, 0 },<br>
     { "no-cutree",                 no_argument, NULL, 0 },<br>
     { "cutree",                    no_argument, NULL, 0 },<br>
+    { "vui",                  no_argument, NULL, 0 },<br>
+    { "sar",            required_argument, NULL, 0 },<br>
+    { "extended-sar",   required_argument, NULL, 0 },<br>
+    { "overscan",       required_argument, NULL, 0 },<br>
+    { "videoformat",    required_argument, NULL, 0 },<br>
+    { "range",                no_argument, NULL, 0 },<br>
+    { "no-range",             no_argument, NULL, 0 },<br>
+    { "colorprim",      required_argument, NULL, 0 },<br>
+    { "transfer",       required_argument, NULL, 0 },<br>
+    { "colormatrix",    required_argument, NULL, 0 },<br>
+    { "chromaloc",      required_argument, NULL, 0 },<br>
+    { "fieldseq",             no_argument, NULL, 0 },<br>
+    { "no-fieldseq",          no_argument, NULL, 0 },<br>
+    { "framefieldinfo",       no_argument, NULL, 0 },<br>
+    { "no-framefieldinfo",    no_argument, NULL, 0 },<br>
+    { "crop-rect",      required_argument, NULL, 0 },<br>
+    { "timinginfo",           no_argument, NULL, 0 },<br>
+    { "nal-hrd",              no_argument, NULL, 0 },<br>
+    { "bitstreamrestriction", no_argument, NULL, 0 },<br>
+    { "subpichrd",            no_argument, NULL, 0 },<br>
     { 0, 0, 0, 0 }<br>
 };<br>
<br>
@@ -351,6 +371,32 @@<br>
     H0("   --recon-depth                 Bit-depth of reconstructed raw image file. Defaults to input bit depth\n");<br>
     H0("\nSEI options:\n");<br>
     H0("   --hash                        Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI);<br>
+    H0("\nVUI options:\n");<br>
+    H0("   --vui                         Add Video Useability Information with all fields to the SPS. Default %s\n", OPT(param->bEnableVuiParametersPresentFlag));<br>
+    H0("   --sar                         Sample Aspect Ratio, the ratio of width to height of an individual pixel.\n");<br>
+    H0("                                 Choose from 0=Unspecified, 1=1:1(\"square\"), 2=12:11, 3=10:11, 4=16:11,\n");<br>
+    H0("                                 5=40:33, 6=24:11, 7=20:11, 8=32:11, 9=80:33, 10=18:11, 11=15:11,\n");<br>
+    H0("                                 12=64:33, 13=160:99, 14=4:3, 15=3:2, 16=2:1. Default %d\n",param->aspectRatioIdc);<br>
+    H0("   --extended-sar                Use a custom Sample Aspect Ratio,[WxH]\n");<br>
+    H0("   --overscan <string>           Specify crop overscan setting from undef, show or crop. Default of undef\n");<br>
+    H0("   --videoformat <string>        Specify video format from undef, component, pal, ntsc, secam, mac. Default of undef\n");<br>
+    H0("   --[no-]range                       Specify black level and range of luma and chroma signals. Default of %s\n", OPT(param->bEnableVideoFullRangeFlag));<br>
+    H0("   --colorprim <string>          Specify color primaries from undef, bt709, bt470m, bt470bg, smpte170m,\n");<br>
+    H0("                                 smpte240m, film, bt2020. Default of undef\n");<br>
+    H0("   --transfer <string>           Specify transfer characteristics from undef, bt709, bt470m, bt470bg, smpte170m,\n");<br>
+    H0("                                 smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1,\n");<br>
+    H0("                                 bt2020-10, bt2020-12. Default of undef\n");<br>
+    H0("   --colormatrix <string>        Specify color matrix setting from undef, bt709, fcc, bt470bg, smpte170m,\n");<br>
+    H0("                                 smpte240m, GBR, YCgCo, bt2020nc, bt2020c\n");<br>
+    H0("   --chromaloc <integer>         Specify chroma sample location (0 to 5). Default of %d\n",param->chromaSampleLocTypeTopField);<br>
+    H0("   --[no-]fieldseq               Specify that pictures are fields and an SEI timing message\n");<br>
+    H0("                                 will be added to every access unit. Default %s\n", OPT(param->bEnableFieldSeqFlag));<br>
+    H0("   --[no-]framefieldinfo         Specify that a pic-struct will be added to the SEI timing message. Default %s\n", OPT(param->bEnableFrameFieldInfoPresentFlag));<br>
+    H0("   --crop-rect <string>          Add 'left,top,right,bottom' to the bitstream-level cropping rectangle\n");<br>
+    H0("   --timinginfo                  Add timing information to the VUI. Defaut %s\n", OPT(param->bEnableVuiTimingInfoPresentFlag));<br>
+    H0("   --nal-hrd                     Signal HRD information. Default %s\n", OPT(param->bEnableVuiHrdParametersPresentFlag));<br>
+    H0("   --bitstreamrestriction        Add bit stream restriction fields to the VUI. Default %s\n", OPT(param->bEnableBitstreamRestrictionFlag));<br>
+    H0("   --subpichrd                   Add sub picture HRD parameters to the HRD. Default %s\n", OPT(param->bEnableSubPicHrdParamsPresentFlag));<br></blockquote><div><br></div><div>nicely done</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 #undef OPT<br>
 #undef H0<br>
     exit(0);<br>
diff -r 1c78bd13a14f -r 8ef0c1405487 source/x265.h<br>
--- a/source/x265.h     Wed Feb 19 09:46:46 2014 -0800<br>
+++ b/source/x265.h     Wed Feb 19 10:00:22 2014 -0800<br>
@@ -332,6 +332,147 @@<br>
      * types are MD5(1), CRC(2), Checksum(3).  Default is 0, none */<br>
     int       decodedPictureHashSEI;<br></blockquote><div><br></div><div>I think these parameters should go within a vui sub-struct, similar to the rc sub-struct.</div><div><br></div><div>Excellent job documenting them all.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
+    /*== Video Usability Information ==*/<br>
+<br>
+    /* Enable the generation of a VUI with all fields in the SPS.  VUI fields<br>
+     * that are not specified on the command line will have default values. */<br>
+    int       bEnableVuiParametersPresentFlag;<br>
+<br>
+    /* Enable aspect ratio in VUI.  Causes the aspect_ratio_idc to be added<br>
+     * to the VUI.  The default is false. */<br>
+    int bEnableAspectRatioIdc;<br>
+<br>
+    /* Aspect ratio idc to be added to the VUI.  The default is 0 indicating<br>
+     * the apsect ratio is unspecified.  If set to EXTENDED_SAR(255) then<br>
+     * sarWidth and sarHeight must also be set. */<br>
+    int       aspectRatioIdc;<br>
+<br>
+    /* Sample Aspect Ratio width in arbitrary units to be added to the VUI<br>
+     * only if aspectRatioIdc is set to EXTENDED_SAR(255).  This is the width<br>
+     * of an individual pixel.  If this is set then sarHeight must also be set.<br>
+     */<br>
+    int       sarWidth;<br>
+<br>
+    /* Sample Aspect Ratio height in arbitrary units to be added to the VUI.<br>
+     * only if aspectRatioIdc is set to EXTENDED_SAR(255).  This is the width<br>
+     * of an individual pixel.  If this is set then sarWidth must also be set.<br>
+     */<br>
+    int       sarHeight;<br>
+<br>
+    /* Enable overscan info present flag in the VUI.  If this is set then<br>
+     * bEnabledOverscanAppropriateFlag will be added to the VUI. The default<br>
+     * is false. */<br>
+    int       bEnableOverscanInfoPresentFlag;<br>
+<br>
+    /* Enable overscan appropriate flag.  The status of this flag is added to<br>
+     * the VUI only if bEnableOverscanInfoPresentFlag is set.  If this flag is<br>
+     * set then cropped decoded pictures may be output for display. The default<br>
+     * is false. */<br>
+    int       bEnableOverscanAppropriateFlag;<br>
+<br>
+    /* Video signal type present flag of the VUI.  If this is set then<br>
+     * videoFormat, bEnableVideoFullRangeFlag and<br>
+     * bEnableColorDescriptionPresentFlag will be added to the VUI.  The default<br>
+     * is false. */<br>
+    int       bEnableVideoSignalTypePresentFlag;<br>
+<br>
+    /* Video format of the source video.  0 = component, 1 = PAL, 2 = NTSC,<br>
+     * 3 = SECAM, 4 = MAC, 5 = unspecified video format is the default. */<br>
+    int       videoFormat;<br>
+<br>
+    /* Video full range flag indicates the black level and range of the luma<br>
+     * and chroma signals as derived from E′Y, E′PB, and E′PR or E′R, E′G, and<br>
+     * E′B real-valued component signals.  False is the default. */<br>
+    int       bEnableVideoFullRangeFlag;<br>
+<br>
+    /* Color description present flag in the VUI.  If this is set then<br>
+     * color_primaries, transfer_characteristics and matrix_coeffs are to be added<br>
+     * to the VUI.  The default is false. */<br>
+    int       bEnableColorDescriptionPresentFlag;<br>
+<br>
+    /* Color primaries holds the chromacity coordinates of the source primaries.<br>
+     * The default is 2. */<br>
+    int       colorPrimaries;<br>
+<br>
+    /* Transfer characteristics indicates the opto-electronic transfer characteristic<br>
+     * of the source picture.  The default is 2. */<br>
+    int       transferCharacteristics;<br>
+<br>
+    /* Matrix coefficients used to derive the luma and chroma signals from the red,<br>
+     * blue and green primaries.  The default is 2. */<br>
+    int       matrixCoeffs;<br>
+<br>
+    /* Chroma location info present flag adds chroma_sample_loc_type_top_field and<br>
+     * chroma_sample_loc_type_bottom_field to the VUI.  The default is false. */<br>
+    int       bEnableChromaLocInfoPresentFlag;<br>
+<br>
+    /* Chroma sample location type top field holds the chroma location in the top<br>
+     * field.  The default is 0. */<br>
+    int       chromaSampleLocTypeTopField;<br>
+<br>
+    /* Chroma sample location type bottom field holds the chroma location in the bottom<br>
+     * field.  The default is 0. */<br>
+    int       chromaSampleLocTypeBottomField;<br>
+<br>
+    /* Field seq flag specifies that the pictures are fields and each one has a<br>
+     * timing SEI message.  The default is false */<br>
+    int       bEnableFieldSeqFlag;<br>
+<br>
+    /* Frame field info present flag indicates that each picture has a timing SEI<br>
+     * message wich includes a pic_struct, source_scan_type and duplicate_flag<br>
+     * elements.  If not set then the pic_struct element is not included.  The<br>
+     * default is false. */<br>
+    int       bEnableFrameFieldInfoPresentFlag;<br>
+<br>
+    /* Default display window flag adds def_disp_win_left_offset ,<br>
+     * def_disp_win_right_offset, def_disp_win_top_offset and<br>
+     * def_disp_win_bottom_offset to the VUI.  The default is false. */<br>
+    int       bEnableDefaultDisplayWindowFlag;<br>
+<br>
+    /* Default display window left offset holds the left offset with the<br>
+     * conformance cropping window to further crop the displayed window. */<br>
+    int       defDispWinLeftOffset;<br>
+<br>
+    /* Default display window right offset holds the right offset with the<br>
+     * conformance cropping window to further crop the displayed window. */<br>
+    int       defDispWinRightOffset;<br>
+<br>
+    /* Default display window top offset holds the top offset with the<br>
+     * conformance cropping window to further crop the displayed window. */<br>
+    int       defDispWinTopOffset;<br>
+<br>
+    /* Default display window bottom offset holds the bottom offset with the<br>
+     * conformance cropping window to further crop the displayed window. */<br>
+    int       defDispWinBottomOffset;<br>
+<br>
+    /* VUI timing info present flag adds vui_num_units_in_tick, vui_time_scale,<br>
+     * vui_poc_proportional_to_timing_flag and vui_hrd_parameters_present_flag<br>
+     * to the VUI.  vui_num_units_in_tick, vui_time_scale and<br>
+     * vui_poc_proportional_to_timing_flag are derived from processing the input<br>
+     * video.  The default is false. */<br>
+    int       bEnableVuiTimingInfoPresentFlag;<br>
+<br>
+    /* VUI hrd parameters present flag adds the HRD to the VUI */<br>
+    int       bEnableVuiHrdParametersPresentFlag;<br>
+<br>
+    /* Bitstream restriction flag adds tiles_fixed_structure_flag,<br>
+     * motion_vectors_over_pic_boundaries_flag, restricted_ref_pic_lists_flag,<br>
+     * min_spatial_segmentation_idc, max_bytes_per_pic_denom,<br>
+     * max_bit_per_min_cu_denom, log2_max_mv_length_horizontal and<br>
+     * log2_max_mv_length_vertical to the VUI. All values are derived from<br>
+     * processing the input video.  The default is false.  */<br>
+    int       bEnableBitstreamRestrictionFlag;<br>
+<br>
+    /*== Hypothetical Reference Decoder Parameters ==*/<br>
+<br>
+    /* Sub pic HRD params present flag determines if tic_divisor_minus2,<br>
+     * du_cpb_removal_delay_increment_length_minus1,<br>
+     * sub_pic_cpb_params_in_pic_timing_sei_flag,<br>
+     * dpb_output_delay_du_length_minus1 and cpb_size_du_scale<br>
+     * are added to the HRD.  All are derived from processing the input video.<br>
+     * The default is false. */<br>
+    int       bEnableSubPicHrdParamsPresentFlag;<br>
+<br>
     /*== Internal Picture Specification ==*/<br>
<br>
     /* Internal encoder bit depth. If x265 was compiled to use 8bit pixels<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>