|
|
@@ -23,10 +23,12 @@ void VideoDecodeThread::run()
|
|
|
qCDebug(playerControllerVideoDecodeThread)
|
|
|
<< "[VideoDecodeThread] run start, m_pState:" << (void*) m_pState;
|
|
|
assert(m_pState);
|
|
|
+
|
|
|
VideoState* is = m_pState;
|
|
|
qCDebug(playerControllerVideoDecodeThread)
|
|
|
<< "[VideoDecodeThread] VideoState* is:" << (void*) is
|
|
|
<< ", abort_request:" << is->abort_request;
|
|
|
+
|
|
|
AVFrame* frame = av_frame_alloc();
|
|
|
AVFrame* sw_frame = av_frame_alloc();
|
|
|
AVFrame* tmp_frame = nullptr;
|
|
|
@@ -35,46 +37,59 @@ void VideoDecodeThread::run()
|
|
|
int ret;
|
|
|
AVRational tb = is->video_st->time_base;
|
|
|
AVRational frame_rate = av_guess_frame_rate(is->ic, is->video_st, nullptr);
|
|
|
+
|
|
|
+#if USE_AVFILTER_VIDEO
|
|
|
+ // AVFilterGraph* graph = nullptr;
|
|
|
+ AVFilterContext *filt_out = nullptr, *filt_in = nullptr;
|
|
|
+ int last_w = 0;
|
|
|
+ int last_h = 0;
|
|
|
+ enum AVPixelFormat last_format = AV_PIX_FMT_NONE;
|
|
|
+ int last_serial = -1;
|
|
|
+ int last_vfilter_idx = 0;
|
|
|
+#endif
|
|
|
+
|
|
|
if (!frame) {
|
|
|
- qCWarning(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] av_frame_alloc failed!";
|
|
|
+ // qCWarning(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] av_frame_alloc failed!";
|
|
|
return;
|
|
|
}
|
|
|
- int loop_count = 0;
|
|
|
+ // int loop_count = 0;
|
|
|
for (;;) {
|
|
|
- qCDebug(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] loop start, loop_count:" << loop_count
|
|
|
- << ", m_exit:" << (m_exit ? m_exit->load() : -1)
|
|
|
- << ", abort_request:" << is->abort_request;
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] loop start, loop_count:" << loop_count
|
|
|
+ // << ", m_exit:" << (m_exit ? m_exit->load() : -1)
|
|
|
+ // << ", abort_request:" << is->abort_request;
|
|
|
if (isExit()) {
|
|
|
- qCDebug(playerControllerVideoDecodeThread) << "[VideoDecodeThread] m_exit set, exit.";
|
|
|
+ //qCDebug(playerControllerVideoDecodeThread) << "[VideoDecodeThread] m_exit set, exit.";
|
|
|
break;
|
|
|
}
|
|
|
if (is->abort_request) {
|
|
|
- qCDebug(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] abort_request set, exit.";
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] abort_request set, exit.";
|
|
|
break;
|
|
|
}
|
|
|
- qCDebug(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] call get_video_frame, loop:" << loop_count;
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] call get_video_frame, loop:" << loop_count;
|
|
|
ret = get_video_frame(is, frame);
|
|
|
- qCDebug(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] get_video_frame ret:" << ret << ", loop:" << loop_count++
|
|
|
- << ", m_exit:" << (m_exit ? m_exit->load() : -1)
|
|
|
- << ", abort_request:" << is->abort_request;
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] get_video_frame ret:" << ret << ", loop:" << loop_count++
|
|
|
+ // << ", m_exit:" << (m_exit ? m_exit->load() : -1)
|
|
|
+ // << ", abort_request:" << is->abort_request;
|
|
|
|
|
|
if (ret < 0) {
|
|
|
- qCWarning(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] get_video_frame failed, exit.";
|
|
|
+ // qCWarning(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] get_video_frame failed, exit.";
|
|
|
goto the_end;
|
|
|
}
|
|
|
if (!ret) {
|
|
|
- qCDebug(playerControllerVideoDecodeThread) << "[VideoDecodeThread] no frame, continue. m_exit:" << (m_exit ? m_exit->load() : -1) << ", abort_request:" << is->abort_request;
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] no frame, continue. m_exit:"
|
|
|
+ // << (m_exit ? m_exit->load() : -1) << ", abort_request:" << is->abort_request;
|
|
|
continue;
|
|
|
}
|
|
|
- qCDebug(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] got video frame, pts:" << frame->pts
|
|
|
- << ", width:" << frame->width << ", height:" << frame->height;
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] got video frame, pts:" << frame->pts
|
|
|
+ // << ", width:" << frame->width << ", height:" << frame->height;
|
|
|
|
|
|
#if USE_AVFILTER_VIDEO
|
|
|
if (last_w != frame->width || last_h != frame->height || last_format != frame->format
|
|
|
@@ -188,8 +203,8 @@ the_end:
|
|
|
av_frame_free(&frame);
|
|
|
av_frame_free(&sw_frame);
|
|
|
// 可加日志输出
|
|
|
- qCDebug(playerControllerVideoDecodeThread)
|
|
|
- << "[VideoDecodeThread] run end, abort_request:" << is->abort_request
|
|
|
- << ", m_exit:" << (m_exit ? m_exit->load() : -1);
|
|
|
+ // qCDebug(playerControllerVideoDecodeThread)
|
|
|
+ // << "[VideoDecodeThread] run end, abort_request:" << is->abort_request
|
|
|
+ // << ", m_exit:" << (m_exit ? m_exit->load() : -1);
|
|
|
return;
|
|
|
}
|