- while (1)
- {
- AVPacket *input_packet = av_packet_alloc();
- if (!input_packet)
- {
- qDebug("failed to allocated memory for AVPacket");
- return;
- }
- res_send = av_read_frame(decoder->avfc, input_packet);
- // qDebug("Status while %d av_read_frame %s ===%d", send_packet_count++,av_err2str(res_send),res_send);
- // qDebug("Packet size = %d stream_index = %d", input_packet->size,input_packet->stream_index);
- if (res_send<0 ){
- break;
- }
- // stream_index =0 是音频流,1是视频流
- if(input_packet->stream_index == 1){
- //qDebug("input_packet = %d %d",input_packet->size,input_packet->pos);
- qDebug("Packet size = %d stream_index = %d flags =%d", input_packet->size,input_packet->stream_index,input_packet->flags);
- t.restart();
- int response = avcodec_send_packet(decoder->video_avcc, input_packet);
- if (response < 0) {
- // qDebug("Error while sending packet to decoder: %s", av_err2str(response));
- qDebug("Error <0 while %d sending packet to decoder: %s", send_packet_count++,av_err2str(response));
- // av_packet_unref(input_packet);
- // break;
- }
- response = 0;
- while (response >= 0)
- {
- receive_frame_count = 0;
- // AVFrame *input_frame = av_frame_alloc();
- response = avcodec_receive_frame(decoder->video_avcc, input_frame);
- qDebug("input_frame pkt_size = %d flags =%d", input_frame->pkt_size,input_frame->flags);
- qDebug("Error while %d avcodec_receive_frame : %s", receive_frame_count++,av_err2str(response));
- if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
- {
- // qDebug("Error == AVERROR_EOF or AVERROR(EAGAIN) while %d avcodec_receive_frame : %s", receive_frame_count++,av_err2str(ret));
- break;
- }
- else if (response < 0)
- {
- // qDebug("Error <0 while %d avcodec_receive_frame : %s", receive_frame_count++,av_err2str(ret));
- // qDebug("Error while receiving frame from decoder: %s", av_err2str(response));
- av_frame_unref(input_frame);
- break;
- }
- else if (response >= 0)
- {
- // qDebug("Error >= 0 while %d avcodec_receive_frame : %s", receive_frame_count++,av_err2str(ret));
- //qDebug("DECODER SUCESS %d %d %d",input_frame->format,input_frame->width,
- // input_frame->height);
- // retrieve data from GPU to CPU
- int err = av_hwframe_transfer_data(
- pFrameOK, // The frame that will contain the usable data.
- input_frame, // Frame returned by avcodec_receive_frame()
- 0);
- qDebug("pFrameOK size = %d flags =%d", pFrameOK->pkt_size,pFrameOK->flags);
- int sws_ret = sws_scale(img_convert_ctx,
- pFrameOK->data,
- pFrameOK->linesize, 0, decoder->video_avcc->height, pFrameRGB->data,
- pFrameRGB->linesize);
- QImage * tmpImg =new QImage ((uchar *)pFrameRGB->data[0], decoder->video_avcc->width, decoder->video_avcc->height, QImage::Format_RGB32);
- //qDebug()<<QDateTime::currentDateTime().toString("hh:mm:ss zzz");
- *tmpImg = tmpImg->scaled(1209, 734, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation);
- //QImage image = tmpImg.copy(); //把图像复制一份 传递给界面显示
- //QPixmap pixmaptemp = QPixmap::fromImage(tmpImg);
- //pixmap.scaled(QSize(1209,723), Qt::KeepAspectRatio);
- int el = t.elapsed();
- int interval = 1000 / 25 - el > 0 ? 1000 / 25 - el : 0;
- //qDebug()<<interval;
- msleep(interval);
- emit sig_GetOneFrame(*tmpImg); //发送信号
- delete tmpImg;
- av_frame_unref(input_frame);
- }
- }
- }
- av_packet_unref(input_packet);
- av_packet_free(&input_packet);
- }
复制代码
- mpi: mpp version: 0b701fe author: Lawrence-Tang DEBIAN: prepare for release_20171218-3
- mpi: mpp version: 0b701fe author: Lawrence-Tang DEBIAN: prepare for release_20171218-3
- hal_h264d_api: hal_h264d_init mpp_buffer_group_get_internal used ion In
- mpp_rt: NOT found ion allocator
- mpp_rt: found drm allocator
- mpi: mpp version: 0b701fe author: Lawrence-Tang DEBIAN: prepare for release_20171218-3
- hal_h264d_api: hal_h264d_init mpp_buffer_group_get_internal used ion In
- Packet size = 55486 stream_index = 1 flags =1
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 8268 stream_index = 1 flags =0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 2609 stream_index = 1 flags =0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 9194 stream_index = 1 flags =0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 2465 stream_index = 1 flags =0
- [h264_rkmpp @ 0x7f34f505c0] Decoder noticed an info change (1920x810), format=0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Success
- pFrameOK size = -1 flags =0
- input_frame pkt_size = -1 flags =0
- 。。。。。
复制代码
- [h264_rkmpp @ 0x7f34f505c0] Received a errinfo frame.
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Unknown error occurred
- Packet size = 1189 stream_index = 1 flags =0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 3621 stream_index = 1 flags =0
- [h264_rkmpp @ 0x7f34f505c0] Received a errinfo frame.
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Unknown error occurred
- Packet size = 15466 stream_index = 1 flags =0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 3456 stream_index = 1 flags =0
- [h264_rkmpp @ 0x7f34f505c0] Received a errinfo frame.
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Unknown error occurred
- Packet size = 14654 stream_index = 1 flags =0
- [h264_rkmpp @ 0x7f34f505c0] Received a errinfo frame.
- Error <0 while 4 sending packet to decoder: Unknown error occurred
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 3173 stream_index = 1 flags =0
- input_frame pkt_size = -1 flags =0
- Error while 0 avcodec_receive_frame : Resource temporarily unavailable
- Packet size = 8468 stream_index = 1 flags =0
- [h264_rkmpp @ 0x7f34f505c0] Received a errinfo frame.
复制代码
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |