[x265] [PATCH] Modify FrameEncoder structure to support multiple color space formats

ashok at multicorewareinc.com ashok at multicorewareinc.com
Fri Dec 20 15:05:00 CET 2013


# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1387548286 -19800
#      Fri Dec 20 19:34:46 2013 +0530
# Node ID 26a1066e7fbbf37d7a9b9780002177e4c89cac09
# Parent  c17ea1b9325b6aa88f7bb4b3293abac395ed07f4
Modify FrameEncoder structure to support multiple color space formats

diff -r c17ea1b9325b -r 26a1066e7fbb source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri Dec 20 19:33:49 2013 +0530
+++ b/source/encoder/encoder.cpp	Fri Dec 20 19:34:46 2013 +0530
@@ -746,6 +746,17 @@
         log2MinCUSize++;
     }
 
+    int chromaFormat = param.sourceCsp >= X265_CSP_I444 ? CHROMA_444 :
+                       param.sourceCsp >= X265_CSP_I422 ? CHROMA_422 : CHROMA_420;
+
+    sps->setChromaFormatIdc(chromaFormat);
+
+    if (chromaFormat == CHROMA_444)
+    {
+        //in this version separate_color_plane_flag is set to 0
+        sps->setSeparateColorPlaneFlag(0);
+    }
+
     sps->setLog2MinCodingBlockSize(log2MinCUSize);
     sps->setLog2DiffMaxMinCodingBlockSize(sps->getMaxCUDepth() - g_addCUDepth);
 
diff -r c17ea1b9325b -r 26a1066e7fbb source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Fri Dec 20 19:33:49 2013 +0530
+++ b/source/encoder/frameencoder.cpp	Fri Dec 20 19:34:46 2013 +0530
@@ -331,11 +331,11 @@
     // instead we weight the distortion of chroma.
     int chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb();
     int qpc = Clip3(0, 57, qp + chromaQPOffset);
-    double cbWeight = pow(2.0, (qp - g_chromaScale[qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
+    double cbWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
 
     chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr();
     qpc = Clip3(0, 57, qp + chromaQPOffset);
-    double crWeight = pow(2.0, (qp - g_chromaScale[qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
+    double crWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
     double chromaLambda = lambda / crWeight;
 
     m_rows[row].m_search.setQPLambda(qp, lambda, chromaLambda);
@@ -372,10 +372,10 @@
     int qpc;
     int chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb();
     qpc = Clip3(0, 57, qp + chromaQPOffset);
-    double cbWeight = pow(2.0, (qp - g_chromaScale[qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
+    double cbWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
     chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr();
     qpc = Clip3(0, 57, qp + chromaQPOffset);
-    double crWeight = pow(2.0, (qp - g_chromaScale[qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
+    double crWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset
     double chromaLambda = lambda / crWeight;
 
     TComPicYuv *fenc = slice->getPic()->getPicYuvOrg();


More information about the x265-devel mailing list