LCOV - code coverage report
Current view: top level - Codec - EbMcp.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 57 42.1 %
Date: 2019-11-25 17:38:06 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /*
       2             : * Copyright(c) 2019 Intel Corporation
       3             : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
       4             : */
       5             : 
       6             : #include <string.h>
       7             : 
       8             : #include "EbMcp.h"
       9             : #include "EbDefinitions.h"
      10             : #include "EbPictureBufferDesc.h"
      11             : #include "EbPictureOperators.h"
      12             : 
      13             : #if (InternalBitDepthIncrement == 0)
      14             : #define ChromaOffset4 (1 << (Shift4 - 1))
      15             : #else
      16             : #define ChromaOffset4 Offset4
      17             : #endif
      18             : #if (InternalBitDepthIncrement == 0)
      19             : #define ChromaMinusOffset1 0
      20             : #else
      21             : #define ChromaMinusOffset1 MinusOffset1
      22             : #endif
      23             : 
      24             : /** generate_padding()
      25             :         is used to pad the target picture. The horizontal padding happens first and then the vertical padding.
      26             :  */
      27        1169 : void generate_padding(
      28             :     EbByte  src_pic,                    //output paramter, pointer to the source picture to be padded.
      29             :     uint32_t   src_stride,                 //input paramter, the stride of the source picture to be padded.
      30             :     uint32_t   original_src_width,          //input paramter, the width of the source picture which excludes the padding.
      31             :     uint32_t   original_src_height,         //input paramter, the height of the source picture which excludes the padding.
      32             :     uint32_t   padding_width,              //input paramter, the padding width.
      33             :     uint32_t   padding_height)             //input paramter, the padding height.
      34             : {
      35        1169 :     uint32_t   verticalIdx = original_src_height;
      36             :     EbByte  tempSrcPic0;
      37             :     EbByte  tempSrcPic1;
      38             :     EbByte  tempSrcPic2;
      39             :     EbByte  tempSrcPic3;
      40             : 
      41        1169 :     tempSrcPic0 = src_pic + padding_width + padding_height * src_stride;
      42      249569 :     while (verticalIdx)
      43             :     {
      44             :         // horizontal padding
      45      248400 :         EB_MEMSET(tempSrcPic0 - padding_width, *tempSrcPic0, padding_width);
      46      248400 :         EB_MEMSET(tempSrcPic0 + original_src_width, *(tempSrcPic0 + original_src_width - 1), padding_width);
      47             : 
      48      248400 :         tempSrcPic0 += src_stride;
      49      248400 :         --verticalIdx;
      50             :     }
      51             : 
      52             :     // vertical padding
      53        1169 :     verticalIdx = padding_height;
      54        1169 :     tempSrcPic0 = src_pic + padding_height * src_stride;
      55        1169 :     tempSrcPic1 = src_pic + (padding_height + original_src_height - 1)*src_stride;
      56        1169 :     tempSrcPic2 = tempSrcPic0;
      57        1169 :     tempSrcPic3 = tempSrcPic1;
      58       82393 :     while (verticalIdx)
      59             :     {
      60             :         // top part data copy
      61       81221 :         tempSrcPic2 -= src_stride;
      62       81221 :         EB_MEMCPY(tempSrcPic2, tempSrcPic0, sizeof(uint8_t)*src_stride);        // uint8_t to be modified
      63             :         // bottom part data copy
      64       81232 :         tempSrcPic3 += src_stride;
      65       81232 :         EB_MEMCPY(tempSrcPic3, tempSrcPic1, sizeof(uint8_t)*src_stride);        // uint8_t to be modified
      66       81224 :         --verticalIdx;
      67             :     }
      68             : 
      69        1172 :     return;
      70             : }
      71             : /** generate_padding16_bit()
      72             : is used to pad the target picture. The horizontal padding happens first and then the vertical padding.
      73             : */
      74           0 : void generate_padding16_bit(
      75             :     EbByte  src_pic,                    //output paramter, pointer to the source picture to be padded.
      76             :     uint32_t   src_stride,                 //input paramter, the stride of the source picture to be padded.
      77             :     uint32_t   original_src_width,          //input paramter, the width of the source picture which excludes the padding.
      78             :     uint32_t   original_src_height,         //input paramter, the height of the source picture which excludes the padding.
      79             :     uint32_t   padding_width,              //input paramter, the padding width.
      80             :     uint32_t   padding_height)             //input paramter, the padding height.
      81             : {
      82           0 :     uint32_t   verticalIdx = original_src_height;
      83             :     EbByte  tempSrcPic0;
      84             :     EbByte  tempSrcPic1;
      85             :     EbByte  tempSrcPic2;
      86             :     EbByte  tempSrcPic3;
      87             : 
      88           0 :     tempSrcPic0 = src_pic + padding_width + padding_height * src_stride;
      89           0 :     while (verticalIdx)
      90             :     {
      91             :         // horizontal padding
      92             :         //EB_MEMSET(tempSrcPic0 - padding_width, tempSrcPic0, padding_width);
      93           0 :         memset16bit((uint16_t*)(tempSrcPic0 - padding_width), ((uint16_t*)(tempSrcPic0))[0], padding_width >> 1);
      94           0 :         memset16bit((uint16_t*)(tempSrcPic0 + original_src_width), ((uint16_t*)(tempSrcPic0 + original_src_width - 2/*1*/))[0], padding_width >> 1);
      95             : 
      96           0 :         tempSrcPic0 += src_stride;
      97           0 :         --verticalIdx;
      98             :     }
      99             : 
     100             :     // vertical padding
     101           0 :     verticalIdx = padding_height;
     102           0 :     tempSrcPic0 = src_pic + padding_height * src_stride;
     103           0 :     tempSrcPic1 = src_pic + (padding_height + original_src_height - 1)*src_stride;
     104           0 :     tempSrcPic2 = tempSrcPic0;
     105           0 :     tempSrcPic3 = tempSrcPic1;
     106           0 :     while (verticalIdx)
     107             :     {
     108             :         // top part data copy
     109           0 :         tempSrcPic2 -= src_stride;
     110           0 :         EB_MEMCPY(tempSrcPic2, tempSrcPic0, sizeof(uint8_t)*src_stride);        // uint8_t to be modified
     111             :         // bottom part data copy
     112           0 :         tempSrcPic3 += src_stride;
     113           0 :         EB_MEMCPY(tempSrcPic3, tempSrcPic1, sizeof(uint8_t)*src_stride);        // uint8_t to be modified
     114           0 :         --verticalIdx;
     115             :     }
     116             : 
     117           0 :     return;
     118             : }
     119             : 
     120             : /** pad_input_picture()
     121             : is used to pad the input picture in order to get . The horizontal padding happens first and then the vertical padding.
     122             : */
     123         357 : void pad_input_picture(
     124             :     EbByte  src_pic,                //output paramter, pointer to the source picture to be padded.
     125             :     uint32_t   src_stride,             //input paramter, the stride of the source picture to be padded.
     126             :     uint32_t   original_src_width,      //input paramter, the width of the source picture which excludes the padding.
     127             :     uint32_t   original_src_height,     //input paramter, the height of the source picture which excludes the padding.
     128             :     uint32_t   pad_right,                //input paramter, the padding right.
     129             :     uint32_t   pad_bottom)             //input paramter, the padding bottom.
     130             : {
     131             :     uint32_t   verticalIdx;
     132             :     EbByte  tempSrcPic0;
     133             :     EbByte  tempSrcPic1;
     134             : 
     135         357 :     if (pad_right) {
     136             :         // Add padding @ the right
     137           0 :         verticalIdx = original_src_height;
     138           0 :         tempSrcPic0 = src_pic;
     139             : 
     140           0 :         while (verticalIdx)
     141             :         {
     142           0 :             EB_MEMSET(tempSrcPic0 + original_src_width, *(tempSrcPic0 + original_src_width - 1), pad_right);
     143           0 :             tempSrcPic0 += src_stride;
     144           0 :             --verticalIdx;
     145             :         }
     146             :     }
     147             : 
     148         357 :     if (pad_bottom) {
     149             :         // Add padding @ the bottom
     150           0 :         verticalIdx = pad_bottom;
     151           0 :         tempSrcPic0 = src_pic + (original_src_height - 1) * src_stride;
     152           0 :         tempSrcPic1 = tempSrcPic0;
     153             : 
     154           0 :         while (verticalIdx)
     155             :         {
     156           0 :             tempSrcPic1 += src_stride;
     157           0 :             EB_MEMCPY(tempSrcPic1, tempSrcPic0, sizeof(uint8_t)* (original_src_width + pad_right));
     158           0 :             --verticalIdx;
     159             :         }
     160             :     }
     161             : 
     162         357 :     return;
     163             : }

Generated by: LCOV version 1.14