FFmpeg
libavcodec
h264chroma_template.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2000, 2001 Fabrice Bellard
3
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
23
#include <stddef.h>
24
25
#include "
libavutil/avassert.h
"
26
#include "
bit_depth_template.c
"
27
28
#define H264_CHROMA_MC(OPNAME, OP)\
29
static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst
/*align 8*/
, const uint8_t *_src
/*align 1*/
, ptrdiff_t stride, int h, int x, int y)\
30
{\
31
pixel *dst = (pixel*)_dst;\
32
const pixel *src = (const pixel*)_src;\
33
const int A=(8-x)*(8-y);\
34
const int B=( x)*(8-y);\
35
const int C=(8-x)*( y);\
36
const int D=( x)*( y);\
37
int i;\
38
stride >>= sizeof(pixel)-1;\
39
\
40
av_assert2(x<8 && y<8 && x>=0 && y>=0);\
41
\
42
if(D){\
43
for(i=0; i<h; i++){\
44
OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
45
OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
46
dst+= stride;\
47
src+= stride;\
48
}\
49
} else if (B + C) {\
50
const int E= B+C;\
51
const ptrdiff_t step = C ? stride : 1;\
52
for(i=0; i<h; i++){\
53
OP(dst[0], (A*src[0] + E*src[step+0]));\
54
OP(dst[1], (A*src[1] + E*src[step+1]));\
55
dst+= stride;\
56
src+= stride;\
57
}\
58
} else {\
59
for ( i = 0; i < h; i++){\
60
OP(dst[0], A * src[0]);\
61
OP(dst[1], A * src[1]);\
62
dst += stride;\
63
src += stride;\
64
}\
65
}\
66
}\
67
\
68
static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst
/*align 8*/
, const uint8_t *_src
/*align 1*/
, ptrdiff_t stride, int h, int x, int y)\
69
{\
70
pixel *dst = (pixel*)_dst;\
71
const pixel *src = (const pixel*)_src;\
72
const int A=(8-x)*(8-y);\
73
const int B=( x)*(8-y);\
74
const int C=(8-x)*( y);\
75
const int D=( x)*( y);\
76
int i;\
77
stride >>= sizeof(pixel)-1;\
78
\
79
av_assert2(x<8 && y<8 && x>=0 && y>=0);\
80
\
81
if(D){\
82
for(i=0; i<h; i++){\
83
OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
84
OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
85
OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
86
OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
87
dst+= stride;\
88
src+= stride;\
89
}\
90
} else if (B + C) {\
91
const int E= B+C;\
92
const ptrdiff_t step = C ? stride : 1;\
93
for(i=0; i<h; i++){\
94
OP(dst[0], (A*src[0] + E*src[step+0]));\
95
OP(dst[1], (A*src[1] + E*src[step+1]));\
96
OP(dst[2], (A*src[2] + E*src[step+2]));\
97
OP(dst[3], (A*src[3] + E*src[step+3]));\
98
dst+= stride;\
99
src+= stride;\
100
}\
101
} else {\
102
for ( i = 0; i < h; i++){\
103
OP(dst[0], A * src[0]);\
104
OP(dst[1], A * src[1]);\
105
OP(dst[2], A * src[2]);\
106
OP(dst[3], A * src[3]);\
107
dst += stride;\
108
src += stride;\
109
}\
110
}\
111
}\
112
\
113
static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst
/*align 8*/
, const uint8_t *_src
/*align 1*/
, ptrdiff_t stride, int h, int x, int y)\
114
{\
115
pixel *dst = (pixel*)_dst;\
116
const pixel *src = (const pixel*)_src;\
117
const int A=(8-x)*(8-y);\
118
const int B=( x)*(8-y);\
119
const int C=(8-x)*( y);\
120
const int D=( x)*( y);\
121
int i;\
122
stride >>= sizeof(pixel)-1;\
123
\
124
av_assert2(x<8 && y<8 && x>=0 && y>=0);\
125
\
126
if(D){\
127
for(i=0; i<h; i++){\
128
OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
129
OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
130
OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
131
OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
132
OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
133
OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
134
OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
135
OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
136
dst+= stride;\
137
src+= stride;\
138
}\
139
} else if (B + C) {\
140
const int E= B+C;\
141
const ptrdiff_t step = C ? stride : 1;\
142
for(i=0; i<h; i++){\
143
OP(dst[0], (A*src[0] + E*src[step+0]));\
144
OP(dst[1], (A*src[1] + E*src[step+1]));\
145
OP(dst[2], (A*src[2] + E*src[step+2]));\
146
OP(dst[3], (A*src[3] + E*src[step+3]));\
147
OP(dst[4], (A*src[4] + E*src[step+4]));\
148
OP(dst[5], (A*src[5] + E*src[step+5]));\
149
OP(dst[6], (A*src[6] + E*src[step+6]));\
150
OP(dst[7], (A*src[7] + E*src[step+7]));\
151
dst+= stride;\
152
src+= stride;\
153
}\
154
} else {\
155
for ( i = 0; i < h; i++){\
156
OP(dst[0], A * src[0]);\
157
OP(dst[1], A * src[1]);\
158
OP(dst[2], A * src[2]);\
159
OP(dst[3], A * src[3]);\
160
OP(dst[4], A * src[4]);\
161
OP(dst[5], A * src[5]);\
162
OP(dst[6], A * src[6]);\
163
OP(dst[7], A * src[7]);\
164
dst += stride;\
165
src += stride;\
166
}\
167
}\
168
}
169
170
#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
171
#define op_put(a, b) a = (((b) + 32)>>6)
172
173
H264_CHROMA_MC
(put_ ,
op_put
)
174
H264_CHROMA_MC
(avg_ ,
op_avg
)
175
#undef op_avg
176
#undef op_put
avassert.h
op_avg
#define op_avg(a, b)
Definition:
h264chroma_template.c:170
bit_depth_template.c
op_put
#define op_put(a, b)
Definition:
h264chroma_template.c:171
H264_CHROMA_MC
#define H264_CHROMA_MC(OPNAME, OP)
Definition:
h264chroma_template.c:28
Generated on Tue Nov 18 2025 19:22:13 for FFmpeg by
1.8.17