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 SetDimensions(
int width,
int height,
const int (&strides)[YuvImage::MAX_PLANES]) {}
100 virtual void SetDimensions(
int width,
102 const int (&strides)[YuvImage::MAX_PLANES],
103 const int (&planeOffsets)[YuvImage::MAX_PLANES])
113 AVPixelFormat m_pixFormat = AV_PIX_FMT_NONE;
114 std::atomic_int m_refCount;
116 std::shared_ptr<IVideoBufferPool> m_pool;
124 uint8_t* GetMemPtr()
override;
125 void GetPlanes(uint8_t*(&planes)[YuvImage::MAX_PLANES])
override;
126 void GetStrides(
int(&strides)[YuvImage::MAX_PLANES])
override;
127 void SetDimensions(
int width,
int height,
const int (&strides)[YuvImage::MAX_PLANES])
override;
128 void SetDimensions(
int width,
int height,
const int (&strides)[YuvImage::MAX_PLANES],
const int (&planeOffsets)[YuvImage::MAX_PLANES])
override;
135 uint8_t *m_data =
nullptr;
148 void Return(
int id)
override;
149 void Configure(AVPixelFormat format,
int size)
override;
150 bool IsConfigured()
override;
151 bool IsCompatible(AVPixelFormat format,
int size)
override;
154 static std::shared_ptr<IVideoBufferPool> CreatePool();
160 AVPixelFormat m_pixFormat = AV_PIX_FMT_NONE;
161 bool m_configured =
false;
162 CCriticalSection m_critSection;
164 ReadyToDispose m_cbDispose;
166 std::vector<CVideoBufferSysMem*> m_all;
167 std::deque<int> m_used;
168 std::deque<int> m_free;
175 typedef std::shared_ptr<IVideoBufferPool> (*CreatePoolFunc)();
181 void RegisterPool(
const std::shared_ptr<IVideoBufferPool>& pool);
182 void RegisterPoolFactory(
const std::string&
id, CreatePoolFunc createFunc);
189 CCriticalSection m_critSection;
190 std::list<std::shared_ptr<IVideoBufferPool>> m_pools;
191 std::list<std::shared_ptr<IVideoBufferPool>> m_discardedPools;
192 std::map<std::string, CreatePoolFunc> m_poolFactories;
Definition: VideoBuffer.h:85
Definition: VideoBuffer.h:119
Definition: VideoBuffer.h:177
Definition: VideoBuffer.h:24
Definition: VideoBuffer.h:51
Definition: VideoBuffer.h:143