FFmpeg
vc1dsp_init_neon.c
Go to the documentation of this file.
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 
26 void ff_vc1_inv_trans_8x8_neon(int16_t *block);
27 void ff_vc1_inv_trans_4x8_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
28 void ff_vc1_inv_trans_8x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
29 void ff_vc1_inv_trans_4x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
30 
31 void ff_vc1_inv_trans_8x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
32 void ff_vc1_inv_trans_4x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
33 void ff_vc1_inv_trans_8x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
34 void ff_vc1_inv_trans_4x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block);
35 
36 void ff_vc1_v_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq);
37 void ff_vc1_h_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq);
38 void ff_vc1_v_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq);
39 void ff_vc1_h_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq);
40 void ff_vc1_v_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq);
41 void ff_vc1_h_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq);
42 
43 void 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) \
47 void ff_put_vc1_mspel_mc##X##Y##_neon(uint8_t *dst, const uint8_t *src, \
48  ptrdiff_t stride, int rnd); \
49 static 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 
59 DECL_PUT(1, 0)
60 DECL_PUT(2, 0)
61 DECL_PUT(3, 0)
62 
63 DECL_PUT(0, 1)
64 DECL_PUT(0, 2)
65 DECL_PUT(0, 3)
66 
67 DECL_PUT(1, 1)
68 DECL_PUT(1, 2)
69 DECL_PUT(1, 3)
70 
71 DECL_PUT(2, 1)
72 DECL_PUT(2, 2)
73 DECL_PUT(2, 3)
74 
75 DECL_PUT(3, 1)
76 DECL_PUT(3, 2)
77 DECL_PUT(3, 3)
78 
79 void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
80  int h, int x, int y);
81 void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
82  int h, int x, int y);
83 void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
84  int h, int x, int y);
85 void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
86  int h, int x, int y);
87 
88 int ff_vc1_unescape_buffer_helper_neon(const uint8_t *src, int size, uint8_t *dst);
89 
90 static 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  {
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 
151 {
160 
167 
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 
192 
194 }
VC1DSPContext::vc1_v_loop_filter16
void(* vc1_v_loop_filter16)(uint8_t *src, ptrdiff_t stride, int pq)
Definition: vc1dsp.h:53
vc1dsp.h
VC1DSPContext::vc1_inv_trans_4x4
void(* vc1_inv_trans_4x4)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:40
VC1DSPContext::avg_no_rnd_vc1_chroma_pixels_tab
h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3]
Definition: vc1dsp.h:64
ff_vc1dsp_init_neon
av_cold void ff_vc1dsp_init_neon(VC1DSPContext *dsp)
Definition: vc1dsp_init_neon.c:150
VC1DSPContext::vc1_inv_trans_8x8_dc
void(* vc1_inv_trans_8x8_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:41
VC1DSPContext::put_no_rnd_vc1_chroma_pixels_tab
h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3]
Definition: vc1dsp.h:63
VC1DSPContext::vc1_inv_trans_4x4_dc
void(* vc1_inv_trans_4x4_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:44
ff_vc1_h_loop_filter16_neon
void ff_vc1_h_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq)
vc1dsp.h
VC1DSPContext::vc1_v_loop_filter4
void(* vc1_v_loop_filter4)(uint8_t *src, ptrdiff_t stride, int pq)
Definition: vc1dsp.h:49
VC1DSPContext::vc1_h_loop_filter4
void(* vc1_h_loop_filter4)(uint8_t *src, ptrdiff_t stride, int pq)
Definition: vc1dsp.h:50
ff_vc1_inv_trans_8x8_neon
void ff_vc1_inv_trans_8x8_neon(int16_t *block)
rnd
#define rnd()
Definition: checkasm.h:122
VC1DSPContext::vc1_inv_trans_8x4_dc
void(* vc1_inv_trans_8x4_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:42
av_cold
#define av_cold
Definition: attributes.h:90
VC1DSPContext::vc1_h_loop_filter16
void(* vc1_h_loop_filter16)(uint8_t *src, ptrdiff_t stride, int pq)
Definition: vc1dsp.h:54
ff_vc1_v_loop_filter4_neon
void ff_vc1_v_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq)
intreadwrite.h
ff_put_vc1_chroma_mc4_neon
void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
ff_put_vc1_chroma_mc8_neon
void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
VC1DSPContext::vc1_inv_trans_8x4
void(* vc1_inv_trans_8x4)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:38
ff_vc1_inv_trans_4x8_dc_neon
void ff_vc1_inv_trans_4x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
ff_vc1_inv_trans_4x8_neon
void ff_vc1_inv_trans_4x8_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
ff_vc1_h_loop_filter8_neon
void ff_vc1_h_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq)
VC1DSPContext::vc1_inv_trans_4x8_dc
void(* vc1_inv_trans_4x8_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:43
size
int size
Definition: twinvq_data.h:10344
ff_vc1_inv_trans_4x4_dc_neon
void ff_vc1_inv_trans_4x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
attributes.h
VC1DSPContext::vc1_inv_trans_8x8
void(* vc1_inv_trans_8x8)(int16_t *b)
Definition: vc1dsp.h:37
ff_vc1_inv_trans_8x4_neon
void ff_vc1_inv_trans_8x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
VC1DSPContext::vc1_unescape_buffer
int(* vc1_unescape_buffer)(const uint8_t *src, int size, uint8_t *dst)
Definition: vc1dsp.h:85
stride
#define stride
Definition: h264pred_template.c:537
VC1DSPContext
Definition: vc1dsp.h:35
VC1DSPContext::vc1_h_loop_filter8
void(* vc1_h_loop_filter8)(uint8_t *src, ptrdiff_t stride, int pq)
Definition: vc1dsp.h:52
VC1DSPContext::put_vc1_mspel_pixels_tab
vc1op_pixels_func put_vc1_mspel_pixels_tab[2][16]
Definition: vc1dsp.h:59
ff_vc1_h_loop_filter4_neon
void ff_vc1_h_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq)
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
FN_ASSIGN
#define FN_ASSIGN(X, Y)
Definition: vc1dsp_init_neon.c:146
vc1_unescape_buffer_neon
static int vc1_unescape_buffer_neon(const uint8_t *src, int size, uint8_t *dst)
Definition: vc1dsp_init_neon.c:90
ff_vc1_inv_trans_8x8_dc_neon
void ff_vc1_inv_trans_8x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
VC1DSPContext::vc1_v_loop_filter8
void(* vc1_v_loop_filter8)(uint8_t *src, ptrdiff_t stride, int pq)
Definition: vc1dsp.h:51
ff_avg_vc1_chroma_mc4_neon
void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
ff_avg_vc1_chroma_mc8_neon
void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
ff_vc1_inv_trans_4x4_neon
void ff_vc1_inv_trans_4x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
DECL_PUT
#define DECL_PUT(X, Y)
Definition: vc1dsp_init_neon.c:46
ff_vc1_v_loop_filter16_neon
void ff_vc1_v_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq)
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
ff_vc1_unescape_buffer_helper_neon
int ff_vc1_unescape_buffer_helper_neon(const uint8_t *src, int size, uint8_t *dst)
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
h
h
Definition: vp9dsp_template.c:2038
VC1DSPContext::vc1_inv_trans_4x8
void(* vc1_inv_trans_4x8)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: vc1dsp.h:39
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375
ff_vc1_v_loop_filter8_neon
void ff_vc1_v_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq)
ff_vc1_inv_trans_8x4_dc_neon
void ff_vc1_inv_trans_8x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block)
ff_put_pixels8x8_neon
void ff_put_pixels8x8_neon(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int rnd)