[x265] [PATCH] tencsbac: WritePCMCode for Cb and Cr merged into single block

gopu at multicorewareinc.com gopu at multicorewareinc.com
Mon Mar 10 09:41:10 CET 2014


# HG changeset patch
# User Gopu Govindaswamy
# Date 1394440478 -19800
#      Mon Mar 10 14:04:38 2014 +0530
# Node ID 592b9b952a71f11b778fb4f8afadf86ff9c9a05c
# Parent  ba31dfc650d88afa937293a40fdaafd20c10c83e
tencsbac: WritePCMCode for Cb and Cr merged into single block

diff -r ba31dfc650d8 -r 592b9b952a71 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Mon Mar 10 12:14:41 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Mon Mar 10 14:04:38 2014 +0530
@@ -1261,7 +1261,7 @@
         int numZeroSubstreamsAtEndOfSlice = slice->getPic()->getFrameHeightInCU() - 1 - ((slice->getSliceCurEndCUAddr() - 1) / maxNumParts / slice->getPic()->getFrameWidthInCU());
         numEntryPointOffsets              = slice->getPic()->getFrameHeightInCU() - numZeroSubstreamsAtEndOfSlice - 1;
         slice->setNumEntryPointOffsets(numEntryPointOffsets);
-        entryPointOffset = new uint32_t[numEntryPointOffsets];
+        entryPointOffset = X265_MALLOC(uint32_t, numEntryPointOffsets);
         for (int idx = 0; idx < numEntryPointOffsets; idx++)
         {
             entryPointOffset[idx] = (substreamSizes[idx] >> 3);
@@ -1290,7 +1290,7 @@
         WRITE_CODE(entryPointOffset[idx] - 1, offsetLenMinus1 + 1, "entry_point_offset_minus1");
     }
 
-    delete [] entryPointOffset;
+    X265_FREE(entryPointOffset);
 }
 
 void TEncSbac::codeTerminatingBit(uint32_t lsLast)
@@ -1891,37 +1891,22 @@
             pcmSample += width;
         }
 
-        pcmSample = cu->getPCMSampleCb() + chromaOffset;
         width = cu->getCUSize(absPartIdx) / 2;
         height = cu->getCUSize(absPartIdx) / 2;
         sampleBits = cu->getSlice()->getSPS()->getPCMBitDepthChroma();
+        pixel* pcmSampleCb = cu->getPCMSampleCb() + chromaOffset;
+        pixel* pcmSampleCr = cu->getPCMSampleCr() + chromaOffset;
 
         for (y = 0; y < height; y++)
         {
             for (x = 0; x < width; x++)
             {
-                uint32_t sample = pcmSample[x];
-
-                m_binIf->xWritePCMCode(sample, sampleBits);
+                m_binIf->xWritePCMCode(pcmSampleCb[x], sampleBits);
+                m_binIf->xWritePCMCode(pcmSampleCr[x], sampleBits);
             }
-
-            pcmSample += width;
+            pcmSampleCb += width;
+            pcmSampleCr += width;
         }
-
-        pcmSample = cu->getPCMSampleCr() + chromaOffset;
-
-        for (y = 0; y < height; y++)
-        {
-            for (x = 0; x < width; x++)
-            {
-                uint32_t sample = pcmSample[x];
-
-                m_binIf->xWritePCMCode(sample, sampleBits);
-            }
-
-            pcmSample += width;
-        }
-
         m_binIf->resetBac();
     }
 }


More information about the x265-devel mailing list