Valkka  1.6.1
OpenSource Video Management
openglframefifo.h
1 #ifndef openglframefifo_HEADER_GUARD
2 #define openglframefifo_HEADER_GUARD
3 /*
4  * openglframefifo.h : FrameFifo for OpenGLThread: stack of YUV frames and uploading to GPU
5  *
6  * (c) Copyright 2017-2024 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 Lesser 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 Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>
24  *
25  */
26 
37 #include "opengl.h"
38 #include "framefilter.h"
39 
45 struct OpenGLFrameFifoContext { // <pyapi>
46  OpenGLFrameFifoContext() : n_720p(20), n_1080p(20), n_1440p(20), n_4K(20), n_setup(20), n_signal(20), flush_when_full(DEFAULT_OPENGLFRAMEFIFO_FLUSH_WHEN_FULL) {}; // <pyapi>
47  int n_720p; // <pyapi>
48  int n_1080p; // <pyapi>
49  int n_1440p; // <pyapi>
50  int n_4K; // <pyapi>
51  int n_setup;
52  int n_signal;
54 }; // <pyapi>
55 
56 
57 std::ostream& operator<< (std::ostream& os, const OpenGLFrameFifoContext& ctx) {
58  return os << "720p: " << ctx.n_720p <<" / 1080p: " << ctx.n_1080p << " / 1440p: " << ctx.n_1440p << " / 4K: " << ctx.n_4K << " / n_setup: " << ctx.n_setup << " / n_signal: " << ctx.n_signal << " / flush_when_full: " << int(ctx.flush_when_full);
59 }
60 
61 
69 class OpenGLFrameFifo : public FrameFifo {
70 
71 friend class OpenGLThread; // can manipulate reservoirs, stacks, etc.
72 
73 public:
81 
82 protected:
84  std::map<BitmapType,YUVReservoir> yuv_reservoirs;
85  std::map<BitmapType,YUVStack> yuv_stacks;
86  // note: we still have "reservoirs" and "stacks" inherited from FrameFifo
87 
88 protected:
90 
91 public: // redefined virtual
92  virtual bool writeCopy(Frame* f, bool wait=false);
93  virtual void recycle_(Frame* f);
94 
95 public:
96  void allocateYUV();
97  void deallocateYUV();
98  void dumpYUVStacks();
99  void YUVdiagnosis();
100 
101 public: // setters
102  void debugOn() {debug=true;}
103  void debugOff(){debug=false;}
104 
105 private:
106  bool debug;
107 };
108 
109 #endif
Decoded YUV/RGB frame in FFMpeg format.
Definition: frame.h:361
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:83
FrameFifoContext ctx
Parameters defining the stack and overflow behaviour.
Definition: framefifo.h:93
Frame: An abstract queueable class.
Definition: frame.h:112
A FrameFifo managed and used by OpenGLThread.
Definition: openglframefifo.h:69
void deallocateYUV()
Deallocate YUVFrame's .. must be done before OpenGLThread exits.
Definition: openglframefifo.cpp:107
OpenGLFrameFifo(OpenGLFrameFifoContext ctx=OpenGLFrameFifoContext())
Default constructor.
Definition: openglframefifo.cpp:42
std::map< BitmapType, YUVReservoir > yuv_reservoirs
Instances of YUVFrame s.
Definition: openglframefifo.h:84
YUVFrame * prepareAVBitmapFrame(AVBitmapFrame *frame)
Tries to get a YUVFrame with correct bitmap dimensions from the stack. If success,...
Definition: openglframefifo.cpp:127
void YUVdiagnosis()
Brief resumen of OpenGLFrameFifo::yuv_stacks.
Definition: openglframefifo.cpp:239
virtual bool writeCopy(Frame *f, bool wait=false)
Redefined. Uses FrameFifo::writeCopy. Separates configuration frames and YUVFrames.
Definition: openglframefifo.cpp:168
~OpenGLFrameFifo()
Default destructor.
Definition: openglframefifo.cpp:77
OpenGLFrameFifoContext gl_ctx
Stack profile and overflow behaviour.
Definition: openglframefifo.h:83
void allocateYUV()
Allocate YUVFrame's .. must be done after OpenGLThread has been started.
Definition: openglframefifo.cpp:82
virtual void recycle_(Frame *f)
Redefined. Uses FrameFifo::recycle_. Separates configuration frames and YUVFrames.
Definition: openglframefifo.cpp:209
std::map< BitmapType, YUVStack > yuv_stacks
Pointers to Frames s in the reservoirs.
Definition: openglframefifo.h:85
void dumpYUVStacks()
Dump frames in OpenGLFrameFifo::yuv_stacks.
Definition: openglframefifo.cpp:223
This class does a lot of things:
Definition: openglthread.h:247
A GPU YUV frame.
Definition: frame.h:492
Definition of FrameFilter and derived classes for various purposes.
OpenGL calls for reserving PBOs and TEXtures, plus some auxiliary routines.
Describes the stack structure and fifo behaviour for an OpenGLFrameFifo.
Definition: openglframefifo.h:45
int n_signal
signals OpenGLThread // <pyapi>
Definition: openglframefifo.h:52
bool flush_when_full
Flush when filled // <pyapi>
Definition: openglframefifo.h:53
int n_setup
setup data // <pyapi>
Definition: openglframefifo.h:51