-
Notifications
You must be signed in to change notification settings - Fork 27
/
ffutils.h
executable file
·63 lines (47 loc) · 1.33 KB
/
ffutils.h
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
#ifndef __FFUTILS_H__
#define __FFUTILS_H__
// °üº¬Í·Îļþ
#include <linux/videodev2.h>
#include <libavutil/pixfmt.h>
#include <gui/Surface.h>
#ifdef __cplusplus
extern "C" {
#endif
// º¯Êý¶¨Òå
inline int v4l2dev_pixfmt_to_ffmpeg_pixfmt(int srcfmt)
{
// src fmt
int dst_fmt = 0;
switch (srcfmt) {
case V4L2_PIX_FMT_YUYV: dst_fmt = AV_PIX_FMT_YUYV422; break;
case V4L2_PIX_FMT_NV12: dst_fmt = AV_PIX_FMT_NV12; break;
case V4L2_PIX_FMT_NV21: dst_fmt = AV_PIX_FMT_NV21; break;
}
return dst_fmt;
}
inline int android_pixfmt_to_ffmpeg_pixfmt(int srcfmt)
{
// dst fmt
int dst_fmt = 0;
switch (srcfmt) {
case HAL_PIXEL_FORMAT_RGB_565: dst_fmt = AV_PIX_FMT_RGB565; break;
case HAL_PIXEL_FORMAT_RGBX_8888: dst_fmt = AV_PIX_FMT_BGR32; break;
case HAL_PIXEL_FORMAT_YV12: dst_fmt = AV_PIX_FMT_YUV420P; break;
case HAL_PIXEL_FORMAT_YCrCb_420_SP: dst_fmt = AV_PIX_FMT_NV12; break;
}
return dst_fmt;
}
inline int ALIGN(int x, int y) {
// y must be a power of 2.
return (x + y - 1) & ~(y - 1);
}
inline uint64_t get_tick_count(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
#ifdef __cplusplus
}
#endif
#endif