diff options
author | Martijn Kaijser <martijn@xbmc.org> | 2018-02-13 19:23:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 19:23:04 +0100 |
commit | ab218e62b90b4f13389840212a5f9aafbd488165 (patch) | |
tree | 4e98c71724979742f3ce8ac70b99b721fb1b90b7 | |
parent | 6a3d3e761b29ffda7ced44b8ef1fc9abe02c8493 (diff) | |
parent | 064704a9ac156b2f485471e62a6acb72eebbf2ce (diff) |
Merge pull request #13539 from kszaq/aml_frametracking
DVDVideoCodecAmlogic: remove pts-based frame rate tracking
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp | 161 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h | 7 |
2 files changed, 0 insertions, 168 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp index 1e5dd5a164..7fa9dcbeb1 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp @@ -73,21 +73,11 @@ void CAMLVideoBufferPool::Return(int id) /***************************************************************************/ -typedef struct frame_queue { - double dts; - double pts; - double sort_time; - struct frame_queue *nextframe; -} frame_queue; - CDVDVideoCodecAmlogic::CDVDVideoCodecAmlogic(CProcessInfo &processInfo) : CDVDVideoCodec(processInfo) , m_pFormatName("amcodec") , m_opened(false) , m_codecControlFlags(0) - , m_last_pts(0.0) - , m_frame_queue(NULL) - , m_queue_depth(0) , m_framerate(0.0) , m_video_rate(0) , m_mpeg2_sequence(NULL) @@ -95,13 +85,11 @@ CDVDVideoCodecAmlogic::CDVDVideoCodecAmlogic(CProcessInfo &processInfo) , m_bitparser(NULL) , m_bitstream(NULL) { - pthread_mutex_init(&m_queue_mutex, NULL); } CDVDVideoCodecAmlogic::~CDVDVideoCodecAmlogic() { Dispose(); - pthread_mutex_destroy(&m_queue_mutex); } CDVDVideoCodec* CDVDVideoCodecAmlogic::Create(CProcessInfo &processInfo) @@ -333,9 +321,6 @@ void CDVDVideoCodecAmlogic::Dispose(void) if (m_bitparser) delete m_bitparser, m_bitparser = NULL; - while (m_queue_depth) - FrameQueuePop(); - m_opened = false; } @@ -393,9 +378,6 @@ bool CDVDVideoCodecAmlogic::AddData(const DemuxPacket &packet) void CDVDVideoCodecAmlogic::Reset(void) { - while (m_queue_depth) - FrameQueuePop(); - m_Codec->Reset(); m_mpeg2_sequence_pts = 0; m_has_keyframe = false; @@ -461,68 +443,6 @@ void CDVDVideoCodecAmlogic::SetSpeed(int iSpeed) m_Codec->SetSpeed(iSpeed); } -void CDVDVideoCodecAmlogic::FrameQueuePop(void) -{ - if (!m_frame_queue || m_queue_depth == 0) - return; - - pthread_mutex_lock(&m_queue_mutex); - // pop the top frame off the queue - frame_queue *top = m_frame_queue; - m_frame_queue = top->nextframe; - m_queue_depth--; - pthread_mutex_unlock(&m_queue_mutex); - - // and release it - free(top); -} - -void CDVDVideoCodecAmlogic::FrameQueuePush(double dts, double pts) -{ - frame_queue *newframe = (frame_queue*)calloc(sizeof(frame_queue), 1); - newframe->dts = dts; - newframe->pts = pts; - // if both dts or pts are good we use those, else use decoder insert time for frame sort - if ((newframe->pts != DVD_NOPTS_VALUE) || (newframe->dts != DVD_NOPTS_VALUE)) - { - // if pts is borked (stupid avi's), use dts for frame sort - if (newframe->pts == DVD_NOPTS_VALUE) - newframe->sort_time = newframe->dts; - else - newframe->sort_time = newframe->pts; - } - - pthread_mutex_lock(&m_queue_mutex); - frame_queue *queueWalker = m_frame_queue; - if (!queueWalker || (newframe->sort_time < queueWalker->sort_time)) - { - // we have an empty queue, or this frame earlier than the current queue head. - newframe->nextframe = queueWalker; - m_frame_queue = newframe; - } - else - { - // walk the queue and insert this frame where it belongs in display order. - bool ptrInserted = false; - frame_queue *nextframe = NULL; - // - while (!ptrInserted) - { - nextframe = queueWalker->nextframe; - if (!nextframe || (newframe->sort_time < nextframe->sort_time)) - { - // if the next frame is the tail of the queue, or our new frame is earlier. - newframe->nextframe = nextframe; - queueWalker->nextframe = newframe; - ptrInserted = true; - } - queueWalker = nextframe; - } - } - m_queue_depth++; - pthread_mutex_unlock(&m_queue_mutex); -} - void CDVDVideoCodecAmlogic::FrameRateTracking(uint8_t *pData, int iSize, double dts, double pts) { // mpeg2 handling @@ -550,85 +470,4 @@ void CDVDVideoCodecAmlogic::FrameRateTracking(uint8_t *pData, int iSize, double } return; } - - // everything else - FrameQueuePush(dts, pts); - - // we might have out-of-order pts, - // so make sure we wait for at least 8 values in sorted queue. - if (m_queue_depth > 16) - { - pthread_mutex_lock(&m_queue_mutex); - - float cur_pts = m_frame_queue->pts; - if (cur_pts == DVD_NOPTS_VALUE) - cur_pts = m_frame_queue->dts; - - pthread_mutex_unlock(&m_queue_mutex); - - float duration = cur_pts - m_last_pts; - m_last_pts = cur_pts; - - // clamp duration to sensible range, - // 66 fsp to 20 fsp - if (duration >= 15000.0 && duration <= 50000.0) - { - double framerate; - switch((int)(0.5 + duration)) - { - // 59.940 (16683.333333) - case 16000 ... 17000: - framerate = 60000.0 / 1001.0; - break; - - // 50.000 (20000.000000) - case 20000: - framerate = 50000.0 / 1000.0; - break; - - // 49.950 (20020.000000) - case 20020: - framerate = 50000.0 / 1001.0; - break; - - // 29.970 (33366.666656) - case 32000 ... 35000: - framerate = 30000.0 / 1001.0; - break; - - // 25.000 (40000.000000) - case 39900 ... 40100: - framerate = 25000.0 / 1000.0; - break; - - // 23.976 (41708.33333) - case 40200 ... 43200: - // 23.976 seems to have the crappiest encodings :) - framerate = 24000.0 / 1001.0; - break; - - default: - framerate = 0.0; - //CLog::Log(LOGDEBUG, "%s: unknown duration(%f), cur_pts(%f)", - // __MODULE_NAME__, duration, cur_pts); - break; - } - - if (framerate > 0.0 && (int)m_framerate != (int)framerate) - { - m_framerate = framerate; - m_video_rate = (int)(0.5 + (96000.0 / framerate)); - - if (m_Codec) - m_Codec->SetVideoRate(m_video_rate); - - m_processInfo.SetVideoFps(m_framerate); - - CLog::Log(LOGDEBUG, "%s: detected new framerate(%f), video_rate(%d)", - __MODULE_NAME__, m_framerate, m_video_rate); - } - } - - FrameQueuePop(); - } } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h index ee0775f15c..11522d92fa 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h @@ -28,7 +28,6 @@ #include <atomic> class CAMLCodec; -struct frame_queue; struct mpeg2_sequence; class CBitstreamParser; class CBitstreamConverter; @@ -88,8 +87,6 @@ public: protected: void Dispose(void); - void FrameQueuePop(void); - void FrameQueuePush(double dts, double pts); void FrameRateTracking(uint8_t *pData, int iSize, double dts, double pts); //void RemoveInfo(CDVDAmlogicInfo* info); @@ -100,10 +97,6 @@ protected: bool m_opened; int m_codecControlFlags; CDVDStreamInfo m_hints; - double m_last_pts; - frame_queue *m_frame_queue; - int32_t m_queue_depth; - pthread_mutex_t m_queue_mutex; double m_framerate; int m_video_rate; float m_aspect_ratio; |