11 #include "threads/CriticalSection.h" 21 #include <libavutil/pixfmt.h> 26 static const int MAX_PLANES = 3;
28 uint8_t* plane[MAX_PLANES];
29 int planesize[MAX_PLANES];
30 int stride[MAX_PLANES];
33 unsigned int cshift_x;
34 unsigned int cshift_y;
42 #define BUFFER_STATE_DECODER 0x01; 43 #define BUFFER_STATE_RENDER 0x02; 60 virtual void Return(
int id) = 0;
64 virtual void Configure(AVPixelFormat format,
int size) {}
67 virtual bool IsConfigured() {
return false; }
71 virtual bool IsCompatible(AVPixelFormat format,
int size) {
return false; }
82 std::shared_ptr<IVideoBufferPool> GetPtr() {
return shared_from_this(); }
91 void Acquire(std::shared_ptr<IVideoBufferPool> pool);
93 int GetId()
const {
return m_id; }
95 virtual AVPixelFormat GetFormat();
96 virtual uint8_t* GetMemPtr() {
return nullptr; }
97 virtual void GetPlanes(uint8_t* (&planes)[YuvImage::MAX_PLANES]) {}
98 virtual void GetStrides(
int (&strides)[YuvImage::MAX_PLANES]) {}
99 virtual void SetPixelFormat(
const AVPixelFormat pixFormat) {}
100 virtual void SetDimensions(
int width,
int height,
const int (&strides)[YuvImage::MAX_PLANES]) {}
101 virtual void SetDimensions(
int width,
103 const int (&strides)[YuvImage::MAX_PLANES],
104 const int (&planeOffsets)[YuvImage::MAX_PLANES])
114 AVPixelFormat m_pixFormat = AV_PIX_FMT_NONE;
115 std::atomic_int m_refCount;
117 std::shared_ptr<IVideoBufferPool> m_pool;
125 uint8_t* GetMemPtr()
override;
126 void GetPlanes(uint8_t*(&planes)[YuvImage::MAX_PLANES])
override;
127 void GetStrides(
int(&strides)[YuvImage::MAX_PLANES])
override;
128 void SetPixelFormat(
const AVPixelFormat pixFormat)
override;
129 void SetDimensions(
int width,
int height,
const int (&strides)[YuvImage::MAX_PLANES])
override;
130 void SetDimensions(
int width,
int height,
const int (&strides)[YuvImage::MAX_PLANES],
const int (&planeOffsets)[YuvImage::MAX_PLANES])
override;
137 uint8_t *m_data =
nullptr;
150 void Return(
int id)
override;
151 void Configure(AVPixelFormat format,
int size)
override;
152 bool IsConfigured()
override;
153 bool IsCompatible(AVPixelFormat format,
int size)
override;
156 static std::shared_ptr<IVideoBufferPool> CreatePool();
162 AVPixelFormat m_pixFormat = AV_PIX_FMT_NONE;
163 bool m_configured =
false;
164 CCriticalSection m_critSection;
166 ReadyToDispose m_cbDispose;
168 std::vector<CVideoBufferSysMem*> m_all;
169 std::deque<int> m_used;
170 std::deque<int> m_free;
177 typedef std::shared_ptr<IVideoBufferPool> (*CreatePoolFunc)();
183 void RegisterPool(
const std::shared_ptr<IVideoBufferPool>& pool);
184 void RegisterPoolFactory(
const std::string&
id, CreatePoolFunc createFunc);
191 CCriticalSection m_critSection;
192 std::list<std::shared_ptr<IVideoBufferPool>> m_pools;
193 std::list<std::shared_ptr<IVideoBufferPool>> m_discardedPools;
194 std::map<std::string, CreatePoolFunc> m_poolFactories;
Definition: VideoBuffer.h:85
Definition: VideoBuffer.h:120
Definition: VideoBuffer.h:179
Definition: VideoBuffer.h:24
Definition: VideoBuffer.h:51
Definition: VideoBuffer.h:145