示例#1
0
/*
 *  ======== unmarshallMsg ========
 */
static XDAS_Int32 unmarshallMsg(IVIDENC1_Handle h, IVIDEO1_BufDescIn *inBufs,
                                XDM_BufDesc *outBufs, IVIDENC1_InArgs *inArgs, IVIDENC1_OutArgs *outArgs,
                                _VIDENC1_Msg *msg, XDAS_Int32 retVal)
{
    VISA_Handle visa = (VISA_Handle)h;
    IVIDENC1_OutArgs *pMsgOutArgs;
    Int i;

    /*
     * Do a wholesale replace of skeleton returned structure.
     * Pointer conversion of fields in outArgs is done below (only
     * in the case of a successful return value).
     */
    pMsgOutArgs = (IVIDENC1_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                                       inArgs->size);

    if (VISA_isChecked()) {
        /* ensure the codec didn't change outArgs->size */
        GT_assert(CURTRACE, pMsgOutArgs->size == outArgs->size);
    }

    memcpy(outArgs, pMsgOutArgs, outArgs->size);

    /* if VISA_call was successful, also unmarshall outBufs and outArgs */
    if (retVal == IVIDENC1_EOK) {
        /* unmarshall the output data: outBufs and outArgs. */

        /* The app consumes encoded buffers via encodedBuf and
         * reconBufs.  Need to translate those addresses here.
         */
        if (outArgs->encodedBuf.buf != NULL) {
            outArgs->encodedBuf.buf = Memory_getBufferVirtualAddress(
                                          (UInt32)outArgs->encodedBuf.buf, outArgs->encodedBuf.bufSize);

            /* Clear .accessMask; the local proc didn't access this buf */
            outArgs->encodedBuf.accessMask = 0;
        }

        for (i = 0; i < IVIDEO_MAX_YUV_BUFFERS; i++) {
            if (outArgs->reconBufs.bufDesc[i].buf != NULL) {
                outArgs->reconBufs.bufDesc[i].buf =
                    Memory_getBufferVirtualAddress(
                        (UInt32)outArgs->reconBufs.bufDesc[i].buf,
                        outArgs->reconBufs.bufDesc[i].bufSize);

                /* Clear .accessMask; the local proc didn't access this buf */
                outArgs->reconBufs.bufDesc[i].accessMask = 0;
            }
        }
    }

    /* Note that we did *nothing* with inBufs nor inArgs.  This should be ok. */

    VISA_freeMsg(visa, (VISA_Msg)msg);

    return (retVal);
}
示例#2
0
/*
 *  ======== unmarshallMsg ========
 */
static XDAS_Int32 unmarshallMsg(IVIDDEC_Handle h, XDM_BufDesc *inBufs,
    XDM_BufDesc *outBufs, IVIDDEC_InArgs *inArgs, IVIDDEC_OutArgs *outArgs,
    _VIDDEC_Msg *msg, XDAS_Int32 retVal)
{
    VISA_Handle visa = (VISA_Handle)h;
    IVIDDEC_OutArgs *pMsgOutArgs;
    Int i;

    /*
     * Do a wholesale replace of skeleton returned structure.
     * Pointer conversion of fields in outArgs is done below (only
     * in the case of a successful return value).
     */
    pMsgOutArgs = (IVIDDEC_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
        inArgs->size);

    if (VISA_isChecked()) {
        /* ensure the codec didn't change outArgs->size */
        GT_assert(CURTRACE, pMsgOutArgs->size == outArgs->size);
    }

    memcpy(outArgs, pMsgOutArgs, outArgs->size);

    /* if VISA_call was successful, also unmarshall outBufs */
    if (retVal == VIDDEC_EOK) {
        /* unmarshall the output data: outBufs and outArgs. */

        /* The outBufs may have changed
         * - [dm]TODO:H find out if outBufs can change so we can save some
         * cycles! and outArgs buffers may have been provided. All these
         * values are "raw", as seen by the DSP, so those physical addresses
         * must be converted to user addresses first.
         */
        for (i = 0; i < msg->cmd.process.numOutBufs; i++) {
            outBufs->bufSizes[i] = msg->cmd.process.outBufSizes[i];

            outBufs->bufs[i] = Memory_getBufferVirtualAddress(
                (UInt32)msg->cmd.process.outBufs[i],
                msg->cmd.process.outBufSizes[i]);
        }

        /* pointers in outArgs.displayBufs are physical, so convert them */
        for (i = 0; i < outArgs->displayBufs.numBufs; i++) {
            outArgs->displayBufs.bufs[i] = Memory_getBufferVirtualAddress(
                (UInt32)(outArgs->displayBufs.bufs[i]),
                outArgs->displayBufs.bufSizes[i]);
        }
    }

    /* Note that we did *nothing* with inBufs nor inArgs.  This should be ok. */

    VISA_freeMsg(visa, (VISA_Msg)msg);

    return (retVal);
}
static int copySparseSingleBufDescArrayWithP2V(XDM1_SingleBufDesc *pDest,
    XDM1_SingleBufDesc *pSrc, XDAS_Int32 numBufs, XDAS_Int32 maxBufs)
{
    int i, foundBufs;

    for (i = 0, foundBufs = 0; ((foundBufs < numBufs) && (i < maxBufs)); i++) {
        if (pSrc[i].buf != NULL) {
            /* valid member of sparse array, convert it */
            pDest[i].bufSize =pSrc[i].bufSize;

            pDest[i].buf = (XDAS_Int8 *)
                Memory_getBufferVirtualAddress((UInt32)pSrc[i].buf,
                    pSrc[i].bufSize);

            if (pDest[i].buf == NULL) {
                foundBufs = -1;
                break;
            }

            /* Clear .accessMask; the local processor won't access this buf */
            pDest[i].accessMask = 0;

            /* found, and handled, another buffer. */
            foundBufs++;
        }
        else {
            /* empty member of sparse array, no conversion needed. */
            pDest[i].bufSize = 0;
            pDest[i].buf = NULL;
        }
    }

    return (foundBufs);
}
示例#4
0
/*
 *  ======== unmarshallMsg ========
 */
static XDAS_Int32 unmarshallMsg(IVIDDEC2_Handle h, XDM1_BufDesc *inBufs,
    XDM_BufDesc *outBufs, IVIDDEC2_InArgs *inArgs, IVIDDEC2_OutArgs *outArgs,
    _VIDDEC2_Msg *msg, XDAS_Int32 retVal)
{
    VISA_Handle visa = (VISA_Handle)h;
    IVIDDEC2_OutArgs *pMsgOutArgs;
    Int i, j;
    Int numBufs;

    /*
     * Do a wholesale replace of skeleton returned structure.
     * Pointer conversion of fields in outArgs is done below (only
     * in the case of a successful return value).
     */
    pMsgOutArgs = (IVIDDEC2_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
        inArgs->size);

    if (VISA_isChecked()) {
        /* ensure the codec didn't change outArgs->size */
        Assert_isTrue(pMsgOutArgs->size == outArgs->size, (Assert_Id)NULL);
    }

    memcpy(outArgs, pMsgOutArgs, outArgs->size);

    /* if VISA_call was successful, unmarshall the necessary buffers. */
    if (retVal == IVIDDEC2_EOK) {
        /* unmarshall the output data: outBufs and mbDataBuf. */

        if (VISA_isChecked()) {
            /* ensure the codec didn't send back "too many" buffers */
            Assert_isTrue(msg->cmd.process.numOutBufs < XDM_MAX_IO_BUFFERS,
                    (Assert_Id)NULL);
        }

        /* The outBufs may have changed, so don't rely on what was passed in */
        outBufs->numBufs = msg->cmd.process.numOutBufs;

        for (i = 0, numBufs = 0;
             ((numBufs < outBufs->numBufs) && (i < XDM_MAX_IO_BUFFERS)); i++) {

            if (msg->cmd.process.outBufs[i] != NULL) {
                /* valid member of sparse array, convert it */
                outBufs->bufSizes[i] = msg->cmd.process.outBufSizes[i];

                outBufs->bufs[i] = (XDAS_Int8 *)
                    Memory_getBufferVirtualAddress(
                        (UInt32)msg->cmd.process.outBufs[i],
                        outBufs->bufSizes[i]);

                if (outBufs->bufs[i] == NULL) {
                    /* TODO:M - should add at least a trace statement when trace
                     * is supported.  Another good idea is to return something
                     * more clear than EFAIL.
                     */
                    retVal = IVIDDEC2_EFAIL;
                    goto exit;
                }

                /* found, and handled, another buffer. */
                numBufs++;
            }
            else {
                /* empty member of sparse array, no conversion needed */
                outBufs->bufSizes[i] = 0;
                outBufs->bufs[i] = NULL;
            }
        }

        /* convert mbDataBuf */
        if (outArgs->mbDataBuf.buf != NULL) {
            Memory_getBufferVirtualAddress((UInt32)outArgs->mbDataBuf.buf,
                outArgs->mbDataBuf.bufSize);

            /* Clear .accessMask; the local processor didn't access this buf */
            outArgs->mbDataBuf.accessMask = 0;
        }

    }

    /*
     * Note that buffers can also be returned if IVIDDEC_EFAIL is returned
     * with a non-fatal .extendedError in displayBufs[] and decodedBufs.
     */

    /* address translate the decoded buffers if non-fatal error */
    if ((retVal == IVIDDEC2_EOK) ||
            (!(XDM_ISFATALERROR(outArgs->decodedBufs.extendedError)))) {
        for (i = 0; i < IVIDEO_MAX_YUV_BUFFERS; i++) {
            if (outArgs->decodedBufs.bufDesc[i].buf != NULL) {
                outArgs->decodedBufs.bufDesc[i].buf =
                    Memory_getBufferVirtualAddress(
                    (UInt32)outArgs->decodedBufs.bufDesc[i].buf,
                    outArgs->decodedBufs.bufDesc[i].bufSize);

                /* Clear .accessMask; the local proc didn't access this buf */
                outArgs->decodedBufs.bufDesc[i].accessMask = 0;
            }
        }
    }

    /* Buffers in outArgs.displayBufs are physical, so convert them if needed */
    for (i = 0; i < IVIDDEC2_MAX_IO_BUFFERS; i++) {
        if (outArgs->outputID[i] != 0) {
            if ((retVal == IVIDDEC2_EOK) ||
                    (!(XDM_ISFATALERROR(outArgs->
                               displayBufs[i].extendedError)))) {

                for (j = 0; j < IVIDEO_MAX_YUV_BUFFERS; j++) {
                    if (outArgs->displayBufs[i].bufDesc[j].buf != NULL) {
                        outArgs->displayBufs[i].bufDesc[j].buf =
                            Memory_getBufferVirtualAddress(
                                (UInt32)outArgs->displayBufs[i].bufDesc[j].buf,
                                outArgs->displayBufs[i].bufDesc[j].bufSize);

                        /*
                         * Clear .accessMask; the local processor didn't
                         * access this buf.
                         */
                        outArgs->displayBufs[i].bufDesc[j].accessMask = 0;
                    }
                }
            }
        }
    }


    /* Note that we did *nothing* with inBufs nor inArgs.  This should be ok. */

exit:
    VISA_freeMsg(visa, (VISA_Msg)msg);

    return (retVal);
}
/*
 *  ======== unmarshallMsg ========
 */
static XDAS_Int32 unmarshallMsg(IVIDDEC2BACK_Handle h, XDM_Context *context,
        IVIDDEC2_OutArgs *outArgs, _VIDDEC2BACK_Msg *msg, XDAS_Int32 retVal)
{
    VISA_Handle visa = (VISA_Handle)h;
    Int i;
    Int numBufs;

#if 0
    if (VISA_isChecked()) {
        /* ensure the codec didn't change outArgs->size */
        Assert_isTrue(msg->cmd.process.outArgs.size == outArgs->size,
                (Assert_Id)NULL);
    }
#endif

    memcpy(outArgs, &(msg->cmd.process.outArgs), outArgs->size);

    /* if VISA_call was successful, also unmarshall outBufs */
    if (retVal == IVIDDEC2_EOK) {
        /* unmarshall the output data: outBufs and outArgs. */

        if (VISA_isChecked()) {
           /* sanity check context */
            Assert_isTrue(msg->cmd.process.context.numInBufs <
                    XDM_MAX_CONTEXT_BUFFERS, (Assert_Id)NULL);
            Assert_isTrue(msg->cmd.process.context.numOutBufs <
                    XDM_MAX_CONTEXT_BUFFERS, (Assert_Id)NULL);
            Assert_isTrue(msg->cmd.process.context.numInOutBufs == 0,
                    (Assert_Id)NULL);
        }

        /* The outBufs may have changed, so don't rely on what was passed in */
        context->numOutBufs = msg->cmd.process.context.numOutBufs;

        numBufs = copySparseSingleBufDescArrayWithP2V(context->outBufs,
            msg->cmd.process.context.outBufs, context->numOutBufs,
            XDM_MAX_CONTEXT_BUFFERS);

        if (numBufs == -1) {
            retVal = IVIDDEC2_EFAIL;
            goto exit;
        }

        if (VISA_isChecked()) {
            /* check that we found the indicated number of buffers */
            Assert_isTrue(context->numOutBufs == numBufs, (Assert_Id)NULL);
        }

        /* address translate the decoded buffers */
        copySingleBufDescArrayWithP2V(outArgs->decodedBufs.bufDesc,
            outArgs->decodedBufs.bufDesc, IVIDEO_MAX_YUV_BUFFERS);

        /* buffers in outArgs.displayBufs are physical, so convert them */
        for (i = 0; i < IVIDDEC2_MAX_IO_BUFFERS; i++) {
            if (outArgs->outputID[i] != 0) {
                copySingleBufDescArrayWithP2V(outArgs->displayBufs[i].bufDesc,
                    outArgs->displayBufs[i].bufDesc, IVIDEO_MAX_YUV_BUFFERS);
            }
        }

        /* and finally the mbDataBuf */
        if (outArgs->mbDataBuf.buf != NULL) {
            Memory_getBufferVirtualAddress((UInt32)outArgs->mbDataBuf.buf,
                outArgs->mbDataBuf.bufSize);

            /* Clear .accessMask; the local processor didn't access this buf */
            outArgs->mbDataBuf.accessMask = 0;
        }
    }

exit:
    VISA_freeMsg(visa, (VISA_Msg)msg);

    return (retVal);
}