FFmpeg
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
bfin
dsputil_bfin.c
Go to the documentation of this file.
1
/*
2
* BlackFin DSPUTILS
3
*
4
* Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
5
* Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
6
*
7
* This file is part of FFmpeg.
8
*
9
* FFmpeg is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
13
*
14
* FFmpeg is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
18
*
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with FFmpeg; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
*/
23
24
#include "
libavutil/attributes.h
"
25
#include "
libavcodec/avcodec.h
"
26
#include "
libavcodec/dsputil.h
"
27
#include "
dsputil_bfin.h
"
28
29
int
off
;
30
31
static
void
bfin_idct_add
(
uint8_t
*dest,
int
line_size, int16_t *
block
)
32
{
33
ff_bfin_idct
(block);
34
ff_bfin_add_pixels_clamped
(block, dest, line_size);
35
}
36
37
static
void
bfin_idct_put
(
uint8_t
*dest,
int
line_size, int16_t *
block
)
38
{
39
ff_bfin_idct
(block);
40
ff_bfin_put_pixels_clamped
(block, dest, line_size);
41
}
42
43
44
static
void
bfin_clear_blocks
(int16_t *blocks)
45
{
46
// This is just a simple memset.
47
//
48
__asm__(
"P0=192; "
49
"I0=%0; "
50
"R0=0; "
51
"LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
52
"clear_blocks_blkfn_lab:"
53
"[I0++]=R0;"
54
::
"a"
(blocks):
"P0"
,
"I0"
,
"R0"
);
55
}
56
57
58
59
static
void
bfin_put_pixels8
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
60
{
61
ff_bfin_put_pixels8uc
(block, pixels, pixels, line_size, line_size, h);
62
}
63
64
static
void
bfin_put_pixels8_x2
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
65
{
66
ff_bfin_put_pixels8uc
(block, pixels, pixels+1, line_size, line_size, h);
67
}
68
69
static
void
bfin_put_pixels8_y2
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
70
{
71
ff_bfin_put_pixels8uc
(block, pixels, pixels+line_size, line_size, line_size, h);
72
}
73
74
static
void
bfin_put_pixels8_xy2
(
uint8_t
*
block
,
const
uint8_t
*
s0
, ptrdiff_t line_size,
int
h)
75
{
76
ff_bfin_z_put_pixels8_xy2
(block,s0,line_size, line_size, h);
77
}
78
79
static
void
bfin_put_pixels16
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
80
{
81
ff_bfin_put_pixels16uc
(block, pixels, pixels, line_size, line_size, h);
82
}
83
84
static
void
bfin_put_pixels16_x2
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
85
{
86
ff_bfin_put_pixels16uc
(block, pixels, pixels+1, line_size, line_size, h);
87
}
88
89
static
void
bfin_put_pixels16_y2
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
90
{
91
ff_bfin_put_pixels16uc
(block, pixels, pixels+line_size, line_size, line_size, h);
92
}
93
94
static
void
bfin_put_pixels16_xy2
(
uint8_t
*
block
,
const
uint8_t
*
s0
, ptrdiff_t line_size,
int
h)
95
{
96
ff_bfin_z_put_pixels16_xy2
(block,s0,line_size, line_size, h);
97
}
98
99
static
void
bfin_put_pixels8_nornd
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
100
{
101
ff_bfin_put_pixels8uc_nornd
(block, pixels, pixels, line_size, h);
102
}
103
104
static
void
bfin_put_pixels8_x2_nornd
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
105
{
106
ff_bfin_put_pixels8uc_nornd
(block, pixels, pixels+1, line_size, h);
107
}
108
109
static
void
bfin_put_pixels8_y2_nornd
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
110
{
111
ff_bfin_put_pixels8uc_nornd
(block, pixels, pixels+line_size, line_size, h);
112
}
113
114
115
static
void
bfin_put_pixels16_nornd
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
116
{
117
ff_bfin_put_pixels16uc_nornd
(block, pixels, pixels, line_size, h);
118
}
119
120
static
void
bfin_put_pixels16_x2_nornd
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
121
{
122
ff_bfin_put_pixels16uc_nornd
(block, pixels, pixels+1, line_size, h);
123
}
124
125
static
void
bfin_put_pixels16_y2_nornd
(
uint8_t
*
block
,
const
uint8_t
*pixels, ptrdiff_t line_size,
int
h)
126
{
127
ff_bfin_put_pixels16uc_nornd
(block, pixels, pixels+line_size, line_size, h);
128
}
129
130
static
int
bfin_pix_abs16
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
131
{
132
return
ff_bfin_z_sad16x16
(blk1,blk2,line_size,line_size,h);
133
}
134
135
static
int
bfin_vsad_intra16
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*
dummy
,
int
stride
,
int
h) {
136
return
ff_bfin_z_sad16x16
(blk1,blk1+stride,stride<<1,stride<<1,h);
137
}
138
139
static
int
bfin_vsad
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
stride
,
int
h) {
140
return
ff_bfin_z_sad16x16
(blk1,blk1+stride,stride<<1,stride<<1,h)
141
+
ff_bfin_z_sad16x16
(blk2,blk2+stride,stride<<1,stride<<1,h);
142
}
143
144
static
uint8_t
vtmp_blk[256]
attribute_l1_data_b
;
145
146
static
int
bfin_pix_abs16_x2
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
147
{
148
ff_bfin_put_pixels16uc
(vtmp_blk, blk2, blk2+1, 16, line_size, h);
149
return
ff_bfin_z_sad16x16
(blk1, vtmp_blk, line_size, 16, h);
150
}
151
152
static
int
bfin_pix_abs16_y2
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
153
{
154
ff_bfin_put_pixels16uc
(vtmp_blk, blk2, blk2+line_size, 16, line_size, h);
155
return
ff_bfin_z_sad16x16
(blk1, vtmp_blk, line_size, 16, h);
156
}
157
158
static
int
bfin_pix_abs16_xy2
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
159
{
160
ff_bfin_z_put_pixels16_xy2
(vtmp_blk, blk2, 16, line_size, h);
161
return
ff_bfin_z_sad16x16
(blk1, vtmp_blk, line_size, 16, h);
162
}
163
164
static
int
bfin_pix_abs8
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
165
{
166
return
ff_bfin_z_sad8x8
(blk1,blk2,line_size,line_size, h);
167
}
168
169
static
int
bfin_pix_abs8_x2
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
170
{
171
ff_bfin_put_pixels8uc
(vtmp_blk, blk2, blk2+1, 8, line_size, h);
172
return
ff_bfin_z_sad8x8
(blk1, vtmp_blk, line_size, 8, h);
173
}
174
175
static
int
bfin_pix_abs8_y2
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
176
{
177
ff_bfin_put_pixels8uc
(vtmp_blk, blk2, blk2+line_size, 8, line_size, h);
178
return
ff_bfin_z_sad8x8
(blk1, vtmp_blk, line_size, 8, h);
179
}
180
181
static
int
bfin_pix_abs8_xy2
(
void
*
c
,
uint8_t
*blk1,
uint8_t
*blk2,
int
line_size,
int
h)
182
{
183
ff_bfin_z_put_pixels8_xy2
(vtmp_blk, blk2, 8, line_size, h);
184
return
ff_bfin_z_sad8x8
(blk1, vtmp_blk, line_size, 8, h);
185
}
186
187
188
/*
189
decoder optimization
190
start on 2/11 100 frames of 352x240@25 compiled with no optimization -g debugging
191
9.824s ~ 2.44x off
192
6.360s ~ 1.58x off with -O2
193
5.740s ~ 1.43x off with idcts
194
195
2.64s 2/20 same sman.mp4 decode only
196
197
*/
198
199
av_cold
void
ff_dsputil_init_bfin
(
DSPContext
*
c
,
AVCodecContext
*avctx)
200
{
201
const
int
high_bit_depth = avctx->
bits_per_raw_sample
> 8;
202
203
c->
diff_pixels
=
ff_bfin_diff_pixels
;
204
c->
put_pixels_clamped
=
ff_bfin_put_pixels_clamped
;
205
c->
add_pixels_clamped
=
ff_bfin_add_pixels_clamped
;
206
207
if
(!high_bit_depth)
208
c->
get_pixels
=
ff_bfin_get_pixels
;
209
c->
clear_blocks
=
bfin_clear_blocks
;
210
c->
pix_sum
=
ff_bfin_pix_sum
;
211
c->
pix_norm1
=
ff_bfin_pix_norm1
;
212
213
c->
sad
[0] =
bfin_pix_abs16
;
214
c->
sad
[1] =
bfin_pix_abs8
;
215
216
/* c->vsad[0] = bfin_vsad; */
217
/* c->vsad[4] = bfin_vsad_intra16; */
218
219
/* TODO [0] 16 [1] 8 */
220
c->
pix_abs
[0][0] =
bfin_pix_abs16
;
221
c->
pix_abs
[0][1] =
bfin_pix_abs16_x2
;
222
c->
pix_abs
[0][2] =
bfin_pix_abs16_y2
;
223
c->
pix_abs
[0][3] =
bfin_pix_abs16_xy2
;
224
225
c->
pix_abs
[1][0] =
bfin_pix_abs8
;
226
c->
pix_abs
[1][1] =
bfin_pix_abs8_x2
;
227
c->
pix_abs
[1][2] =
bfin_pix_abs8_y2
;
228
c->
pix_abs
[1][3] =
bfin_pix_abs8_xy2
;
229
230
231
c->
sse
[0] =
ff_bfin_sse16
;
232
c->
sse
[1] =
ff_bfin_sse8
;
233
c->
sse
[2] =
ff_bfin_sse4
;
234
235
if
(!high_bit_depth) {
236
c->
put_pixels_tab
[0][0] =
bfin_put_pixels16
;
237
c->
put_pixels_tab
[0][1] =
bfin_put_pixels16_x2
;
238
c->
put_pixels_tab
[0][2] =
bfin_put_pixels16_y2
;
239
c->
put_pixels_tab
[0][3] =
bfin_put_pixels16_xy2
;
240
241
c->
put_pixels_tab
[1][0] =
bfin_put_pixels8
;
242
c->
put_pixels_tab
[1][1] =
bfin_put_pixels8_x2
;
243
c->
put_pixels_tab
[1][2] =
bfin_put_pixels8_y2
;
244
c->
put_pixels_tab
[1][3] =
bfin_put_pixels8_xy2
;
245
246
c->
put_no_rnd_pixels_tab
[1][0] =
bfin_put_pixels8_nornd
;
247
c->
put_no_rnd_pixels_tab
[1][1] =
bfin_put_pixels8_x2_nornd
;
248
c->
put_no_rnd_pixels_tab
[1][2] =
bfin_put_pixels8_y2_nornd
;
249
/* c->put_no_rnd_pixels_tab[1][3] = ff_bfin_put_pixels8_xy2_nornd; */
250
251
c->
put_no_rnd_pixels_tab
[0][0] =
bfin_put_pixels16_nornd
;
252
c->
put_no_rnd_pixels_tab
[0][1] =
bfin_put_pixels16_x2_nornd
;
253
c->
put_no_rnd_pixels_tab
[0][2] =
bfin_put_pixels16_y2_nornd
;
254
/* c->put_no_rnd_pixels_tab[0][3] = ff_bfin_put_pixels16_xy2_nornd; */
255
}
256
257
if
(avctx->
bits_per_raw_sample
<= 8) {
258
if
(avctx->
dct_algo
==
FF_DCT_AUTO
)
259
c->
fdct
=
ff_bfin_fdct
;
260
261
if
(avctx->
idct_algo
==
FF_IDCT_AUTO
) {
262
c->
idct_permutation_type
=
FF_NO_IDCT_PERM
;
263
c->
idct
=
ff_bfin_idct
;
264
c->
idct_add
=
bfin_idct_add
;
265
c->
idct_put
=
bfin_idct_put
;
266
}
267
}
268
}
Generated on Sat May 25 2013 04:01:01 for FFmpeg by
1.8.2