| 
 | 
 
如题,参照mpp中的【mpi_dec_test.c】例程,使用ffmpeg接入RTSP流解封装为packet,然后传给mpp进行硬解码 
 
 
代码如下 
初始化函数 
- int decodecRockchip::decodec_init(std::string rtsp_addr){
 
 -     MPP_RET ret=MPP_OK;
 
 -     MpiCmd mpi_cmd;
 
  
-     std::string ttt="h264";
 
 -     mpp_dec_type= (in_rtsp_codec_type != ttt)? MPP_VIDEO_CodingMPEG4 : MPP_VIDEO_CodingHEVC ;
 
  
-     // config for runtime mode
 
 -     MppDecCfg cfg       = NULL;
 
 -     RK_U32 need_split   = 1;//硬件解码器的拆分模式
 
  
-     /********************************************************************/
 
 -     //初始化流
 
 -     InVideo_init(rtsp_addr);
 
 -     /********************************************************************/
 
  
-     //创建MPP context 和 MPP api 接口
 
 -     ret = mpp_create(&mpp_ctx, &mpp_mpi);
 
 -     if (MPP_OK != ret) {
 
 -         printf("mpp_create failed\n");
 
 -         decodec_deinit();
 
 -     }
 
 -     printf("%p mpi_dec_test decoder test start w %d h %d type %d\n",mpp_ctx, in_rtsp_width, in_rtsp_height, mpp_dec_type);
 
  
-     //设置一些MPP的模式
 
 -     mpi_cmd = MPP_DEC_SET_PARSER_SPLIT_MODE;//使能MPP内的协议解析器使用内部分帧处理
 
 -     MppParam param = &need_split;
 
 -     ret = mpp_mpi->control(mpp_ctx, mpi_cmd, param);
 
 -     if (MPP_OK != ret) {
 
 -         printf("mpi->control failed\n");
 
 -         decodec_deinit();
 
 -     }
 
  
-     //初始化Mpp,解码功能
 
 -     ret = mpp_init(mpp_ctx, MPP_CTX_DEC, mpp_dec_type);
 
 -     if (MPP_OK != ret) {
 
 -         printf("mpp_init failed,%d\n",ret);
 
 -         decodec_deinit();
 
 -     }
 
 -    
 
 -     /********************************************************************/
 
 -     printf("dec init endl\n\r");
 
 -     return 0;
 
 - }
 
 开始解码函数 
- int decodecRockchip::decodec_start(){
 
 -     RK_U32 pkt_done = 0;//用于标记是否发送完数据
 
 -     RK_U32 pkt_eos  = 0;
 
  
-     MPP_RET ret=MPP_OK;
 
 -     RK_S32 times = 3;//等待计时,单位毫秒
 
  
 
-     //测试保存视频文件
 
 -     data.fp_output = fopen("./dec.yuv","ab+");
 
  
-     ret = mpp_packet_init(&mpp_packet, av_packet->data, av_packet->size);
 
 -     if (ret) {
 
 -         printf("mpp_packet_init failed\n");
 
 -     }
 
 -     mpp_packet_set_pts(mpp_packet, av_packet->pts);//设置数据包内容的播放时间
 
  
-     //循环
 
 -     do
 
 -     {
 
 -         RK_U32 frm_eos = 0;
 
  
-         //获取一包视频数据
 
 -         if(av_read_frame(pFormatCtx,av_packet)>=0 && av_packet->stream_index==is_Video)//获取ffmpeg的包
 
 -         {
 
 -             printf(">>>packet data size:%d \n\r",av_packet->size);
 
 -         }else{
 
 -             continue;//跳过
 
 -         }
 
  
 
-         //喂数据给硬件解码器
 
 -         if(!pkt_done){
 
 -             ret = mpp_mpi->decode_put_packet(mpp_ctx, mpp_packet);
 
 -             if (MPP_OK == ret) {
 
 -                 printf("to packet for MPP\n\r");
 
 -                 pkt_done = 1;
 
 -             }
 
 -         }
 
  
-         do
 
 -         {
 
 -             /* 拿数据 */
 
 -             ret = mpp_mpi->decode_get_frame(mpp_ctx, &mpp_frame);
 
 -             if (ret != MPP_OK) {
 
 -                 printf("%p decode_get_frame failed ret %d\n", mpp_ctx, ret);
 
 -                 break;
 
 -             }else{
 
 -                 if (MPP_ERR_TIMEOUT == ret) {
 
 -                     if (times > 0) {
 
 -                         times--;
 
 -                         msleep(2);
 
 -                     }
 
 -                     printf("%p decode_get_frame failed too much time\n", mpp_ctx);
 
 -                 }else{printf("aaa\n\r");}
 
 -             }
 
  
-             if(mpp_frame){//当前卡在这里了~~~无法到里面去
 
 -                 if(mpp_frame_get_info_change(mpp_frame)){
 
 -                     //此时,mpp_frame中包含了解码后的帧数据
 
  
-                     RK_U32 width = mpp_frame_get_width(mpp_frame);
 
 -                     RK_U32 height = mpp_frame_get_height(mpp_frame);
 
 -                     RK_U32 hor_stride = mpp_frame_get_hor_stride(mpp_frame);
 
 -                     RK_U32 ver_stride = mpp_frame_get_ver_stride(mpp_frame);
 
 -                     RK_U32 buf_size = mpp_frame_get_buf_size(mpp_frame);
 
 -                     printf("dec in frame width:%d,height:%d,hor_stride:%d,ver_stride:%d,buf_size:%d \n\r",width
 
 -                                                                                                         ,height
 
 -                                                                                                         ,hor_stride
 
 -                                                                                                         ,ver_stride
 
 -                                                                                                         ,buf_size);
 
  
-                     //测试
 
 -                     dump_mpp_frame_to_file(mpp_frame, data.fp_output);
 
 -                     printf(">>>保存一帧\n\r");
 
  
-                 }else{
 
 -                     printf("aaa\n\r");
 
 -                 }
 
  
-                 frm_eos = mpp_frame_get_eos(mpp_frame);
 
 -                 mpp_frame_deinit(&mpp_frame);
 
 -             }//else{printf("什么情况??\n\r");}
 
  
-             // 如果发送了最后一个数据包,但未找到最后一帧,则继续
 
 -             if (pkt_eos && pkt_done && !frm_eos) {
 
 -                 msleep(1);
 
 -                 continue;
 
 -             }
 
 -             
 
 -         } while (1);
 
  
-         if(av_packet != NULL)av_packet_unref(av_packet);
 
 -         
 
 -     } while (1);
 
 -     
 
 -     return 0;
 
 - }
 
  
 
然而获取到的【mpp_frame】为0(if(mpp_frame)一直没有进去) 
请问一下,我说提供的信息是否可以看出问题所在? 
 
同时询问一下是否有最新版本的MPP开发者手册?或是相关教程。万分感谢!!! 
 
 |   
 
 
 
 |