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.

合众达VPM6467 jpeg编码问题



在使用合众达的VPM6467开发板过程中,有个jpeg编码的例程,就是用的dvsdk里面

dmai里的例子,例子是对一副图像进行编码 ,输出一副jpg图像,我想用它对视频进行

编码,但是在读函数那地方加while(1)但是第二次的话也显示编码成功但是保存文件什么

没有 只有第一次保存的完整的。之后都不行,在engine_open 前加while(1)可以,但是

感觉这样很不合理,每一次都要创建算法例程,buffer等,有没有遇见过同样问题的,

是编码的算法有限制还是处理的方式不对。求高手解答!

  • 1. 初始化创建一次,然后在process那加循环,就可以对视频做成MJPEG流了

  •    while(1)
        {  
                 framePtr = Buffer_getUserPtr(hInBuf);
                    ret=fread(framePtr, 1,1920*1080*2, inFile);
             Buffer_setNumBytesUsed(hInBuf, Buffer_getSize(hInBuf));
          /* Encode the image buffer */
          if (Ienc1_process(hIe, hInBuf, hOutBuf) < 0) {
              printf("Failed to encode image buffer\n");
              goto cleanup;
          }
             /* Write the encoded frame to the file system */
      
          if (Buffer_getNumBytesUsed(hOutBuf)) {

              if (fwrite(Buffer_getUserPtr(hOutBuf),Buffer_getNumBytesUsed(hOutBuf), 1, outFile) != 1) {
                  printf("Failed to write encoded image data to file\n");
                  goto cleanup;
              }  }
       printf("Encode done \n");
      printf("Wrote encoded image of size %d to file \n", 
      (int)Buffer_getNumBytesUsed(hOutBuf)); 
      printf("frame count = %d \n",++cnt);
                Buffer_setNumBytesUsed(hOutBuf,0);
    }  // end while(1)

    这样加的话,编码第一帧输出完整的图像,第二帧之后 就一直有问题 保存的图片也没有显示。

    感觉还是不行的。