| | |
| | | */ |
| | | void BASICGB28181::FFmpegDecoderJPG::BareFlowDecoderThd(FFmpegDecoderJPG *p_this) { |
| | | DBG(p_this->m_camIdx << " BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx); |
| | | // while(!p_this->m_running) { |
| | | while(!p_this->m_running) { |
| | | |
| | | p_this->m_running = true; |
| | | // av_register_all(); |
| | |
| | | if (!p_this->iobuffer) { |
| | | ERR("av_malloc: err======" << p_this->m_camIdx); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | p_this->avio = avio_alloc_context(p_this->iobuffer, p_this->m_buf_size, 0, p_this, p_this->read_data, NULL, |
| | | NULL); |
| | | if (!p_this->avio) { |
| | | ERR("avio_alloc_context: err======" << p_this->m_camIdx); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | p_this->ic->pb = p_this->avio; |
| | | |
| | |
| | | if (err) { |
| | | ERR("av_probe_input_buffer: err======" << err << p_this->m_camIdx); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | err = avformat_open_input(&p_this->ic, "", NULL, NULL); |
| | | if (err) { |
| | | ERR("avformat_open_input: err======" << err << p_this->m_camIdx); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | // int err2 = avformat_find_stream_info(ic, nullptr); |
| | | err = avformat_find_stream_info(p_this->ic, NULL); |
| | |
| | | // avformat_close_input(&p_this->ic); |
| | | // DBG("avformat_close_input(&p_this->ic);"); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | int vi = -1; |
| | | for (int i = 0; i < p_this->ic->nb_streams; ++i) { |
| | |
| | | // avformat_close_input(&p_this->ic); |
| | | // DBG("avformat_close_input(&p_this->ic);"); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | p_this->codec = avcodec_find_decoder(p_this->ctx->codec_id); |
| | |
| | | // avcodec_free_context(&p_this->ctx); |
| | | // DBG("avcodec_free_context(&p_this->ctx);"); |
| | | p_this->m_running = false; |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | av_init_packet(&p_this->pkt); |
| | |
| | | p_this->frame = av_frame_alloc(); |
| | | unsigned int usleepTime = (1000 / p_this->m_fps) - 12; |
| | | usleepTime *= 1000; |
| | | DBG(" before while <<usleepTime is " << usleepTime); |
| | | DBG("===open ok, camid: " << p_this->m_camIdx ); |
| | | while (p_this->m_running) { |
| | | #ifdef TestCode |
| | | ClockTimer Test("while time"); |
| | |
| | | } |
| | | DBG(" after while "); |
| | | av_frame_free(&p_this->frame); |
| | | // } |
| | | } |
| | | } |
| | | |
| | | bool BASICGB28181::FFmpegDecoderJPG::startThd(const std::string &camIdx, const int &fps, const int &gpuIdx) { |