Mesa (master): st/omx: Fix port format enumeration

Christian König deathsimple at kemper.freedesktop.org
Mon Mar 6 13:12:43 UTC 2017


Module: Mesa
Branch: master
Commit: 6d95358aacc184b8927ff138e90d5920885365e7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d95358aacc184b8927ff138e90d5920885365e7

Author: Mark Thompson <sw at jkqxz.net>
Date:   Sun Mar  5 22:10:14 2017 +0000

st/omx: Fix port format enumeration

>From OpenMAX IL section 4.3.5:
"The value of nIndex is the range 0 to N-1, where N is the number of
formats supported by the port.  There is no need for the port to
report N, as the caller can determine N by enumerating all the
formats supported by the port.  Each port shall support at least one
format.  If there are no more formats, OMX_GetParameter returns
OMX_ErrorNoMore (i.e., nIndex is supplied where the value is N or
greater)."

Only one format is supported, so N = 1 and OMX_ErrorNoMore should be
returned if nIndex >= 1.  The previous code here would return the
same format for all values of nIndex, resulting in an infinite loop
when a client attempts to enumerate all formats.

Signed-off-by: Mark Thompson <sw at jkqxz.net>
Reviewed-by: Christian König <christian.koenig at amd.com>

---

 src/gallium/state_trackers/omx/vid_enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c
index 07f6799..b2970a5 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -473,6 +473,8 @@ static OMX_ERRORTYPE vid_enc_GetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE i
 
       if (format->nPortIndex > 1)
          return OMX_ErrorBadPortIndex;
+      if (format->nIndex >= 1)
+         return OMX_ErrorNoMore;
 
       port = (omx_base_video_PortType *)priv->ports[format->nPortIndex];
       memcpy(format, &port->sVideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));




More information about the mesa-commit mailing list