aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/cores/RetroPlayer/process/rbpi/RenderBufferPoolMMAL.cpp2
-rw-r--r--xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp36
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp20
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h5
-rw-r--r--xbmc/platform/linux/RBP.cpp50
-rw-r--r--xbmc/platform/linux/RBP.h39
6 files changed, 84 insertions, 68 deletions
diff --git a/xbmc/cores/RetroPlayer/process/rbpi/RenderBufferPoolMMAL.cpp b/xbmc/cores/RetroPlayer/process/rbpi/RenderBufferPoolMMAL.cpp
index 9d0bc784bf..068608fc6f 100644
--- a/xbmc/cores/RetroPlayer/process/rbpi/RenderBufferPoolMMAL.cpp
+++ b/xbmc/cores/RetroPlayer/process/rbpi/RenderBufferPoolMMAL.cpp
@@ -66,7 +66,7 @@ bool CRenderBufferPoolMMAL::ConfigureInternal()
m_alignedWidth = m_width;
m_alignedHeight = m_height;
- const unsigned int bpp = g_RBP.GetFrameGeometry(m_mmal_format, m_width, m_height).bytes_per_pixel;
+ const unsigned int bpp = g_RBP.GetFrameGeometry(m_mmal_format, m_width, m_height).getBytesPerPixel();
m_frameSize = m_width * m_height * bpp;
if (m_frameSize == 0)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp
index b655cca8ef..ac97643490 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp
@@ -64,22 +64,19 @@ void CMMALYUVBuffer::GetPlanes(uint8_t*(&planes)[YuvImage::MAX_PLANES])
{
for (int i = 0; i < YuvImage::MAX_PLANES; i++)
planes[i] = nullptr;
- if (!m_gmem)
- return;
std::shared_ptr<CMMALPool> pool = std::dynamic_pointer_cast<CMMALPool>(m_pool);
assert(pool);
AVRpiZcFrameGeometry geo = pool->GetGeometry();
- const int size_y = geo.stride_y * geo.height_y;
- const int size_c = geo.stride_c * geo.height_c;
- CLog::Log(LOGDEBUG, LOGVIDEO, "%s::%s %dx%d %dx%d (%dx%d %dx%d)", CLASSNAME, __FUNCTION__, geo.stride_y, geo.height_y, geo.stride_c, geo.height_c, Width(), Height(), AlignedWidth(), AlignedHeight());
+ if (VERBOSE)
+ CLog::Log(LOGDEBUG, LOGVIDEO, "%s::%s %dx%d %dx%d (%dx%d %dx%d)", CLASSNAME, __FUNCTION__, geo.getStrideY(), geo.getHeightY(), geo.getStrideC(), geo.getHeightC(), Width(), Height(), AlignedWidth(), AlignedHeight());
- planes[0] = static_cast<uint8_t *>(m_gmem->m_arm);
- if (geo.planes_c >= 1)
- planes[1] = planes[0] + size_y;
- if (geo.planes_c >= 2)
- planes[2] = planes[1] + size_c;
+ planes[0] = GetMemPtr();
+ if (planes[0] && geo.getPlanesC() >= 1)
+ planes[1] = planes[0] + geo.getSizeY();
+ if (planes[1] && geo.getPlanesC() >= 2)
+ planes[2] = planes[1] + geo.getSizeC();
}
void CMMALYUVBuffer::GetStrides(int(&strides)[YuvImage::MAX_PLANES])
@@ -89,9 +86,9 @@ void CMMALYUVBuffer::GetStrides(int(&strides)[YuvImage::MAX_PLANES])
std::shared_ptr<CMMALPool> pool = std::dynamic_pointer_cast<CMMALPool>(m_pool);
assert(pool);
AVRpiZcFrameGeometry geo = pool->GetGeometry();
- strides[0] = geo.stride_y;
- strides[1] = geo.stride_c;
- strides[2] = geo.stride_c;
+ strides[0] = geo.getStrideY();
+ strides[1] = geo.getStrideC();
+ strides[2] = geo.getStrideC();
}
void CMMALYUVBuffer::SetDimensions(int width, int height, const int (&strides)[YuvImage::MAX_PLANES], const int (&planeOffsets)[YuvImage::MAX_PLANES])
@@ -187,11 +184,14 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
int aligned_width = frame->width;
int aligned_height = frame->height;
- // ffmpeg requirements
- AlignedSize(dec->m_avctx, aligned_width, aligned_height);
- // GPU requirements
- aligned_width = ALIGN_UP(aligned_width, 32);
- aligned_height = ALIGN_UP(aligned_height, 16);
+ if (pool->Encoding() != MMAL_ENCODING_YUVUV128 && pool->Encoding() != MMAL_ENCODING_YUVUV64_16)
+ {
+ // ffmpeg requirements
+ AlignedSize(dec->m_avctx, aligned_width, aligned_height);
+ // GPU requirements
+ aligned_width = ALIGN_UP(aligned_width, 32);
+ aligned_height = ALIGN_UP(aligned_height, 16);
+ }
pool->Configure(dec->m_fmt, frame->width, frame->height, aligned_width, aligned_height, 0);
}
CMMALYUVBuffer *YUVBuffer = dynamic_cast<CMMALYUVBuffer *>(pool->Get());
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp
index 8a29126fc6..ccf55e1d60 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp
@@ -130,8 +130,6 @@ CMMALPool::CMMALPool(const char *component_name, bool input, uint32_t num_buffer
CSingleLock lock(m_critSection);
MMAL_STATUS_T status;
- memset(&m_geo, 0, sizeof m_geo);
-
status = mmal_component_create(component_name, &m_component);
if (status != MMAL_SUCCESS)
CLog::Log(LOGERROR, "%s::%s Failed to create component %s", CLASSNAME, __func__, component_name);
@@ -242,22 +240,18 @@ void CMMALPool::Configure(AVPixelFormat format, int width, int height, int align
{
if (alignedWidth)
{
- m_geo.stride_y = alignedWidth * m_geo.bytes_per_pixel;
- m_geo.stride_c = alignedWidth * m_geo.bytes_per_pixel >> 1;
+ m_geo.setStrideY(alignedWidth * m_geo.getBytesPerPixel());
+ m_geo.setStrideC(alignedWidth * m_geo.getBytesPerPixel() >> 1);
}
if (alignedHeight)
{
- m_geo.height_y = alignedHeight;
- m_geo.height_c = alignedHeight >> 1;
+ m_geo.setHeightY(alignedHeight);
+ m_geo.setHeightC(alignedHeight >> 1);
}
}
}
if (m_size == 0)
- {
- const unsigned int size_y = m_geo.stride_y * m_geo.height_y;
- const unsigned int size_c = m_geo.stride_c * m_geo.height_c;
- m_size = (size_y + size_c * m_geo.planes_c) * m_geo.stripes;
- }
+ m_size = m_geo.getSize();
CLog::Log(LOGDEBUG, "%s::%s pool:%p %dx%d (%dx%d) pix:%d size:%d fmt:%.4s", CLASSNAME, __func__,
static_cast<void*>(m_mmal_pool), width, height, alignedWidth, alignedHeight, format, size,
(char*)&m_mmal_format);
@@ -270,8 +264,8 @@ void CMMALPool::Configure(AVPixelFormat format, int size)
void CMMALPool::SetDimensions(int width, int height, const int (&strides)[YuvImage::MAX_PLANES], const int (&planeOffsets)[YuvImage::MAX_PLANES])
{
- assert(m_geo.bytes_per_pixel);
- int alignedWidth = strides[0] ? strides[0] / m_geo.bytes_per_pixel : width;
+ assert(m_geo.getBytesPerPixel());
+ int alignedWidth = strides[0] ? strides[0] / m_geo.getBytesPerPixel() : width;
int alignedHeight = planeOffsets[1] ? planeOffsets[1] / strides[0] : height;
Configure(AV_PIX_FMT_NONE, width, height, alignedWidth, alignedHeight, 0);
}
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h
index 71ea46a5d0..d1810809aa 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h
@@ -69,8 +69,9 @@ public:
static uint32_t TranslateFormat(AVPixelFormat pixfmt);
virtual int Width() { return m_width; }
virtual int Height() { return m_height; }
- virtual int AlignedWidth() { return m_geo.stride_y / m_geo.bytes_per_pixel; }
- virtual int AlignedHeight() { return m_geo.height_y; }
+ virtual int AlignedWidth() { return m_mmal_format == MMAL_ENCODING_YUVUV128 || m_mmal_format == MMAL_ENCODING_YUVUV64_16 ? 0 : m_geo.getStrideY() / m_geo.getBytesPerPixel(); }
+ virtual int AlignedHeight() { return m_mmal_format == MMAL_ENCODING_YUVUV128 || m_mmal_format == MMAL_ENCODING_YUVUV64_16 ? 0 : m_geo.getHeightY(); }
+ virtual int BitsPerPixel() { return m_geo.getBitsPerPixel(); }
virtual uint32_t &Encoding() { return m_mmal_format; }
virtual int Size() { return m_size; }
AVRpiZcFrameGeometry &GetGeometry() { return m_geo; }
diff --git a/xbmc/platform/linux/RBP.cpp b/xbmc/platform/linux/RBP.cpp
index 6ef7f8b434..bee729ec51 100644
--- a/xbmc/platform/linux/RBP.cpp
+++ b/xbmc/platform/linux/RBP.cpp
@@ -419,37 +419,37 @@ void CGPUMEM::Flush()
AVRpiZcFrameGeometry CRBP::GetFrameGeometry(uint32_t encoding, unsigned short video_width, unsigned short video_height)
{
- AVRpiZcFrameGeometry geo = {};
- geo.stripes = 1;
- geo.bytes_per_pixel = 1;
+ AVRpiZcFrameGeometry geo;
+ geo.setStripes(1);
+ geo.setBitsPerPixel(8);
switch (encoding)
{
case MMAL_ENCODING_RGBA: case MMAL_ENCODING_BGRA:
- geo.bytes_per_pixel = 4;
- geo.stride_y = video_width * geo.bytes_per_pixel;
- geo.height_y = video_height;
+ geo.setBitsPerPixel(32);
+ geo.setStrideY(video_width * geo.getBytesPerPixel());
+ geo.setHeightY(video_height);
break;
case MMAL_ENCODING_RGB24: case MMAL_ENCODING_BGR24:
- geo.bytes_per_pixel = 3;
- geo.stride_y = video_width * geo.bytes_per_pixel;
- geo.height_y = video_height;
+ geo.setBitsPerPixel(32);
+ geo.setStrideY(video_width * geo.getBytesPerPixel());
+ geo.setHeightY(video_height);
break;
case MMAL_ENCODING_RGB16: case MMAL_ENCODING_BGR16:
- geo.bytes_per_pixel = 2;
- geo.stride_y = video_width * geo.bytes_per_pixel;
- geo.height_y = video_height;
+ geo.setBitsPerPixel(16);
+ geo.setStrideY(video_width * geo.getBytesPerPixel());
+ geo.setHeightY(video_height);
break;
case MMAL_ENCODING_I420:
- geo.stride_y = (video_width + 31) & ~31;
- geo.stride_c = geo.stride_y >> 1;
- geo.height_y = (video_height + 15) & ~15;
- geo.height_c = geo.height_y >> 1;
- geo.planes_c = 2;
+ geo.setStrideY((video_width + 31) & ~31);
+ geo.setStrideC(geo.getStrideY() >> 1);
+ geo.setHeightY((video_height + 15) & ~15);
+ geo.setHeightC(geo.getHeightY() >> 1);
+ geo.setPlanesC(2);
break;
case MMAL_ENCODING_OPAQUE:
- geo.stride_y = video_width;
- geo.height_y = video_height;
+ geo.setStrideY(video_width);
+ geo.setHeightY(video_height);
break;
case MMAL_ENCODING_YUVUV128:
{
@@ -460,12 +460,12 @@ AVRpiZcFrameGeometry CRBP::GetFrameGeometry(uint32_t encoding, unsigned short vi
int rc = get_image_params(GetMBox(), &img);
assert(rc == 0);
const unsigned int stripe_w = 128;
- geo.stride_y = stripe_w;
- geo.stride_c = stripe_w;
- geo.height_y = ((intptr_t)img.extra.uv.u - (intptr_t)img.image_data) / stripe_w;
- geo.height_c = img.pitch / stripe_w - geo.height_y;
- geo.planes_c = 1;
- geo.stripes = (video_width + stripe_w - 1) / stripe_w;
+ geo.setStrideY(stripe_w);
+ geo.setStrideC(stripe_w);
+ geo.setHeightY(((intptr_t)img.extra.uv.u - (intptr_t)img.image_data) / stripe_w);
+ geo.setHeightC(img.pitch / stripe_w - geo.getHeightY());
+ geo.setPlanesC(1);
+ geo.setStripes((video_width + stripe_w - 1) / stripe_w);
break;
}
default: assert(0);
diff --git a/xbmc/platform/linux/RBP.h b/xbmc/platform/linux/RBP.h
index d8a4285e08..0eec93dd95 100644
--- a/xbmc/platform/linux/RBP.h
+++ b/xbmc/platform/linux/RBP.h
@@ -36,16 +36,37 @@
#include "threads/Event.h"
-typedef struct AVRpiZcFrameGeometry
+class AVRpiZcFrameGeometry
{
- unsigned int stride_y;
- unsigned int height_y;
- unsigned int stride_c;
- unsigned int height_c;
- unsigned int planes_c;
- unsigned int stripes;
- unsigned int bytes_per_pixel;
-} AVRpiZcFrameGeometry;
+public:
+ unsigned int getStrideY() { return stride_y; }
+ unsigned int getHeightY() { return height_y; }
+ unsigned int getStrideC() { return stride_c; }
+ unsigned int getHeightC() { return height_c; }
+ unsigned int getPlanesC() { return planes_c; }
+ unsigned int getStripes() { return stripes; }
+ unsigned int getBitsPerPixel() { return bits_per_pixel; }
+ unsigned int getBytesPerPixel() { return (bits_per_pixel + 7) >> 3; }
+ unsigned int getSizeY() { return stride_y * height_y; }
+ unsigned int getSizeC() { return stride_c * height_c; }
+ unsigned int getSize() { return (getSizeY() + getSizeC() * getPlanesC()) * getStripes(); }
+ void setStrideY(unsigned int v) { stride_y = v; }
+ void setHeightY(unsigned int v) { height_y = v; }
+ void setStrideC(unsigned int v) { stride_c = v; }
+ void setHeightC(unsigned int v) { height_c = v; }
+ void setPlanesC(unsigned int v) { planes_c = v; }
+ void setStripes(unsigned int v) { stripes = v; }
+ void setBitsPerPixel(unsigned int v) { bits_per_pixel = v; }
+ void setBytesPerPixel(unsigned int v) { bits_per_pixel = v * 8; }
+private:
+ unsigned int stride_y = 0;
+ unsigned int height_y = 0;
+ unsigned int stride_c = 0;
+ unsigned int height_c = 0;
+ unsigned int planes_c = 0;
+ unsigned int stripes = 0;
+ unsigned int bits_per_pixel = 0;
+};
class CGPUMEM
{