<div dir="ltr"><div># HG changeset patch</div><div># User Deepthi Nandakumar <<a href="mailto:deepthi@multicorewareinc.com">deepthi@multicorewareinc.com</a>></div><div># Date 1456988948 -19800</div><div># Thu Mar 03 12:39:08 2016 +0530</div><div># Node ID 8e99beacb197e4a0e9a85f4b7ff2a9df4e5bfaac</div><div># Parent 9cc9920bf82be1b43efd2a3628e28a3a78ab3b2f</div><div>calcHDRStats: cleanup, remove bug related to min/max luma</div><div><br></div><div>diff -r 9cc9920bf82b -r 8e99beacb197 source/common/picyuv.cpp</div><div>--- a/source/common/picyuv.cpp<span class="" style="white-space:pre"> </span>Wed Mar 02 17:26:11 2016 +0530</div><div>+++ b/source/common/picyuv.cpp<span class="" style="white-space:pre"> </span>Thu Mar 03 12:39:08 2016 +0530</div><div>@@ -48,6 +48,8 @@</div><div> m_avgLumaLevel = 0;</div><div> m_stride = 0;</div><div> m_strideC = 0;</div><div>+ m_hChromaShift = 0;</div><div>+ m_vChromaShift = 0;</div><div> }</div><div> </div><div> bool PicYuv::create(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp)</div><div>diff -r 9cc9920bf82b -r 8e99beacb197 source/common/pixel.cpp</div><div>--- a/source/common/pixel.cpp<span class="" style="white-space:pre"> </span>Wed Mar 02 17:26:11 2016 +0530</div><div>+++ b/source/common/pixel.cpp<span class="" style="white-space:pre"> </span>Thu Mar 03 12:39:08 2016 +0530</div><div>@@ -880,75 +880,50 @@</div><div> uint64_t sumLuma = 0;</div><div> pixel rgb[3];</div><div> </div><div>- if (!hShift && !vShift) /* YUV444 */</div><div>+ for (int r = 0; r < height >> vShift; r++)</div><div> {</div><div>- for (int r = 0; r < height; r++)</div><div>+ for (int c = 0; c < width >> hShift; c++)</div><div> {</div><div>- for (int c = 0; c < width; c++)</div><div>+ pixel y, cb, cr;</div><div>+ /* Clip luma of source picture to max and min, only if they are specified. Average luma values for RGB conversions */</div><div>+ if (!hShift && !vShift) /* YUV444 */</div><div> {</div><div>- /* Clip luma of source picture to max and min */</div><div>- srcY[c] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[c]);</div><div>-</div><div>- /* Rec 2020 Yuv to RGB */</div><div>- for (int i = 0; i < 3; i++)</div><div>- rgb[i] = (pixel) (srcY[c] * g_YUVtoRGB_BT2020[i][0] + srcU[c] * g_YUVtoRGB_BT2020[i][1] + srcV[c] * g_YUVtoRGB_BT2020[i][2]);</div><div>- /* maxCLL and maxFALL */</div><div>- maxLumaLevel = X265_MAX(maxLumaLevel, X265_MAX(rgb[0], X265_MAX(rgb[1], rgb[2])));</div><div>- sumLuma += maxLumaLevel;</div><div>+ y = srcY[c] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[c]) : X265_MAX(minPix, srcY[c]);</div><div>+ cb = srcU[c]; cr = srcV[c];</div><div> }</div><div>- srcY += stride; srcU += strideC; srcV += strideC;</div><div>+ else if (hShift && !vShift) /* YUV422 */</div><div>+ {</div><div>+ srcY[2*c] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c]) : X265_MAX(minPix, srcY[2*c]);</div><div>+ srcY[2*c + 1] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c + 1]) : X265_MAX(minPix, srcY[2*c + 1]);</div><div>+ y = (srcY[2*c] + srcY[2*c + 1]) >> 1;</div><div>+ cb = srcU[c]; cr = srcV[c];</div><div>+ }</div><div>+ else if (hShift && vShift) /* YUV420 */</div><div>+ {</div><div>+ srcY[2*c] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c]) : X265_MAX(minPix, srcY[2*c]);</div><div>+ srcY[2*c + 1] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c + 1]) : X265_MAX(minPix, srcY[2*c + 1]);</div><div>+ srcY[stride + 2*c] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[stride + 2*c]) : X265_MAX(minPix, srcY[stride + 2*c]);</div><div>+ srcY[stride + 2*c + 1] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[stride + 2*c + 1]) : X265_MAX(minPix, srcY[stride + 2*c + 1]);</div><div>+ y = (srcY[2*c] + srcY[2*c + 1] + srcY[stride + 2*c] + srcY[stride + 2*c + 1]) >> 2;</div><div>+ cb = srcU[c]; cr = srcV[c];</div><div>+ }</div><div>+ else if (!strideC) /* YUV400 */</div><div>+ {</div><div>+ y = srcY[c] = maxPix ? x265_clip3((pixel)minPix, (pixel)maxPix, srcY[c]) : X265_MAX(minPix, srcY[c]);</div><div>+ cb = cr = 0;</div><div>+ }</div><div>+ /* Rec 2020 Yuv to RGB */</div><div>+ for (int i = 0; i < 3; i++)</div><div>+ rgb[i] = (pixel) (y * g_YUVtoRGB_BT2020[i][0] + cb * g_YUVtoRGB_BT2020[i][1] + cr * g_YUVtoRGB_BT2020[i][2]);</div><div>+ /* maxCLL and maxFALL */</div><div>+ maxLumaLevel = X265_MAX(maxLumaLevel, X265_MAX(rgb[0], X265_MAX(rgb[1], rgb[2])));</div><div>+ sumLuma += maxLumaLevel;</div><div> }</div><div>- }</div><div>- else if (hShift && !vShift) /* YUV422 */</div><div>- {</div><div>- for (int r = 0; r < height; r++)</div><div>+ srcY += stride << vShift; </div><div>+ if (strideC)</div><div> {</div><div>- for (int c = 0; c < width >> hShift; c++)</div><div>- {</div><div>- srcY[2*c] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c]);</div><div>- srcY[2*c + 1] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c + 1]);</div><div>- pixel y = (srcY[2*c] + srcY[2*c + 1]) >> 1;</div><div>- for (int i = 0; i < 3; i++)</div><div>- rgb[i] = (pixel)(y * g_YUVtoRGB_BT2020[i][0] + srcU[c] * g_YUVtoRGB_BT2020[i][1] + srcV[c] * g_YUVtoRGB_BT2020[i][2]);</div><div>- maxLumaLevel = X265_MAX(maxLumaLevel, X265_MAX(rgb[0], X265_MAX(rgb[1], rgb[2])));</div><div>- sumLuma += maxLumaLevel;</div><div>- }</div><div>- srcY += stride; srcU += strideC; srcV += strideC;</div><div>- }</div><div>- }</div><div>- else if (hShift && vShift) /* YUV420 */</div><div>- {</div><div>- for (int r = 0; r < height >> vShift; r++)</div><div>- {</div><div>- for (int c = 0; c < width >> vShift; c++)</div><div>- {</div><div>- srcY[2*c] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c]);</div><div>- srcY[2*c + 1] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[2*c + 1]);</div><div>- srcY[stride + 2*c] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[stride + 2*c]);</div><div>- srcY[stride + 2*c + 1] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[stride + 2*c + 1]);</div><div>- pixel y = (srcY[2*c] + srcY[2*c + 1] + srcY[stride + 2*c] + srcY[stride + 2*c + 1]) >> 2;</div><div>- for (int i = 0; i < 3; i++)</div><div>- rgb[i] = (pixel) (y * g_YUVtoRGB_BT2020[i][0] + srcU[c] * g_YUVtoRGB_BT2020[i][1] + srcV[c] * g_YUVtoRGB_BT2020[i][2]);</div><div>- maxLumaLevel = X265_MAX(maxLumaLevel, X265_MAX(rgb[0], X265_MAX(rgb[1], rgb[2])));</div><div>- sumLuma += maxLumaLevel;</div><div>- }</div><div>- srcY += (stride << 1); srcU += strideC; srcV += strideC;</div><div>- }</div><div>- }</div><div>- else if (!strideC) /* YUV400 */</div><div>- {</div><div>- for (int r = 0; r < height; r++)</div><div>- {</div><div>- for (int c = 0; c < width; c++)</div><div>- {</div><div>- srcY[c] = x265_clip3((pixel)minPix, (pixel)maxPix, srcY[c]);</div><div>- for (int i = 0; i < 3; i++)</div><div>- rgb[i] = (pixel) (srcY[c] * g_YUVtoRGB_BT2020[i][0]);</div><div>- /* maxCLL and maxFALL */</div><div>- maxLumaLevel = X265_MAX(maxLumaLevel, X265_MAX(rgb[0], X265_MAX(rgb[1], rgb[2])));</div><div>- sumLuma += maxLumaLevel;</div><div>- }</div><div>- srcY += stride;</div><div>+ srcU += strideC;</div><div>+ srcV += strideC;</div><div> }</div><div> }</div><div> *outsum = sumLuma;</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>