FFmpeg
4.4.9
libavcodec
huffyuvencdsp.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 "
config.h
"
20
#include "
libavutil/attributes.h
"
21
#include "
libavutil/intreadwrite.h
"
22
#include "
huffyuvencdsp.h
"
23
#include "
mathops.h
"
24
25
#if HAVE_FAST_64BIT
26
#define BITS 64
27
typedef
uint64_t
uint_native
;
28
#else
29
#define BITS 32
30
typedef
uint32_t
uint_native
;
31
#endif
32
#define RN AV_JOIN(AV_RN, BITS)
33
#define RNA AV_JOIN(AV_JOIN(AV_RN, BITS), A)
34
#define WNA AV_JOIN(AV_JOIN(AV_WN, BITS), A)
35
36
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
37
#define pb_7f (~(uint_native)0 / 255 * 0x7f)
38
#define pb_80 (~(uint_native)0 / 255 * 0x80)
39
40
// 0x00010001 or 0x0001000100010001 or whatever, depending on the cpu's native arithmetic size
41
#define pw_1 ((uint_native)-1 / UINT16_MAX)
42
43
static
void
diff_int16_c
(uint16_t *dst,
const
uint16_t *
src1
,
const
uint16_t *src2,
unsigned
mask
,
int
w
){
44
long
i
;
45
#if !HAVE_FAST_UNALIGNED
46
if
((uintptr_t)src2 & (
sizeof
(
uint_native
) - 1)) {
47
for
(
i
=0;
i
+3<
w
;
i
+=4){
48
dst[
i
+0] = (
src1
[
i
+0]-src2[
i
+0]) &
mask
;
49
dst[
i
+1] = (
src1
[
i
+1]-src2[
i
+1]) &
mask
;
50
dst[
i
+2] = (
src1
[
i
+2]-src2[
i
+2]) &
mask
;
51
dst[
i
+3] = (
src1
[
i
+3]-src2[
i
+3]) &
mask
;
52
}
53
}
else
54
#endif
55
{
56
uint_native
pw_lsb = (
mask
>> 1) *
pw_1
;
57
uint_native
pw_msb = pw_lsb +
pw_1
;
58
59
for
(
i
= 0;
i
<=
w
- (
int
)
sizeof
(
uint_native
)/2;
i
+=
sizeof
(
uint_native
)/2) {
60
uint_native
a
=
RNA
(
src1
+
i
);
61
uint_native
b
=
RN
(src2 +
i
);
62
WNA
(dst +
i
, ((
a
| pw_msb) - (
b
& pw_lsb)) ^ ((
a
^
b
^pw_msb) & pw_msb));
63
}
64
}
65
for
(;
i
<
w
;
i
++)
66
dst[
i
] = (
src1
[
i
] - src2[
i
]) &
mask
;
67
}
68
69
static
void
sub_hfyu_median_pred_int16_c
(uint16_t *dst,
const
uint16_t *
src1
,
const
uint16_t *src2,
unsigned
mask
,
int
w
,
int
*left,
int
*left_top){
70
int
i
;
71
uint16_t l, lt;
72
73
l = *left;
74
lt = *left_top;
75
76
for
(
i
=0;
i
<
w
;
i
++){
77
const
int
pred
=
mid_pred
(l,
src1
[
i
], (l +
src1
[
i
] - lt) &
mask
);
78
lt =
src1
[
i
];
79
l = src2[
i
];
80
dst[
i
] = (l -
pred
) &
mask
;
81
}
82
83
*left = l;
84
*left_top = lt;
85
}
86
87
av_cold
void
ff_huffyuvencdsp_init
(
HuffYUVEncDSPContext
*
c
,
AVCodecContext
*avctx)
88
{
89
c
->diff_int16 =
diff_int16_c
;
90
c
->sub_hfyu_median_pred_int16 =
sub_hfyu_median_pred_int16_c
;
91
92
if
(
ARCH_X86
)
93
ff_huffyuvencdsp_init_x86
(
c
, avctx);
94
}
attributes.h
Macro definitions for various function/variable attributes.
av_cold
#define av_cold
Definition:
attributes.h:88
config.h
ARCH_X86
#define ARCH_X86
Definition:
config.h:39
int
int
Definition:
ffmpeg_filter.c:167
a
a
Definition:
h264pred_template.c:468
WNA
#define WNA
Definition:
huffyuvencdsp.c:34
sub_hfyu_median_pred_int16_c
static void sub_hfyu_median_pred_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w, int *left, int *left_top)
Definition:
huffyuvencdsp.c:69
uint_native
uint32_t uint_native
Definition:
huffyuvencdsp.c:30
RNA
#define RNA
Definition:
huffyuvencdsp.c:33
diff_int16_c
static void diff_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w)
Definition:
huffyuvencdsp.c:43
pw_1
#define pw_1
Definition:
huffyuvencdsp.c:41
RN
#define RN
Definition:
huffyuvencdsp.c:32
ff_huffyuvencdsp_init
av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, AVCodecContext *avctx)
Definition:
huffyuvencdsp.c:87
huffyuvencdsp.h
ff_huffyuvencdsp_init_x86
void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, AVCodecContext *avctx)
Definition:
huffyuvencdsp_init.c:40
i
int i
Definition:
input.c:407
intreadwrite.h
w
uint8_t w
Definition:
llviddspenc.c:39
mask
static const uint16_t mask[17]
Definition:
lzw.c:38
mid_pred
#define mid_pred
Definition:
mathops.h:97
pred
static const float pred[4]
Definition:
siprdata.h:259
AVCodecContext
main external API structure.
Definition:
avcodec.h:536
HuffYUVEncDSPContext
Definition:
huffyuvencdsp.h:26
src1
#define src1
Definition:
h264pred.c:140
b
const char * b
Definition:
vf_curves.c:119
c
static double c[64]
Definition:
vsrc_mptestsrc.c:92
mathops.h
Generated on Wed Dec 2 2026 14:05:25 for FFmpeg by
1.9.1