LCOV - code coverage report
Current view: top level - gfx/ycbcr - yuv_row_c.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 77 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2010 The Chromium Authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "yuv_row.h"
       6             : 
       7             : #define DCHECK(a)
       8             : 
       9             : extern "C" {
      10             : 
      11             : // C reference code that mimic the YUV assembly.
      12             : #define packuswb(x) ((x) < 0 ? 0 : ((x) > 255 ? 255 : (x)))
      13             : #define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \
      14             :     (((x) + (y)) > 32767 ? 32767 : ((x) + (y))))
      15             : 
      16           0 : static inline void YuvPixel(uint8 y,
      17             :                             uint8 u,
      18             :                             uint8 v,
      19             :                             uint8* rgb_buf) {
      20             : 
      21           0 :   int b = kCoefficientsRgbY[256+u][0];
      22           0 :   int g = kCoefficientsRgbY[256+u][1];
      23           0 :   int r = kCoefficientsRgbY[256+u][2];
      24           0 :   int a = kCoefficientsRgbY[256+u][3];
      25             : 
      26           0 :   b = paddsw(b, kCoefficientsRgbY[512+v][0]);
      27           0 :   g = paddsw(g, kCoefficientsRgbY[512+v][1]);
      28           0 :   r = paddsw(r, kCoefficientsRgbY[512+v][2]);
      29           0 :   a = paddsw(a, kCoefficientsRgbY[512+v][3]);
      30             : 
      31           0 :   b = paddsw(b, kCoefficientsRgbY[y][0]);
      32           0 :   g = paddsw(g, kCoefficientsRgbY[y][1]);
      33           0 :   r = paddsw(r, kCoefficientsRgbY[y][2]);
      34           0 :   a = paddsw(a, kCoefficientsRgbY[y][3]);
      35             : 
      36           0 :   b >>= 6;
      37           0 :   g >>= 6;
      38           0 :   r >>= 6;
      39           0 :   a >>= 6;
      40             : 
      41           0 :   *reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b)) |
      42           0 :                                         (packuswb(g) << 8) |
      43           0 :                                         (packuswb(r) << 16) |
      44           0 :                                         (packuswb(a) << 24);
      45           0 : }
      46             : 
      47           0 : void FastConvertYUVToRGB32Row_C(const uint8* y_buf,
      48             :                                 const uint8* u_buf,
      49             :                                 const uint8* v_buf,
      50             :                                 uint8* rgb_buf,
      51             :                                 int width,
      52             :                                 unsigned int x_shift) {
      53           0 :   for (int x = 0; x < width; x += 2) {
      54           0 :     uint8 u = u_buf[x >> x_shift];
      55           0 :     uint8 v = v_buf[x >> x_shift];
      56           0 :     uint8 y0 = y_buf[x];
      57           0 :     YuvPixel(y0, u, v, rgb_buf);
      58           0 :     if ((x + 1) < width) {
      59           0 :       uint8 y1 = y_buf[x + 1];
      60           0 :       if (x_shift == 0) {
      61           0 :         u = u_buf[x + 1];
      62           0 :         v = v_buf[x + 1];
      63             :       }
      64           0 :       YuvPixel(y1, u, v, rgb_buf + 4);
      65             :     }
      66           0 :     rgb_buf += 8;  // Advance 2 pixels.
      67             :   }
      68           0 : }
      69             : 
      70             : // 16.16 fixed point is used.  A shift by 16 isolates the integer.
      71             : // A shift by 17 is used to further subsample the chrominence channels.
      72             : // & 0xffff isolates the fixed point fraction.  >> 2 to get the upper 2 bits,
      73             : // for 1/65536 pixel accurate interpolation.
      74           0 : void ScaleYUVToRGB32Row_C(const uint8* y_buf,
      75             :                           const uint8* u_buf,
      76             :                           const uint8* v_buf,
      77             :                           uint8* rgb_buf,
      78             :                           int width,
      79             :                           int source_dx) {
      80           0 :   int x = 0;
      81           0 :   for (int i = 0; i < width; i += 2) {
      82           0 :     int y = y_buf[x >> 16];
      83           0 :     int u = u_buf[(x >> 17)];
      84           0 :     int v = v_buf[(x >> 17)];
      85           0 :     YuvPixel(y, u, v, rgb_buf);
      86           0 :     x += source_dx;
      87           0 :     if ((i + 1) < width) {
      88           0 :       y = y_buf[x >> 16];
      89           0 :       YuvPixel(y, u, v, rgb_buf+4);
      90           0 :       x += source_dx;
      91             :     }
      92           0 :     rgb_buf += 8;
      93             :   }
      94           0 : }
      95             : 
      96           0 : void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
      97             :                                 const uint8* u_buf,
      98             :                                 const uint8* v_buf,
      99             :                                 uint8* rgb_buf,
     100             :                                 int width,
     101             :                                 int source_dx) {
     102           0 :   int x = 0;
     103           0 :   if (source_dx >= 0x20000) {
     104           0 :     x = 32768;
     105             :   }
     106           0 :   for (int i = 0; i < width; i += 2) {
     107           0 :     int y0 = y_buf[x >> 16];
     108           0 :     int y1 = y_buf[(x >> 16) + 1];
     109           0 :     int u0 = u_buf[(x >> 17)];
     110           0 :     int u1 = u_buf[(x >> 17) + 1];
     111           0 :     int v0 = v_buf[(x >> 17)];
     112           0 :     int v1 = v_buf[(x >> 17) + 1];
     113           0 :     int y_frac = (x & 65535);
     114           0 :     int uv_frac = ((x >> 1) & 65535);
     115           0 :     int y = (y_frac * y1 + (y_frac ^ 65535) * y0) >> 16;
     116           0 :     int u = (uv_frac * u1 + (uv_frac ^ 65535) * u0) >> 16;
     117           0 :     int v = (uv_frac * v1 + (uv_frac ^ 65535) * v0) >> 16;
     118           0 :     YuvPixel(y, u, v, rgb_buf);
     119           0 :     x += source_dx;
     120           0 :     if ((i + 1) < width) {
     121           0 :       y0 = y_buf[x >> 16];
     122           0 :       y1 = y_buf[(x >> 16) + 1];
     123           0 :       y_frac = (x & 65535);
     124           0 :       y = (y_frac * y1 + (y_frac ^ 65535) * y0) >> 16;
     125           0 :       YuvPixel(y, u, v, rgb_buf+4);
     126           0 :       x += source_dx;
     127             :     }
     128           0 :     rgb_buf += 8;
     129             :   }
     130           0 : }
     131             : 
     132             : }  // extern "C"
     133             : 

Generated by: LCOV version 1.13