57#define MOD_NAME "[video] "
84 if(strcasecmp(requested_mode,
"help") == 0) {
85 printf(
"Video mode options:\n");
92 printf(
"\t%s\n", it->second.name);
99 if (strcasecmp(requested_mode, it.second.name) == 0) {
103 fprintf(stderr,
"Unknown video mode (see -M help)\n");
125 assert(num_substreams > 0);
127 switch (num_substreams) {
143 std::streamsize p = os.precision();
144 ios_base::fmtflags f = os.flags();
148 os <<
desc.
width <<
"x" <<
desc.
height <<
" @" << setprecision(2) << setiosflags(ios_base::fixed)
169 char interl_suffix[4] =
"";
170 char codec_name[11] =
"";
176 while (is.good() && i <
sizeof buf - 1) {
182 if (num_spaces == 3 &&
183 !(isalnum(c) || c ==
'.'))
197 if (strchr(line,
'*')) {
199 line = strchr(line,
'*') + 1;
201 int ret = sscanf(line,
"%dx%d @%lf%3[a-z], codec %10s", &out.
width, &out.
height,
202 &out.
fps, interl_suffix, codec_name);
205 is.setstate(std::ios::failbit);
234video_desc::operator string()
const
243 thread_local string desc_str;
245 return desc_str.c_str();
255 const char *fps_str = strpbrk(
string,
"DKdikp");
256 assert(fps_str !=
nullptr);
258 if (strlen(fps_str) == 0) {
261 char *endptr =
nullptr;
262 const long fps_l = strtol(fps_str, &endptr, 10);
263 if (fps_l <= 0 || fps_l >
FPS_MAX || *endptr !=
'\0') {
264 MSG(ERROR,
"Wrong mode FPS specification: %s\n",
string);
280 fps = (double) fps_l;
284 return interlaced ? fps / 2.0 : fps;
322 if (strcasecmp(
string,
"help") == 0) {
323 printf(
"Recognized video formats: ");
324 for (
unsigned i = 0; i <
sizeof map /
sizeof map[0]; ++i) {
327 color_printf(
TBOLD(
"{Hp,Hi,hp,2d,4k,4d,1080i,1080p,720p,2160p}{23,24,25,29,30,59,60}")
"\n");
331 for (
unsigned i = 0; i <
sizeof map /
sizeof map[0]; ++i) {
332 if (strcasecmp(map[i].
name,
string) == 0 || (strlen(
string) == 4 &&
string[3] ==
' ' && strncasecmp(map[i].
name,
string, 3) == 0)) {
340 if (strncmp(
string,
"Hp", 2) == 0 ||
STARTS_WITH(
string,
"1080p")) {
343 }
else if (strncmp(
string,
"Hi", 2) == 0 ||
348 }
else if (strncmp(
string,
"hp", 2) == 0 ||
352 }
else if (strncasecmp(
string,
"2d", 2) == 0) {
355 }
else if (strncasecmp(
string,
"4k", 2) == 0 ||
359 }
else if (strncasecmp(
string,
"4d", 2) == 0) {
363 if (ret.
width == 0) {
364 MSG(ERROR,
"Unrecognized video mode: %s\n",
string);
const char * get_codec_name(codec_t codec)
codec_t get_codec_from_name(const char *name)
int color_printf(const char *format,...)
void log_msg(int level, const char *format,...)
#define LOG_LEVEL_ERROR
general errors
#define STARTS_WITH(str, token)
@ FPS_MAX
given by UG RTP payload header
bool operator!=(video_desc const &) const
enum interlacing_t interlacing
bool operator==(video_desc const &) const
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
operator std::string() const
@ VIDEO_STEREO
stereoscopic 3D video (full left and right eye)
@ VIDEO_UNKNOWN
unspecified video mode
@ VIDEO_NORMAL
normal video (one tile)
@ VIDEO_DUAL
1x2 video grid (is this ever used?)
@ PROGRESSIVE
progressive frame
@ SEGMENTED_FRAME
Segmented frame. Contains the same data as progressive frame.
@ INTERLACED_MERGED
Columngs of both fields are interlaced together.
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ VIDEO_CODEC_NONE
dummy color spec
const char * video_desc_to_string(struct video_desc d)
static const map< enum video_mode, video_mode_info_t > video_mode_info
enum video_mode get_video_mode_from_str(const char *requested_mode)
static double parse_fps(const char *string, bool interlaced)
std::ostream & operator<<(std::ostream &os, const video_desc &desc)
enum video_mode guess_video_mode(int num_substreams)
Tries to guess video mode from number of substreams.
std::istream & operator>>(std::istream &is, video_desc &desc)
struct video_desc get_video_desc_from_string(const char *string)
int get_video_mode_tiles_x(enum video_mode video_mode)
const char * get_video_mode_description(enum video_mode video_mode)
int get_video_mode_tiles_y(enum video_mode video_mode)
This is an umbrella header for video functions.
enum interlacing_t get_interlacing_from_suffix(const char *suffix)
const char * get_interlacing_suffix(enum interlacing_t interlacing)
Returns suffix describing interlacing Eg. p, i or psf.
bool video_desc_eq(struct video_desc a, struct video_desc b)
Compares two video descriptions.