| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- // ***********************************************************/
- // subtitle_decode_thread.cpp
- //
- // Copy Right @ Steven Huang. All rights reserved.
- //
- // Subtitles decode thread.
- // ***********************************************************/
- #include "subtitle_decode_thread.h"
- SubtitleDecodeThread::SubtitleDecodeThread(VideoState* pState)
- : m_pState(pState)
- {
- }
- SubtitleDecodeThread::~SubtitleDecodeThread()
- {
- }
- void SubtitleDecodeThread::stop()
- {
- m_exit = true;
- m_cv.notify_all();
- }
- void SubtitleDecodeThread::run()
- {
- assert(m_pState);
- VideoState* is = m_pState;
- Frame* sp;
- int got_subtitle;
- double pts = 0;
- for (;;)
- {
- if (m_exit)
- break;
- if (!(sp = frame_queue_peek_writable(&is->subpq)))
- return;
- if ((got_subtitle = decoder_decode_frame(&is->subdec, nullptr, &sp->sub)) < 0)
- break;
- pts = 0;
- if (got_subtitle && sp->sub.format == 1)
- {
- if (sp->sub.pts != AV_NOPTS_VALUE)
- pts = sp->sub.pts / (double)AV_TIME_BASE;
- sp->pts = pts;
- sp->serial = is->subdec.pkt_serial;
- sp->width = is->subdec.avctx->width;
- sp->height = is->subdec.avctx->height;
- sp->uploaded = 0;
- /* now we can update the picture count */
- frame_queue_push(&is->subpq);
- }
- else if (got_subtitle)
- {
- // qWarning("Not handled subtitle type:%d", sp->sub.format);
- avsubtitle_free(&sp->sub);
- }
- }
- // 可加日志输出
- return;
- }
|