From 5e5908b4d6ca88ecf4892e0e853e6b2a78a0546e Mon Sep 17 00:00:00 2001 From: Mark Kendall Date: Mon, 6 Dec 2010 14:57:47 +0800 Subject: [PATCH] More XvMC code removal. --- mythtv/libs/libmythtv/avformatdecoder.cpp | 48 ---- mythtv/libs/libmythtv/frame.h | 3 - mythtv/libs/libmythtv/tv_play.cpp | 1 - mythtv/libs/libmythtv/videobuffers.cpp | 311 +--------------------- mythtv/libs/libmythtv/videobuffers.h | 32 --- mythtv/libs/libmythtv/videoout_vdpau.cpp | 1 - mythtv/libs/libmythtv/videoout_xv.cpp | 10 +- mythtv/libs/libmythtv/videooutbase.cpp | 3 +- mythtv/libs/libmythtv/videoouttypes.h | 6 +- 9 files changed, 9 insertions(+), 406 deletions(-) diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp index 5d6bb8ecb59..4d8a7409a5e 100644 --- a/mythtv/libs/libmythtv/avformatdecoder.cpp +++ b/mythtv/libs/libmythtv/avformatdecoder.cpp @@ -4018,54 +4018,6 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype) continue; } - if (ringBuffer->IsDVD() && - curstream->codec->codec_type == CODEC_TYPE_VIDEO) - { -#ifdef USING_XVMC - if (!private_dec) - { - int current_width = curstream->codec->width; - int video_width = m_parent->GetVideoSize().width(); - if (dvd_xvmc_enabled && m_parent && m_parent->getVideoOutput()) - { - bool dvd_xvmc_active = false; - if (codec_is_xvmc(video_codec_id)) - { - dvd_xvmc_active = true; - } - - bool indiscmenu = ringBuffer->IsInDiscMenuOrStillFrame(); - if ((indiscmenu && dvd_xvmc_active) || - ((!indiscmenu && !dvd_xvmc_active))) - { - VERBOSE(VB_PLAYBACK, LOC + QString("DVD Codec Change " - "indiscmenu %1 dvd_xvmc_active %2") - .arg(indiscmenu).arg(dvd_xvmc_active)); - dvd_video_codec_changed = true; - } - } - - if ((video_width > 0) && dvd_video_codec_changed) - { - VERBOSE(VB_PLAYBACK, LOC + - QString("DVD Stream/Codec Change " - "video_width %1 current_width %2 " - "dvd_video_codec_changed %3") - .arg(video_width).arg(current_width) - .arg(dvd_video_codec_changed)); - av_free_packet(pkt); - if (current_width > 0) { - CloseCodecs(); - ScanStreams(false); - allowedquit = true; - dvd_video_codec_changed = false; - } - continue; - } - } -#endif //USING_XVMC - } - enum CodecType codec_type = curstream->codec->codec_type; if (storevideoframes && codec_type == CODEC_TYPE_VIDEO) diff --git a/mythtv/libs/libmythtv/frame.h b/mythtv/libs/libmythtv/frame.h index 988cdf32750..6f53f336e29 100644 --- a/mythtv/libs/libmythtv/frame.h +++ b/mythtv/libs/libmythtv/frame.h @@ -14,9 +14,6 @@ typedef enum FrameType_ FMT_NONE = -1, FMT_RGB24 = 0, FMT_YV12, - FMT_XVMC_IDCT_MPEG2, - FMT_XVMC_MOCO_MPEG2, - FMT_VIA_HWSLICE, FMT_IA44, FMT_AI44, FMT_ARGB32, diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index b31036499a1..0dcbcc68fa7 100644 --- a/mythtv/libs/libmythtv/tv_play.cpp +++ b/mythtv/libs/libmythtv/tv_play.cpp @@ -5090,7 +5090,6 @@ bool TV::CreatePIP(PlayerContext *ctx, const ProgramInfo *info) return false; } - /* TODO implement PIP solution for Xvmc playback */ if (!IsPIPSupported(mctx)) { VERBOSE(VB_IMPORTANT, LOC + "PiP not supported by video method."); diff --git a/mythtv/libs/libmythtv/videobuffers.cpp b/mythtv/libs/libmythtv/videobuffers.cpp index ebb4e0f495b..874b028eb89 100644 --- a/mythtv/libs/libmythtv/videobuffers.cpp +++ b/mythtv/libs/libmythtv/videobuffers.cpp @@ -14,10 +14,6 @@ extern "C" { #include "compat.h" #include "mythverbose.h" -#ifdef USING_XVMC -#include "videoout_xv.h" // for xvmc stuff -#endif - #define DEBUG_FRAME_LOCKS 0 #define TRY_LOCK_SPINS 100 @@ -214,8 +210,6 @@ void VideoBuffers::Reset() limbo.clear(); pause.clear(); displayed.clear(); - parents.clear(); - children.clear(); vbufferMap.clear(); } @@ -655,21 +649,10 @@ void VideoBuffers::DiscardFrames(bool next_frame_keyframe) if (!next_frame_keyframe) { - for (bool change = true; change;) - { - change = false; - frame_queue_t ula(used); - frame_queue_t::iterator it = ula.begin(); - for (; it != ula.end(); ++it) - { - if (!HasChildren(*it)) - { - RemoveInheritence(*it); - DiscardFrame(*it); - change = true; - } - } - } + frame_queue_t ula(used); + frame_queue_t::iterator it = ula.begin(); + for (; it != ula.end(); ++it) + DiscardFrame(*it); VERBOSE(VB_PLAYBACK, QString("VideoBuffers::DiscardFrames(%1): %2 -- done") .arg(next_frame_keyframe).arg(GetStatus())); @@ -681,8 +664,6 @@ void VideoBuffers::DiscardFrames(bool next_frame_keyframe) ula.insert(ula.end(), limbo.begin(), limbo.end()); ula.insert(ula.end(), available.begin(), available.end()); frame_queue_t::iterator it; - for (it = ula.begin(); it != ula.end(); ++it) - RemoveInheritence(*it); // Discard frames frame_queue_t discards(used); @@ -893,209 +874,6 @@ void VideoBuffers::UnlockFrames(vector& vec, UnlockFrame(vec[i], ""); } -void VideoBuffers::AddInheritence(const VideoFrame *frame) -{ - (void)frame; -#ifdef USING_XVMC - QMutexLocker locker(&global_lock); - - frame_map_t::iterator it = parents.find(frame); - if (it == parents.end()) - { - // find "parents"... - frame_queue_t new_parents; - VideoFrame *past = PastFrame(frame); - if (past == frame) - VERBOSE(VB_IMPORTANT, QString("AddInheritence(%1) Error, past=frame") - .arg(DebugString(frame))); - else if (past) - { - bool in_correct_buffer = - used.contains(past) || displayed.contains(past) || - limbo.contains(past) || pause.contains(past); - if (in_correct_buffer) - new_parents.push_back(past); - else - VERBOSE(VB_IMPORTANT, QString("AddInheritence past %1 NOT " - "in used or in done. %2") - .arg(DebugString(past)).arg(GetStatus())); - } - - VideoFrame *future = FutureFrame(frame); - if (future == frame) - VERBOSE(VB_IMPORTANT, QString("AddInheritence(%1) Error, future=frame") - .arg(DebugString(frame))); - else if (future) - { - if (used.contains(future) || limbo.contains(future)) - new_parents.push_back(future); - else - VERBOSE(VB_IMPORTANT, QString("AddInheritence future %1 NOT " - "in used or in limbo. %2") - .arg(DebugString(future)).arg(GetStatus())); - } - - parents[frame] = new_parents; - // add self as "child" - frame_queue_t::iterator it = new_parents.begin(); - for (; it != new_parents.end(); ++it) - children[*it].push_back((VideoFrame*)frame); - } -#endif // USING_XVMC -} - -void VideoBuffers::RemoveInheritence(const VideoFrame *frame) -{ - QMutexLocker locker(&global_lock); - - frame_map_t::iterator it = parents.find(frame); - if (it == parents.end()) - return; - - frame_queue_t new_parents; - frame_queue_t &p = it->second; - for (frame_queue_t::iterator pit = p.begin(); pit != p.end(); ++pit) - { - frame_map_t::iterator cit = children.find(*pit); - if (cit != children.end()) - { - frame_queue_t::iterator fit = cit->second.find((VideoFrame*)frame); - if (fit != cit->second.end()) - cit->second.erase(fit); - else - new_parents.push_back(*pit); - } - } - - if (new_parents.empty()) - parents.erase(it); - else - { - parents[frame] = new_parents; - VERBOSE(VB_IMPORTANT, QString("RemoveInheritenc:%1 parents.size() = ") - .arg(DebugString(frame)).arg(parents.size())); - frame_queue_t::iterator pit = new_parents.begin(); - for (int i=0; pit != new_parents.end() && i<8; (++pit), (++i)) - VERBOSE(VB_IMPORTANT, QString("Parent #%1: %2") - .arg(i).arg(DebugString(*pit))); - } -} - -frame_queue_t VideoBuffers::Children(const VideoFrame *frame) -{ - QMutexLocker locker(&global_lock); - - frame_queue_t c; - frame_map_t::iterator it = children.find(frame); - if (it != children.end()) - c = it->second; - return c; -} - -bool VideoBuffers::HasChildren(const VideoFrame *frame) -{ - QMutexLocker locker(&global_lock); - - frame_map_t::iterator it = children.find(frame); - if (it != children.end()) - return !(it->second.empty()); - return false; -} - -#ifdef USING_XVMC - -inline struct xvmc_pix_fmt *GetRender(VideoFrame *frame) -{ - if (frame) - return (struct xvmc_pix_fmt*) frame->buf; - else - return NULL; -} - -inline const struct xvmc_pix_fmt *GetRender(const VideoFrame *frame) -{ - if (frame) - return (const struct xvmc_pix_fmt*) frame->buf; - else - return NULL; -} - -VideoFrame* VideoBuffers::PastFrame(const VideoFrame *frame) -{ - LockFrame(frame, "PastFrame"); - const struct xvmc_pix_fmt* r = GetRender(frame); - VideoFrame* f = NULL; - if (r) - f = xvmc_surf_to_frame[r->p_past_surface]; - UnlockFrame(frame, "PastFrame"); - return f; -} - -VideoFrame* VideoBuffers::FutureFrame(const VideoFrame *frame) -{ - LockFrame(frame, "FutureFrame"); - const struct xvmc_pix_fmt* r = GetRender(frame); - VideoFrame* f = NULL; - if (r) - f = xvmc_surf_to_frame[r->p_future_surface]; - UnlockFrame(frame, "FutureFrame"); - return f; -} - -VideoFrame* VideoBuffers::GetOSDFrame(const VideoFrame *frame) -{ - LockFrame(frame, "GetOSDFrame"); - const struct xvmc_pix_fmt* r = GetRender(frame); - VideoFrame* f = NULL; - if (r) - f = (VideoFrame*) (r->p_osd_target_surface_render); - - QString dbg_str("GetOSDFrame "); -#if DEBUG_FRAME_LOCKS - if (f) - dbg_str.append(DebugString(f, true)); -#endif - UnlockFrame(frame, dbg_str.toLocal8Bit().constData()); - - return f; -} - -void VideoBuffers::SetOSDFrame(VideoFrame *frame, VideoFrame *osd) -{ - if (frame == osd) - { - VERBOSE(VB_IMPORTANT, QString("SetOSDFrame() -- frame==osd %1") - .arg(GetStatus())); - return; - } - - LockFrame(frame, "SetOSDFrame"); - struct xvmc_pix_fmt* r = GetRender(frame); - if (r) - { - QMutexLocker locker(&global_lock); - - VideoFrame* old_osd = (VideoFrame*) r->p_osd_target_surface_render; - if (old_osd) - xvmc_osd_parent[old_osd] = NULL; - - r->p_osd_target_surface_render = osd; - - if (osd) - xvmc_osd_parent[osd] = frame; - } - - UnlockFrame(frame, "SetOSDFrame"); -} - -VideoFrame* VideoBuffers::GetOSDParent(const VideoFrame *osd) -{ - QMutexLocker locker(&global_lock); - return xvmc_osd_parent[osd]; -} - -#endif - bool VideoBuffers::CreateBuffers(VideoFrameType type, int width, int height) { vector bufs; @@ -1174,84 +952,6 @@ bool VideoBuffers::CreateBuffer(int width, int height, uint num, void* data, return true; } -#ifdef USING_XVMC -bool VideoBuffers::CreateBuffers(int width, int height, - MythXDisplay *disp, - void *p_xvmc_ctx, - void *p_xvmc_surf_info, - vector surfs) -{ - XvMCContext &xvmc_ctx = *((XvMCContext*) p_xvmc_ctx); - XvMCSurfaceInfo &xvmc_surf_info = *((XvMCSurfaceInfo*) p_xvmc_surf_info); - - static unsigned char *ffmpeg_vld_hack = (unsigned char*) - "avlib should not use this private data in XvMC-VLD mode."; - - if (surfs.size()>allocSize()) - { - VERBOSE(VB_PLAYBACK, - QString("Allocated %1 XvMC surfaces, minimum was %2 surfaces") - .arg(surfs.size()).arg(allocSize())); - - Reset(); - uint increment = surfs.size() - allocSize(); - - Init(surfs.size(), - false /* create an extra frame for pause? */, - needfreeframes, - needprebufferframes_normal + increment - 1, - needprebufferframes_small, - keepprebufferframes + 1); - } - - for (uint i = 0; i < allocSize(); i++) - { - xvmc_vo_surf_t *surf = (xvmc_vo_surf_t*) surfs[i]; - struct xvmc_pix_fmt *render = new struct xvmc_pix_fmt; - allocated_structs.push_back((unsigned char*)render); - memset(render, 0, sizeof(struct xvmc_pix_fmt)); - - // constants - render->xvmc_id = AV_XVMC_ID; - render->state = 0; - - // from videoout_xv - render->disp = disp->GetDisplay(); - render->ctx = &xvmc_ctx; - - // from xvmv block and surface arrays - render->p_surface = &surf->surface; - - render->allocated_data_blocks = surf->blocks.num_blocks; - render->allocated_mv_blocks = surf->macro_blocks.num_blocks; - - init(&buffers[i], - FMT_XVMC_IDCT_MPEG2, (unsigned char*) render, - width, height, sizeof(XvMCSurface)); - - buffers[i].priv[0] = ffmpeg_vld_hack; - buffers[i].priv[1] = ffmpeg_vld_hack; - - if (surf->blocks.blocks) - { - render->data_blocks = surf->blocks.blocks; - buffers[i].priv[0] = (unsigned char*) &(surf->blocks); - - render->mv_blocks = surf->macro_blocks.macro_blocks; - buffers[i].priv[1] = (unsigned char*) &(surf->macro_blocks); - } - - // from surface info - render->idct = (xvmc_surf_info.mc_type & XVMC_IDCT) == XVMC_IDCT; - render->unsigned_intra = (xvmc_surf_info.flags & - XVMC_INTRA_UNSIGNED) == XVMC_INTRA_UNSIGNED; - - xvmc_surf_to_frame[render->p_surface] = &buffers[i]; - } - return true; -} -#endif - void VideoBuffers::DeleteBuffers() { next_dbg_str = 0; @@ -1273,9 +973,6 @@ void VideoBuffers::DeleteBuffers() for (uint i = 0; i < allocated_arrays.size(); i++) av_free(allocated_arrays[i]); allocated_arrays.clear(); -#ifdef USING_XVMC - xvmc_surf_to_frame.clear(); -#endif } static unsigned long long to_bitmap(const frame_queue_t& list); diff --git a/mythtv/libs/libmythtv/videobuffers.h b/mythtv/libs/libmythtv/videobuffers.h index 80c0ca9a3ad..2fe0dc6f16d 100644 --- a/mythtv/libs/libmythtv/videobuffers.h +++ b/mythtv/libs/libmythtv/videobuffers.h @@ -14,10 +14,6 @@ using namespace std; #include #include -#ifdef USING_XVMC -#include -#endif // USING_XVMC - #include "mythdeque.h" #ifdef USING_X11 @@ -26,12 +22,9 @@ class MythXDisplay; typedef MythDeque frame_queue_t; typedef vector frame_vector_t; -typedef map frame_map_t; -typedef map surf_to_frame_map_t; typedef map buffer_map_t; typedef map vbuffer_map_t; typedef map frame_lock_map_t; -typedef map frame_to_frame_map_t; typedef vector uchar_vector_t; @@ -136,27 +129,9 @@ class VideoBuffers void UnlockFrame(const VideoFrame *, const char* owner); void UnlockFrames(vector&, const char* owner); - void AddInheritence(const VideoFrame *frame); - void RemoveInheritence(const VideoFrame *frame); - frame_queue_t Children(const VideoFrame *frame); - bool HasChildren(const VideoFrame *frame); - void Clear(uint i); void Clear(void); -#ifdef USING_XVMC - VideoFrame* PastFrame(const VideoFrame *frame); - VideoFrame* FutureFrame(const VideoFrame *frame); - VideoFrame* GetOSDFrame(const VideoFrame *frame); - void SetOSDFrame(VideoFrame *frame, VideoFrame *osd); - VideoFrame* GetOSDParent(const VideoFrame *osd); - bool CreateBuffers(int width, int height, - MythXDisplay *disp, - void* xvmc_ctx, - void* xvmc_surf_info, - vector surfs); -#endif - bool CreateBuffer(int width, int height, uint num, void *data, VideoFrameType fmt); @@ -172,8 +147,6 @@ class VideoBuffers frame_vector_t buffers; uchar_vector_t allocated_structs; // for DeleteBuffers uchar_vector_t allocated_arrays; // for DeleteBuffers - frame_map_t parents; // prev & future frames - frame_map_t children; // frames that depend on a parent frame uint numbuffers; uint needfreeframes; @@ -191,11 +164,6 @@ class VideoBuffers bool use_frame_locks; QMutex frame_lock; frame_lock_map_t frame_locks; - -#ifdef USING_XVMC - surf_to_frame_map_t xvmc_surf_to_frame; - frame_to_frame_map_t xvmc_osd_parent; -#endif }; #endif // __VIDEOBUFFERS_H__ diff --git a/mythtv/libs/libmythtv/videoout_vdpau.cpp b/mythtv/libs/libmythtv/videoout_vdpau.cpp index 37af613fe2f..df3c31292c7 100644 --- a/mythtv/libs/libmythtv/videoout_vdpau.cpp +++ b/mythtv/libs/libmythtv/videoout_vdpau.cpp @@ -960,7 +960,6 @@ void VideoOutputVDPAU::CheckFrameStates(void) } else { - vbuffers.RemoveInheritence(frame); vbuffers.safeEnqueue(kVideoBuffer_avail, frame); vbuffers.end_lock(); it = vbuffers.begin_lock(kVideoBuffer_displayed); diff --git a/mythtv/libs/libmythtv/videoout_xv.cpp b/mythtv/libs/libmythtv/videoout_xv.cpp index 6d3458a8f82..53089a692c3 100644 --- a/mythtv/libs/libmythtv/videoout_xv.cpp +++ b/mythtv/libs/libmythtv/videoout_xv.cpp @@ -1362,15 +1362,7 @@ void VideoOutputXv::DiscardFrame(VideoFrame *frame) if (!frame) return; - if (vbuffers.HasChildren(frame)) - { - vbuffers.safeEnqueue(kVideoBuffer_displayed, frame); - } - else - { - vbuffers.RemoveInheritence(frame); - vbuffers.DiscardFrame(frame); - } + vbuffers.DiscardFrame(frame); } void VideoOutputXv::ClearAfterSeek(void) diff --git a/mythtv/libs/libmythtv/videooutbase.cpp b/mythtv/libs/libmythtv/videooutbase.cpp index bf3c80d18a2..4119fb5a1f2 100644 --- a/mythtv/libs/libmythtv/videooutbase.cpp +++ b/mythtv/libs/libmythtv/videooutbase.cpp @@ -953,8 +953,7 @@ void VideoOutput::ShowPIPs(VideoFrame *frame, const PIPMap &pipPlayers) * \fn VideoOutput::ShowPIP(VideoFrame*,MythPlayer*,PIPLocation) * \brief Composites PiP image onto a video frame. * - * Note: This only works with memory backed VideoFrames, - * that is not XvMC, OpenGL, VDPAU, etc. + * Note: This only works with memory backed VideoFrames. * * \param frame Frame to composite PiP onto. * \param pipplayer Picture-in-Picture Player. diff --git a/mythtv/libs/libmythtv/videoouttypes.h b/mythtv/libs/libmythtv/videoouttypes.h index 04eb007f973..49eeab73ce2 100644 --- a/mythtv/libs/libmythtv/videoouttypes.h +++ b/mythtv/libs/libmythtv/videoouttypes.h @@ -74,9 +74,9 @@ typedef enum FrameScanType { kScan_Ignore = -1, kScan_Detect = 0, - kScan_Interlaced = 1, // == XVMC_TOP_PICTURE - kScan_Intr2ndField = 2, // == XVMC_BOTTOM_PICTURE - kScan_Progressive = 3, // == XVMC_FRAME_PICTURE + kScan_Interlaced = 1, + kScan_Intr2ndField = 2, + kScan_Progressive = 3, } FrameScanType; typedef enum PictureAttribute