写的不错的代码

char *tComponentName[MAXCOMP][2] = {
    /*video and image components */
    //{"OMX.TI.JPEG.decoder", "image_decoder.jpeg" },
    {"OMX.TI.JPEG.Encoder", "image_encoder.jpeg"},
    //{"OMX.TI.Video.Decoder", "video_decoder.h263"},
    {"OMX.TI.Video.Decoder", "video_decoder.avc"},
    //{"OMX.TI.Video.Decoder", "video_decoder.mpeg2"},
    {"OMX.TI.Video.Decoder", "video_decoder.mpeg4"},
    {"OMX.TI.Video.Decoder", "video_decoder.wmv"},
    {"OMX.TI.Video.encoder", "video_encoder.mpeg4"},
    {"OMX.TI.Video.encoder", "video_encoder.h263"},
    {"OMX.TI.Video.encoder", "video_encoder.avc"},
    //{"OMX.TI.VPP", "iv_renderer.yuv.overlay"},
    //{"OMX.TI.Camera", "camera.yuv"},

    /* Speech components */
/*  {"OMX.TI.G729.encode", NULL},
    {"OMX.TI.G729.decode", NULL},	
    {"OMX.TI.G722.encode", NULL},
    {"OMX.TI.G722.decode", NULL},
    {"OMX.TI.G711.encode", NULL},
    {"OMX.TI.G711.decode", NULL},
    {"OMX.TI.G723.encode", NULL},
    {"OMX.TI.G723.decode", NULL},
    {"OMX.TI.G726.encode", NULL},
    {"OMX.TI.G726.decode", NULL},
    {"OMX.TI.GSMFR.encode", NULL},
    {"OMX.TI.GSMFR.decode", NULL},
*/

    /* Audio components */
#ifdef BUILD_WITH_TI_AUDIO
    {"OMX.TI.MP3.decode", "audio_decoder.mp3"},
    {"OMX.TI.AAC.encode", "audio_encoder.aac"},
    {"OMX.TI.AAC.decode", "audio_decoder.aac"},
    {"OMX.TI.WMA.decode", "audio_decoder.wma"},
    {"OMX.TI.WBAMR.decode", "audio_decoder.amrwb"},
    {"OMX.TI.AMR.decode", "audio_decoder.amrnb"},
    {"OMX.TI.AMR.encode", "audio_encoder.amrnb"},
    {"OMX.TI.WBAMR.encode", "audio_encoder.amrwb"},
#endif
/*  {"OMX.TI.PCM.encode", NULL},
    {"OMX.TI.PCM.decode", NULL},     
    {"OMX.TI.RAG.decode", "audio_decoder.ra"},
    {"OMX.TI.IMAADPCM.decode", NULL},
    {"OMX.TI.IMAADPCM.encode", NULL},
*/

    /* terminate the table */
    {NULL, NULL},
};

typedef struct _ComponentTable {
   OMX_STRING name;
   OMX_U16 nRoles;
   OMX_STRING pRoleArray[MAX_ROLES];
   OMX_HANDLETYPE* pHandle[MAX_CONCURRENT_INSTANCES];
   int refCount;
}ComponentTable; 

OMX_ERRORTYPE TIOMX_BuildComponentTable()
{
    OMX_ERRORTYPE eError = OMX_ErrorNone;
    OMX_CALLBACKTYPE sCallbacks;
    int j = 0;
    int numFiles = 0;
    int i;

    for (i = 0, numFiles = 0; i < MAXCOMP; i ++) {
        if (tComponentName[i][0] == NULL) {
            break;
        }
        if (numFiles <= MAX_TABLE_SIZE){
            for (j = 0; j < numFiles; j ++) {
                /* componentTable[j] 表示图片,视频,音频分类, numFiles表示已经有的几个分类*/
                if (!strcmp(componentTable[j].name, tComponentName[i][0])) { //组件name相同,都是video
                    /* insert the role */
                    if (tComponentName[i][1] != NULL)
                    {
                        /* componentTable[j].pRoleArray[componentTable[j].nRoles] 表示视频中的不同格式分类,如h264,h265 */
                        componentTable[j].pRoleArray[componentTable[j].nRoles] = tComponentName[i][1];/* role */
                        componentTable[j].pHandle[componentTable[j].nRoles] = NULL; //initilize the pHandle element
                        componentTable[j].nRoles ++; //组件role不同
                    }
                    break; //已经处理完,不用再判断在哪个类(不再j++)
                }
            }
            if (j == numFiles) { /* new component */
                if (tComponentName[i][1] != NULL){
                    componentTable[numFiles].pRoleArray[0] = tComponentName[i][1];
                    componentTable[numFiles].nRoles = 1;
                }
                strcpy(compName[numFiles], tComponentName[i][0]);
                componentTable[numFiles].name = compName[numFiles]; /* name is  OMX.TI.Video.Decoder */
                componentTable[numFiles].refCount = 0; //initialize reference counter.
                numFiles ++;
            }
        }
    }
    tableCount = numFiles;
    if (eError != OMX_ErrorNone){
        ALOGE("Could not build Component Table\n");
    }

    return eError;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值