[x265] uhd-bd: Clarifications to level and tier determination

Deepthi Nandakumar deepthi at multicorewareinc.com
Fri Jun 3 08:36:35 CEST 2016


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1464935525 -19800
#      Fri Jun 03 12:02:05 2016 +0530
# Node ID 91de20bfe2affa6e225681be129208e654c2ba48
# Parent  e00b80fe105e30e2ac8927e441db45111eb734ad
uhd-bd: Clarifications to level and tier determination

diff -r e00b80fe105e -r 91de20bfe2af source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Jun 03 06:20:37 2016 +0200
+++ b/source/encoder/encoder.cpp Fri Jun 03 12:02:05 2016 +0530
@@ -1884,6 +1884,19 @@
         p->vui.aspectRatioIdc = 1;
         p->bEmitHRDSEI = 1;
         int disableUhdBd = 0;
+
+        if (p->levelIdc && p->levelIdc != 51)
+        {
+            x265_log(p, X265_LOG_WARNING, "uhd-bd: Wrong level specified,
UHD Bluray mandates Level 5.1\n");
+        }
+        p->levelIdc = 51;
+
+        if (!p->bHighTier)
+        {
+            x265_log(p, X265_LOG_WARNING, "uhd-bd: Turning on high
tier\n");
+            p->bHighTier = 1;
+        }
+
         if (!p->bRepeatHeaders)
         {
             x265_log(p, X265_LOG_WARNING, "uhd-bd: Turning on
repeat-headers\n");
diff -r e00b80fe105e -r 91de20bfe2af source/encoder/level.cpp
--- a/source/encoder/level.cpp Fri Jun 03 06:20:37 2016 +0200
+++ b/source/encoder/level.cpp Fri Jun 03 12:02:05 2016 +0530
@@ -131,33 +131,33 @@
         vps.ptl.levelIdc = Level::LEVEL8_5;
         vps.ptl.tierFlag = Level::MAIN;
     }
+    else if (param.uhdBluray)
+    {
+        i = 8;
+        vps.ptl.levelIdc = levels[i].levelEnum;
+        vps.ptl.tierFlag = Level::HIGH;
+        vps.ptl.minCrForLevel = levels[i].minCompressionRatio;
+        vps.ptl.maxLumaSrForLevel = levels[i].maxLumaSamplesPerSecond;
+    }
     else for (i = 0; i < NumLevels; i++)
     {
-        if (param.uhdBluray && levels[i].levelIdc != 51)
-        {
+        if (lumaSamples > levels[i].maxLumaSamples)
             continue;
-        }
-        else if (!param.uhdBluray)
-        {
-            if (lumaSamples > levels[i].maxLumaSamples)
-                continue;
-            else if (samplesPerSec > levels[i].maxLumaSamplesPerSecond)
-                continue;
-            else if (bitrate > levels[i].maxBitrateMain &&
levels[i].maxBitrateHigh == MAX_UINT)
-                continue;
-            else if (bitrate > levels[i].maxBitrateHigh)
-                continue;
-            else if (param.sourceWidth > sqrt(levels[i].maxLumaSamples *
8.0f))
-                continue;
-            else if (param.sourceHeight > sqrt(levels[i].maxLumaSamples *
8.0f))
-                continue;
-            else if (param.levelIdc && param.levelIdc !=
levels[i].levelIdc)
-                continue;
-        }
+        else if (samplesPerSec > levels[i].maxLumaSamplesPerSecond)
+            continue;
+        else if (bitrate > levels[i].maxBitrateMain &&
levels[i].maxBitrateHigh == MAX_UINT)
+            continue;
+        else if (bitrate > levels[i].maxBitrateHigh)
+            continue;
+        else if (param.sourceWidth > sqrt(levels[i].maxLumaSamples * 8.0f))
+            continue;
+        else if (param.sourceHeight > sqrt(levels[i].maxLumaSamples *
8.0f))
+            continue;
+        else if (param.levelIdc && param.levelIdc != levels[i].levelIdc)
+            continue;
         uint32_t maxDpbSize = MaxDpbPicBuf;
-        if (param.uhdBluray)
-            maxDpbSize = 6;
-        else if (lumaSamples <= (levels[i].maxLumaSamples >> 2))
+
+        if (lumaSamples <= (levels[i].maxLumaSamples >> 2))
             maxDpbSize = X265_MIN(4 * MaxDpbPicBuf, 16);
         else if (lumaSamples <= (levels[i].maxLumaSamples >> 1))
             maxDpbSize = X265_MIN(2 * MaxDpbPicBuf, 16);
@@ -209,8 +209,6 @@
         else
             vps.ptl.tierFlag = Level::MAIN;
 #undef CHECK_RANGE
-        if (param.uhdBluray)
-            vps.ptl.tierFlag = Level::HIGH;

         vps.ptl.levelIdc = levels[i].levelEnum;
         vps.ptl.minCrForLevel = levels[i].minCompressionRatio;
@@ -381,12 +379,15 @@
     /* The value of sps_max_dec_pic_buffering_minus1[ HighestTid ] + 1
shall be less than or equal to MaxDpbSize */
     const uint32_t MaxDpbPicBuf = 6;
     uint32_t maxDpbSize = MaxDpbPicBuf;
-    if (lumaSamples <= (l.maxLumaSamples >> 2))
-        maxDpbSize = X265_MIN(4 * MaxDpbPicBuf, 16);
-    else if (lumaSamples <= (l.maxLumaSamples >> 1))
-        maxDpbSize = X265_MIN(2 * MaxDpbPicBuf, 16);
-    else if (lumaSamples <= ((3 * l.maxLumaSamples) >> 2))
-        maxDpbSize = X265_MIN((4 * MaxDpbPicBuf) / 3, 16);
+    if (!param.uhdBluray) /* Do not change MaxDpbPicBuf for UHD-Bluray */
+    {
+        if (lumaSamples <= (l.maxLumaSamples >> 2))
+            maxDpbSize = X265_MIN(4 * MaxDpbPicBuf, 16);
+        else if (lumaSamples <= (l.maxLumaSamples >> 1))
+            maxDpbSize = X265_MIN(2 * MaxDpbPicBuf, 16);
+        else if (lumaSamples <= ((3 * l.maxLumaSamples) >> 2))
+            maxDpbSize = X265_MIN((4 * MaxDpbPicBuf) / 3, 16);
+    }

     int savedRefCount = param.maxNumReferences;
     while (vps.maxDecPicBuffering > maxDpbSize && param.maxNumReferences >
1)


-- 
Deepthi Nandakumar
Engineering Manager, x265
Multicoreware, Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160603/f6235c32/attachment.html>


More information about the x265-devel mailing list