void QCameraHAL3RawSnapshotTest::configureRawSnapshotStream(hal3_camera_test_obj_t *my_test_obj,
                                    int camid, int w, int h)
{
    camera3_device_t *device_handle = my_test_obj->device;
    LOGD(" configureSnapshotStream testcase dim :%d  X %d", w, h);
    mPreviewStream = new camera3_stream_t;
    mRawSnapshotStream = new camera3_stream_t;

    memset(mPreviewStream, 0, sizeof(camera3_stream_t));
    memset(mRawSnapshotStream, 0, sizeof(camera3_stream_t));

    mPreviewStream = initStream(CAMERA3_STREAM_OUTPUT, camid, PREVIEW_WIDTH, PREVIEW_HEIGHT, 0,
            HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, HAL3_DATASPACE_UNKNOWN);
    mRawSnapshotStream = initStream(CAMERA3_STREAM_OUTPUT, camid, RAWSNAPSHOT_CAPTURE_WIDTH,
            RAWSNAPSHOT_CAPTURE_HEIGHT, 0, HAL_PIXEL_FORMAT_RAW16, HAL3_DATASPACE_ARBITRARY);
    mRawSnapshotConfig = configureStream(CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE, 2);

    mRawSnapshotConfig.streams[0] = mPreviewStream;
    mRawSnapshotConfig.streams[1] = mRawSnapshotStream;
    device_handle->ops->configure_streams(my_test_obj->device, &(mRawSnapshotConfig));
}
Beispiel #2
0
bool String::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_iDims*/)
{
    int iPrecision = ConfigVariable::getFormatSize();
    int iLineLen = ConfigVariable::getConsoleWidth();
    int iMaxLines = ConfigVariable::getConsoleLines();
    int iCurrentLine = 0;

    // less the two "!" (or two " " in scalar case)
    // for iLineLen = 50 we will write "!48char!"
    int iStrMaxSize = iLineLen - 2;

    if (isScalar())
    {
        int iMaxLen = 0;
        _piDims[0]  = 0;
        _piDims[1]  = 0;

        int iPos = getIndex(_piDims);
        wchar_t* wcsStr = get(iPos);
        int iCurLen = static_cast<int>(wcslen(wcsStr));
        iMaxLen = std::max(iMaxLen, iCurLen);
        iMaxLen = std::min(iMaxLen, iStrMaxSize);

        if (iCurLen > iMaxLen)
        {
            int iStrPos = 0;
            while (iCurLen > iStrMaxSize)
            {
                ostr << L" ";
                ostr.write(wcsStr + iStrPos, iStrMaxSize);
                ostr << L" " << std::endl;
                iCurLen -= iStrMaxSize;
                iStrPos += iStrMaxSize;
            }

            ostr << L" ";
            configureStream(&ostr, iStrMaxSize, iPrecision, ' ');
            ostr << std::left << wcsStr + iStrPos;
        }
        else
        {
            ostr << L" " << wcsStr << std::endl;
        }
    }
    else if (getCols() == 1)
    {
        std::wstring spaces(L"");

        // compte max string size
        int iMaxLen = 0;
        for (int i = 0 ; i < getRows() ; i++)
        {
            _piDims[1] = 0;
            _piDims[0] = i;
            int iPos = getIndex(_piDims);
            iMaxLen = std::max(iMaxLen, static_cast<int>(wcslen(get(iPos))));
            iMaxLen = std::min(iMaxLen, iStrMaxSize);
        }

        int iEmptyLineSize = iMaxLen;
        if (iMaxLen != iStrMaxSize)
        {
            // count SPACE_BETWEEN_TWO_STRING_VALUES size in padding of empty line
            // only if all lines have not a size greater than max size of a line.
            iEmptyLineSize += SIZE_BETWEEN_TWO_STRING_VALUES;
            spaces = SPACE_BETWEEN_TWO_STRING_VALUES;
        }

        for (int i = m_iRows1PrintState ; i < getRows() ; i++)
        {
            iCurrentLine += 2;
            if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines))
            {
                m_iRows1PrintState = i;
                return false;
            }

            _piDims[1] = 0;
            _piDims[0] = i;
            int iPos = getIndex(_piDims);
            wchar_t* wcsStr = get(iPos);
            int iCurLen = static_cast<int>(wcslen(wcsStr));

            ostr << L"!";
            if (iCurLen > iMaxLen)
            {
                int iStrPos = 0;
                while (iCurLen > iStrMaxSize)
                {
                    ostr.write(wcsStr + iStrPos, iStrMaxSize);
                    ostr << L"!" << std::endl << L"!";
                    iCurLen -= iStrMaxSize;
                    iStrPos += iStrMaxSize;
                }

                configureStream(&ostr, iStrMaxSize, iPrecision, ' ');
                ostr << std::left << wcsStr + iStrPos;
            }
            else
            {
                configureStream(&ostr, iMaxLen, iPrecision, ' ');
                ostr << std::left << wcsStr << spaces;
            }

            ostr << L"!" << std::endl;

            if ((i + 1) < m_iSize)
            {
                //for all but last one
                ostr << L"!";
                configureStream(&ostr, iEmptyLineSize, iPrecision, ' ');
                ostr << std::left << L" ";
                ostr << L"!" << std::endl;
            }
        }
    }
    else if (getRows() == 1)
    {
        std::wostringstream ostemp;
        int iLastVal = m_iCols1PrintState;

        for (int i = m_iCols1PrintState ; i < getCols() ; i++)
        {
            _piDims[0] = 0;
            _piDims[1] = i;
            int iPos = getIndex(_piDims);

            int iLen = 0;
            int iCurLen = static_cast<int>(wcslen(get(iPos)));
            iLen = iCurLen + SIZE_BETWEEN_TWO_STRING_VALUES + static_cast<int>(ostemp.str().size());
            if (iLen > iLineLen && iLastVal != i)
            {
                //Max length, new line
                iCurrentLine += 4; //"column x to Y" + empty line + value + empty line
                if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines))
                {
                    m_iCols1PrintState = iLastVal;
                    return false;
                }

                addColumnString(ostr, iLastVal + 1, i);
                ostr << L"!" << ostemp.str() << L"!" << std::endl;
                ostemp.str(L"");
                iLastVal = i;
            }

            // Manage case where string length is greater than max line size.
            if (iStrMaxSize < iCurLen)
            {
                wchar_t* wcsStr = get(iPos);
                int iStrPos = 0;
                while (iCurLen > iStrMaxSize) // -2 because of two "!"
                {
                    ostemp.write(wcsStr + iStrPos, iStrMaxSize);
                    ostemp << L"!" << std::endl << L"!";
                    iCurLen -= iStrMaxSize;
                    iStrPos += iStrMaxSize;
                }

                configureStream(&ostemp, iStrMaxSize, iPrecision, ' ');
                ostemp << std::left << wcsStr + iStrPos;
            }
            else
            {
                configureStream(&ostemp, iCurLen + 2, iPrecision, ' ');
                ostemp << std::left << get(iPos);
            }
        }

        if (iLastVal != 0)
        {
            addColumnString(ostr, iLastVal + 1, getCols());
        }

        ostr << L"!" << ostemp.str() << L"!" << std::endl;
    }
    else //Matrix
    {
        std::wostringstream ostemp;
        int iLen = 0;
        int iLastCol = m_iCols1PrintState;

        //Array with the max printed size of each col
        int *piSize = new int[getCols()];
        memset(piSize, 0x00, getCols() * sizeof(int));

        for (int iCols1 = m_iCols1PrintState ; iCols1 < getCols() ; iCols1++)
        {
            std::wstring spaces(L"");
            for (int iRows1 = 0 ; iRows1 < getRows() ; iRows1++)
            {
                _piDims[1] = iCols1;
                _piDims[0] = iRows1;
                int iPos = getIndex(_piDims);
                piSize[iCols1] = std::max(piSize[iCols1], static_cast<int>(wcslen(get(iPos))));
                piSize[iCols1] = std::min(piSize[iCols1], iStrMaxSize);
            }

            int iEmptyLineSize = piSize[iLastCol];
            if (piSize[iLastCol] != iStrMaxSize)
            {
                // count SPACE_BETWEEN_TWO_STRING_VALUES size in padding of empty line
                // only if all lines have not a size greater than max size of a line.
                iEmptyLineSize += SIZE_BETWEEN_TWO_STRING_VALUES;
                spaces = SPACE_BETWEEN_TWO_STRING_VALUES;
            }

            if (iLen + piSize[iCols1] > iLineLen && iLastCol != iCols1)
            {
                //find the limit, print this part
                for (int iRows2 = m_iRows2PrintState ; iRows2 < getRows() ; iRows2++)
                {
                    iCurrentLine += 2;
                    if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) ||
                            ( (iMaxLines != 0 && iCurrentLine + 3 >= iMaxLines && iRows2 == m_iRows2PrintState) ||
                              (iMaxLines != 0 && iCurrentLine + 1 >= iMaxLines && iRows2 != m_iRows2PrintState)))
                    {
                        if (m_iRows2PrintState == 0 && iRows2 != 0)
                        {
                            //add header
                            addColumnString(ostr, iLastCol + 1, iCols1);
                        }
                        ostr << ostemp.str();
                        m_iRows2PrintState = iRows2;
                        m_iCols1PrintState = iLastCol;
                        return false;
                    }

                    ostemp << L"!";
                    for (int iCols2 = iLastCol; iCols2 < iCols1; iCols2++)
                    {
                        _piDims[0] = iRows2;
                        _piDims[1] = iCols2;
                        int iPos = getIndex(_piDims);
                        wchar_t* wcsStr = get(iPos);
                        int iLenStr = static_cast<int>(wcslen(wcsStr));

                        // Manage case where string length is greater than max line size.
                        if (iLenStr > iStrMaxSize)
                        {
                            int iStrPos = 0;
                            while (iLenStr > iStrMaxSize)
                            {
                                ostemp.write(wcsStr + iStrPos, iStrMaxSize);
                                ostemp << L"!" << std::endl << L"!";
                                iLenStr -= iStrMaxSize;
                                iStrPos += iStrMaxSize;
                            }

                            configureStream(&ostemp, iStrMaxSize, iPrecision, ' ');
                            ostemp << std::left << wcsStr + iStrPos;
                        }
                        else
                        {
                            configureStream(&ostemp, piSize[iCols2], iPrecision, ' ');
                            ostemp << std::left << get(iPos) << spaces;
                        }
                    }
                    ostemp << L"!" << std::endl;

                    if ((iRows2 + 1) != m_iRows)
                    {
                        ostemp << L"!";
                        // -2 because of two "!"
                        configureStream(&ostemp, iEmptyLineSize, iPrecision, ' ');
                        ostemp << std::left << L" ";
                        ostemp << L"!" << std::endl;
                    }
                }

                iLen = 0;
                iCurrentLine += 2;
                if (m_iRows2PrintState == 0)
                {
                    iCurrentLine += 3;
                    addColumnString(ostr, iLastCol + 1, iCols1);
                }

                ostr << ostemp.str();
                ostemp.str(L"");
                iLastCol = iCols1;
                m_iRows2PrintState = 0;
                m_iCols1PrintState = 0;
            }
            iLen += piSize[iCols1] + SIZE_BETWEEN_TWO_STRING_VALUES;
        }

        for (int iRows2 = m_iRows2PrintState ; iRows2 < getRows() ; iRows2++)
        {
            std::wstring spaces(L"");
            iCurrentLine += 2;
            if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines))
            {
                if (m_iRows2PrintState == 0 && iLastCol != 0)
                {
                    //add header
                    addColumnString(ostr, iLastCol + 1, getCols());
                }

                ostr << ostemp.str();
                m_iRows2PrintState = iRows2;
                m_iCols1PrintState = iLastCol;
                return false;
            }

            int iEmptyLineSize = piSize[iLastCol];
            if (piSize[iLastCol] != iStrMaxSize)
            {
                // count SPACE_BETWEEN_TWO_STRING_VALUES size in padding of empty line
                // only if all lines have not a size greater than max size of a line.
                iEmptyLineSize += SIZE_BETWEEN_TWO_STRING_VALUES;
                spaces = SPACE_BETWEEN_TWO_STRING_VALUES;
            }


            ostemp << L"!";
            iLen = 0;
            for (int iCols2 = iLastCol ; iCols2 < getCols() ; iCols2++)
            {
                _piDims[0] = iRows2;
                _piDims[1] = iCols2;
                int iPos = getIndex(_piDims);
                wchar_t* wcsStr = get(iPos);
                int iLenStr = static_cast<int>(wcslen(wcsStr));

                // Manage case where string length is greater than max line size.
                if (iStrMaxSize < iLenStr)
                {
                    int iStrPos = 0;
                    while (iLenStr > iStrMaxSize)
                    {
                        ostemp.write(wcsStr + iStrPos, iStrMaxSize);
                        ostemp << L"!" << std::endl << L"!";
                        iLenStr -= iStrMaxSize;
                        iStrPos += iStrMaxSize;
                    }

                    configureStream(&ostemp, iStrMaxSize, iPrecision, ' ');
                    ostemp << wcsStr + iStrPos << std::left;
                    iLen = iStrMaxSize;
                }
                else
                {
                    configureStream(&ostemp, piSize[iCols2], iPrecision, ' ');
                    ostemp << std::left << get(iPos) << spaces;
                    iLen += piSize[iCols2] + static_cast<int>(spaces.size());
                }
            }
            ostemp << L"!" << std::endl;

            if ((iRows2 + 1) != m_iRows)
            {
                ostemp << L"!";
                configureStream(&ostemp, iLen, iPrecision, ' ');
                ostemp << std::left << L" ";
                ostemp << L"!" << std::endl;
            }
        }

        if (m_iRows2PrintState == 0 && iLastCol != 0)
        {
            addColumnString(ostr, iLastCol + 1, getCols());
        }
        ostr << ostemp.str();
    }

    return true;
}
Beispiel #3
0
/**
** toString to display Structs
** FIXME : Find a better indentation process
*/
bool Cell::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_iDims*/)
{
    int iPrecision = ConfigVariable::getFormatSize();

    if (isEmpty())
    {
        ostr << L"   {}";
    }
    else
    {
        //max len for each column
        int *piTypeLen = new int[getCols()];
        int *piSizeLen = new int[getCols()];

        memset(piTypeLen, 0x00, getCols() * sizeof(int));
        memset(piSizeLen, 0x00, getCols() * sizeof(int));

        for (int j = 0 ; j < getCols() ; j++)
        {
            for (int i = 0 ; i < getRows() ; i++)
            {
                _piDims[0] = i;
                _piDims[1] = j;

                int iPos = getIndex(_piDims);
                InternalType* pIT = get(iPos);

                if (pIT->isAssignable())
                {
                    //compute number of digits to write dimensions
                    int iTypeLen = 0;
                    if (pIT->isGenericType())
                    {
                        GenericType* pGT = pIT->getAs<GenericType>();
                        for (int k = 0 ; k < pGT->getDims() ; k++)
                        {
                            iTypeLen += static_cast<int>(log10(static_cast<double>(pGT->getDimsArray()[k])) + 1);
                        }
                        piSizeLen[j] = std::max(piSizeLen[j], iTypeLen + (pGT->getDims() - 1));//add number of "x"
                    }
                    else
                    {
                        //types non derived from ArrayOf.
                        int iSize = static_cast<int>(log10(static_cast<double>(pIT->getAs<GenericType>()->getRows())) + 1);
                        piSizeLen[j] = std::max(piSizeLen[j], iSize);
                    }
                }
                else
                {
                    //no size so let a white space, size == 1
                    piSizeLen[j] = std::max(piSizeLen[j], 1);
                }

                piTypeLen[j] = std::max(piTypeLen[j], static_cast<int>(pIT->getTypeStr().size()));
            }
        }

        for (int i = 0 ; i < getRows() ; i++)
        {
            for (int j = 0 ; j < getCols() ; j++)
            {
                _piDims[0] = i;
                _piDims[1] = j;
                int iPos = getIndex(_piDims);
                InternalType* pIT = get(iPos);

                ostr << L"  [";
                if (pIT->isAssignable())
                {
                    if (pIT->isGenericType())
                    {
                        //"  ixjxkxl type   "
                        GenericType* pGT = pIT->getAs<GenericType>();
                        std::wostringstream ostemp;
                        for (int k = 0 ; k < pGT->getDims() ; k++)
                        {
                            if (k != 0)
                            {
                                ostemp << L"x";
                            }
                            ostemp << pGT->getDimsArray()[k];
                        }
                        configureStream(&ostr, piSizeLen[j], iPrecision, ' ');
                        ostr << std::right << ostemp.str();
                    }
                    else
                    {
                        //" i   "
                        configureStream(&ostr, piSizeLen[j], iPrecision, ' ');
                        if (pIT->isList())
                        {
                            ostr << std::right << pIT->getAs<List>()->getSize();
                        }
                        else
                        {
                            ostr << std::right << 1;
                        }
                    }
                }
                else
                {
                    configureStream(&ostr, piSizeLen[j], iPrecision, ' ');
                    ostr << L"";//fill with space
                }
                ostr << L" ";
                configureStream(&ostr, piTypeLen[j], iPrecision, ' ');
                ostr << std::left << pIT->getTypeStr();
                ostr << L"]";
            }
            ostr << std::endl;
        }

        delete[] piSizeLen;
        delete[] piTypeLen;
    }
    ostr << std::endl;
    return true;
}