Valkka  0.17.0
OpenSource Video Management
constant.h
Go to the documentation of this file.
1 #ifndef constant_HEADER_GUARD
2 #define constant_HEADER_GUARD
3 /*
4  * constant.h : Constant/default values, version numbers
5  *
6  * Copyright 2017, 2018 Valkka Security Ltd. and Sampsa Riikonen.
7  *
8  * Authors: Sampsa Riikonen <sampsa.riikonen@iki.fi>
9  *
10  * This file is part of the Valkka library.
11  *
12  * Valkka is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Affero General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Affero General Public License for more details.
21  *
22  * You should have received a copy of the GNU Affero General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>
24  *
25  */
26 
37 #include "common.h"
38 
39 #define GLX_CONTEXT_MAJOR_VERSION 0x2091
40 #define GLX_CONTEXT_MINOR_VERSION 0x2092
41 
42 #define ALIGNMENT 1
43 /*
44 
45 https://stackoverflow.com/questions/35678041/what-is-linesize-alignment-meaning
46 https://softwareengineering.stackexchange.com/questions/328775/how-important-is-memory-alignment-does-it-still-matter
47 
48 - decoder returns YUV frames that are aligned
49 - ..during YUV => RGB interpolation (SwScaleFrameFilter, etc.), we get rid of the alignment (i.e. the extra padding bytes)
50 - ..anyway, that must be done at some moment before passing the frames downstream (for analyzers, etc.)
51 
52 => KEEP ALIGNMENT = 1
53 
54 - ..there might be performance benefits in using, for the final rgb bitmap images, widths that are multiples of 32
55 */
56 
57 const char* get_numpy_version() { // <pyapi>
58  return NUMPY_VERSION; // <pyapi>
59 } // <pyapi>
60 
61 static const int VERSION_MAJOR = 0; // <pyapi>
62 static const int VERSION_MINOR = 17; // <pyapi>
63 static const int VERSION_PATCH = 0; // <pyapi>
64 
65 static const unsigned LIVE_GET_PARAMETER_PING = 50; // ping the camera with GET_PARAMETER_PING every N:th second while the connection is active
66 
67 static const unsigned DEFAULT_OPENGLTHREAD_BUFFERING_TIME = 300; // in milliseconds // <pyapi>
68 static const bool DEFAULT_FRAMEFIFO_FLUSH_WHEN_FULL = false; // <pyapi>
69 static const bool DEFAULT_OPENGLFRAMEFIFO_FLUSH_WHEN_FULL = false; // <pyapi>
70 static const long int DEFAULT_TIMESTAMP_RESET_TIME = 60000; // <pyapi>
71 // static const long int TIMESTAMP_CORRECT_TRESHOLD = 30000; // <pyapi> // timestamp correctors start correcting timestamps if they are this much off (in milliseconds)
72 static const long int TIMESTAMP_CORRECT_TRESHOLD = 2000; // <pyapi> // people don't get it.. and besides, it might be difficult to adjust camera's internal clock. So, if frame is 2+ seconds late,
73 // the timestamp will be step-corrected
74 static const std::size_t FS_GRAIN_SIZE = 4096; // <pyapi> // grain size for ValkkaFS
75 
76 namespace Timeout {
77  const static long unsigned thread =250; // Timeout::thread
78  const static long unsigned livethread =250; // Timeout::livethread
79  const static long unsigned avthread =250; // Timeout::avthread
80  const static long unsigned openglthread =250; // Timeout::openglthread
81  const static long unsigned valkkafswriterthread = 250; // Timeout::valkkafswriterthread
82  const static long unsigned valkkafsreaderthread = 250; // Timeout::valkkafswriterthread
83  const static long unsigned filecachethread = 1000; // Timeout::valkkacachethread
84  // const static long unsigned filecachethread = 500; // Timeout::valkkacachethread
85  const static long unsigned usbthread =250; // Timeout::usbthread
86  const static long int filethread =2000; // Timeout::filethread
87  const static long int fdwritethread =250; // Timeout::filethread
88 }
89 
90 
93 
94  // DEFAULT_PAYLOAD_SIZE_H264 = 1024*100, ///< Default buffer size in Live555 for h264
96  // DEFAULT_PAYLOAD_SIZE_H264 = 1024*500, ///< Default buffer size in Live555 for h264
97  // DEFAULT_PAYLOAD_SIZE_H264 = 1024*10, ///< Default buffer size in Live555 for h264 // debug
98  // DEFAULT_PAYLOAD_SIZE_H264 = 1024, // use this small value for debugging (( debug
99 
101 };
102 
103 enum MaxSizes {
104  N_MAX_SLOTS =256,
106  // N_MAX_GPU_STACK =200 // not used..
107 };
108 
109 
110 // using BitmapType = unsigned;
111 // using SlotNumber = unsigned short; // swig does not get this ..
112 
113 typedef unsigned BitmapType;
114 typedef unsigned short SlotNumber; // <pyapi>
115 typedef std::size_t IdNumber; // <pyapi>
116 
117 static const SlotNumber I_MAX_SLOTS = 255; // Slot number maximum index. Max number of slots = I_MAX_SLOTS+1
118 static const int I_MAX_SUBSESSIONS = 3;
119 
120 
129 struct BitmapPars {
130  BitmapPars(BitmapType type=0, int width=0, int height=0, int w_fac=1, int h_fac=1) : type(type), width(width), height(height), w_fac(w_fac), h_fac(h_fac) {
131  y_size =width*height;
132  u_size =y_size/w_fac/h_fac;
133  v_size =u_size;
134 
135  // linesize aka maximum allowed width
136  y_width =width;
137  u_width =width/w_fac;
138  v_width =u_width;
139 
140  y_height =height;
141  u_height =height/h_fac;
142  v_height =u_height;
143 
144  // the default
145  y_linesize =y_width;
146  u_linesize =u_width;
147  v_linesize =v_width;
148  };
149 
150  BitmapType type;
151 
152  int width;
153  int height;
154  int w_fac;
155  int h_fac;
156 
157  int y_size;
158  int u_size;
159  int v_size;
160 
161  int y_width;
162  int u_width;
163  int v_width;
164 
165  int y_height;
166  int u_height;
167  int v_height;
168 
169  int y_linesize;
170  int u_linesize;
171  int v_linesize;
172 };
173 
174 bool operator==(BitmapPars const &a, BitmapPars const &b) { // is copyable ?
175  return ( (a.y_linesize == b.y_linesize) and (a.u_linesize == b.u_linesize) and (a.v_linesize == b.v_linesize) );
176 }
177 
178 inline std::ostream &operator<<(std::ostream &os, BitmapPars const &m) {
179  return os << "<BitmapPars: type=" << int(m.type) << " w, h=" << m.width << ", " << m.height << ">";
180 }
181 
182 static const BitmapPars N720 (1,1280,720, 2,2);
183 static const BitmapPars N1080 (2,1920,1080,2,2);
184 
185 // static const BitmapPars N1440 (3,2560,1440,2,2); // this is 2K, but not "universal" one, where all 2Ks would fit
186 static const BitmapPars N1440 (3,3000,1690,2,2); // all 2Ks will fit here :) Takes more than two times less space than 4K
187 
188 static const BitmapPars N4K (4,4032,3000,2,2);
189 
190 static const std::vector<uint8_t> nalstamp = {0,0,0,1};
191 
192 
193 #endif
int h_fac
height factor for chroma plane
Definition: constant.h:155
PayloadSizes
Definition: constant.h:91
For AVBitmapFrames, linesizes are the widths + padding bytes.
Definition: constant.h:129
int width
width of luma plane
Definition: constant.h:152
Default buffer size in Live555 for h264 // debug.
Definition: constant.h:92
Definition: constant.h:76
Maximum number of slots (used both by livethread.cpp and openglthread.cpp.
Definition: constant.h:104
int w_fac
width factor for chroma plane
Definition: constant.h:154
Default buffer size in Live555 for pcmu.
Definition: constant.h:100
Maximum number of decoders per one AVThread instance.
Definition: constant.h:105
Default buffer size in Live555 for h264.
Definition: constant.h:95
int height
height of luma plane
Definition: constant.h:153
List of common header files.
MaxSizes
Definition: constant.h:103