-
Notifications
You must be signed in to change notification settings - Fork 4
/
common.h
167 lines (134 loc) · 3.54 KB
/
common.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
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
/*
* V4L2 Codec decoding example application
* Kamil Debski <[email protected]>
*
* Common stuff header file
*
* Copyright 2012 Samsung Electronics Co., Ltd.
* Copyright (c) 2015 Linaro Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef INCLUDE_COMMON_H
#define INCLUDE_COMMON_H
#include <stdio.h>
#include <stdint.h>
#include <pthread.h>
#include <termios.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include "display.h"
#include "list.h"
extern int debug_level;
#define ARRAY_LENGTH(x) (sizeof (x) / sizeof (*(x)))
#define print(l, msg, ...) \
do { \
if (debug_level >= l) \
fprintf(stderr, msg, ##__VA_ARGS__); \
} while (0)
#define err(msg, ...) \
print(1, "error: " msg "\n", ##__VA_ARGS__)
#define info(msg, ...) \
print(2, msg "\n", ##__VA_ARGS__)
#define dbg(msg, ...) \
print(3, DBG_TAG ": " msg "\n", ##__VA_ARGS__)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define memzero(x) memset(&(x), 0, sizeof (x));
/* Maximum number of output buffers */
#define MAX_OUT_BUF 16
/* Maximum number of capture buffers (32 is the limit imposed by MFC */
#define MAX_CAP_BUF 32
/* Number of output planes */
#define OUT_PLANES 1
/* Number of capture planes */
#define CAP_PLANES 2
/* Maximum number of planes used in the application */
#define MAX_PLANES CAP_PLANES
/* video decoder related parameters */
struct video {
char *name;
int fd;
/* Output queue related */
int out_buf_cnt;
int out_buf_size;
int out_buf_off[MAX_OUT_BUF];
char *out_buf_addr[MAX_OUT_BUF];
int out_buf_flag[MAX_OUT_BUF];
int out_ion_fd;
int out_ion_size;
void *out_ion_addr;
/* Capture queue related */
int cap_w;
int cap_h;
int cap_buf_cnt;
uint32_t cap_buf_format;
int cap_planes_count;
int cap_plane_off[CAP_PLANES];
int cap_plane_stride[CAP_PLANES];
int cap_buf_flag[MAX_CAP_BUF];
int cap_buf_size;
int cap_buf_fd[MAX_CAP_BUF];
void *cap_buf_addr[MAX_CAP_BUF];
/* timestamp list for all pending frames */
struct list_head pending_ts_list;
uint64_t cap_last_pts;
uint64_t pts_dts_delta;
/* Extradata stuff */
int extradata_index;
int extradata_size;
int extradata_ion_fd;
void *extradata_ion_addr;
int extradata_off[MAX_CAP_BUF];
void *extradata_addr[MAX_CAP_BUF];
/* Metrics */
unsigned long total_captured;
};
struct instance {
int width;
int height;
int fullscreen;
uint32_t fourcc;
int fps_n, fps_d;
int depth;
int interlaced;
int decode_order;
int skip_frames;
int insert_sc;
int need_header;
int secure;
int continue_data_transfer;
char *url;
/* video decoder related parameters */
struct video video;
pthread_mutex_t lock;
pthread_cond_t cond;
/* Control */
int sigfd;
int paused;
int prerolled;
int finish; /* Flag set when decoding has been completed and all
threads finish */
int reconfigure_pending;
int group;
struct display *display;
struct window *window;
struct list_head fb_list;
int stdin_valid;
struct termios stdin_termios;
AVFormatContext *avctx;
AVStream *stream;
AVBSFContext *bsf;
int bsf_data_pending;
};
#endif /* INCLUDE_COMMON_H */