This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
0002-swscale-Add-swscale-and-fate-support-for-0YUV.patch
352 lines (341 loc) · 13.5 KB
/
0002-swscale-Add-swscale-and-fate-support-for-0YUV.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
From 599db06f0729ba76fdcf054f181c650aa44ad22b Mon Sep 17 00:00:00 2001
From: Linjie Fu <[email protected]>
Date: Mon, 15 Jun 2020 15:38:48 +0800
Subject: [PATCH 2/2] swscale: Add swscale and fate support for 0YUV
Add input and output support in swscale for 0YUV.
Since AV_PIX_FMT_0RGB would be treated as AV_PIX_FMT_ARGB, the
default X(0) channel for 0YUV is set to 0xFF as well.
Add fate test for 0YUV.
Signed-off-by: Linjie Fu <[email protected]>
---
libswscale/input.c | 25 ++++++++++++++++
libswscale/output.c | 50 ++++++++++++++++++++++++++++++++
libswscale/swscale_unscaled.c | 40 +++++++++++++++++++++++++
libswscale/utils.c | 1 +
tests/ref/fate/filter-pixdesc-0yuv | 1 +
tests/ref/fate/filter-pixfmts-copy | 1 +
tests/ref/fate/filter-pixfmts-crop | 1 +
tests/ref/fate/filter-pixfmts-field | 1 +
tests/ref/fate/filter-pixfmts-fieldorder | 1 +
tests/ref/fate/filter-pixfmts-hflip | 1 +
tests/ref/fate/filter-pixfmts-il | 1 +
tests/ref/fate/filter-pixfmts-null | 1 +
tests/ref/fate/filter-pixfmts-pad | 1 +
tests/ref/fate/filter-pixfmts-scale | 1 +
tests/ref/fate/filter-pixfmts-transpose | 1 +
tests/ref/fate/filter-pixfmts-vflip | 1 +
16 files changed, 128 insertions(+)
create mode 100644 tests/ref/fate/filter-pixdesc-0yuv
diff --git a/libswscale/input.c b/libswscale/input.c
index 0bd1aa7..0b6ce6c 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -572,6 +572,25 @@ static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0,
AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
}
+static void XyuvToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
+ uint32_t *unused)
+{
+ int i;
+ for (i = 0; i < width; i++)
+ dst[i] = src[4 * i + 2];
+}
+
+static void XyuvToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
+ const uint8_t *src2, int width, uint32_t *unused)
+{
+ int i;
+ for (i = 0; i < width; i++) {
+ dstV[i] = src1[4 * i];
+ dstU[i] = src1[4 * i + 1];
+ }
+ av_assert1(src1 == src2);
+}
+
static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
uint32_t *unused)
{
@@ -1258,6 +1277,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_Y210LE:
c->chrToYV12 = y210le_UV_c;
break;
+ case AV_PIX_FMT_0YUV:
+ c->chrToYV12 = XyuvToUV_c;
+ break;
}
if (c->chrSrcHSubSample) {
switch (srcFormat) {
@@ -1709,6 +1731,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_Y210LE:
c->lumToYV12 = y210le_Y_c;
break;
+ case AV_PIX_FMT_0YUV:
+ c->lumToYV12 = XyuvToY_c;
+ break;
case AV_PIX_FMT_X2RGB10LE:
c->lumToYV12 =rgb30leToY_c;
break;
diff --git a/libswscale/output.c b/libswscale/output.c
index 4ef436e..8e988f9 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2491,6 +2491,53 @@ yuv2ya8_X_c(SwsContext *c, const int16_t *lumFilter,
}
static void
+yuv2Xyuv_X_c(SwsContext *c, const int16_t *lumFilter,
+ const int16_t **lumSrc, int lumFilterSize,
+ const int16_t *chrFilter, const int16_t **chrUSrc,
+ const int16_t **chrVSrc, int chrFilterSize,
+ const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
+{
+ int hasAlpha = !!alpSrc;
+ int i;
+
+ for (i = 0; i < dstW; i++) {
+ int j;
+ int A = 1 << 18;
+ int Y = 1 << 18;
+ int U = 1 << 18;
+ int V = 1 << 18;
+
+ for (j = 0; j < lumFilterSize; j++) {
+ Y += lumSrc[j][i] * lumFilter[j];
+ }
+ for (j = 0; j < chrFilterSize; j++) {
+ U += chrUSrc[j][i] * chrFilter[j];
+ V += chrVSrc[j][i] * chrFilter[j];
+ }
+ if (hasAlpha)
+ for (j = 0; j < lumFilterSize; j++)
+ A += alpSrc[j][i] * lumFilter[j];
+ A >>= 19;
+ Y >>= 19;
+ U >>= 19;
+ V >>= 19;
+ A = hasAlpha ? A : 255;
+
+ if ((A | Y | U | V) & 0x100) {
+ A = av_clip_uint8(A);
+ Y = av_clip_uint8(Y);
+ U = av_clip_uint8(U);
+ V = av_clip_uint8(V);
+ }
+
+ dest[4*i] = V;
+ dest[4*i + 1] = U;
+ dest[4*i + 2] = Y;
+ dest[4*i + 3] = A;
+ }
+}
+
+static void
yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter,
const int16_t **_lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **_chrUSrc,
@@ -3032,6 +3079,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed2 = yuv2ya16be_2_c;
*yuv2packedX = yuv2ya16be_X_c;
break;
+ case AV_PIX_FMT_0YUV:
+ *yuv2packedX = yuv2Xyuv_X_c;
+ break;
case AV_PIX_FMT_AYUV64LE:
*yuv2packedX = yuv2ayuv64le_X_c;
break;
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 5fb572b..198d08c 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -371,6 +371,41 @@ static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[],
return srcSliceH;
}
+static void yuv444pTo0yuv(const uint8_t *src[], int srcStride[],
+ uint8_t *dst, int dstStride, int srcSliceH, int width)
+{
+ int x, h, i;
+ for (h = 0; h < srcSliceH; h++) {
+ uint8_t *dest = dst + dstStride * h;
+
+ for (x = 0; x < width; x++) {
+ *dest++ = src[2][x];
+ *dest++ = src[1][x];
+ *dest++ = src[0][x];
+ *dest++ = 0xFF;
+ }
+
+ for (i = 0; i < 3; i++)
+ src[i] += srcStride[i];
+ }
+}
+
+
+static int yuv444pTo0yuvWrapper(SwsContext *c, const uint8_t *src[],
+ int srcStride[], int srcSliceY, int srcSliceH,
+ uint8_t *dstParam[], int dstStride[])
+{
+ uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
+
+ const uint8_t *source[] = { src[0], src[1], src[2] };
+ int stride[] = { srcStride[0], srcStride[1], srcStride[2] };
+
+ yuv444pTo0yuv(source, stride, dst + srcSliceY * dstStride[0], dstStride[0],
+ srcSliceH, c->srcW);
+
+ return srcSliceH;
+}
+
static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY, int srcSliceH,
uint8_t *dstParam[], int dstStride[])
@@ -2120,6 +2155,11 @@ void ff_get_unscaled_swscale(SwsContext *c)
c->swscale = yuv422pToUyvyWrapper;
}
+ if (srcFormat == AV_PIX_FMT_YUV444P) {
+ if (dstFormat == AV_PIX_FMT_0YUV)
+ c->swscale = yuv444pTo0yuvWrapper;
+ }
+
/* uint Y to float Y */
if (srcFormat == AV_PIX_FMT_GRAY8 && dstFormat == AV_PIX_FMT_GRAYF32){
c->swscale = uint_y_to_float_y_wrapper;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index dcd1dba..4f41384 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -271,6 +271,7 @@ static const FormatEntry format_entries[] = {
[AV_PIX_FMT_NV24] = { 1, 1 },
[AV_PIX_FMT_NV42] = { 1, 1 },
[AV_PIX_FMT_Y210LE] = { 1, 0 },
+ [AV_PIX_FMT_0YUV] = { 1, 1 },
[AV_PIX_FMT_X2RGB10LE] = { 1, 1 },
};
diff --git a/tests/ref/fate/filter-pixdesc-0yuv b/tests/ref/fate/filter-pixdesc-0yuv
new file mode 100644
index 0000000..fb71b0b
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-0yuv
@@ -0,0 +1 @@
+pixdesc-0yuv 25e04681539b84434e6687583d196771
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index 1d7657c..e99fa80 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -1,5 +1,6 @@
0bgr 4060279c35dd8810a2f55a021b836557
0rgb 527ef3d164c8fd0700493733959689c2
+0yuv 0af13a42f9d0932c5a9bb6a8a5d1c5ee
abgr 023ecf6396d324edb113e4a483b79ba2
argb f003b555ef429222005d33844cca9325
ayuv64le 07b9c969dfbe4add4c0626773b151d4f
diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop
index 8fc7614..b059fca 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -1,5 +1,6 @@
0bgr 8a83998de96327cb334538d7a265304e
0rgb 974833c777e6abe6d84dc59af2ca5625
+0yuv 615241c5406eb556fca0ad8606c23a02
abgr 1d21f5b8a20186ac9dd54459c986a2a7
argb 8b822972049a1e207000763f2564d6e0
ayuv64le ab2f7bc8f150af47c42c778e3ea28bce
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field
index ce8e535..a404396 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -1,5 +1,6 @@
0bgr 8f34406a8e6f293b6468b6941d8944e6
0rgb e2c35753a2271d1f9455b1809bc0e907
+0yuv 3d02eeab336d0a8106f6fdd91be61073
abgr c0eb95959edf5d40ff8af315e62d0f8a
argb 6dca4f2987b49b7d63f702d17bace630
ayuv64le d9836decca6323ba88b3b3d02257c0b6
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder
index 90d36ad..bd1eb0b 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -1,5 +1,6 @@
0bgr 955efde1695e9f4da276622e462ea9cf
0rgb 2b0f066cfa0bef378a492875d541de8f
+0yuv 9e4480c5fcb7c091ec3e517420764ef3
abgr 832924b5351361db68dbdbb96c60ae55
argb 80d08e68cb91bc8f2f817516e65f0bd0
ayuv64le 84ef6260fe02427da946d4a2207fb54c
diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip
index 0d40b93..12a1722 100644
--- a/tests/ref/fate/filter-pixfmts-hflip
+++ b/tests/ref/fate/filter-pixfmts-hflip
@@ -1,5 +1,6 @@
0bgr 823994965cfb2ba4566f878c75eed684
0rgb ada57572ee2b35f86edac9b911ce8523
+0yuv f1d087284fb1556d76e6def5f94bf273
abgr d2da6c3ee72e4a89a7cd011dd08566b2
argb 36cf791c52c5463bfc52a070de54337e
ayuv64le 4cedbc38b3d4dcb26cdab170ce6d667b
diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il
index d1bc866..29144ce 100644
--- a/tests/ref/fate/filter-pixfmts-il
+++ b/tests/ref/fate/filter-pixfmts-il
@@ -1,5 +1,6 @@
0bgr 501a8320becc400e2a72dc847003d82d
0rgb 53efe0182723cd1dedfdbf56357c76f5
+0yuv 4251d94ee49e6a3cc1c10c09cd331308
abgr 97603869e6248a8e5d8501563a11b114
argb 9e50e6ef02c83f28e97865a1f46ddfcd
ayuv64le 6f45f683e99ddf4180c7c7f47719efcc
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index 1d7657c..e99fa80 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -1,5 +1,6 @@
0bgr 4060279c35dd8810a2f55a021b836557
0rgb 527ef3d164c8fd0700493733959689c2
+0yuv 0af13a42f9d0932c5a9bb6a8a5d1c5ee
abgr 023ecf6396d324edb113e4a483b79ba2
argb f003b555ef429222005d33844cca9325
ayuv64le 07b9c969dfbe4add4c0626773b151d4f
diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad
index 9a5db82..af8f91f 100644
--- a/tests/ref/fate/filter-pixfmts-pad
+++ b/tests/ref/fate/filter-pixfmts-pad
@@ -1,5 +1,6 @@
0bgr 7bc6f5a1c44cdd7506174dccf52c68d7
0rgb ff12e0f1e576b47a4c962729d5c0b868
+0yuv 93fca69f640574dc7d8cce6282f72e96
abgr 52738042432893de555e6a3833172806
argb 2a10108ac524b422b8a2393c064b3eab
bgr0 32207a2de1b2ac7937e940a8459b97c0
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index d7020ad..c9904f5 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -1,5 +1,6 @@
0bgr 0576e427ba28f19e55a856f528e7c282
0rgb 80a58af8c639743307207ab4b69ca863
+0yuv a6ff68f46c6b4b7595ec91b2a497df8e
abgr 63f2eaa8712ea6108985f4a0b83587c9
argb f0e17c71a40643c33a5bcfb481f6d8f8
ayuv64le 59fb016f9874062d0be77cb3920ffed2
diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose
index 0a8542b..93cabd7 100644
--- a/tests/ref/fate/filter-pixfmts-transpose
+++ b/tests/ref/fate/filter-pixfmts-transpose
@@ -1,5 +1,6 @@
0bgr 6929c1e308d2f4f941d002627047d262
0rgb cf1bedd0784a3efd3ab00c4e44005c37
+0yuv 46b5b821d7ee6ddedb3ddafd1e5b007c
abgr 6d6f896f853a6c6f93ee70dba9af3d17
argb 87bbd23debb94d486ac3a6b6c0b005f9
ayuv64le e4c07e0d5b333b3bc9eb4f3ce6af3a2c
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index 732db8d..3110952 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -1,5 +1,6 @@
0bgr e6f5c50fa0330cd5d5e69ffc09bc085a
0rgb 76b792f8ce8a72925e04294dc2f25b36
+0yuv ed7de87da324b39090a8961dfd56ca5a
abgr 8b94f489e68802d76f1e2844688a4911
argb 3fd6af7ef2364d8aa845d45db289a04a
ayuv64le 558671dd31d0754cfa6344eaf441df78
--
2.7.4