Blame view

ffmpeg-4.2.2/libswscale/hscale_fast_bilinear.c 2.01 KB
aac5773f   hucm   功能基本完成,接口待打磨
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  /*
   * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
   *
   * This file is part of FFmpeg.
   *
   * FFmpeg is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
   * FFmpeg is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
  #include "swscale_internal.h"
  
  void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
                             const uint8_t *src, int srcW, int xInc)
  {
      int i;
      unsigned int xpos = 0;
      for (i = 0; i < dstWidth; i++) {
          register unsigned int xx     = xpos >> 16;
          register unsigned int xalpha = (xpos & 0xFFFF) >> 9;
          dst[i] = (src[xx] << 7) + (src[xx + 1] - src[xx]) * xalpha;
          xpos  += xInc;
      }
      for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
          dst[i] = src[srcW-1]*128;
  }
  
  void ff_hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
                             int dstWidth, const uint8_t *src1,
                             const uint8_t *src2, int srcW, int xInc)
  {
      int i;
      unsigned int xpos = 0;
      for (i = 0; i < dstWidth; i++) {
          register unsigned int xx     = xpos >> 16;
          register unsigned int xalpha = (xpos & 0xFFFF) >> 9;
          dst1[i] = (src1[xx] * (xalpha ^ 127) + src1[xx + 1] * xalpha);
          dst2[i] = (src2[xx] * (xalpha ^ 127) + src2[xx + 1] * xalpha);
          xpos   += xInc;
      }
      for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
          dst1[i] = src1[srcW-1]*128;
          dst2[i] = src2[srcW-1]*128;
      }
  }