void VideoOutputOpenGL::EmbedInWidget(const QRect &rect) { if (!window.IsEmbedding()) VideoOutput::EmbedInWidget(rect); MoveResize(); }
bool VideoOutputOpenGLVAAPI::InputChanged(const QSize &input_size, float aspect, MythCodecID av_codec_id, void *codec_private, bool &aspect_only) { LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("InputChanged(%1,%2,%3) %4->%5") .arg(input_size.width()).arg(input_size.height()).arg(aspect) .arg(toString(video_codec_id)).arg(toString(av_codec_id))); if (!codec_is_vaapi(av_codec_id)) return VideoOutputOpenGL::InputChanged(input_size, aspect, av_codec_id, codec_private, aspect_only); QMutexLocker locker(&gl_context_lock); bool wasembedding = window.IsEmbedding(); QRect oldrect; if (wasembedding) { oldrect = window.GetEmbeddingRect(); StopEmbedding(); } bool cid_changed = (video_codec_id != av_codec_id); bool res_changed = input_size != window.GetActualVideoDim(); bool asp_changed = aspect != window.GetVideoAspect(); if (!res_changed && !cid_changed) { if (asp_changed) { aspect_only = true; VideoAspectRatioChanged(aspect); MoveResize(); if (wasembedding) EmbedInWidget(oldrect); } return true; } if (gCoreContext->IsUIThread()) TearDown(); else DestroyCPUResources(); QRect disp = window.GetDisplayVisibleRect(); if (Init(input_size.width(), input_size.height(), aspect, gl_parent_win, disp, av_codec_id)) { if (wasembedding) EmbedInWidget(oldrect); if (gCoreContext->IsUIThread()) BestDeint(); return true; } LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to re-initialise video output."); errorState = kError_Unknown; return false; }
bool VideoOutputVDPAU::Init(int width, int height, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) { // Attempt to free up as much video memory as possible // only works when using the VDPAU painter for the UI MythPainter *painter = GetMythPainter(); if (painter) painter->FreeResources(); m_win = winid; QMutexLocker locker(&m_lock); window.SetNeedRepaint(true); bool ok = VideoOutput::Init(width, height, aspect, winid, win_rect,codec_id); if (db_vdisp_profile) db_vdisp_profile->SetVideoRenderer("vdpau"); InitDisplayMeasurements(width, height, true); ParseOptions(); if (ok) ok = InitRender(); if (ok) ok = InitBuffers(); if (!ok) { TearDown(); return ok; } InitPictureAttributes(); MoveResize(); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created VDPAU context (%1 decode)") .arg(codec_is_std(video_codec_id) ? "software" : "GPU")); return ok; }
//TODO sensible defaults Log::Log(void) : TextWindow(0, 0, 80, 24, NULL) { conf = Conf::Instance(); /* Xerox */ #define REGISTER_G_LOG_HANDLER(name) \ g_log_set_handler((name), (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | G_LOG_FLAG_RECURSION), \ glib_log_handler_, NULL) SetBorder(new Border()); max_lines = conf->GetLogMaxLines(); MoveResize(conf->GetLogDimensions()); /* Register the glib log handlers. */ REGISTER_G_LOG_HANDLER(NULL); REGISTER_G_LOG_HANDLER("GLib"); REGISTER_G_LOG_HANDLER("GModule"); REGISTER_G_LOG_HANDLER("GLib-GObject"); REGISTER_G_LOG_HANDLER("GThread"); /* Redirect the debug messages to stderr */ g_set_print_handler(glib_print_); g_set_printerr_handler(glib_printerr_); /* Set the purple debug callbacks */ purple_debug_set_ui_ops(¢erim_debug_ui_ops); }
bool VideoOutputOpenGL::Init(int width, int height, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) { QMutexLocker locker(&gl_context_lock); bool success = true; // FIXME Mac OS X overlay does not work with preview window.SetAllowPreviewEPG(true); gl_parent_win = winid; VideoOutput::Init(width, height, aspect, winid, win_rect, codec_id); SetProfile(); InitPictureAttributes(); success &= SetupContext(); InitDisplayMeasurements(width, height, false); success &= CreateBuffers(); success &= CreatePauseFrame(); success &= SetupOpenGL(); InitOSD(); MoveResize(); if (!success) TearDown(); return success; }
bool VideoOutputOpenGL::SetDeinterlacingEnabled(bool enable) { (void) enable; if (!gl_videochain || !gl_context) return false; OpenGLLocker ctx_lock(gl_context); if (enable) { if (m_deintfiltername.isEmpty()) return SetupDeinterlace(enable); if (m_deintfiltername.contains("opengl")) { if (gl_videochain->GetDeinterlacer().isEmpty()) return SetupDeinterlace(enable); } else if (!m_deintfiltername.contains("opengl")) { // make sure opengl deinterlacing is disabled gl_videochain->SetDeinterlacing(false); if (!m_deintFiltMan || !m_deintFilter) return VideoOutput::SetupDeinterlace(enable); } } MoveResize(); gl_videochain->SetDeinterlacing(enable); m_deinterlacing = enable; return m_deinterlacing; }
void VideoOutputOpenGL::StopEmbedding(void) { if (!window.IsEmbedding()) return; VideoOutput::StopEmbedding(); MoveResize(); }
/** * \fn VideoOutWindow::StopEmbedding(void) * \brief Tells video output to stop embedding video in an existing window. * \sa EmbedInWidget(WId, int, int, int, int) */ void VideoOutWindow::StopEmbedding(void) { display_visible_rect = tmp_display_visible_rect; MoveResize(); embedding = false; }
/** * \brief Resize Display Window */ void VideoOutWindow::ResizeDisplayWindow(const QRect &rect, bool save_visible_rect) { if (save_visible_rect) tmp_display_visible_rect = display_visible_rect; display_visible_rect = rect; MoveResize(); }
/** * \fn VideoOutWindow::ToggleAdjustFill(AdjustFillMode) * \brief Sets up letterboxing for various standard video frame and * monitor dimensions, then calls MoveResize() * to apply them. * \sa Zoom(ZoomDirection), ToggleAspectOverride(AspectOverrideMode) */ void VideoOutWindow::ToggleAdjustFill(AdjustFillMode adjustFill) { if (adjustFill == kAdjustFill_Toggle) adjustFill = (AdjustFillMode) ((int) (adjustfill + 1) % kAdjustFill_END); adjustfill = adjustFill; MoveResize(); }
/** * \brief Disable or enable underscan/overscan */ void VideoOutWindow::SetVideoScalingAllowed(bool change) { if (change) { db_scale_vert = gCoreContext->GetNumSetting("VertScanPercentage", 0) * 0.01f; db_scale_horiz = gCoreContext->GetNumSetting("HorizScanPercentage", 0) * 0.01f; db_scaling_allowed = true; } else { db_scale_vert = 0.0f; db_scale_horiz = 0.0f; db_scaling_allowed = false; } VERBOSE(VB_PLAYBACK, QString("Over/underscan. V: %1, H: %2") .arg(db_scale_vert).arg(db_scale_horiz)); MoveResize(); }
bool VideoOutputOpenGL::SetupDeinterlace( bool interlaced, const QString &overridefilter) { if (!gl_videochain || !gl_context) return false; OpenGLLocker ctx_lock(gl_context); if (db_vdisp_profile) m_deintfiltername = db_vdisp_profile->GetFilteredDeint(overridefilter); if (MythCodecContext::isCodecDeinterlacer(m_deintfiltername)) return false; if (!m_deintfiltername.contains("opengl")) { gl_videochain->SetDeinterlacing(false); gl_videochain->SetSoftwareDeinterlacer(QString()); VideoOutput::SetupDeinterlace(interlaced, overridefilter); if (m_deinterlacing) gl_videochain->SetSoftwareDeinterlacer(m_deintfiltername); return m_deinterlacing; } // clear any non opengl filters if (m_deintFiltMan) { delete m_deintFiltMan; m_deintFiltMan = nullptr; } if (m_deintFilter) { delete m_deintFilter; m_deintFilter = nullptr; } MoveResize(); m_deinterlacing = interlaced; if (m_deinterlacing && !m_deintfiltername.isEmpty()) { if (gl_videochain->GetDeinterlacer() != m_deintfiltername) { if (!gl_videochain->AddDeinterlacer(m_deintfiltername)) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("Couldn't load deinterlace filter %1") .arg(m_deintfiltername)); m_deinterlacing = false; m_deintfiltername = ""; } else { LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Using deinterlace method %1") .arg(m_deintfiltername)); } } } gl_videochain->SetDeinterlacing(m_deinterlacing); return m_deinterlacing; }
void VideoOutputOpenGL::Zoom(ZoomDirection direction) { QMutexLocker locker(&gl_context_lock); VideoOutput::Zoom(direction); MoveResize(); }
bool VideoOutputOpenGL::InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID av_codec_id, void */*codec_private*/, bool &aspect_only) { LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("InputChanged(%1,%2,%3) %4->%5") .arg(video_dim_disp.width()).arg(video_dim_disp.height()) .arg(aspect) .arg(toString(video_codec_id)).arg(toString(av_codec_id))); QMutexLocker locker(&gl_context_lock); // Ensure we don't lose embedding through program changes. This duplicates // code in VideoOutput::Init but we need start here otherwise the embedding // is lost during window re-initialistion. bool wasembedding = window.IsEmbedding(); QRect oldrect; if (wasembedding) { oldrect = window.GetEmbeddingRect(); StopEmbedding(); } if (!codec_is_std(av_codec_id) && !codec_is_mediacodec(av_codec_id) && !codec_is_vaapi2(av_codec_id)) { LOG(VB_GENERAL, LOG_ERR, LOC + "New video codec is not supported."); errorState = kError_Unknown; return false; } bool cid_changed = (video_codec_id != av_codec_id); bool res_changed = video_dim_disp != window.GetActualVideoDim(); bool asp_changed = aspect != window.GetVideoAspect(); if (!res_changed && !cid_changed) { if (asp_changed) { aspect_only = true; VideoAspectRatioChanged(aspect); MoveResize(); } if (wasembedding) EmbedInWidget(oldrect); return true; } if (gCoreContext->IsUIThread()) TearDown(); else DestroyCPUResources(); QRect disp = window.GetDisplayVisibleRect(); if (Init(video_dim_buf, video_dim_disp, aspect, gl_parent_win, disp, av_codec_id)) { if (wasembedding) EmbedInWidget(oldrect); if (gCoreContext->IsUIThread()) BestDeint(); return true; } LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to re-initialise video output."); errorState = kError_Unknown; return false; }
bool VideoOutputOpenGL::CreateVideoResources(void) { bool result = SetupOpenGL(); MoveResize(); return result; }
/** * \fn VideoOutWindow::VideoAspectRatioChanged(float aspect) * \brief Calls SetVideoAspectRatio(float aspect), * then calls MoveResize() to apply changes. * \param aspect video aspect ratio to use */ void VideoOutWindow::VideoAspectRatioChanged(float aspect) { SetVideoAspectRatio(aspect); MoveResize(); }
bool VideoOutputOpenGL::InputChanged(const QSize &input_size, float aspect, MythCodecID av_codec_id, void *codec_private, bool &aspect_only) { VERBOSE(VB_PLAYBACK, LOC + QString("InputChanged(%1,%2,%3) %4->%5") .arg(input_size.width()).arg(input_size.height()).arg(aspect) .arg(toString(video_codec_id)).arg(toString(av_codec_id))); QMutexLocker locker(&gl_context_lock); // Ensure we don't lose embedding through program changes. This duplicates // code in VideoOutput::Init but we need start here otherwise the embedding // is lost during window re-initialistion. bool wasembedding = window.IsEmbedding(); QRect oldrect; if (wasembedding) { oldrect = window.GetEmbeddingRect(); StopEmbedding(); } if (!codec_is_std(av_codec_id)) { VERBOSE(VB_IMPORTANT, LOC_ERR + QString("New video codec is not supported.")); errorState = kError_Unknown; return false; } if (input_size == window.GetActualVideoDim()) { aspect_only = video_codec_id == av_codec_id; if (window.GetVideoAspect() != aspect) { VideoAspectRatioChanged(aspect); MoveResize(); if (wasembedding) EmbedInWidget(oldrect); } return true; } TearDown(); QRect disp = window.GetDisplayVisibleRect(); if (Init(input_size.width(), input_size.height(), aspect, gl_parent_win, disp, av_codec_id)) { if (wasembedding) EmbedInWidget(oldrect); BestDeint(); return true; } VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Failed to re-initialise video output.")); errorState = kError_Unknown; return false; }