Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4103f8e1 authored by Juan Escamilla's avatar Juan Escamilla Committed by Steve Kondik
Browse files

libstagefright: Select appropriate color format

Iterate through supported color formats to select appropriate
color format for third party applications

Change-Id: Ib243b4051dfe967ea9b22902c8f461eab3a0a427
parent a92da66b
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -1358,7 +1358,31 @@ status_t OMXCodec::setVideoOutputFormat(
        OMX_VIDEO_PARAM_PORTFORMATTYPE format;
        InitOMXParams(&format);
        format.nPortIndex = kPortIndexOutput;

        // For 3rd party applications we want to iterate through all the
        // supported color formats by the OMX component. If OMX codec is
        // being run in a sepparate process, then pick the second iterated
        // color format.
#if 1
        if (!strncmp(mComponentName, "OMX.qcom.7x30",13)) {
            OMX_U32 index;
	    
            for(index = 0 ;; index++){
              format.nIndex = index;
	      if(mOMX->getParameter(
			    mNode, OMX_IndexParamVideoPortFormat,
			    &format, sizeof(format)) != OK) {
		if(format.nIndex) format.nIndex--;
		break;
	      }
            }
            if(mOMXLivesLocally)
              format.nIndex = 0;
        } else
          format.nIndex = 0;
#else
        format.nIndex = 0;
#endif

        status_t err = mOMX->getParameter(
                mNode, OMX_IndexParamVideoPortFormat,
@@ -1367,11 +1391,15 @@ status_t OMXCodec::setVideoOutputFormat(
        CHECK_EQ(format.eCompressionFormat, OMX_VIDEO_CodingUnused);

        static const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00;
        static const int QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka = 0x7FA30C01;
        static const int QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7FA30C03;

        CHECK(format.eColorFormat == OMX_COLOR_FormatYUV420Planar
               || format.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar
               || format.eColorFormat == OMX_COLOR_FormatCbYCrY
               || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar);
               || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar
               || format.eColorFormat == QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka
               || format.eColorFormat == QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka);

        err = mOMX->setParameter(
                mNode, OMX_IndexParamVideoPortFormat,