-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path420ToNv12.c
61 lines (50 loc) · 1.08 KB
/
420ToNv12.c
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
//
// 420ToNv12.c
// 420ToNv12
//
// Created by Hank Lee on 5/31/15.
// Copyright (c) 2015 Hank Lee. All rights reserved.
//
#include <stdint.h>
#define SSE
typedef char __attribute__((vector_size(8))) v8qi;
#ifdef SSE
int planar_to_interleave
(
uint32_t wxh,
uint64_t *u_et_v,
const uint64_t *u,
const uint64_t *v
)
{
int i;
v8qi *res;
res = (v8qi *) u_et_v;
for (i = 0; i < wxh / 32; i++)
{
res[0] = __builtin_ia32_punpcklbw( (v8qi) u[i], (v8qi) v[i]);
res[1] = __builtin_ia32_punpckhbw( (v8qi) u[i], (v8qi) v[i]);
res += 2;
}
return 0;
}
#else
int planar_to_interleave
(
uint32_t wxh,
uint8_t *u_et_v,
const uint8_t *u,
const uint8_t *v
)
{
int i;
for (i = 0; i < wxh / 4; i++)
{
uint8_t u_data = u[i]; // fetch u data
uint8_t v_data = v[i]; // fetch v data
u_et_v[2 * i] = u_data; // write u data
u_et_v[2 * i + 1] = v_data; // write v data
}
return 0;
}
#endif