tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cdef.h (4784B)


      1 /*
      2 * Copyright © 2018, VideoLAN and dav1d authors
      3 * All rights reserved.
      4 *
      5 * Redistribution and use in source and binary forms, with or without
      6 * modification, are permitted provided that the following conditions are met:
      7 *
      8 * 1. Redistributions of source code must retain the above copyright notice, this
      9 *    list of conditions and the following disclaimer.
     10 *
     11 * 2. Redistributions in binary form must reproduce the above copyright notice,
     12 *    this list of conditions and the following disclaimer in the documentation
     13 *    and/or other materials provided with the distribution.
     14 *
     15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
     19 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25 */
     26 
     27 #include "src/cpu.h"
     28 #include "src/cdef.h"
     29 
     30 decl_cdef_dir_fn(BF(dav1d_cdef_find_dir, neon));
     31 
     32 void BF(dav1d_cdef_padding4, neon)(uint16_t *tmp, const pixel *src,
     33                                   ptrdiff_t src_stride, const pixel (*left)[2],
     34                                   const pixel *const top,
     35                                   const pixel *const bottom, int h,
     36                                   enum CdefEdgeFlags edges);
     37 void BF(dav1d_cdef_padding8, neon)(uint16_t *tmp, const pixel *src,
     38                                   ptrdiff_t src_stride, const pixel (*left)[2],
     39                                   const pixel *const top,
     40                                   const pixel *const bottom, int h,
     41                                   enum CdefEdgeFlags edges);
     42 
     43 // Passing edges to this function, to allow it to switch to a more
     44 // optimized version for fully edged cases. Using size_t for edges,
     45 // to avoid ABI differences for passing more than one argument on the stack.
     46 void BF(dav1d_cdef_filter4, neon)(pixel *dst, ptrdiff_t dst_stride,
     47                                  const uint16_t *tmp, int pri_strength,
     48                                  int sec_strength, int dir, int damping, int h,
     49                                  size_t edges HIGHBD_DECL_SUFFIX);
     50 void BF(dav1d_cdef_filter8, neon)(pixel *dst, ptrdiff_t dst_stride,
     51                                  const uint16_t *tmp, int pri_strength,
     52                                  int sec_strength, int dir, int damping, int h,
     53                                  size_t edges HIGHBD_DECL_SUFFIX);
     54 
     55 #define DEFINE_FILTER(w, h, tmp_stride)                                      \
     56 static void                                                                  \
     57 cdef_filter_##w##x##h##_neon(pixel *dst, const ptrdiff_t stride,             \
     58                             const pixel (*left)[2],                         \
     59                             const pixel *const top,                         \
     60                             const pixel *const bottom,                      \
     61                             const int pri_strength, const int sec_strength, \
     62                             const int dir, const int damping,               \
     63                             const enum CdefEdgeFlags edges                  \
     64                             HIGHBD_DECL_SUFFIX)                             \
     65 {                                                                            \
     66    ALIGN_STK_16(uint16_t, tmp_buf, 12 * tmp_stride + 8,);                   \
     67    uint16_t *tmp = tmp_buf + 2 * tmp_stride + 8;                            \
     68    BF(dav1d_cdef_padding##w, neon)(tmp, dst, stride,                        \
     69                                    left, top, bottom, h, edges);            \
     70    BF(dav1d_cdef_filter##w, neon)(dst, stride, tmp, pri_strength,           \
     71                                   sec_strength, dir, damping, h, edges      \
     72                                   HIGHBD_TAIL_SUFFIX);                      \
     73 }
     74 
     75 DEFINE_FILTER(8, 8, 16)
     76 DEFINE_FILTER(4, 8, 8)
     77 DEFINE_FILTER(4, 4, 8)
     78 
     79 static ALWAYS_INLINE void cdef_dsp_init_arm(Dav1dCdefDSPContext *const c) {
     80    const unsigned flags = dav1d_get_cpu_flags();
     81 
     82    if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return;
     83 
     84    c->dir = BF(dav1d_cdef_find_dir, neon);
     85    c->fb[0] = cdef_filter_8x8_neon;
     86    c->fb[1] = cdef_filter_4x8_neon;
     87    c->fb[2] = cdef_filter_4x4_neon;
     88 }