[x265] [PATCH] vui: Fix discard-vui to only remove optional VUI information

Pradeep Ramachandran pradeep at multicorewareinc.com
Tue Sep 20 06:23:55 CEST 2016


# HG changeset patch
# User Pradeep Ramachandran <pradeep at multicorewareinc.com>
# Date 1474345427 -19800
#      Tue Sep 20 09:53:47 2016 +0530
# Node ID f29d88d93c2c23802bf4f99f923afc0e411de71f
# Parent  f837dee98769a8461ea202125eb6655038e25705
vui: Fix discard-vui to only remove optional VUI information

diff -r f837dee98769 -r f29d88d93c2c doc/reST/cli.rst
--- a/doc/reST/cli.rst	Mon Sep 19 17:46:55 2016 +0530
+++ b/doc/reST/cli.rst	Tue Sep 20 09:53:47 2016 +0530
@@ -1842,7 +1842,8 @@
 	
 .. option:: --discard-vui
 
-	Discard VUI information from the bitstream. Default disabled.
+	Discard optional VUI information (timing, HRD info) from the
+	bitstream. Default disabled.
 
 Debugging options
 =================
diff -r f837dee98769 -r f29d88d93c2c source/CMakeLists.txt
--- a/source/CMakeLists.txt	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/CMakeLists.txt	Tue Sep 20 09:53:47 2016 +0530
@@ -30,7 +30,7 @@
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 94)
+set(X265_BUILD 95)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r f837dee98769 -r f29d88d93c2c source/common/param.cpp
--- a/source/common/param.cpp	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/common/param.cpp	Tue Sep 20 09:53:47 2016 +0530
@@ -229,7 +229,7 @@
     param->rc.qpMin = 0;
     param->rc.qpMax = QP_MAX_MAX;
 
-    param->bDiscardVUI = 0;
+    param->bDiscardOptionalVUI = 0;
 
     /* Video Usability Information (VUI) */
     param->vui.aspectRatioIdc = 0;
@@ -915,7 +915,7 @@
         OPT("analyze-src-pics") p->bSourceReferenceEstimation = atobool(value);
         OPT("log2-max-poc-lsb") p->log2MaxPocLsb = atoi(value);
         OPT("discard-sei") p->bDiscardSEI = atobool(value);
-        OPT("discard-vui") p->bDiscardVUI = atobool(value);
+        OPT("discard-vui") p->bDiscardOptionalVUI = atobool(value);
         else
             return X265_PARAM_BAD_NAME;
     }
diff -r f837dee98769 -r f29d88d93c2c source/common/slice.h
--- a/source/common/slice.h	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/common/slice.h	Tue Sep 20 09:53:47 2016 +0530
@@ -243,7 +243,7 @@
     bool     bUseAMP; // use param
     bool     bUseStrongIntraSmoothing; // use param
     bool     bTemporalMVPEnabled;
-    bool     bDiscardVUI;
+    bool     bDiscardOptionalVUI;
 
     Window   conformanceWindow;
     VUI      vuiParameters;
diff -r f837dee98769 -r f29d88d93c2c source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/encoder/encoder.cpp	Tue Sep 20 09:53:47 2016 +0530
@@ -1543,7 +1543,7 @@
 
     sps->bUseStrongIntraSmoothing = m_param->bEnableStrongIntraSmoothing;
     sps->bTemporalMVPEnabled = m_param->bEnableTemporalMvp;
-    sps->bDiscardVUI = m_param->bDiscardVUI;
+    sps->bDiscardOptionalVUI = m_param->bDiscardOptionalVUI;
     sps->log2MaxPocLsb = m_param->log2MaxPocLsb;
     int maxDeltaPOC = (m_param->bframes + 2) * (!!m_param->bBPyramid + 1) * 2;
     while ((1 << sps->log2MaxPocLsb) <= maxDeltaPOC * 2)
diff -r f837dee98769 -r f29d88d93c2c source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/encoder/entropy.cpp	Tue Sep 20 09:53:47 2016 +0530
@@ -318,15 +318,8 @@
     WRITE_FLAG(sps.bTemporalMVPEnabled, "sps_temporal_mvp_enable_flag");
     WRITE_FLAG(sps.bUseStrongIntraSmoothing, "sps_strong_intra_smoothing_enable_flag");
 
-    if (sps.bDiscardVUI)
-    {
-        WRITE_FLAG(0, "vui_parameters_present_flag");
-    }
-    else
-    {
-        WRITE_FLAG(1, "vui_parameters_present_flag");
-        codeVUI(sps.vuiParameters, sps.maxTempSubLayers);
-    }
+    WRITE_FLAG(1, "vui_parameters_present_flag");
+    codeVUI(sps.vuiParameters, sps.maxTempSubLayers, sps.bDiscardOptionalVUI);
 
     WRITE_FLAG(0, "sps_extension_flag");
 }
@@ -429,65 +422,75 @@
     }
 }
 
-void Entropy::codeVUI(const VUI& vui, int maxSubTLayers)
+void Entropy::codeVUI(const VUI& vui, int maxSubTLayers, bool bDiscardOptionalVUI)
 {
-    WRITE_FLAG(vui.aspectRatioInfoPresentFlag,  "aspect_ratio_info_present_flag");
+    WRITE_FLAG(vui.aspectRatioInfoPresentFlag, "aspect_ratio_info_present_flag");
     if (vui.aspectRatioInfoPresentFlag)
     {
-        WRITE_CODE(vui.aspectRatioIdc, 8,       "aspect_ratio_idc");
+        WRITE_CODE(vui.aspectRatioIdc, 8, "aspect_ratio_idc");
         if (vui.aspectRatioIdc == 255)
         {
-            WRITE_CODE(vui.sarWidth, 16,        "sar_width");
-            WRITE_CODE(vui.sarHeight, 16,       "sar_height");
+            WRITE_CODE(vui.sarWidth, 16, "sar_width");
+            WRITE_CODE(vui.sarHeight, 16, "sar_height");
         }
     }
 
-    WRITE_FLAG(vui.overscanInfoPresentFlag,     "overscan_info_present_flag");
+    WRITE_FLAG(vui.overscanInfoPresentFlag, "overscan_info_present_flag");
     if (vui.overscanInfoPresentFlag)
         WRITE_FLAG(vui.overscanAppropriateFlag, "overscan_appropriate_flag");
 
-    WRITE_FLAG(vui.videoSignalTypePresentFlag,  "video_signal_type_present_flag");
+    WRITE_FLAG(vui.videoSignalTypePresentFlag, "video_signal_type_present_flag");
     if (vui.videoSignalTypePresentFlag)
     {
-        WRITE_CODE(vui.videoFormat, 3,          "video_format");
-        WRITE_FLAG(vui.videoFullRangeFlag,      "video_full_range_flag");
+        WRITE_CODE(vui.videoFormat, 3, "video_format");
+        WRITE_FLAG(vui.videoFullRangeFlag, "video_full_range_flag");
         WRITE_FLAG(vui.colourDescriptionPresentFlag, "colour_description_present_flag");
         if (vui.colourDescriptionPresentFlag)
         {
-            WRITE_CODE(vui.colourPrimaries, 8,         "colour_primaries");
+            WRITE_CODE(vui.colourPrimaries, 8, "colour_primaries");
             WRITE_CODE(vui.transferCharacteristics, 8, "transfer_characteristics");
-            WRITE_CODE(vui.matrixCoefficients, 8,      "matrix_coefficients");
+            WRITE_CODE(vui.matrixCoefficients, 8, "matrix_coefficients");
         }
     }
 
-    WRITE_FLAG(vui.chromaLocInfoPresentFlag,           "chroma_loc_info_present_flag");
+    WRITE_FLAG(vui.chromaLocInfoPresentFlag, "chroma_loc_info_present_flag");
     if (vui.chromaLocInfoPresentFlag)
     {
-        WRITE_UVLC(vui.chromaSampleLocTypeTopField,    "chroma_sample_loc_type_top_field");
+        WRITE_UVLC(vui.chromaSampleLocTypeTopField, "chroma_sample_loc_type_top_field");
         WRITE_UVLC(vui.chromaSampleLocTypeBottomField, "chroma_sample_loc_type_bottom_field");
     }
 
-    WRITE_FLAG(0,                                     "neutral_chroma_indication_flag");
-    WRITE_FLAG(vui.fieldSeqFlag,                      "field_seq_flag");
-    WRITE_FLAG(vui.frameFieldInfoPresentFlag,         "frame_field_info_present_flag");
-
-    WRITE_FLAG(vui.defaultDisplayWindow.bEnabled,    "default_display_window_flag");
+    WRITE_FLAG(0, "neutral_chroma_indication_flag");
+    WRITE_FLAG(vui.fieldSeqFlag, "field_seq_flag");
+    WRITE_FLAG(vui.frameFieldInfoPresentFlag, "frame_field_info_present_flag");
+
+    WRITE_FLAG(vui.defaultDisplayWindow.bEnabled, "default_display_window_flag");
     if (vui.defaultDisplayWindow.bEnabled)
     {
-        WRITE_UVLC(vui.defaultDisplayWindow.leftOffset,   "def_disp_win_left_offset");
-        WRITE_UVLC(vui.defaultDisplayWindow.rightOffset,  "def_disp_win_right_offset");
-        WRITE_UVLC(vui.defaultDisplayWindow.topOffset,    "def_disp_win_top_offset");
+        WRITE_UVLC(vui.defaultDisplayWindow.leftOffset, "def_disp_win_left_offset");
+        WRITE_UVLC(vui.defaultDisplayWindow.rightOffset, "def_disp_win_right_offset");
+        WRITE_UVLC(vui.defaultDisplayWindow.topOffset, "def_disp_win_top_offset");
         WRITE_UVLC(vui.defaultDisplayWindow.bottomOffset, "def_disp_win_bottom_offset");
     }
 
-    WRITE_FLAG(1,                                 "vui_timing_info_present_flag");
-    WRITE_CODE(vui.timingInfo.numUnitsInTick, 32, "vui_num_units_in_tick");
-    WRITE_CODE(vui.timingInfo.timeScale, 32,      "vui_time_scale");
-    WRITE_FLAG(0,                                 "vui_poc_proportional_to_timing_flag");
-
-    WRITE_FLAG(vui.hrdParametersPresentFlag,  "vui_hrd_parameters_present_flag");
-    if (vui.hrdParametersPresentFlag)
-        codeHrdParameters(vui.hrdParameters, maxSubTLayers);
+    if (bDiscardOptionalVUI)
+        WRITE_FLAG(0, "vui_timing_info_present_flag");
+    else
+    {
+        WRITE_FLAG(1, "vui_timing_info_present_flag");
+        WRITE_CODE(vui.timingInfo.numUnitsInTick, 32, "vui_num_units_in_tick");
+        WRITE_CODE(vui.timingInfo.timeScale, 32, "vui_time_scale");
+        WRITE_FLAG(0, "vui_poc_proportional_to_timing_flag");
+    }
+
+    if (bDiscardOptionalVUI)
+        WRITE_FLAG(0, "vui_hrd_parameters_present_flag");
+    else
+    {
+        WRITE_FLAG(vui.hrdParametersPresentFlag, "vui_hrd_parameters_present_flag");
+        if (vui.hrdParametersPresentFlag)
+            codeHrdParameters(vui.hrdParameters, maxSubTLayers);
+    }
 
     WRITE_FLAG(0, "bitstream_restriction_flag");
 }
diff -r f837dee98769 -r f29d88d93c2c source/encoder/entropy.h
--- a/source/encoder/entropy.h	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/encoder/entropy.h	Tue Sep 20 09:53:47 2016 +0530
@@ -143,7 +143,7 @@
     void codeVPS(const VPS& vps);
     void codeSPS(const SPS& sps, const ScalingList& scalingList, const ProfileTierLevel& ptl);
     void codePPS(const PPS& pps, bool filerAcross);
-    void codeVUI(const VUI& vui, int maxSubTLayers);
+    void codeVUI(const VUI& vui, int maxSubTLayers, bool discardOptionalVUI);
     void codeAUD(const Slice& slice);
     void codeHrdParameters(const HRDInfo& hrd, int maxSubTLayers);
 
diff -r f837dee98769 -r f29d88d93c2c source/x265.h
--- a/source/x265.h	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/x265.h	Tue Sep 20 09:53:47 2016 +0530
@@ -1303,8 +1303,8 @@
     /* Dicard SEI messages when printing */
     int bDiscardSEI;
     
-    /* Control remove vui information to get low bitrate */
-    int       bDiscardVUI;
+    /* Control removing optional vui information (timing, HRD info) to get low bitrate */
+    int       bDiscardOptionalVUI;
 
     /* Maximum count of Slices of picture, the value range is [1, maximum rows] */
     unsigned int maxSlices;
diff -r f837dee98769 -r f29d88d93c2c source/x265cli.h
--- a/source/x265cli.h	Mon Sep 19 17:46:55 2016 +0530
+++ b/source/x265cli.h	Tue Sep 20 09:53:47 2016 +0530
@@ -449,7 +449,7 @@
     H1("   --hash <integer>              Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI);
     H0("   --log2-max-poc-lsb <integer>  Maximum of the picture order count\n");
     H0("   --discard-sei                 Discard SEI packets in bitstream. Default %s\n", OPT(param->bDiscardSEI));
-    H0("   --discard-vui                 Discard VUI information from the bistream. Default %s\n", OPT(param->bDiscardVUI));
+    H0("   --discard-vui                 Discard optional VUI information from the bistream. Default %s\n", OPT(param->bDiscardOptionalVUI));
     H1("\nReconstructed video options (debugging):\n");
     H1("-r/--recon <filename>            Reconstructed raw image YUV or Y4M output file name\n");
     H1("   --recon-depth <integer>       Bit-depth of reconstructed raw image file. Defaults to input bit depth, or 8 if Y4M\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repo.patch
Type: text/x-patch
Size: 11463 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160920/84ba89ca/attachment-0001.bin>


More information about the x265-devel mailing list