rockchip-linux / mpp

Media Process Platform (MPP) module
604 stars 172 forks source link

advanced_decode 解码MJPEG速度太慢 #284

Open XxChang opened 2 years ago

XxChang commented 2 years ago

平台:RK3399

图片格式 MJPEG 1920*1080

代码片段如下:

    RK_U32 pkt_eos = 0 ;
    int ret = 0 ;
    MppTask task = NULL ;

    long mTimeS0 = get_time() ;

    mpp_packet_set_pos(mPkt, mBuf) ;
    mpp_packet_set_length(mPkt, size) ;

    if (pkt_eos)
      mpp_packet_set_eos(mPkt) ;

    ret = mApi->poll(mCtx, MPP_PORT_INPUT, MPP_POLL_BLOCK) ;
    if (ret != MPP_OK) {
      fprintf(stderr, "mpp input poll failed\n") ;
      return ret ;
    }

    ret = mApi->dequeue(mCtx, MPP_PORT_INPUT, &task) ;
    if (ret != MPP_OK) {
      fprintf(stderr, "mpp task input dequeue failed\n") ;
      return ret ;
    }
   mpp_assert(task) ;

   mpp_task_meta_set_packet(task, KEY_INPUT_PACKET, mPkt) ;
   mpp_task_meta_set_frame(task, KEY_OUTPUT_FRAME, mFrm) ;

    ret = mApi->enqueue(mCtx, MPP_PORT_INPUT, task) ;
    if (MPP_OK != ret) {
      fprintf(stderr, "mpp task input enqueue failed\n") ;
      return ret ;
    }

    long mTimeS1 = get_time() ;

    ret = mApi->poll(mCtx, MPP_PORT_OUTPUT, MPP_POLL_BLOCK) ;
    if (ret != MPP_OK) {
      fprintf(stderr, "mpp output poll failed\n") ;
      return ret ;
    }

    ret = mApi->dequeue(mCtx, MPP_PORT_OUTPUT, &task) ;
    if (ret != MPP_OK) {
      fprintf(stderr, "mpp task output dequeue failed\n") ;
      return ret ;
    }
    mpp_assert(task) ;

    if (task) {
      MppFrame frame_out = NULL ;
      mpp_task_meta_get_frame(task, KEY_OUTPUT_FRAME, &frame_out) ;

      if (mFrm) {

      } 
     ret = mApi->enqueue(mCtx, MPP_PORT_OUTPUT, task) ;
     if (ret != MPP_OK) {
       fprintf(stderr, "mpp task output enqueue failed\n") ;
     }
   }
    long mTimeE = get_time() ;

    double timeDiffI = double( mTimeS1 - mTimeS0 )/1000.0 ;
    double timeDiffO = double( mTimeE - mTimeS1 )/1000.0 ;
    printf("input time:%lf output time:%lf\n",timeDiffI,timeDiffO);

input time:0.110000 output time:305.199000 一帧耗时300毫秒左右,fps 3 左右 我看benchmark上有介绍 MJPEG 1080P 可以达到 30fps 请问有什么办法吗

xiangxud commented 1 year ago

我测试耗时6ms-24ms,也是用的mpi task