LCOV - code coverage report
Current view: top level - C_DEFAULT - EbPackUnPack_C.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 70 0.0 %
Date: 2019-11-25 17:38:06 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /*
       2             : * Copyright(c) 2019 Intel Corporation
       3             : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
       4             : */
       5             : 
       6             : #include "EbPackUnPack_C.h"
       7             : #include "EbSvtAv1.h"
       8             : 
       9             : /************************************************
      10             : * pack 8 and 2 bit 2D data into 10 bit data
      11             : ************************************************/
      12           0 : void eb_enc_msb_pack2_d(
      13             :     uint8_t     *in8_bit_buffer,
      14             :     uint32_t     in8_stride,
      15             :     uint8_t     *inn_bit_buffer,
      16             :     uint16_t    *out16_bit_buffer,
      17             :     uint32_t     inn_stride,
      18             :     uint32_t     out_stride,
      19             :     uint32_t     width,
      20             :     uint32_t     height)
      21             : {
      22             :     uint64_t   j, k;
      23             :     uint16_t   outPixel;
      24             :     uint8_t    nBitPixel;
      25             : 
      26             :     //SIMD hint: use _mm_unpacklo_epi8 +_mm_unpackhi_epi8 to do the concatenation
      27             : 
      28           0 :     for (j = 0; j < height; j++)
      29             :     {
      30           0 :         for (k = 0; k < width; k++)
      31             :         {
      32           0 :             outPixel = (in8_bit_buffer[k + j * in8_stride]) << 2;
      33           0 :             nBitPixel = (inn_bit_buffer[k + j * inn_stride] >> 6) & 3;
      34             : 
      35           0 :             out16_bit_buffer[k + j * out_stride] = outPixel | nBitPixel;
      36             :         }
      37             :     }
      38           0 : }
      39             : 
      40             : /************************************************
      41             : * pack 8 and 2 bit 2D data into 10 bit data
      42             : 2bit data storage : 4 2bit-pixels in one byte
      43             : ************************************************/
      44           0 : void compressed_packmsb_c(
      45             :     uint8_t     *in8_bit_buffer,
      46             :     uint32_t     in8_stride,
      47             :     uint8_t     *inn_bit_buffer,
      48             :     uint16_t    *out16_bit_buffer,
      49             :     uint32_t     inn_stride,
      50             :     uint32_t     out_stride,
      51             :     uint32_t     width,
      52             :     uint32_t     height)
      53             : {
      54             :     uint64_t   row, kIdx;
      55             :     uint16_t   outPixel;
      56             :     uint8_t    nBitPixel;
      57             :     uint8_t   four2bitPels;
      58             : 
      59           0 :     for (row = 0; row < height; row++)
      60             :     {
      61           0 :         for (kIdx = 0; kIdx < width / 4; kIdx++)
      62             :         {
      63           0 :             four2bitPels = inn_bit_buffer[kIdx + row * inn_stride];
      64             : 
      65           0 :             nBitPixel = (four2bitPels >> 6) & 3;
      66             : 
      67           0 :             outPixel = in8_bit_buffer[kIdx * 4 + 0 + row * in8_stride] << 2;
      68           0 :             out16_bit_buffer[kIdx * 4 + 0 + row * out_stride] = outPixel | nBitPixel;
      69             : 
      70           0 :             nBitPixel = (four2bitPels >> 4) & 3;
      71           0 :             outPixel = in8_bit_buffer[kIdx * 4 + 1 + row * in8_stride] << 2;
      72           0 :             out16_bit_buffer[kIdx * 4 + 1 + row * out_stride] = outPixel | nBitPixel;
      73             : 
      74           0 :             nBitPixel = (four2bitPels >> 2) & 3;
      75           0 :             outPixel = in8_bit_buffer[kIdx * 4 + 2 + row * in8_stride] << 2;
      76           0 :             out16_bit_buffer[kIdx * 4 + 2 + row * out_stride] = outPixel | nBitPixel;
      77             : 
      78           0 :             nBitPixel = (four2bitPels >> 0) & 3;
      79           0 :             outPixel = in8_bit_buffer[kIdx * 4 + 3 + row * in8_stride] << 2;
      80           0 :             out16_bit_buffer[kIdx * 4 + 3 + row * out_stride] = outPixel | nBitPixel;
      81             :         }
      82             :     }
      83           0 : }
      84             : 
      85             : /************************************************
      86             : * convert unpacked nbit (n=2) data to compressedPAcked
      87             : 2bit data storage : 4 2bit-pixels in one byte
      88             : ************************************************/
      89           0 : void c_pack_c(
      90             :     const uint8_t     *inn_bit_buffer,
      91             :     uint32_t     inn_stride,
      92             :     uint8_t     *in_compn_bit_buffer,
      93             :     uint32_t     out_stride,
      94             :     uint8_t    *local_cache,
      95             :     uint32_t     width,
      96             :     uint32_t     height)
      97             : {
      98             :     uint32_t row_index, colIndex;
      99             :     (void)local_cache;
     100             : 
     101           0 :     for (row_index = 0; row_index < height; row_index++)
     102             :     {
     103           0 :         for (colIndex = 0; colIndex < width; colIndex += 4)
     104             :         {
     105           0 :             uint32_t i = colIndex + row_index * inn_stride;
     106             : 
     107           0 :             uint8_t compressedUnpackedPixel = 0;
     108           0 :             compressedUnpackedPixel = compressedUnpackedPixel | ((inn_bit_buffer[i + 0] >> 0) & 0xC0);//1100.0000
     109           0 :             compressedUnpackedPixel = compressedUnpackedPixel | ((inn_bit_buffer[i + 1] >> 2) & 0x30);//0011.0000
     110           0 :             compressedUnpackedPixel = compressedUnpackedPixel | ((inn_bit_buffer[i + 2] >> 4) & 0x0C);//0000.1100
     111           0 :             compressedUnpackedPixel = compressedUnpackedPixel | ((inn_bit_buffer[i + 3] >> 6) & 0x03);//0000.0011
     112             : 
     113           0 :             uint32_t j = colIndex / 4 + row_index * out_stride;
     114           0 :             in_compn_bit_buffer[j] = compressedUnpackedPixel;
     115             :         }
     116             :     }
     117           0 : }
     118             : 
     119             : /************************************************
     120             : * unpack 10 bit data into  8 and 2 bit 2D data
     121             : ************************************************/
     122           0 : void eb_enc_msb_un_pack2_d(
     123             :     uint16_t      *in16_bit_buffer,
     124             :     uint32_t       in_stride,
     125             :     uint8_t       *out8_bit_buffer,
     126             :     uint8_t       *outn_bit_buffer,
     127             :     uint32_t       out8_stride,
     128             :     uint32_t       outn_stride,
     129             :     uint32_t       width,
     130             :     uint32_t       height)
     131             : {
     132             :     uint64_t   j, k;
     133             :     uint16_t   inPixel;
     134             :     uint8_t    tmpPixel;
     135           0 :     for (j = 0; j < height; j++)
     136             :     {
     137           0 :         for (k = 0; k < width; k++)
     138             :         {
     139           0 :             inPixel = in16_bit_buffer[k + j * in_stride];
     140           0 :             out8_bit_buffer[k + j * out8_stride] = (uint8_t)(inPixel >> 2);
     141           0 :             tmpPixel = (uint8_t)(inPixel << 6);
     142           0 :             outn_bit_buffer[k + j * outn_stride] = tmpPixel;
     143             :         }
     144             :     }
     145           0 : }
     146           0 : void un_pack8_bit_data_c(
     147             :     uint16_t      *in16_bit_buffer,
     148             :     uint32_t       in_stride,
     149             :     uint8_t       *out8_bit_buffer,
     150             :     uint32_t       out8_stride,
     151             :     uint32_t       width,
     152             :     uint32_t       height)
     153             : {
     154             :     uint64_t   j, k;
     155             :     uint16_t   inPixel;
     156             :     //uint8_t    tmpPixel;
     157           0 :     for (j = 0; j < height; j++)
     158             :     {
     159           0 :         for (k = 0; k < width; k++)
     160             :         {
     161           0 :             inPixel = in16_bit_buffer[k + j * in_stride];
     162           0 :             out8_bit_buffer[k + j * out8_stride] = (uint8_t)(inPixel >> 2);
     163             :             //tmpPixel = (uint8_t)(inPixel << 6);
     164             :             //outn_bit_buffer[k + j*outn_stride] = tmpPixel;
     165             :         }
     166             :     }
     167           0 : }
     168           0 : void unpack_avg_c(
     169             :     uint16_t *ref16_l0,
     170             :     uint32_t  ref_l0_stride,
     171             :     uint16_t *ref16_l1,
     172             :     uint32_t  ref_l1_stride,
     173             :     uint8_t  *dst_ptr,
     174             :     uint32_t  dst_stride,
     175             :     uint32_t  width,
     176             :     uint32_t  height)
     177             : {
     178             :     uint64_t   j, k;
     179             :     uint8_t   inPixelL0, inPixelL1;
     180             : 
     181           0 :     for (j = 0; j < height; j++)
     182             :     {
     183           0 :         for (k = 0; k < width; k++)
     184             :         {
     185           0 :             inPixelL0 = (uint8_t)(ref16_l0[k + j * ref_l0_stride] >> 2);
     186           0 :             inPixelL1 = (uint8_t)(ref16_l1[k + j * ref_l1_stride] >> 2);
     187           0 :             dst_ptr[k + j * dst_stride] = (inPixelL0 + inPixelL1 + 1) >> 1;
     188             :         }
     189             :     }
     190           0 : }
     191             : 
     192           0 : void unpack_avg_safe_sub_c(
     193             :     uint16_t *ref16_l0,
     194             :     uint32_t  ref_l0_stride,
     195             :     uint16_t *ref16_l1,
     196             :     uint32_t  ref_l1_stride,
     197             :     uint8_t  *dst_ptr,
     198             :     uint32_t  dst_stride,
     199             :     EbBool      sub_pred,
     200             :     uint32_t  width,
     201             :     uint32_t  height)
     202             : {
     203             :     uint64_t   j, k;
     204             :     uint8_t   inPixelL0, inPixelL1;
     205             : 
     206           0 :     for (j = 0; j < height; j++)
     207             :     {
     208           0 :         for (k = 0; k < width; k++)
     209             :         {
     210           0 :             inPixelL0 = (uint8_t)(ref16_l0[k + j * ref_l0_stride] >> 2);
     211           0 :             inPixelL1 = (uint8_t)(ref16_l1[k + j * ref_l1_stride] >> 2);
     212           0 :             dst_ptr[k + j * dst_stride] = (inPixelL0 + inPixelL1 + 1) >> 1;
     213             :         }
     214             :     }
     215             : 
     216           0 :     if (sub_pred) {
     217             :         //Last row
     218           0 :         j = height * 2 - 1;
     219           0 :         for (k = 0; k < width; k++)
     220             :         {
     221           0 :             inPixelL0 = (uint8_t)(ref16_l0[k + j * ref_l0_stride / 2] >> 2);
     222           0 :             inPixelL1 = (uint8_t)(ref16_l1[k + j * ref_l1_stride / 2] >> 2);
     223           0 :             dst_ptr[k + j * dst_stride / 2] = (inPixelL0 + inPixelL1 + 1) >> 1;
     224             :         }
     225             :     }
     226           0 : }

Generated by: LCOV version 1.14