This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM6446使用TI的jpegenc编码codec失败,求助。

Other Parts Discussed in Thread: DM644XCODECS

硬件:DM6446,公司自己做的开发板

软件:DVSDK     centOS操作系统

研发阶段:项目开发阶段

构建了最简单的codec/server/app架构,现在加入了www.ti.com/.../dm644xcodecs这里下载的jpegenc算法,由于此处提供的app是CCS工程,不能移植到Linux下,因此尝试自己编写app。

#include <xdc/std.h>
#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/osal/Memory.h>
#include <ti/sdo/ce/video/viddec.h>
#include <ti/sdo/ce/video/videnc.h>
#include <ti/sdo/ce/trace/gt.h>
#include <ti/sdo/ce/video1/videnc1.h>
#include <ti/sdo/ce/utils/trace/TraceUtil.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

#include <ti/sdo/ce/image1/imgenc1.h>
#include <ti/sdo/ce/image1/imgdec1.h>

#define ENABLE_DEBUG 0

static String engineName = "encode";

const char *inFileName = "1.yuv";
const char *outFileName = "1.jpg";

Engine_Handle ce = NULL;
IIMGENC1_Handle enc= NULL;

XDAS_Int8 *inBuf;
XDAS_Int8 *outBuf;

#define WIDTH 800
#define HEIGHT 480

IIMGENC1_InArgs encInArgs;
IIMGENC1_OutArgs encOutArgs;
IIMGENC1_DynamicParams encDynParams = {
 sizeof(IIMGENC1_DynamicParams),
 0,
 XDM_YUV_422P,
 WIDTH,
 HEIGHT,
 0,
 0,
 80,
 };
IIMGENC1_Status encStatus;
 
XDM1_BufDesc inBufDesc;
XDM1_BufDesc outBufDesc;


static void encode(IMGENC1_Handle enc)
{
 int status; 
 
 encInArgs.size = sizeof(encInArgs);
 encOutArgs.size = sizeof(encOutArgs);
 encStatus.size = sizeof(encStatus); 
//get buffer information
 status = IMGENC1_control(enc, XDM_GETBUFINFO, &encDynParams, &encStatus);
 printf("getBuf control = %d\n", status);

 inBufDesc.numBufs = encStatus.bufInfo.minNumInBufs;
 inBufDesc.descs[0].bufSize = encStatus.bufInfo.minInBufSize[0];
 inBufDesc.descs[0].buf = inBuf;
 
 outBufDesc.numBufs = encStatus.bufInfo.minNumOutBufs;
 outBufDesc.descs[0].bufSize = encStatus.bufInfo.minOutBufSize[0];
 outBufDesc.descs[0].buf = outBuf;
//process
 status = IMGENC1_process(enc, &inBufDesc, &outBufDesc, &encInArgs, &encOutArgs);
 printf("process = %d\n", status);
 
 status = encOutArgs.bytesGenerated;
 printf("byteGenerated = %d\n", status);

}

int main(int argc, char * argv[])
{
 struct timeval tpstart,tpend;
 unsigned long timeuses=0;

 
 FILE* fpIn;
 FILE* fpOut;
 
 int ret;
 CERuntime_init();
//此用法是参照Memory.h里的说明使用的
 Memory_AllocParams myParams;
 myParams = Memory_DEFAULTPARAMS;
 myParams.type = Memory_CONTIGPOOL;
 
 inBuf = Memory_alloc(WIDTH*HEIGHT*2, &myParams);
 outBuf = Memory_alloc(WIDTH*HEIGHT*2, &myParams);

 printf("inbuf = 0x%x\n", (int)inBuf); 
 printf("outbuf = 0x%x\n", (int)outBuf); 

 fpIn = fopen(inFileName, "rb");
 if(fpIn != NULL)printf("open fin ok!\n");
 fpOut= fopen(outFileName, "wb");
 if(fpOut != NULL)printf("open out ok!\n");

 ret = fread(inBuf, WIDTH*HEIGHT, 2, fpIn); 
 printf("ret = %d\n", ret);
//打开引擎
 if ((ce = Engine_open(engineName, NULL, NULL)) == NULL){
 printf("engine open error\n");
 exit(0);
 }else{
 printf("engine open ok\n");
 }
//创建算法
 enc = IMGENC1_create(ce, "jpegenc", NULL);
 if (enc == NULL){
 printf("imgenc1_copy create error\n");
 exit(0);
 }else{
 printf("hy_jpeg create ok\n");
 }
//开始编码 
 gettimeofday(&tpstart,0);
 encode(enc);
 gettimeofday(&tpend,0);
 // 微秒
 timeuses=(tpend.tv_sec-tpstart.tv_sec)*1000000+tpend.tv_usec-tpstart.tv_usec;
 printf("use time: %uus\n",timeuses);
//编码完成 
 fwrite(outBuf, encOutArgs.bytesGenerated, 1, fpOut);
 
 fclose(fpIn);
 fclose(fpOut);

 IMGENC1_delete(enc);
 
 Engine_close(ce);
 
 if(outBuf)Memory_free(outBuf,WIDTH*HEIGHT*2, &myParams);
 if(inBuf)Memory_free(inBuf, WIDTH*HEIGHT*2, &myParams);
 
 CERuntime_exit();
}



这是所有打印信息
inbuf = 0x40a32000
outbuf = 0x40afd000
open fin ok!
open out ok!
ret = 2
engine open ok
hy_jpeg create ok
getBuf control = 0
CMEM Error: getPhys: Failed to get physical address of 0x415a3aff
@0x000a8160:[T:0x4001e880] OM - Memory_getBufferPhysicalAddress> ERROR: user buffer at addr=0x40a32000, size=12000000 is NOT contiguous
process = -1
byteGenerated = 0
use time: 18488us

process执行后返回的是-1,执行失败了。
  • #include <xdc/std.h>
    #include <ti/sdo/ce/Engine.h>
    #include <ti/sdo/ce/osal/Memory.h>
    #include <ti/sdo/ce/video/viddec.h>
    #include <ti/sdo/ce/video/videnc.h>
    #include <ti/sdo/ce/trace/gt.h>
    #include <ti/sdo/ce/video1/videnc1.h>
    #include <ti/sdo/ce/utils/trace/TraceUtil.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/time.h>
    
    #include <ti/sdo/ce/image1/imgenc1.h>
    #include <ti/sdo/ce/image1/imgdec1.h>
    
    #define ENABLE_DEBUG   0
    
    static String engineName   = "encode";
    
    const char *inFileName = "1.yuv";
    const char *outFileName = "1.jpg";
    
    Engine_Handle ce = NULL;
    IIMGENC1_Handle enc= NULL;
    
    XDAS_Int8 *inBuf;
    XDAS_Int8 *outBuf;
    
    #define WIDTH  800
    #define HEIGHT 480
    
    IIMGENC1_InArgs		encInArgs;
    IIMGENC1_OutArgs	encOutArgs;
    IIMGENC1_DynamicParams	encDynParams = {
    		sizeof(IIMGENC1_DynamicParams),
    		0,
    		XDM_YUV_422P,
    		WIDTH,
    		HEIGHT,
    		0,
    		0,
    		80,
    	};
    IIMGENC1_Status		encStatus;
    	
    XDM1_BufDesc		inBufDesc;
    XDM1_BufDesc		outBufDesc;
    
    
    static void encode(IMGENC1_Handle enc)
    {
    	int status;	
    	
    	encInArgs.size		= sizeof(encInArgs);
    	encOutArgs.size		= sizeof(encOutArgs);
    	encStatus.size		= sizeof(encStatus);	
    //get buffer information
    	status = IMGENC1_control(enc, XDM_GETBUFINFO, &encDynParams, &encStatus);
    	printf("getBuf control = %d\n", status);
    
    	inBufDesc.numBufs		= encStatus.bufInfo.minNumInBufs;
    	inBufDesc.descs[0].bufSize	= encStatus.bufInfo.minInBufSize[0];
    	inBufDesc.descs[0].buf		= inBuf;
    	
    	outBufDesc.numBufs		= encStatus.bufInfo.minNumOutBufs;
    	outBufDesc.descs[0].bufSize	= encStatus.bufInfo.minOutBufSize[0];
    	outBufDesc.descs[0].buf		= outBuf;
    //process
    	status = IMGENC1_process(enc, &inBufDesc, &outBufDesc, &encInArgs, &encOutArgs);
    	printf("process = %d\n", status);
    	
    	status = encOutArgs.bytesGenerated;
    	printf("byteGenerated = %d\n", status);
    
    }
    
    int main(int argc, char * argv[])
    {
        struct timeval tpstart,tpend;
        unsigned long timeuses=0;
    
        
        FILE* fpIn;
        FILE* fpOut;
    	
        int ret;
        CERuntime_init();
    //此用法是参照Memory.h里的说明使用的
        Memory_AllocParams  myParams;
        myParams = Memory_DEFAULTPARAMS;
        myParams.type = Memory_CONTIGPOOL;
        
        inBuf = Memory_alloc(WIDTH*HEIGHT*2, &myParams);
        outBuf = Memory_alloc(WIDTH*HEIGHT*2, &myParams);
    
        printf("inbuf = 0x%x\n", (int)inBuf); 
        printf("outbuf = 0x%x\n", (int)outBuf); 
    
        fpIn = fopen(inFileName, "rb");
    	if(fpIn != NULL)printf("open fin ok!\n");
        fpOut= fopen(outFileName, "wb");
    	if(fpOut != NULL)printf("open out ok!\n");
    
        ret =  fread(inBuf, WIDTH*HEIGHT, 2, fpIn);    
        printf("ret = %d\n", ret);
    //打开引擎
        if ((ce = Engine_open(engineName, NULL, NULL)) == NULL){
    	printf("engine open error\n");
    	exit(0);
        }else{
    	printf("engine open ok\n");
        }
    //创建算法
        enc = IMGENC1_create(ce, "jpegenc", NULL);
        if (enc == NULL){
    	printf("imgenc1_copy create error\n");
    	exit(0);
        }else{
    	printf("hy_jpeg create ok\n");
        }
    //开始编码    
        gettimeofday(&tpstart,0);
        encode(enc);
        gettimeofday(&tpend,0);
        // 微秒
        timeuses=(tpend.tv_sec-tpstart.tv_sec)*1000000+tpend.tv_usec-tpstart.tv_usec;
        printf("use time: %uus\n",timeuses);
    //编码完成	
        fwrite(outBuf, encOutArgs.bytesGenerated, 1, fpOut);
        
        fclose(fpIn);
        fclose(fpOut);
    
        IMGENC1_delete(enc);
    	
        Engine_close(ce);
    	
        if(outBuf)Memory_free(outBuf,WIDTH*HEIGHT*2, &myParams);
        if(inBuf)Memory_free(inBuf, WIDTH*HEIGHT*2, &myParams);
    		
        CERuntime_exit();
    }
    
    
    
    这是所有打印信息
    inbuf = 0x40a32000
    outbuf = 0x40afd000
    open fin ok!
    open out ok!
    ret = 2
    engine open ok
    hy_jpeg create ok
    getBuf control = 0
    CMEM Error: getPhys: Failed to get physical address of 0x415a3aff
    @0x000a8160:[T:0x4001e880] OM - Memory_getBufferPhysicalAddress> ERROR: user buffer at addr=0x40a32000, size=12000000 is NOT contiguous
    process = -1
    byteGenerated = 0
    use time: 18488us
    
    process执行后返回的是-1,执行失败了。
  • 没人回答么?我应该写的很清楚了啊。。