📄 viddec_copy.c
字号:
/* * Copyright 2008 * Texas Instruments Incorporated * * All rights reserved. Property of Texas Instruments Incorporated * Restricted rights to use, duplicate or disclose this code are * granted through contract. * *//* * ======== viddec_copy.c ======== * Video Decoder "copy" algorithm. * * This file contains an implementation of the IALG interface * required by XDAS. */#include <xdc/std.h>#include <string.h>#include <ti/xdais/dm/ividdec.h>#include <ti/sdo/ce/trace/gt.h>#include "viddec_copy_ti.h"#include "viddec_copy_ti_priv.h"/* buffer definitions */#define MININBUFS 1#define MINOUTBUFS 1#define MININBUFSIZE 1#define MINOUTBUFSIZE 1extern IALG_Fxns VIDDECCOPY_TI_IALG;#define IALGFXNS \ &VIDDECCOPY_TI_IALG,/* module ID */ \ NULL, /* activate */ \ VIDDECCOPY_TI_alloc,/* alloc */ \ NULL, /* control (NULL => no control ops) */ \ NULL, /* deactivate */ \ VIDDECCOPY_TI_free, /* free */ \ VIDDECCOPY_TI_initObj, /* init */ \ NULL, /* moved */ \ NULL /* numAlloc (NULL => IALG_MAXMEMRECS) *//* * ======== VIDDECCOPY_TI_IVIDDEC ======== * This structure defines TI's implementation of the IVIDDEC interface * for the VIDDECCOPY_TI module. */IVIDDEC_Fxns VIDDECCOPY_TI_VIDDECCOPY = { /* module_vendor_interface */ {IALGFXNS}, VIDDECCOPY_TI_process, VIDDECCOPY_TI_control,};/* * ======== VIDDEC_TI_IALG ======== * This structure defines TI's implementation of the IALG interface * for the VIDDECCOPY_TI module. */#ifdef _TI_asm("_VIDDECCOPY_TI_IALG .set _VIDDECCOPY_TI_VIDDECCOPY");#else/* * We duplicate the structure here to allow this code to be compiled and * run non-DSP platforms at the expense of unnecessary data space * consumed by the definition below. */IALG_Fxns VIDDECCOPY_TI_IALG = { /* module_vendor_interface */ IALGFXNS};#endif/* tracing information */#define GTNAME "ti.sdo.ce.examples.codecs.viddec_copy"static GT_Mask curTrace = {NULL,NULL};/* * ======== VIDDECCOPY_TI_alloc ======== */Int VIDDECCOPY_TI_alloc(const IALG_Params *algParams, IALG_Fxns **pf, IALG_MemRec memTab[]){ if (curTrace.modName == NULL) { /* initialize GT (tracing) */ GT_create(&curTrace, GTNAME); } GT_3trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_alloc(0x%lx, 0x%lx, 0x%lx)\n", algParams, pf, memTab); /* Request memory for my object */ memTab[0].size = sizeof(VIDDECCOPY_TI_Obj); memTab[0].alignment = 0; memTab[0].space = IALG_EXTERNAL; memTab[0].attrs = IALG_PERSIST; return (1);}/* * ======== VIDDECCOPY_TI_free ======== */Int VIDDECCOPY_TI_free(IALG_Handle handle, IALG_MemRec memTab[]){ GT_2trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_free(0x%lx, 0x%lx)\n", handle, memTab); VIDDECCOPY_TI_alloc(NULL, NULL, memTab); return (1);}/* * ======== VIDDECCOPY_TI_initObj ======== */Int VIDDECCOPY_TI_initObj(IALG_Handle handle, const IALG_MemRec memTab[], IALG_Handle p, const IALG_Params *algParams){ GT_4trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_initObj(0x%lx, 0x%lx, 0x%lx, " "0x%lx)\n", handle, memTab, p, algParams); return (IALG_EOK);}/* * ======== VIDDECCOPY_TI_process ======== */XDAS_Int32 VIDDECCOPY_TI_process(IVIDDEC_Handle h, XDM_BufDesc *inBufs, XDM_BufDesc *outBufs, IVIDDEC_InArgs *inArgs, IVIDDEC_OutArgs *outArgs){ XDAS_Int32 curBuf; XDAS_Int32 minSamples; GT_5trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_process(0x%lx, 0x%lx, 0x%lx, " "0x%lx, 0x%lx)\n", h, inBufs, outBufs, inArgs, outArgs); /* validate arguments - this codec only supports "base" xDM. */ if ((inArgs->size != sizeof(*inArgs)) || (outArgs->size != sizeof(*outArgs))) { GT_2trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_process, unsupported size " "(0x%lx, 0x%lx)\n", inArgs->size, outArgs->size); return (IVIDDEC_EFAIL); } /* outArgs->bytesConsumed reports the total number of bytes consumed */ outArgs->bytesConsumed = 0; /* * A couple constraints for this simple "copy" codec: * - Given a different number of input and output buffers, only * decode (i.e., copy) the lesser number of buffers. * - Given a different size of an input and output buffers, only * decode (i.e., copy) the lesser of the sizes. */ for (curBuf = 0; (curBuf < inBufs->numBufs) && (curBuf < outBufs->numBufs); curBuf++) { /* there's an available in and out buffer, how many samples? */ minSamples = inBufs->bufSizes[curBuf] < outBufs->bufSizes[curBuf] ? inBufs->bufSizes[curBuf] : outBufs->bufSizes[curBuf]; /* process the data: read input, produce output */ memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples); GT_1trace( curTrace, GT_2CLASS, "VIDDECCOPY_TI_process> " "Processed %d bytes.\n", minSamples ); outArgs->bytesConsumed += minSamples; } /* Fill out the rest of the outArgs struct */ outArgs->extendedError = 0; outArgs->decodedFrameType = 0; /* TODO */ outArgs->outputID = inArgs->inputID; outArgs->displayBufs.numBufs = 0; /* important: indicate no displayBufs */ return (IVIDDEC_EOK);}/* * ======== VIDDECCOPY_TI_control ======== */XDAS_Int32 VIDDECCOPY_TI_control(IVIDDEC_Handle handle, IVIDDEC_Cmd id, IVIDDEC_DynamicParams *params, IVIDDEC_Status *status){ XDAS_Int32 retVal; GT_4trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_control(0x%lx, 0x%lx, 0x%lx, " "0x%lx)\n", handle, id, params, status); /* validate arguments - this codec only supports "base" xDM. */ if ((params->size != sizeof(*params)) || (status->size != sizeof(*status))) { GT_2trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_control, unsupported size " "(0x%lx, 0x%lx)\n", params->size, status->size); return (IVIDDEC_EFAIL); } switch (id) { case XDM_GETSTATUS: status->extendedError = 0; status->outputHeight = 0; /* TODO */ status->outputWidth = 0; /* TODO */ status->frameRate = 0; /* TODO */ status->bitRate = 0; /* TODO */ status->contentType = 0; /* TODO */ status->outputChromaFormat = 0; /* TODO */ /* Note, intentionally no break here so we fill in bufInfo, too */ case XDM_GETBUFINFO: status->bufInfo.minNumInBufs = MININBUFS; status->bufInfo.minNumOutBufs = MINOUTBUFS; status->bufInfo.minInBufSize[0] = MININBUFSIZE; status->bufInfo.minOutBufSize[0] = MINOUTBUFSIZE; retVal = IVIDDEC_EOK; break; case XDM_SETPARAMS: case XDM_SETDEFAULT: case XDM_RESET: case XDM_FLUSH: /* TODO - for now just return success. */ retVal = IVIDDEC_EOK; break; default: /* unsupported cmd */ retVal = IVIDDEC_EFAIL; break; } return (retVal);}/* * @(#) ti.sdo.ce.examples.codecs.viddec_copy; 1,0,0,104; 1-14-2008 09:54:04; /db/atree/library/trees/ce-g30x/src/ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -