?? videnc1_copy.c
字號:
/* * Copyright 2006 * Texas Instruments Incorporated * * All rights reserved. Property of Texas Instruments Incorporated * Restricted rights to use, duplicate or disclose this code are * granted through contract. * *//* * ======== videnc1_copy.c ======== * Image encoder "copy" algorithm. * * This file contains an implementation of the IALG interface * required by xDAIS. */#include <xdc/std.h>#include <string.h>#include <ti/xdais/dm/ividenc1.h>#include "videnc1_copy_ti.h"#include "videnc1_copy_ti_priv.h"/* buffer definitions */#define MININBUFS 1#define MINOUTBUFS 1#define MININBUFSIZE 1#define MINOUTBUFSIZE 1extern IALG_Fxns VIDENC1COPY_TI_IALG;#define IALGFXNS \ &VIDENC1COPY_TI_IALG,/* module ID */ \ NULL, /* activate */ \ VIDENC1COPY_TI_alloc,/* alloc */ \ NULL, /* control (NULL => no control ops) */ \ NULL, /* deactivate */ \ VIDENC1COPY_TI_free, /* free */ \ VIDENC1COPY_TI_initObj, /* init */ \ NULL, /* moved */ \ NULL /* numAlloc (NULL => IALG_MAXMEMRECS) *//* * ======== VIDENC1COPY_TI_IVIDENCCOPY ======== * This structure defines TI's implementation of the IVIDENC1 interface * for the VIDENC1COPY_TI module. */IVIDENC1_Fxns VIDENC1COPY_TI_VIDENCCOPY = { /* module_vendor_interface */ {IALGFXNS}, VIDENC1COPY_TI_process, VIDENC1COPY_TI_control,};/* * ======== VIDENC1COPY_TI_IALG ======== * This structure defines TI's implementation of the IALG interface * for the VIDENC1COPY_TI module. */#ifdef _TI_asm("_VIDENC1COPY_TI_IALG .set _VIDENC1COPY_TI_VIDENCCOPY");#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 VIDENC1COPY_TI_IALG = { /* module_vendor_interface */ IALGFXNS};#endif/* * ======== VIDENC1COPY_TI_alloc ======== */Int VIDENC1COPY_TI_alloc(const IALG_Params *algParams, IALG_Fxns **pf, IALG_MemRec memTab[]){ /* Request memory for my object */ memTab[0].size = sizeof(VIDENC1COPY_TI_Obj); memTab[0].alignment = 0; memTab[0].space = IALG_EXTERNAL; memTab[0].attrs = IALG_PERSIST; return (1);}/* * ======== VIDENC1COPY_TI_free ======== */Int VIDENC1COPY_TI_free(IALG_Handle handle, IALG_MemRec memTab[]){ VIDENC1COPY_TI_alloc(NULL, NULL, memTab); return (1);}/* * ======== VIDENC1COPY_TI_initObj ======== */Int VIDENC1COPY_TI_initObj(IALG_Handle handle, const IALG_MemRec memTab[], IALG_Handle p, const IALG_Params *algParams){ return (IALG_EOK);}/* * ======== VIDENC1COPY_TI_process ======== */XDAS_Int32 VIDENC1COPY_TI_process(IVIDENC1_Handle h, XDM_BufDesc *inBufs, XDM_BufDesc *outBufs, IVIDENC1_InArgs *inArgs, IVIDENC1_OutArgs *outArgs){ XDAS_Int32 numSamples; /* * Validate arguments - this codec supports "base" xDM and an extended * inArgs. */ if (((inArgs->size != sizeof(*inArgs)) && (inArgs->size != sizeof(IVIDENC1CPY_InArgs))) || (outArgs->size != sizeof(*outArgs))) { return (IVIDENC1_EUNSUPPORTED); } /* outArgs->bytesGenerated reports the total number of bytes encoded */ outArgs->bytesGenerated = 0; /* * This copy codec only "encodes" a single input buffer into a * single output buffer. Also, given a different size of an input * and output buffers, only encode (i.e., copy) the lesser of the * sizes. */ if ((inBufs->numBufs >= 1) && (outBufs->numBufs >= 1)) { /* there's an available in and out buffer, how many samples? */ numSamples = inBufs->bufSizes[0] < outBufs->bufSizes[0] ? inBufs->bufSizes[0] : outBufs->bufSizes[0]; /* and honor the extended maxBytes if it was provided */ if (inArgs->size == sizeof(IVIDENC1CPY_InArgs)) { if (numSamples > ((IVIDENC1CPY_InArgs *)inArgs)->maxBytes) { numSamples = ((IVIDENC1CPY_InArgs *)inArgs)->maxBytes; } } /* process the data: read input, produce output */ memcpy(outBufs->bufs[0], inBufs->bufs[0], numSamples); outArgs->bytesGenerated = numSamples; } /* Fill out the rest of the outArgs struct */ outArgs->extendedError = 0; outArgs->encodedFrameType = 0; /* TODO */ outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED; /* TODO - add support for reconBufs */ outArgs->reconBufs.numBufs = 0; return (IVIDENC1_EOK);}/* * ======== VIDENC1COPY_TI_control ======== */XDAS_Int32 VIDENC1COPY_TI_control(IVIDENC1_Handle handle, IVIDENC1_Cmd id, IVIDENC1_DynamicParams *params, IVIDENC1_Status *status){ XDAS_Int32 retVal; /* validate arguments - this codec only supports "base" xDM. */ if ((params->size != sizeof(*params)) || (status->size != sizeof(*status))) { return (IVIDENC1_EUNSUPPORTED); } switch (id) { case XDM_GETSTATUS: case XDM_GETBUFINFO: status->extendedError = 0; status->bufInfo.minNumInBufs = MININBUFS; status->bufInfo.minNumOutBufs = MINOUTBUFS; status->bufInfo.minInBufSize[0] = MININBUFSIZE; status->bufInfo.minOutBufSize[0] = MINOUTBUFSIZE; retVal = IVIDENC1_EOK; break; case XDM_RESET: case XDM_FLUSH: retVal = IVIDENC1_EOK; break; default: /* unsupported cmd */ retVal = IVIDENC1_EUNSUPPORTED; break; } return (retVal);}/* * @(#) ti.xdais.dm.examples.videnc1_copy; 1,0,0,7; 10-18-2006 19:12:30; /db/wtree/library/trees/dais-g07x/src/ */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -