X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=ycbcr.cpp;h=277ea9c7b3a3de1c97cf95a51b1941661656bcbd;hb=4a35c01ed5407a3d9b9616f9d13e77970ee003ef;hp=08c8cd25d4603c43b092abe078b6d98815a466e9;hpb=54c233d62900640a60a25db95123a5fc37b95d66;p=movit diff --git a/ycbcr.cpp b/ycbcr.cpp index 08c8cd2..277ea9c 100644 --- a/ycbcr.cpp +++ b/ycbcr.cpp @@ -48,7 +48,12 @@ namespace movit { float compute_chroma_offset(float pos, unsigned subsampling_factor, unsigned resolution) { float local_chroma_pos = (0.5 + pos * (subsampling_factor - 1)) / subsampling_factor; - return (0.5 - local_chroma_pos) / resolution; + if (fabs(local_chroma_pos - 0.5) < 1e-10) { + // x + (-0) can be optimized away freely, as opposed to x + 0. + return -0.0; + } else { + return (0.5 - local_chroma_pos) / resolution; + } } // Given , compute the values needed to turn Y'CbCr into R'G'B';