LCOV - code coverage report
Current view: top level - libavcodec - videodsp_template.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 42 43 97.7 %
Date: 2017-12-18 06:23:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2002-2012 Michael Niedermayer
       3             :  * Copyright (C) 2012 Ronald S. Bultje
       4             :  *
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : #include "bit_depth_template.c"
      23    13305675 : void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
      24             :                                ptrdiff_t buf_linesize,
      25             :                                ptrdiff_t src_linesize,
      26             :                                int block_w, int block_h,
      27             :                                int src_x, int src_y, int w, int h)
      28             : {
      29             :     int x, y;
      30             :     int start_y, start_x, end_y, end_x;
      31             : 
      32    13305675 :     if (!w || !h)
      33           0 :         return;
      34             : 
      35             :     av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize));
      36             : 
      37    13305675 :     if (src_y >= h) {
      38      129620 :         src -= src_y * src_linesize;
      39      129620 :         src += (h - 1) * src_linesize;
      40      129620 :         src_y = h - 1;
      41    13176055 :     } else if (src_y <= -block_h) {
      42       31203 :         src -= src_y * src_linesize;
      43       31203 :         src += (1 - block_h) * src_linesize;
      44       31203 :         src_y = 1 - block_h;
      45             :     }
      46    13305675 :     if (src_x >= w) {
      47      160846 :         src  += (w - 1 - src_x) * sizeof(pixel);
      48      160846 :         src_x = w - 1;
      49    13144829 :     } else if (src_x <= -block_w) {
      50       39569 :         src  += (1 - block_w - src_x) * sizeof(pixel);
      51       39569 :         src_x = 1 - block_w;
      52             :     }
      53             : 
      54    13305675 :     start_y = FFMAX(0, -src_y);
      55    13305675 :     start_x = FFMAX(0, -src_x);
      56    13305675 :     end_y = FFMIN(block_h, h-src_y);
      57    13305675 :     end_x = FFMIN(block_w, w-src_x);
      58             :     av_assert2(start_y < end_y && block_h);
      59             :     av_assert2(start_x < end_x && block_w);
      60             : 
      61    13305675 :     w    = end_x - start_x;
      62    13305675 :     src += start_y * src_linesize + start_x * sizeof(pixel);
      63    13305675 :     buf += start_x * sizeof(pixel);
      64             : 
      65             :     // top
      66    19595525 :     for (y = 0; y < start_y; y++) {
      67     6289850 :         memcpy(buf, src, w * sizeof(pixel));
      68     6289850 :         buf += buf_linesize;
      69             :     }
      70             : 
      71             :     // copy existing part
      72   177314615 :     for (; y < end_y; y++) {
      73   164008940 :         memcpy(buf, src, w * sizeof(pixel));
      74   164008940 :         src += src_linesize;
      75   164008940 :         buf += buf_linesize;
      76             :     }
      77             : 
      78             :     // bottom
      79    13305675 :     src -= src_linesize;
      80    38214685 :     for (; y < block_h; y++) {
      81    24909010 :         memcpy(buf, src, w * sizeof(pixel));
      82    24909010 :         buf += buf_linesize;
      83             :     }
      84             : 
      85    13305675 :     buf -= block_h * buf_linesize + start_x * sizeof(pixel);
      86   221819150 :     while (block_h--) {
      87   195207800 :         pixel *bufp = (pixel *) buf;
      88             : 
      89             :         // left
      90   284754264 :         for(x = 0; x < start_x; x++) {
      91    89546464 :             bufp[x] = bufp[start_x];
      92             :         }
      93             : 
      94             :         // right
      95   430846882 :         for (x = end_x; x < block_w; x++) {
      96   235639082 :             bufp[x] = bufp[end_x - 1];
      97             :         }
      98   195207800 :         buf += buf_linesize;
      99             :     }
     100             : }

Generated by: LCOV version 1.13