From a5d2f886741aa552c1df2b733a473059a5c20d57 Mon Sep 17 00:00:00 2001 From: Thomas Reufer Date: Thu, 10 Dec 2015 10:08:54 +0100 Subject: report pixel aspect ratio --- omx.c | 24 ++++++++++++++++++++++++ omx.h | 1 + omxdevice.c | 6 ++++-- tools.h | 4 +++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/omx.c b/omx.c index 8c23a4f..eea90fd 100644 --- a/omx.c +++ b/omx.c @@ -290,6 +290,13 @@ void cOmx::HandlePortSettingsChanged(unsigned int portId) &portdef) != OMX_ErrorNone) ELOG("failed to get video decoder port format!"); + OMX_CONFIG_POINTTYPE pixelAspect; + OMX_INIT_STRUCT(pixelAspect); + pixelAspect.nPortIndex = 131; + if (OMX_GetParameter(ILC_GET_HANDLE(m_comp[eVideoDecoder]), OMX_IndexParamBrcmPixelAspectRatio, + &pixelAspect) != OMX_ErrorNone) + ELOG("failed to get pixel aspect ratio!"); + OMX_CONFIG_INTERLACETYPE interlace; OMX_INIT_STRUCT(interlace); interlace.nPortIndex = 131; @@ -299,6 +306,8 @@ void cOmx::HandlePortSettingsChanged(unsigned int portId) m_videoFrameFormat.width = portdef.format.video.nFrameWidth; m_videoFrameFormat.height = portdef.format.video.nFrameHeight; + m_videoFrameFormat.pixelWidth = pixelAspect.nX; + m_videoFrameFormat.pixelHeight = pixelAspect.nY; m_videoFrameFormat.scanMode = interlace.eMode == OMX_InterlaceProgressive ? cScanMode::eProgressive : interlace.eMode == OMX_InterlaceFieldSingleUpperFirst ? cScanMode::eTopFieldFirst : @@ -1195,6 +1204,21 @@ void cOmx::SetDisplayMode(bool fill, bool noaspect) ELOG("failed to set display region!"); } +void cOmx::SetPixelAspectRatio(int width, int height) +{ + OMX_CONFIG_DISPLAYREGIONTYPE region; + OMX_INIT_STRUCT(region); + region.nPortIndex = 90; + region.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_PIXEL); + + region.pixel_x = width; + region.pixel_y = height; + + if (OMX_SetConfig(ILC_GET_HANDLE(m_comp[eVideoRender]), + OMX_IndexConfigDisplayRegion, ®ion) != OMX_ErrorNone) + ELOG("failed to set pixel apect ratio!"); +} + void cOmx::SetDisplayRegion(int x, int y, int width, int height) { OMX_CONFIG_DISPLAYREGIONTYPE region; diff --git a/omx.h b/omx.h index e79154b..8544e01 100644 --- a/omx.h +++ b/omx.h @@ -86,6 +86,7 @@ public: } void SetDisplayMode(bool letterbox, bool noaspect); + void SetPixelAspectRatio(int width, int height); void SetDisplayRegion(int x, int y, int width, int height); void SetDisplay(int display, int layer); diff --git a/omxdevice.c b/omxdevice.c index 270deac..2771ec5 100644 --- a/omxdevice.c +++ b/omxdevice.c @@ -672,8 +672,10 @@ void cOmxDevice::HandleStreamStart() DBG("HandleStreamStart()"); const cVideoFrameFormat *format = m_omx->GetVideoFrameFormat(); - DLOG("video stream started %dx%d@%d%s", format->width, format->height, - format->frameRate, format->Interlaced() ? "i" : "p"); + DLOG("video stream started %dx%d@%d%s PAR(%d:%d)", + format->width, format->height, format->frameRate, + format->Interlaced() ? "i" : "p", + format->pixelWidth, format->pixelHeight); cRpiDisplay::SetVideoFormat(format); } diff --git a/tools.h b/tools.h index 248c666..46a8a54 100644 --- a/tools.h +++ b/tools.h @@ -186,12 +186,14 @@ class cVideoFrameFormat public: cVideoFrameFormat() : width(0), height(0), frameRate(0), - scanMode(cScanMode::eProgressive) { }; + scanMode(cScanMode::eProgressive), pixelWidth(0), pixelHeight(0) { }; int width; int height; int frameRate; cScanMode::eMode scanMode; + int pixelWidth; + int pixelHeight; bool Interlaced(void) const { return cScanMode::Interlaced(scanMode); -- cgit v1.2.3