FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
huffyuvdsp.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 "config.h"
22
#include "
libavutil/attributes.h
"
23
#include "
mathops.h
"
24
#include "
huffyuvdsp.h
"
25
26
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
27
#define pb_7f (~0UL / 255 * 0x7f)
28
#define pb_80 (~0UL / 255 * 0x80)
29
30
static
void
add_bytes_c
(
uint8_t
*dst,
uint8_t
*
src
, intptr_t w)
31
{
32
long
i;
33
34
for
(i = 0; i <= w - (int)
sizeof
(
long
); i +=
sizeof
(long)) {
35
long
a
= *(
long
*) (src + i);
36
long
b
= *(
long
*) (dst + i);
37
*(
long
*) (dst + i) = ((a &
pb_7f
) + (b &
pb_7f
)) ^ ((a ^ b) &
pb_80
);
38
}
39
for
(; i < w; i++)
40
dst[i + 0] += src[i + 0];
41
}
42
43
static
void
add_hfyu_median_pred_c
(
uint8_t
*dst,
const
uint8_t
*src1,
44
const
uint8_t
*diff, intptr_t w,
45
int
*left,
int
*left_top)
46
{
47
int
i;
48
uint8_t
l, lt;
49
50
l = *left;
51
lt = *left_top;
52
53
for
(i = 0; i < w; i++) {
54
l =
mid_pred
(l, src1[i], (l + src1[i] - lt) & 0xFF) + diff[i];
55
lt = src1[i];
56
dst[i] = l;
57
}
58
59
*left = l;
60
*left_top = lt;
61
}
62
63
static
int
add_hfyu_left_pred_c
(
uint8_t
*dst,
const
uint8_t
*
src
, intptr_t w,
64
int
acc
)
65
{
66
int
i;
67
68
for
(i = 0; i < w - 1; i++) {
69
acc += src[i];
70
dst[i] =
acc
;
71
i++;
72
acc += src[i];
73
dst[i] =
acc
;
74
}
75
76
for
(; i < w; i++) {
77
acc += src[i];
78
dst[i] =
acc
;
79
}
80
81
return
acc
;
82
}
83
84
static
void
add_hfyu_left_pred_bgr32_c
(
uint8_t
*dst,
const
uint8_t
*
src
,
85
intptr_t w,
uint8_t
*left)
86
{
87
int
i;
88
uint8_t
r
= left[
R
],
g
= left[
G
],
b
= left[
B
],
a
= left[
A
];
89
90
for
(i = 0; i < w; i++) {
91
b += src[4 * i +
B
];
92
g += src[4 * i +
G
];
93
r += src[4 * i +
R
];
94
a += src[4 * i +
A
];
95
96
dst[4 * i +
B
] =
b
;
97
dst[4 * i +
G
] =
g
;
98
dst[4 * i +
R
] =
r
;
99
dst[4 * i +
A
] =
a
;
100
}
101
102
left[
B
] =
b
;
103
left[
G
] =
g
;
104
left[
R
] =
r
;
105
left[
A
] =
a
;
106
}
107
108
av_cold
void
ff_huffyuvdsp_init
(
HuffYUVDSPContext
*
c
)
109
{
110
c->
add_bytes
=
add_bytes_c
;
111
c->
add_hfyu_median_pred
=
add_hfyu_median_pred_c
;
112
c->
add_hfyu_left_pred
=
add_hfyu_left_pred_c
;
113
c->
add_hfyu_left_pred_bgr32
=
add_hfyu_left_pred_bgr32_c
;
114
115
if
(ARCH_X86)
116
ff_huffyuvdsp_init_x86
(c);
117
}
Generated on Sun Jul 20 2014 23:05:49 for FFmpeg by
1.8.2