Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
2c01ad8b
Commit
2c01ad8b
authored
Jan 09, 2014
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsputil_template: Detemplatize the code
The indirection makes no sense without multiple instantiation.
parent
aba70bb5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
127 deletions
+114
-127
dsputil.c
libavcodec/dsputil.c
+5
-13
dsputil_template.c
libavcodec/dsputil_template.c
+109
-114
No files found.
libavcodec/dsputil.c
View file @
2c01ad8b
...
...
@@ -2602,26 +2602,18 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
c
->
add_pixels8
=
add_pixels8_c
;
#undef FUNC
#undef FUNCC
#define FUNC(f, depth) f ## _ ## depth
#define FUNCC(f, depth) f ## _ ## depth ## _c
c
->
draw_edges
=
draw_edges_8_c
;
c
->
draw_edges
=
FUNCC
(
draw_edges
,
8
);
c
->
clear_block
=
FUNCC
(
clear_block
,
8
);
c
->
clear_blocks
=
FUNCC
(
clear_blocks
,
8
);
#define BIT_DEPTH_FUNCS(depth) \
c->get_pixels = FUNCC(get_pixels, depth);
c
->
clear_block
=
clear_block_8_c
;
c
->
clear_blocks
=
clear_blocks_8_c
;
switch
(
avctx
->
bits_per_raw_sample
)
{
case
9
:
case
10
:
BIT_DEPTH_FUNCS
(
16
)
;
c
->
get_pixels
=
get_pixels_16_c
;
break
;
default
:
BIT_DEPTH_FUNCS
(
8
)
;
c
->
get_pixels
=
get_pixels_8_c
;
break
;
}
...
...
libavcodec/dsputil_template.c
View file @
2c01ad8b
...
...
@@ -29,16 +29,12 @@
#include "pixels.h"
#include "bit_depth_template.c"
/* draw the edges of width 'w' of an image of size width, height */
// FIXME: Check that this is OK for MPEG-4 interlaced.
static
void
FUNCC
(
draw_edges
)(
uint8_t
*
_buf
,
int
_
wrap
,
int
width
,
int
height
,
int
w
,
int
h
,
int
sides
)
static
void
draw_edges_8_c
(
uint8_t
*
buf
,
int
wrap
,
int
width
,
int
height
,
int
w
,
int
h
,
int
sides
)
{
pixel
*
buf
=
(
pixel
*
)
_buf
;
int
wrap
=
_wrap
/
sizeof
(
pixel
);
pixel
*
ptr
=
buf
,
*
last_line
;
uint8_t
*
ptr
=
buf
,
*
last_line
;
int
i
;
/* left and right */
...
...
@@ -54,76 +50,75 @@ static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height,
if
(
sides
&
EDGE_TOP
)
for
(
i
=
0
;
i
<
h
;
i
++
)
// top
memcpy
(
buf
-
(
i
+
1
)
*
wrap
,
buf
,
(
width
+
w
+
w
)
*
sizeof
(
pixel
)
);
memcpy
(
buf
-
(
i
+
1
)
*
wrap
,
buf
,
width
+
w
+
w
);
if
(
sides
&
EDGE_BOTTOM
)
for
(
i
=
0
;
i
<
h
;
i
++
)
// bottom
memcpy
(
last_line
+
(
i
+
1
)
*
wrap
,
last_line
,
(
width
+
w
+
w
)
*
sizeof
(
pixel
));
memcpy
(
last_line
+
(
i
+
1
)
*
wrap
,
last_line
,
width
+
w
+
w
);
}
static
void
FUNCC
(
clear_block
)
(
int16_t
*
block
)
static
void
clear_block_8_c
(
int16_t
*
block
)
{
memset
(
block
,
0
,
sizeof
(
int16_t
)
*
64
);
}
static
void
FUNCC
(
clear_blocks
)
(
int16_t
*
blocks
)
static
void
clear_blocks_8_c
(
int16_t
*
blocks
)
{
memset
(
blocks
,
0
,
sizeof
(
int16_t
)
*
6
*
64
);
}
#define PIXOP2(OPNAME, OP) \
static inline void
FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst,
\
const uint8_t *src1,
\
const uint8_t *src2,
\
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int h)
\
static inline void
OPNAME ## _no_rnd_pixels8_l2_8(uint8_t *dst,
\
const uint8_t *src1,
\
const uint8_t *src2,
\
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int h)
\
{ \
int i; \
\
for (i = 0; i < h; i++) { \
pixel4 a, b;
\
a = AV_RN
4P
(&src1[i * src_stride1]); \
b = AV_RN
4P
(&src2[i * src_stride2]); \
OP(*((
pixel4 *) &dst[i * dst_stride]),
\
no_rnd_avg
_pixel4(a, b));
\
a = AV_RN
4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]);
\
b = AV_RN
4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]);
\
OP(*((
pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]),
\
no_rnd_avg
_pixel4(a, b));
\
uint32_t a, b;
\
a = AV_RN
32
(&src1[i * src_stride1]); \
b = AV_RN
32
(&src2[i * src_stride2]); \
OP(*((
uint32_t *) &dst[i * dst_stride]),
\
no_rnd_avg
32(a, b));
\
a = AV_RN
32(&src1[i * src_stride1 + 4]);
\
b = AV_RN
32(&src2[i * src_stride2 + 4]);
\
OP(*((
uint32_t *) &dst[i * dst_stride + 4]),
\
no_rnd_avg
32(a, b));
\
} \
} \
\
static inline void
FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst,
\
const uint8_t *src1, \
const uint8_t *src2, \
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int h)
\
static inline void
OPNAME ## _no_rnd_pixels16_l2_8(uint8_t *dst,
\
const uint8_t *src1, \
const uint8_t *src2, \
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int h)
\
{ \
FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst, src1, src2, dst_stride,
\
src_stride1, src_stride2, h);
\
FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst + 8 * sizeof(pixel),
\
src1 + 8 * sizeof(pixel),
\
src2 + 8 * sizeof(pixel),
\
dst_stride, src_stride1,
\
src_stride2, h);
\
OPNAME ## _no_rnd_pixels8_l2_8(dst, src1, src2, dst_stride,
\
src_stride1, src_stride2, h);
\
OPNAME ## _no_rnd_pixels8_l2_8(dst + 8,
\
src1 + 8,
\
src2 + 8,
\
dst_stride, src_stride1,
\
src_stride2, h);
\
} \
\
static inline void
FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst,
\
const uint8_t *src1,
\
const uint8_t *src2,
\
const uint8_t *src3,
\
const uint8_t *src4,
\
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int src_stride3,
\
int src_stride4,
\
int h)
\
static inline void
OPNAME ## _pixels8_l4_8(uint8_t *dst,
\
const uint8_t *src1,
\
const uint8_t *src2,
\
const uint8_t *src3,
\
const uint8_t *src4,
\
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int src_stride3,
\
int src_stride4,
\
int h)
\
{ \
/* FIXME HIGH BIT DEPTH */
\
int i; \
...
...
@@ -163,17 +158,17 @@ static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, \
} \
} \
\
static inline void
FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst,
\
const uint8_t *src1,
\
const uint8_t *src2,
\
const uint8_t *src3,
\
const uint8_t *src4,
\
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int src_stride3,
\
int src_stride4,
\
int h)
\
static inline void
OPNAME ## _no_rnd_pixels8_l4_8(uint8_t *dst,
\
const uint8_t *src1,
\
const uint8_t *src2,
\
const uint8_t *src3,
\
const uint8_t *src4,
\
int dst_stride,
\
int src_stride1,
\
int src_stride2,
\
int src_stride3,
\
int src_stride4,
\
int h)
\
{ \
/* FIXME HIGH BIT DEPTH */
\
int i; \
...
...
@@ -212,57 +207,57 @@ static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, \
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
} \
} \
static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, \
const uint8_t *src1, \
const uint8_t *src2, \
const uint8_t *src3, \
const uint8_t *src4, \
int dst_stride, \
int src_stride1, \
int src_stride2, \
int src_stride3, \
int src_stride4, \
int h) \
\
static inline void OPNAME ## _pixels16_l4_8(uint8_t *dst, \
const uint8_t *src1, \
const uint8_t *src2, \
const uint8_t *src3, \
const uint8_t *src4, \
int dst_stride, \
int src_stride1, \
int src_stride2, \
int src_stride3, \
int src_stride4, \
int h) \
{ \
FUNC(OPNAME ## _pixels8_l4)(dst, src1, src2, src3, src4, dst_stride, \
src_stride1, src_stride2, src_stride3, \
src_stride4, h); \
FUNC(OPNAME ## _pixels8_l4)(dst + 8 * sizeof(pixel), \
src1 + 8 * sizeof(pixel), \
src2 + 8 * sizeof(pixel), \
src3 + 8 * sizeof(pixel), \
src4 + 8 * sizeof(pixel), \
dst_stride, src_stride1, src_stride2, \
src_stride3, src_stride4, h); \
OPNAME ## _pixels8_l4_8(dst, src1, src2, src3, src4, dst_stride, \
src_stride1, src_stride2, src_stride3, \
src_stride4, h); \
OPNAME ## _pixels8_l4_8(dst + 8, \
src1 + 8, src2 + 8, \
src3 + 8, src4 + 8, \
dst_stride, src_stride1, src_stride2, \
src_stride3, src_stride4, h); \
} \
static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, \
const uint8_t *src1, \
const uint8_t *src2, \
const uint8_t *src3, \
const uint8_t *src4, \
int dst_stride, \
int src_stride1, \
int src_stride2, \
int src_stride3, \
int src_stride4, \
int h) \
\
static inline void OPNAME ## _no_rnd_pixels16_l4_8(uint8_t *dst, \
const uint8_t *src1, \
const uint8_t *src2, \
const uint8_t *src3, \
const uint8_t *src4, \
int dst_stride, \
int src_stride1, \
int src_stride2, \
int src_stride3, \
int src_stride4, \
int h) \
{ \
FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst, src1, src2, src3, src4,
\
dst_stride, src_stride1, src_stride2,
\
src_stride3, src_stride4, h);
\
FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst + 8 * sizeof(pixel),
\
src1 + 8 * sizeof(pixel),
\
src2 + 8 * sizeof(pixel),
\
src3 + 8 * sizeof(pixel),
\
src4 + 8 * sizeof(pixel),
\
dst_stride, src_stride1, src_stride2,
\
src_stride3, src_stride4, h);
\
OPNAME ## _no_rnd_pixels8_l4_8(dst, src1, src2, src3, src4,
\
dst_stride, src_stride1,
\
src_stride2, src_stride3,
\
src_stride4, h);
\
OPNAME ## _no_rnd_pixels8_l4_8(dst + 8,
\
src1 + 8, src2 + 8,
\
src3 + 8, src4 + 8,
\
dst_stride, src_stride1,
\
src_stride2, src_stride3,
\
src_stride4, h);
\
} \
\
static inline void
FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block,
\
const uint8_t *pixels,
\
ptrdiff_t line_size,
\
int h)
\
static inline void
OPNAME ## _pixels8_xy2_8_c(uint8_t *block,
\
const uint8_t *pixels,
\
ptrdiff_t line_size,
\
int h)
\
{ \
/* FIXME HIGH BIT DEPTH */
\
int j; \
...
...
@@ -307,11 +302,11 @@ static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, \
} \
} \
\
CALL_2X_PIXELS(
FUNCC(OPNAME ## _pixels16_xy2),
\
FUNCC(OPNAME ## _pixels8_xy2),
\
8
* sizeof(pixel))
\
CALL_2X_PIXELS(
OPNAME ## _pixels16_xy2_8_c,
\
OPNAME ## _pixels8_xy2_8_c,
\
8
)
\
#define op_avg(a, b) a = rnd_avg
_pixel4
(a, b)
#define op_avg(a, b) a = rnd_avg
32
(a, b)
#define op_put(a, b) a = b
#define put_no_rnd_pixels8_8_c put_pixels8_8_c
PIXOP2
(
avg
,
op_avg
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment