1/* 2 * This file is part of FFmpeg. 3 * 4 * FFmpeg is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * FFmpeg is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with FFmpeg; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19#include <stdint.h> 20 21#include "libavutil/attributes.h" 22#include "libavutil/intreadwrite.h" 23#include "libavcodec/vc1dsp.h" 24#include "vc1dsp.h" 25 26void ff_vc1_inv_trans_8x8_neon(int16_t *block); 27void ff_vc1_inv_trans_4x8_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 28void ff_vc1_inv_trans_8x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 29void ff_vc1_inv_trans_4x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 30 31void ff_vc1_inv_trans_8x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 32void ff_vc1_inv_trans_4x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 33void ff_vc1_inv_trans_8x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 34void ff_vc1_inv_trans_4x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); 35 36void ff_vc1_v_loop_filter4_neon(uint8_t *src, int stride, int pq); 37void ff_vc1_h_loop_filter4_neon(uint8_t *src, int stride, int pq); 38void ff_vc1_v_loop_filter8_neon(uint8_t *src, int stride, int pq); 39void ff_vc1_h_loop_filter8_neon(uint8_t *src, int stride, int pq); 40void ff_vc1_v_loop_filter16_neon(uint8_t *src, int stride, int pq); 41void ff_vc1_h_loop_filter16_neon(uint8_t *src, int stride, int pq); 42 43void ff_put_pixels8x8_neon(uint8_t *block, const uint8_t *pixels, 44 ptrdiff_t line_size, int rnd); 45 46#define DECL_PUT(X, Y) \ 47void ff_put_vc1_mspel_mc##X##Y##_neon(uint8_t *dst, const uint8_t *src, \ 48 ptrdiff_t stride, int rnd); \ 49static void ff_put_vc1_mspel_mc##X##Y##_16_neon(uint8_t *dst, const uint8_t *src, \ 50 ptrdiff_t stride, int rnd) \ 51{ \ 52 ff_put_vc1_mspel_mc##X##Y##_neon(dst+0, src+0, stride, rnd); \ 53 ff_put_vc1_mspel_mc##X##Y##_neon(dst+8, src+8, stride, rnd); \ 54 dst += 8*stride; src += 8*stride; \ 55 ff_put_vc1_mspel_mc##X##Y##_neon(dst+0, src+0, stride, rnd); \ 56 ff_put_vc1_mspel_mc##X##Y##_neon(dst+8, src+8, stride, rnd); \ 57} 58 59DECL_PUT(1, 0) 60DECL_PUT(2, 0) 61DECL_PUT(3, 0) 62 63DECL_PUT(0, 1) 64DECL_PUT(0, 2) 65DECL_PUT(0, 3) 66 67DECL_PUT(1, 1) 68DECL_PUT(1, 2) 69DECL_PUT(1, 3) 70 71DECL_PUT(2, 1) 72DECL_PUT(2, 2) 73DECL_PUT(2, 3) 74 75DECL_PUT(3, 1) 76DECL_PUT(3, 2) 77DECL_PUT(3, 3) 78 79void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, 80 int h, int x, int y); 81void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, 82 int h, int x, int y); 83void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, 84 int h, int x, int y); 85void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, 86 int h, int x, int y); 87 88int ff_vc1_unescape_buffer_helper_neon(const uint8_t *src, int size, uint8_t *dst); 89 90static int vc1_unescape_buffer_neon(const uint8_t *src, int size, uint8_t *dst) 91{ 92 /* Dealing with starting and stopping, and removing escape bytes, are 93 * comparatively less time-sensitive, so are more clearly expressed using 94 * a C wrapper around the assembly inner loop. Note that we assume a 95 * little-endian machine that supports unaligned loads. */ 96 int dsize = 0; 97 while (size >= 4) 98 { 99 int found = 0; 100 while (!found && (((uintptr_t) dst) & 7) && size >= 4) 101 { 102 found = (AV_RL32(src) &~ 0x03000000) == 0x00030000; 103 if (!found) 104 { 105 *dst++ = *src++; 106 --size; 107 ++dsize; 108 } 109 } 110 if (!found) 111 { 112 int skip = size - ff_vc1_unescape_buffer_helper_neon(src, size, dst); 113 dst += skip; 114 src += skip; 115 size -= skip; 116 dsize += skip; 117 while (!found && size >= 4) 118 { 119 found = (AV_RL32(src) &~ 0x03000000) == 0x00030000; 120 if (!found) 121 { 122 *dst++ = *src++; 123 --size; 124 ++dsize; 125 } 126 } 127 } 128 if (found) 129 { 130 *dst++ = *src++; 131 *dst++ = *src++; 132 ++src; 133 size -= 3; 134 dsize += 2; 135 } 136 } 137 while (size > 0) 138 { 139 *dst++ = *src++; 140 --size; 141 ++dsize; 142 } 143 return dsize; 144} 145 146#define FN_ASSIGN(X, Y) \ 147 dsp->put_vc1_mspel_pixels_tab[0][X+4*Y] = ff_put_vc1_mspel_mc##X##Y##_16_neon; \ 148 dsp->put_vc1_mspel_pixels_tab[1][X+4*Y] = ff_put_vc1_mspel_mc##X##Y##_neon 149 150av_cold void ff_vc1dsp_init_neon(VC1DSPContext *dsp) 151{ 152 dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_neon; 153 dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_neon; 154 dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_neon; 155 dsp->vc1_inv_trans_4x4 = ff_vc1_inv_trans_4x4_neon; 156 dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_neon; 157 dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_neon; 158 dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_neon; 159 dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_neon; 160 161 dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_neon; 162 dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_neon; 163 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_neon; 164 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_neon; 165 dsp->vc1_v_loop_filter16 = ff_vc1_v_loop_filter16_neon; 166 dsp->vc1_h_loop_filter16 = ff_vc1_h_loop_filter16_neon; 167 168 dsp->put_vc1_mspel_pixels_tab[1][ 0] = ff_put_pixels8x8_neon; 169 FN_ASSIGN(1, 0); 170 FN_ASSIGN(2, 0); 171 FN_ASSIGN(3, 0); 172 173 FN_ASSIGN(0, 1); 174 FN_ASSIGN(1, 1); 175 FN_ASSIGN(2, 1); 176 FN_ASSIGN(3, 1); 177 178 FN_ASSIGN(0, 2); 179 FN_ASSIGN(1, 2); 180 FN_ASSIGN(2, 2); 181 FN_ASSIGN(3, 2); 182 183 FN_ASSIGN(0, 3); 184 FN_ASSIGN(1, 3); 185 FN_ASSIGN(2, 3); 186 FN_ASSIGN(3, 3); 187 188 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_neon; 189 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_neon; 190 dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_vc1_chroma_mc4_neon; 191 dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_vc1_chroma_mc4_neon; 192 193 dsp->vc1_unescape_buffer = vc1_unescape_buffer_neon; 194} 195