LCOV - code coverage report
Current view: top level - libavcodec - lossless_videodsp.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 54 55 98.2 %
Date: 2017-12-14 08:27:08 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Lossless video DSP utils
       3             :  *
       4             :  * This file is part of FFmpeg.
       5             :  *
       6             :  * FFmpeg is free software; you can redistribute it and/or
       7             :  * modify it under the terms of the GNU Lesser General Public
       8             :  * License as published by the Free Software Foundation; either
       9             :  * version 2.1 of the License, or (at your option) any later version.
      10             :  *
      11             :  * FFmpeg is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with FFmpeg; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : #include "avcodec.h"
      21             : #include "lossless_videodsp.h"
      22             : #include "libavcodec/mathops.h"
      23             : 
      24             : // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
      25             : #define pb_7f (~0UL / 255 * 0x7f)
      26             : #define pb_80 (~0UL / 255 * 0x80)
      27             : 
      28        1859 : static void add_bytes_c(uint8_t *dst, uint8_t *src, ptrdiff_t w)
      29             : {
      30             :     long i;
      31             : 
      32       50211 :     for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
      33       48352 :         long a = *(long *) (src + i);
      34       48352 :         long b = *(long *) (dst + i);
      35       48352 :         *(long *) (dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80);
      36             :     }
      37        1859 :     for (; i < w; i++)
      38           0 :         dst[i + 0] += src[i + 0];
      39        1859 : }
      40             : 
      41       47711 : static void add_median_pred_c(uint8_t *dst, const uint8_t *src1,
      42             :                               const uint8_t *diff, ptrdiff_t w,
      43             :                               int *left, int *left_top)
      44             : {
      45             :     int i;
      46             :     uint8_t l, lt;
      47             : 
      48       47711 :     l  = *left;
      49       47711 :     lt = *left_top;
      50             : 
      51    28817663 :     for (i = 0; i < w; i++) {
      52    28769952 :         l      = mid_pred(l, src1[i], (l + src1[i] - lt) & 0xFF) + diff[i];
      53    28769952 :         lt     = src1[i];
      54    28769952 :         dst[i] = l;
      55             :     }
      56             : 
      57       47711 :     *left     = l;
      58       47711 :     *left_top = lt;
      59       47711 : }
      60             : 
      61      363460 : static int add_left_pred_c(uint8_t *dst, const uint8_t *src, ptrdiff_t w,
      62             :                            int acc)
      63             : {
      64             :     int i;
      65             : 
      66    50469620 :     for (i = 0; i < w - 1; i++) {
      67    50106160 :         acc   += src[i];
      68    50106160 :         dst[i] = acc;
      69    50106160 :         i++;
      70    50106160 :         acc   += src[i];
      71    50106160 :         dst[i] = acc;
      72             :     }
      73             : 
      74      368976 :     for (; i < w; i++) {
      75        5516 :         acc   += src[i];
      76        5516 :         dst[i] = acc;
      77             :     }
      78             : 
      79      363460 :     return acc;
      80             : }
      81             : 
      82      359203 : static int add_left_pred_int16_c(uint16_t *dst, const uint16_t *src, unsigned mask, ptrdiff_t w, unsigned acc){
      83             :     int i;
      84             : 
      85    49966583 :     for(i=0; i<w-1; i++){
      86    49607380 :         acc+= src[i];
      87    49607380 :         dst[i]= acc &= mask;
      88    49607380 :         i++;
      89    49607380 :         acc+= src[i];
      90    49607380 :         dst[i]= acc &= mask;
      91             :     }
      92             : 
      93      364303 :     for(; i<w; i++){
      94        5100 :         acc+= src[i];
      95        5100 :         dst[i]= acc &= mask;
      96             :     }
      97             : 
      98      359203 :     return acc;
      99             : }
     100             : 
     101         325 : static void add_gradient_pred_c(uint8_t *src, const ptrdiff_t stride, const ptrdiff_t width){
     102             :     int A, B, C, i;
     103             : 
     104        6973 :     for (i = 0; i < width; i++) {
     105        6648 :         A = src[i - stride];
     106        6648 :         B = src[i - (stride + 1)];
     107        6648 :         C = src[i - 1];
     108        6648 :         src[i] = (A - B + C + src[i]) & 0xFF;
     109             :     }
     110         325 : }
     111             : 
     112         164 : void ff_llviddsp_init(LLVidDSPContext *c)
     113             : {
     114         164 :     c->add_bytes                  = add_bytes_c;
     115         164 :     c->add_median_pred            = add_median_pred_c;
     116         164 :     c->add_left_pred              = add_left_pred_c;
     117             : 
     118         164 :     c->add_left_pred_int16        = add_left_pred_int16_c;
     119         164 :     c->add_gradient_pred          = add_gradient_pred_c;
     120             : 
     121             :     if (ARCH_PPC)
     122             :         ff_llviddsp_init_ppc(c);
     123             :     if (ARCH_X86)
     124         164 :         ff_llviddsp_init_x86(c);
     125         164 : }

Generated by: LCOV version 1.13