AnsweredAssumed Answered

VPU decode. Function vpu_DecOpen .

Question asked by JP Lai on Jul 30, 2016
Latest reply on Aug 12, 2016 by Joan Xie

Hello everyone.

I was a beginner. I have some question need to help.Thank you in advance for your help.

I used the vpu library to decode a jpeg image.

Here is my vpu Fw and lib version.

[INFO]Product Info: i.MX6Q/D/S

             VPU firmware version: 3.1.1_r46063

             VPU library version: 5.4.28


My code result.

VPU Init Success.

[INFO] Product Info: i.MX6Q/D/S

VPU firmware version: 3.1.1_r46063

VPU library version: 5.4.28

Success to obtain physical mem

Success to obtain virtual mem

vpu_DecOpen failed, ret:-3


I know the vpu_DecOpen  function which return -3 is represents DecOpenParam's parameter is wrong.

but I don't know what parameters that I need to use.

I just want to decode jpeg. Please help me to resolve this probram.

Thank you.


Here is my code.

int main()


    unsigned char *buf;

    unsigned long int fileLength, bufLength;

    FILE *pfile;

    pfile = fopen("red.jpeg","rb");

    if(fseek(pfile, 0, SEEK_END)) {                                                        //移到最後算長度

    return -1;//File seek error.}

    fileLength = ftell(pfile);                                                                       //長度

    rewind(pfile);                                                                                      //移到最前面

    buf = (unsigned char*)malloc(sizeof(unsigned char)*fileLength);

    if (pfile == NULL){

        printf("Fail");system("pause");return 0;}

    fread ( buf, 1, fileLength, pfile);                                                          //讀檔到buf

    printf("%ld\n%p\n%ld\n",fileLength, buf, bufLength);




    int err;

    if (vpu_Init(NULL)) {

    printf("VPU Init Failure.\n");

    return 0;}

    else printf("VPU Init Success.\n");


    struct decode *dec;

    dec = (struct decode *)calloc(1, sizeof(struct decode));                  //reserve

    vpu_versioninfo ver = {0};

    vpu_mem_desc mem_desc = {0};

    mem_desc.size = 0x35975;


  err = vpu_GetVersionInfo(&ver);

  if (err) {

  printf("Cannot get version info, err:%d\n", err);


  return 0;



  printf("VPU firmware version: %d.%d.%d_r%d\n", ver.fw_major, ver.fw_minor,

  ver.fw_release, ver.fw_code);

  printf("VPU library version: %d.%d.%d\n", ver.lib_major, ver.lib_minor,



   if(IOGetPhyMem(&mem_desc)) { //input buff size,then buff

  printf("Unable to obtain physical mem\n"); //then buff phy_addr is output

  return 0;} //after return success.

    else printf("Success to obtain physical mem\n");


  if (IOGetVirtMem(&mem_desc) <= 0) {

  printf("Unable to obtain virtual mem\n");



  return 0;}

    else printf("Success to obtain virtual mem\n");                                         //Susses to obtain address


    dec->phy_bsbuf_addr = mem_desc.phy_addr;

    dec->virt_bsbuf_addr = mem_desc.virt_uaddr;


    RetCode ret;

    DecHandle handle;

    DecOpenParam oparam;


    oparam.bitstreamFormat = 7;

    oparam.bitstreamBuffer = dec->phy_bsbuf_addr;

    oparam.bitstreamBufferSize = 0x35975;

    //oparam.pBitStream = dec->virt_bsbuf_addr;

    oparam.reorderEnable = 0; // force to zero

    oparam.mp4DeblkEnable = 0;

    oparam.chromaInterleave = 0; //unknow

    //oparam.mjpg_thumbNailDecEnable = 0;

    //oparam.avcExtension = 0;

    //oparam.mapType = 0;

    //oparam.tiled2LinearEnable = 0;

    //oparam.bitstreamMode = 0;

    ret = vpu_DecOpen(&handle,&oparam);

    if (ret != RETCODE_SUCCESS) {

  printf("vpu_DecOpen failed, ret:%d\n", ret);

  return 0;


    else printf("vpu_DecOpen Success \n");


    return 0;