vdr-plugin-softhddevice-drm-gles 1.4.0
misc.h
Go to the documentation of this file.
1
21#ifndef __MISC_H
22#define __MISC_H
23
24#include <syslog.h>
25#include <stdarg.h>
26#include <stdio.h>
27#include <time.h> // clock_gettime
28#include <unistd.h>
29#include <sys/syscall.h>
30#include <string.h>
31#include <inttypes.h>
32#include <stdint.h>
33
34#ifndef AV_NOPTS_VALUE
35#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
36#endif
37
38#define VIDEO_SURFACES_MAX 3
39
47static inline bool isInterlacedFrame(AVFrame *frame)
48{
49#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58,7,100)
50 return frame->interlaced_frame;
51#else
52 return frame->flags & AV_FRAME_FLAG_INTERLACED;
53#endif
54}
55
59#ifdef av_err2str
60#undef av_err2str
61static inline const char* av_err2string(int errnum)
62{
63 static char str[3][AV_ERROR_MAX_STRING_SIZE];
64 char buf[AV_ERROR_MAX_STRING_SIZE];
65 static int idx = 0;
66
67 idx = (idx + 1) % 3;
68 av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, errnum);
69 snprintf(str[idx], sizeof(str[idx]), "%s", buf);
70
71 return str[idx];
72}
73#define av_err2str(err) av_err2string(err)
74#endif
75
81static inline const char *Timestamp2String(int64_t ts, uint8_t divisor)
82{
83 static char buf[3][20];
84 static int idx = 0;
85
86 if (ts == (int64_t) AV_NOPTS_VALUE) {
87 return "--:--:--.---";
88 }
89
90 ts /= divisor;
91
92 idx = (idx + 1) % 3;
93 snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d",
94 (int)(ts / (3600000)), (int)((ts / (60000)) % 60),
95 (int)((ts / (1000)) % 60), (int)(ts % 1000));
96
97 return buf[idx];
98}
99
100#endif
#define AV_NOPTS_VALUE
Definition: misc.h:35
static bool isInterlacedFrame(AVFrame *frame)
Check, if this is an interlaced frame.
Definition: misc.h:47
static const char * Timestamp2String(int64_t ts, uint8_t divisor)
Workaround for av_err2str() not working with C++.
Definition: misc.h:81