void VideoOutWindow::PrintMoveResizeDebug(void) { #if 0 LOG(VB_PLAYBACK, LOG_DEBUG, "VideoOutWindow::MoveResize:"); LOG(VB_PLAYBACK, LOG_DEBUG, QString("Img(%1,%2 %3,%4)") .arg(video_rect.left()).arg(video_rect.top()) .arg(video_rect.width()).arg(video_rect.height())); LOG(VB_PLAYBACK, LOG_DEBUG, QString("Disp(%1,%1 %2,%4)") .arg(display_video_rect.left()).arg(display_video_rect.top()) .arg(display_video_rect.width()).arg(display_video_rect.height())); LOG(VB_PLAYBACK, LOG_DEBUG, QString("Offset(%1,%2)") .arg(xoff).arg(yoff)); LOG(VB_PLAYBACK, LOG_DEBUG, QString("Vscan(%1, %2)") .arg(db_scale_vert).arg(db_scale_vert)); LOG(VB_PLAYBACK, LOG_DEBUG, QString("DisplayAspect: %1") .arg(GetDisplayAspect())); LOG(VB_PLAYBACK, LOG_DEBUG, QString("VideoAspect(%1)") .arg(video_aspect)); LOG(VB_PLAYBACK, LOG_DEBUG, QString("overriden_video_aspect(%1)") .arg(overriden_video_aspect)); LOG(VB_PLAYBACK, LOG_DEBUG, QString("CDisplayAspect: %1") .arg(fix_aspect(GetDisplayAspect()))); LOG(VB_PLAYBACK, LOG_DEBUG, QString("AspectOverride: %1") .arg(aspectoverride)); LOG(VB_PLAYBACK, LOG_DEBUG, QString("AdjustFill: %d") .arg(adjustfill)); #endif LOG(VB_PLAYBACK, LOG_INFO, QString("Display Rect left: %1, top: %2, width: %3, " "height: %4, aspect: %5") .arg(display_video_rect.left()) .arg(display_video_rect.top()) .arg(display_video_rect.width()) .arg(display_video_rect.height()) .arg(fix_aspect(GetDisplayAspect()))); LOG(VB_PLAYBACK, LOG_INFO, QString("Video Rect left: %1, top: %2, width: %3, " "height: %4, aspect: %5") .arg(video_rect.left()) .arg(video_rect.top()) .arg(video_rect.width()) .arg(video_rect.height()) .arg(overriden_video_aspect)); }
void VideoOutWindow::PrintMoveResizeDebug(void) { #if 0 printf("VideoOutWindow::MoveResize:\n"); printf("Img(%d,%d %d,%d)\n", video_rect.left(), video_rect.top(), video_rect.width(), video_rect.height()); printf("Disp(%d,%d %d,%d)\n", display_video_rect.left(), display_video_rect.top(), display_video_rect.width(), display_video_rect.height()); printf("Offset(%d,%d)\n", xoff, yoff); printf("Vscan(%f, %f)\n", db_scale_vert, db_scale_vert); printf("DisplayAspect: %f\n", GetDisplayAspect()); printf("VideoAspect(%f)\n", video_aspect); printf("overriden_video_aspect(%f)\n", overriden_video_aspect); printf("CDisplayAspect: %f\n", fix_aspect(GetDisplayAspect())); printf("AspectOverride: %d\n", aspectoverride); printf("AdjustFill: %d\n", adjustfill); #endif VERBOSE(VB_PLAYBACK, QString( "Display Rect left: %1, top: %2, width: %3, " "height: %4, aspect: %5") .arg(display_video_rect.left()) .arg(display_video_rect.top()) .arg(display_video_rect.width()) .arg(display_video_rect.height()) .arg(fix_aspect(GetDisplayAspect()))); VERBOSE(VB_PLAYBACK, QString( "Video Rect left: %1, top: %2, width: %3, " "height: %4, aspect: %5") .arg(video_rect.left()) .arg(video_rect.top()) .arg(video_rect.width()) .arg(video_rect.height()) .arg(overriden_video_aspect)); }
// Code should take into account the aspect ratios of both the video as // well as the actual screen to allow proper letterboxing to take place. void VideoOutWindow::ApplyLetterboxing(void) { float disp_aspect = fix_aspect(GetDisplayAspect()); float aspect_diff = disp_aspect - overriden_video_aspect; bool aspects_match = abs(aspect_diff / disp_aspect) <= 0.02f; bool nomatch_with_fill = !aspects_match && ((kAdjustFill_HorizontalStretch == adjustfill) || (kAdjustFill_VerticalStretch == adjustfill)); bool nomatch_without_fill = (!aspects_match) && !nomatch_with_fill; // Adjust for video/display aspect ratio mismatch if (nomatch_with_fill && (disp_aspect > overriden_video_aspect)) { float pixNeeded = ((disp_aspect / overriden_video_aspect) * (float) display_video_rect.height()) + 0.5f; display_video_rect.moveTop( display_video_rect.top() + (display_video_rect.height() - (int) pixNeeded) / 2); display_video_rect.setHeight((int) pixNeeded); } else if (nomatch_with_fill) { float pixNeeded = ((overriden_video_aspect / disp_aspect) * (float) display_video_rect.width()) + 0.5f; display_video_rect.moveLeft( display_video_rect.left() + (display_video_rect.width() - (int) pixNeeded) / 2); display_video_rect.setWidth((int) pixNeeded); } else if (nomatch_without_fill && (disp_aspect > overriden_video_aspect)) { float pixNeeded = ((overriden_video_aspect / disp_aspect) * (float) display_video_rect.width()) + 0.5f; display_video_rect.moveLeft( display_video_rect.left() + (display_video_rect.width() - (int) pixNeeded) / 2); display_video_rect.setWidth((int) pixNeeded); } else if (nomatch_without_fill) { float pixNeeded = ((disp_aspect / overriden_video_aspect) * (float) display_video_rect.height()) + 0.5f; display_video_rect.moveTop( display_video_rect.top() + (display_video_rect.height() - (int) pixNeeded) / 2); display_video_rect.setHeight((int) pixNeeded); } // Process letterbox zoom modes if (adjustfill == kAdjustFill_Full) { // Zoom mode -- Expand by 4/3 and overscan. // 1/6 of original is 1/8 of new display_video_rect = QRect( display_video_rect.left() - (display_video_rect.width() / 6), display_video_rect.top() - (display_video_rect.height() / 6), display_video_rect.width() * 4 / 3, display_video_rect.height() * 4 / 3); } else if (adjustfill == kAdjustFill_Half) { // Zoom mode -- Expand by 7/6 and overscan. // Intended for eliminating the top bars on 14:9 material. // Also good compromise for 4:3 material on 16:9 screen. // Expanding by 7/6, so remove 1/6 of original from overscan; // take half from each side, so remove 1/12. display_video_rect = QRect( display_video_rect.left() - (display_video_rect.width() / 12), display_video_rect.top() - (display_video_rect.height() / 12), display_video_rect.width() * 7 / 6, display_video_rect.height() * 7 / 6); } else if (adjustfill == kAdjustFill_HorizontalStretch) { // Horizontal Stretch mode -- 1/6 of original is 1/8 of new // Intended to be used to eliminate side bars on 4:3 material // encoded to 16:9. display_video_rect.moveLeft( display_video_rect.left() - (display_video_rect.width() / 6)); display_video_rect.setWidth(display_video_rect.width() * 4 / 3); } else if (adjustfill == kAdjustFill_VerticalStretch) { // Vertical Stretch mode -- 1/6 of original is 1/8 of new // Intended to be used to eliminate top/bottom bars on 16:9 // material encoded to 4:3. display_video_rect.moveTop( display_video_rect.top() - (display_video_rect.height() / 6)); display_video_rect.setHeight(display_video_rect.height() * 4 / 3); } }