Beispiel #1
0
DvevmStRetCode
dvtb_deInterEncode(DvevmStDeInterInfo *deinter, int* encDuration)
{
	XDAS_Int32 status = -1;
	int i = 0;
	DvevmStTime timeStmpBfrEnc, timeStmpAftrEnc;
	DvevmStRetCode retCode = DVEVM_ST_SUCCESS;
        XDM1_BufDesc inBufDesc;
        XDM1_BufDesc outBufDesc;

	ASSERT(deinter != NULL);
	ASSERT(deinter->ceHdl != NULL);
	ASSERT(deinter->deinterHdl != NULL);
	ASSERT(deinter->inBuf.numBufs > 0);
	ASSERT(deinter->inBuf.numBufs > 0);
	
	outBufDesc.numBufs = deinter->outBuf.numBufs;
	for(i = 0 ; i < outBufDesc.numBufs; i++)
	{
		outBufDesc.descs[i].bufSize = deinter->outBuf.bufSizes[i];
		outBufDesc.descs[i].buf	= (XDAS_Int8 *)deinter->outBuf.bufs[i];
	}

	inBufDesc.numBufs = deinter->inBuf.numBufs;
	for(i = 0 ; i < inBufDesc.numBufs; i++)
	{
		inBufDesc.descs[i].bufSize = deinter->inBuf.bufSizes[i];
		inBufDesc.descs[i].buf     = (XDAS_Int8 *) deinter->inBuf.bufs[i];
	}

	timeStmpBfrEnc = dvtb_getTime();
	
	status = UNIVERSAL_process(deinter->deinterHdl, &inBufDesc, &outBufDesc, NULL, (UNIVERSAL_InArgs *)&deinter->deinterInArgs, (UNIVERSAL_OutArgs *)&deinter->deinterOutArgs);

	timeStmpAftrEnc = dvtb_getTime();

	*encDuration = ((timeStmpAftrEnc.tv_sec * NUM_MICROSECS_IN_SEC) + timeStmpAftrEnc.tv_usec) - ((timeStmpBfrEnc.tv_sec * NUM_MICROSECS_IN_SEC) + timeStmpBfrEnc.tv_usec);

	if (status != UNIVERSAL_EOK )
	{
		SYS_ERROR("DeInterlacer Process failed (%d)\n", (int) status);
		retCode = DVEVM_ST_FAIL;
	}


	return retCode;
}
Beispiel #2
0
/*
 *  ======== processLoop ========
 */
static Void processLoop(UNIVERSAL_Handle hUniversal, FILE *in, FILE *out,
        XDAS_Int8 *inBuf, XDAS_Int8 *outBuf, XDAS_Int8 *versionBuf)
{
    Int                         n;
    Int32                       status;

    UNIVERSAL_InArgs            universalInArgs;
    UNIVERSAL_OutArgs           universalOutArgs;
    UNIVERSAL_DynamicParams     universalDynParams;
    UNIVERSAL_Status            universalStatus;

    XDM1_BufDesc                universalInBufDesc;
    XDM1_BufDesc                universalOutBufDesc;

    /* initialize bufDescs */
    universalInBufDesc.numBufs = universalOutBufDesc.numBufs = 1;
    universalInBufDesc.descs[0].bufSize = universalOutBufDesc.descs[0].bufSize =
        NSAMPLES;

    universalInBufDesc.descs[0].buf = inBuf;
    universalOutBufDesc.descs[0].buf = outBuf;

    /* initialize all "sized" fields */
    universalInArgs.size    = sizeof(universalInArgs);
    universalOutArgs.size   = sizeof(universalOutArgs);
    universalDynParams.size = sizeof(universalDynParams);
    universalStatus.size    = sizeof(universalStatus);

    /* if the codecs support it, dump their versions */
    universalStatus.data.numBufs = 1;
    universalStatus.data.descs[0].buf = versionBuf;
    universalStatus.data.descs[0].bufSize = MAXVERSIONSIZE;
    universalStatus.data.descs[1].buf = NULL;

#ifdef CACHE_ENABLED
    /* invalidate versionBuf it before the alg fills it */
    Memory_cacheInv(versionBuf, MAXVERSIONSIZE);
#endif

    status = UNIVERSAL_control(hUniversal, XDM_GETVERSION, &universalDynParams,
        &universalStatus);
    Log_print1(Diags_USER1, "[+1] Alg version:  %s",
            (IArg)((status == UNIVERSAL_EOK ?
            ((char *)universalStatus.data.descs[0].buf) : "[unknown]")));

    /*
     * Read complete frames from in, process them, and write to out.
     */
    for (n = 0; fread(inBuf, IFRAMESIZE, 1, in) == 1; n++) {

#ifdef CACHE_ENABLED
#if defined(xdc_target__isaCompatible_64P) || \
    defined(xdc_target__isaCompatible_64T)
        /*
         *  fread() on this processor is implemented using CCS's stdio, which
         *  is known to write into the cache, not physical memory.  To meet
         *  XDAIS DMA Rule 7, we must writeback the cache into physical
         *  memory.  Also, per DMA Rule 7, we must invalidate the buffer's
         *  cache before providing it to any XDAIS algorithm.
         */
        Memory_cacheWbInv(inBuf, IFRAMESIZE);
#else
#error Unvalidated config - add appropriate fread-related cache maintenance
#endif
        /* Per DMA Rule 7, our output buffer cache lines must be cleaned */
        Memory_cacheInv(outBuf, OFRAMESIZE);
#endif

        Log_print1(Diags_USER1, "[+1] App-> Processing frame %d...", (IArg)n);

        /*
         * Transcode the frame.
         *
         * Note, inputID == 0 is an error.  This example doesn't account
         * for the case where 'n + 1' wraps to zero.
         */
        status = UNIVERSAL_process(hUniversal, &universalInBufDesc,
                &universalOutBufDesc, NULL, &universalInArgs, &universalOutArgs);

        Log_print2(Diags_USER2,
                "[+2] App-> Alg frame %d process returned - 0x%x",
                (IArg)n, (IArg)status);

        if (status != UNIVERSAL_EOK) {
            Log_print3(Diags_USER7,
                    "[+7] App-> Alg frame %d processing FAILED, status = 0x%x, "
                    "extendedError = 0x%x",
                    (IArg)n, (IArg)status,
                    (IArg)(universalOutArgs.extendedError));
            break;
        }

#ifdef CACHE_ENABLED
        /*
         * Conditionally writeback the processed buf from the previous
         * call.  This [pessimistic] writeback illustrates the general
         * situation where the subsequent access of outBuf (fwrite(), in
         * this case), is not known to be via CPU/cache or DMA/physical mem.
         *
         * An optimized system, where the access mode of outBufs known,
         * may be able to eliminate this writeback.
         */
        if (XDM_ISACCESSMODE_WRITE(universalOutBufDesc.descs[0].accessMask)) {
            Memory_cacheWb(outBuf, OFRAMESIZE);
        }
#endif

        /* write to file */
        fwrite(outBuf, OFRAMESIZE, 1, out);
    }

    Log_print1(Diags_USER1, "[+1] %d frames processed", (IArg)n);
}
Beispiel #3
0
/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _UNIVERSAL_Msg *msg  = (_UNIVERSAL_Msg *)visaMsg;
    UNIVERSAL_Handle handle = (UNIVERSAL_Handle)visaHandle;
    Int i;
    XDM1_BufDesc inBufs, *pInBufs = &inBufs;
    XDM1_BufDesc outBufs, *pOutBufs = &outBufs;
    XDM1_BufDesc inOutBufs, *pInOutBufs = &inOutBufs;
    IUNIVERSAL_OutArgs *pOutArgs;
    IUNIVERSAL_Status *pStatus;
    Int numBufs;

    /* perform the requested UNIVERSAL operation by parsing message. */
    switch (msg->visa.cmd) {

        case _UNIVERSAL_CPROCESS: {
            /* unmarshal buffers */
            if (msg->cmd.process.inBufs.numBufs == 0) {
                pInBufs = NULL;
            }
            else {
                inBufs = msg->cmd.process.inBufs;

                if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                    /* invalidate cache for all input buffers */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (inBufs.descs[i].buf != NULL) {
                            /* valid member of sparse array, manage it */
                            Memory_cacheInv(inBufs.descs[i].buf,
                                    inBufs.descs[i].bufSize);

                            if (++numBufs == inBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }

            if (msg->cmd.process.outBufs.numBufs == 0) {
                pOutBufs = NULL;
            }
            else {
                outBufs = msg->cmd.process.outBufs;

                if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                    /* invalidate cache for all output buffers */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (outBufs.descs[i].buf != NULL) {
                            /* valid member of sparse array, manage it */
                            Memory_cacheInv(outBufs.descs[i].buf,
                                    outBufs.descs[i].bufSize);

                            if (++numBufs == outBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }

            if (msg->cmd.process.inOutBufs.numBufs == 0) {
                pInOutBufs = NULL;
            }
            else {
                inOutBufs = msg->cmd.process.inOutBufs;

                if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                    /* invalidate cache for all in/out buffers */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (inOutBufs.descs[i].buf != NULL) {
                            /* valid member of sparse array, manage it */
                            Memory_cacheInv(inOutBufs.descs[i].buf,
                                    inOutBufs.descs[i].bufSize);

                            if (++numBufs == inOutBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs =
                (IUNIVERSAL_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                        msg->cmd.process.inArgs.size);

            /* make the process call */
            msg->visa.status = UNIVERSAL_process(handle,
                    pInBufs, pOutBufs, pInOutBufs, &(msg->cmd.process.inArgs),
                    pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* writeback cache for output buffers  */
                if (pOutBufs != NULL) {
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (outBufs.descs[i].buf != NULL) {
                            if (XDM_ISACCESSMODE_WRITE(outBufs.descs[i]
                                        .accessMask)) {

                                /* valid member of sparse array, written via CPU */
                                Memory_cacheWb(outBufs.descs[i].buf,
                                        outBufs.descs[i].bufSize);

                                /*
                                 * Since we've cacheWb this buffer, we arguably
                                 * should reflect this cache state and clear the
                                 * WRITE bit in the .accessMask field.  However,
                                 * we know the stub doesn't propogate this field
                                 * to the calling app, so this extra buffer
                                 * management detail isn't necessary:
                                 *
                                 * XDM_CLEARACCESSMODE_WRITE(outBufs.descs[i]
                                 *         .accessMask);
                                 */
                            }

                            if (++numBufs == outBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }

                if (pInOutBufs != NULL) {
                    /* writeback cache for in/out buffers  */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (inOutBufs.descs[i].buf != NULL) {
                            if (XDM_ISACCESSMODE_WRITE(inOutBufs.descs[i]
                                        .accessMask)) {
                        
                                /* valid member of sparse array, written via CPU */
                                Memory_cacheWb(inOutBufs.descs[i].buf,
                                        inOutBufs.descs[i].bufSize);

                                /*
                                 * Since we've cacheWb this buffer, we arguably
                                 * should reflect this cache state and clear the
                                 * WRITE bit in the .accessMask field.  However,
                                 * we know the stub doesn't propogate this field
                                 * to the calling app, so this extra buffer
                                 * management detail isn't necessary:
                                 *
                                 * XDM_CLEARACCESSMODE_WRITE(inOutBufs.descs[i]
                                 *         .accessMask);
                                 */
                            }

                            if (++numBufs == inOutBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }
            break;
        }

        case _UNIVERSAL_CCONTROL: {
            /* unmarshall status based on the "size" of dynParams */
            pStatus =
                (IUNIVERSAL_Status *)((UInt)(&(msg->cmd.control.dynParams)) +
                msg->cmd.control.dynParams.size);

            /* invalidate data buffers */
            for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                if (pStatus->data.descs[i].buf != NULL) {
                    /* valid member of sparse array, manage it */
                    Memory_cacheInv(pStatus->data.descs[i].buf,
                            pStatus->data.descs[i].bufSize);

                    if (++numBufs == pStatus->data.numBufs) {
                        break;
                    }
                }
            }

            msg->visa.status = UNIVERSAL_control(handle, msg->cmd.control.id,
                    &(msg->cmd.control.dynParams), pStatus);

            /* writeback data buffers */
            for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                if (pStatus->data.descs[i].buf != NULL) {
                    if (XDM_ISACCESSMODE_WRITE(pStatus->data.descs[i]
                            .accessMask)) {

                        /* valid member of sparse array, manage it */
                        Memory_cacheWb(pStatus->data.descs[i].buf,
                                pStatus->data.descs[i].bufSize);

                        /*
                         * Since we've cacheWb this buffer, we arguably should
                         * reflect this cache state and clear the WRITE bit in
                         * the .accessMask field.  However, we know the stub
                         * doesn't propogate this field to the calling app, so
                         * this extra buffer management detail isn't necessary:
                         *
                         * XDM_CLEARACCESSMODE_WRITE(pStatus->data.descs[i]
                         *         .accessMask);
                         */
                    }

                    if (++numBufs == pStatus->data.numBufs) {
                        break;
                    }
                }
            }

            break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}
/*
 *  ======== processLoop ========
 */
static Void processLoop(UNIVERSAL_Handle hUniversal, FILE *in, FILE *out)
{
    Int                         n;
    Int32                       status;

    UNIVERSAL_InArgs            universalInArgs;
    UNIVERSAL_OutArgs           universalOutArgs;
    UNIVERSAL_DynamicParams     universalDynParams;
    UNIVERSAL_Status            universalStatus;

    XDM1_BufDesc                universalInBufDesc;
    XDM1_BufDesc                universalOutBufDesc;

    /* initialize bufDescs */
    universalInBufDesc.numBufs = universalOutBufDesc.numBufs = 1;
    universalInBufDesc.descs[0].bufSize = universalOutBufDesc.descs[0].bufSize =
            NSAMPLES;

    universalInBufDesc.descs[0].buf = inBuf;
    universalOutBufDesc.descs[0].buf = outBuf;

    /* initialize all "sized" fields */
    universalInArgs.size    = sizeof(universalInArgs);
    universalOutArgs.size   = sizeof(universalOutArgs);
    universalDynParams.size = sizeof(universalDynParams);
    universalStatus.size    = sizeof(universalStatus);

    /* if the codecs support it, dump their versions */
    universalStatus.data.numBufs = 1;
    universalStatus.data.descs[0].buf = versionBuf;
    universalStatus.data.descs[0].bufSize = MAXVERSIONSIZE;
    universalStatus.data.descs[1].buf = NULL;

    status = UNIVERSAL_control(hUniversal, XDM_GETVERSION, &universalDynParams,
                               &universalStatus);
    GT_1trace(curMask, GT_1CLASS, "Alg version:  %s\n",
              (status == UNIVERSAL_EOK ?
               ((char *)universalStatus.data.descs[0].buf) : "[unknown]"));

    /*
     * Read complete frames from in, process them, and write to out.
     */
    for (n = 0; fread(inBuf, IFRAMESIZE, 1, in) == 1; n++) {

#ifdef CACHE_ENABLED
#ifdef xdc_target__isaCompatible_64P
        /*
         *  fread() on this processor is implemented using CCS's stdio, which
         *  is known to write into the cache, not physical memory.  To meet
         *  xDAIS DMA Rule 7, we must writeback the cache into physical
         *  memory.  Also, per DMA Rule 7, we must invalidate the buffer's
         *  cache before providing it to any xDAIS algorithm.
         */
        Memory_cacheWbInv(inBuf, IFRAMESIZE);
#else
#error Unvalidated config - add appropriate fread-related cache maintenance
#endif
        /* Per DMA Rule 7, our output buffer cache lines must be cleaned */
        Memory_cacheInv(outBuf, OFRAMESIZE);
#endif

        GT_1trace(curMask, GT_1CLASS, "App-> Processing frame %d...\n", n);

        /*
         * Transcode the frame.
         *
         * Note, inputID == 0 is an error.  This example doesn't account
         * for the case where 'n + 1' wraps to zero.
         */
        status = UNIVERSAL_process(hUniversal, &universalInBufDesc,
                                   &universalOutBufDesc, NULL, &universalInArgs, &universalOutArgs);

        GT_2trace(curMask, GT_2CLASS,
                  "App-> Alg frame %d process returned - 0x%x)\n", n, status);

        if (status != UNIVERSAL_EOK) {
            GT_3trace(curMask, GT_7CLASS,
                      "App-> Alg frame %d processing FAILED, status = 0x%x, "
                      "extendedError = 0x%x\n", n, status,
                      universalOutArgs.extendedError);
            break;
        }

#ifdef CACHE_ENABLED
        /*
         * Conditionally writeback the processed buf from the previous
         * call.
         */
        if (XDM_ISACCESSMODE_WRITE(universalOutBufDesc.descs[0].accessMask)) {
            Memory_cacheWb(outBuf, OFRAMESIZE);
        }
#endif

        /* write to file */
        fwrite(outBuf, OFRAMESIZE, 1, out);
    }

    GT_1trace(curMask, GT_1CLASS, "%d frames processed\n", n);
}