Skip to content

Commit

Permalink
MMAL: Make setting the decoder more consistent between MMALCodec and …
Browse files Browse the repository at this point in the history
…MMALFFMpeg
  • Loading branch information
popcornmix committed Sep 18, 2016
1 parent b74de6c commit d9731f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp
Expand Up @@ -42,8 +42,8 @@ using namespace MMAL;

#define CLASSNAME "CMMALYUVBuffer"

CMMALYUVBuffer::CMMALYUVBuffer(std::shared_ptr<CMMALPool> pool, uint32_t mmal_encoding, uint32_t width, uint32_t height, uint32_t aligned_width, uint32_t aligned_height, uint32_t size)
: CMMALBuffer(pool), m_omv(omv)
CMMALYUVBuffer::CMMALYUVBuffer(CDecoder *omv, std::shared_ptr<CMMALPool> pool, uint32_t mmal_encoding, uint32_t width, uint32_t height, uint32_t aligned_width, uint32_t aligned_height, uint32_t size)
: CMMALBuffer(pool), m_omv(omv)
{
uint32_t size_pic = 0;
m_width = width;
Expand Down Expand Up @@ -243,6 +243,7 @@ bool CDecoder::Open(AVCodecContext *avctx, AVCodecContext* mainctx, enum AVPixel
CLog::Log(LOGERROR, "%s::%s Failed to create pool for decoder output", CLASSNAME, __func__);
return false;
}
m_pool->SetDecoder(this);

std::list<EINTERLACEMETHOD> deintMethods;
deintMethods.push_back(EINTERLACEMETHOD::VS_INTERLACEMETHOD_AUTO);
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.h
Expand Up @@ -40,10 +40,11 @@ class CGPUPool;
class CMMALYUVBuffer : public CMMALBuffer
{
public:
CMMALYUVBuffer(std::shared_ptr<CMMALPool> pool, uint32_t mmal_encoding, uint32_t width, uint32_t height, uint32_t aligned_width, uint32_t aligned_height, uint32_t size);
CMMALYUVBuffer(CDecoder *dec, std::shared_ptr<CMMALPool> pool, uint32_t mmal_encoding, uint32_t width, uint32_t height, uint32_t aligned_width, uint32_t aligned_height, uint32_t size);
virtual ~CMMALYUVBuffer();

CGPUMEM *gmem;
CDecoder *m_omv;
private:
};

Expand Down
Expand Up @@ -72,6 +72,7 @@ CMMALPool::CMMALPool(const char *component_name, bool input, uint32_t num_buffer

m_mmal_pool = mmal_port_pool_create(port, port->buffer_num, port->buffer_size);
m_closing = false;
m_software = false;
m_mmal_format = 0;
m_width = 0;
m_height = 0;
Expand Down Expand Up @@ -208,14 +209,14 @@ CMMALBuffer *CMMALPool::GetBuffer(uint32_t timeout)
// ffmpeg requirements
uint32_t aligned_width = m_aligned_width, aligned_height = m_aligned_height;
AlignedSize(m_avctx, aligned_width, aligned_height);
if (m_dec)
if (!IsSoftware())
{
CMMALVideoBuffer *vid = new CMMALVideoBuffer(m_dec, shared_from_this());
CMMALVideoBuffer *vid = new CMMALVideoBuffer(static_cast<CMMALVideo *>(m_dec), shared_from_this());
omvb = vid;
}
else
{
MMAL::CMMALYUVBuffer *yuv = new MMAL::CMMALYUVBuffer(shared_from_this(), m_mmal_format, m_width, m_height, aligned_width, aligned_height, m_size);
MMAL::CMMALYUVBuffer *yuv = new MMAL::CMMALYUVBuffer(static_cast<MMAL::CDecoder *>(m_dec), shared_from_this(), m_mmal_format, m_width, m_height, aligned_width, aligned_height, m_size);
if (yuv)
{
CGPUMEM *gmem = yuv->gmem;
Expand Down
Expand Up @@ -62,20 +62,22 @@ class CMMALPool : public std::enable_shared_from_this<CMMALPool>
void ReleaseBuffer(CGPUMEM *gmem);
void Close();
void Prime();
void SetDecoder(CMMALVideo *dec) { m_dec = dec; }
void SetDecoder(void *dec) { m_dec = dec; }
void SetFormat(uint32_t mmal_format, uint32_t width, uint32_t height, uint32_t aligned_width, uint32_t aligned_height, uint32_t size, AVCodecContext *avctx)
{ m_mmal_format = mmal_format; m_width = width; m_height = height; m_aligned_width = aligned_width; m_aligned_height = aligned_height; m_size = size, m_avctx = avctx; }
{ m_mmal_format = mmal_format; m_width = width; m_height = height; m_aligned_width = aligned_width; m_aligned_height = aligned_height; m_size = size, m_avctx = avctx; m_software = true; }
bool IsSoftware() { return m_software; }
protected:
uint32_t m_mmal_format, m_width, m_height, m_aligned_width, m_aligned_height, m_size;
AVCodecContext *m_avctx;
CMMALVideo *m_dec;
void *m_dec;
MMALState m_state;
bool m_input;
MMAL_POOL_T *m_mmal_pool;
MMAL_COMPONENT_T *m_component;
CCriticalSection m_section;
std::deque<CGPUMEM *> m_freeBuffers;
bool m_closing;
bool m_software;
};

class CMMALRenderer : public CBaseRenderer, public CThread, public IRunnable
Expand Down

0 comments on commit d9731f2

Please sign in to comment.