Ticket #6211: fix.QuartzOutput-0.23-r24879.patch

File fix.QuartzOutput-0.23-r24879.patch, 14.8 KB (added by chr, 15 years ago)

fixes quartz video renderer on OsX

  • mythtv/libs/libmythtv/videoout_quartz.cpp

    diff --git a/mythtv/libs/libmythtv/videoout_quartz.cpp b/mythtv/libs/libmythtv/videoout_quartz.cpp
    index 458f15a..d43d5eb 100644
    a b class VideoOutputQuartzView  
    8686    virtual void Show(void);
    8787
    8888    virtual void InputChanged(int width, int height, float aspect,
    8989                              MythCodecID av_codec_id);
    90     virtual void MoveResize(QRect newRect);
     90    virtual void MoveResize();
    9191
    9292    virtual void EmbedChanged(bool embedded);
    9393
    9494  protected:
    9595    virtual bool Begin(void);
    9696    virtual void End(void);
    97     virtual void Transform(QRect newRect);
     97    virtual void Transform();
    9898    virtual void BlankScreen(bool deferred);
    9999
    100100    // Subclasses implement the following methods:
    101101    virtual bool BeginPort(void) = 0;   // Set up a valid thePort object
    class VideoOutputQuartzView  
    105105
    106106    QuartzData *       parentData;    // information about video source is here
    107107
    108108    CGrafPtr           thePort;       // QuickDraw graphics port
    109     QRect              m_desired;     // Desired output size characteristics
    110109    ImageSequence      theCodec;      // QuickTime sequence ID
    111110    RgnHandle          theMask;       // clipping region
    112111
    113112    int                frameSkip;     // do we skip frames?
    class QuartzData  
    178177    WindowRef          window;            // MythTV window
    179178    Rect               windowBounds;      // dimensions, to restore size later
    180179    CGDirectDisplayID  screen;            // screen containing main window
    181180    float              refreshRate;       // for screen above
     181    QRect              display_rect;
    182182
    183183    // Global preferences:
    184184    bool               drawInWindow;      // Fullscreen or in GUI view?
    185185    bool               windowedMode;      // GUI runs in window?
    bool VideoOutputQuartzView::Begin(void)  
    221221        viewLock.unlock();
    222222        return false;
    223223    }
    224224
    225     // Set initial output size
    226     Rect portBounds;
    227     GetPortBounds(thePort, &portBounds);
    228     VERBOSE(VB_PLAYBACK, QString("%0Viewport currently %1,%2 -> %3,%4")
    229                          .arg(name).arg(portBounds.left).arg(portBounds.top)
    230                          .arg(portBounds.right).arg(portBounds.bottom));
    231     m_desired.setWidth(portBounds.right);
    232     m_desired.setHeight(portBounds.bottom);
    233225#if 0
    234226    // The clipping mask
    235227    theMask = NewRgn();
    236228    SetRectRgn(theMask, m_desired.left(),  m_desired.top(),
    bool VideoOutputQuartzView::Begin(void)  
    269261                      codecDSequenceFlushInsteadOfDirtying);
    270262    viewLock.unlock();
    271263
    272264    // set transformation matrix
    273     Transform(m_desired);
     265    Transform();
    274266
    275267    return true;
    276268}
    277269
    void VideoOutputQuartzView::End(void)  
    293285    viewLock.unlock();
    294286}
    295287
    296288/// Build the transformation matrix to scale the video appropriately.
    297 void VideoOutputQuartzView::Transform(QRect newRect)
     289void VideoOutputQuartzView::Transform()
    298290{
    299291    MatrixRecord matrix;
    300292    SetIdentityMatrix(&matrix);
    301293
    302     int x, y, w, h, sw, sh;
    303     x = newRect.left();
    304     y = newRect.top();
    305     w = newRect.width();
    306     h = newRect.height();
    307     sw = parentData->srcWidth;
    308     sh = parentData->srcHeight;
    309 
    310     // constants for transformation operations
    311     Fixed one, zero;
    312     one  = Long2Fix(1);
    313     zero = Long2Fix(0);
    314 
    315     VERBOSE(VB_PLAYBACK, QString("%0Viewport is %1 x %2")
    316                                 .arg(name).arg(w).arg(h));
    317     VERBOSE(VB_PLAYBACK, QString("%0Image is %1 x %2")
    318                                 .arg(name).arg(sw).arg(sh));
    319 
    320     double hscale = (double) w / sw;
    321     double vscale = (double) h / sh;
    322 
    323     // cap zooming if we requested it
    324     if (!parentData->scaleUpVideo)
    325     {
    326         double maxScale = fmax(hscale, vscale);
    327         hscale /= maxScale;
    328         vscale /= maxScale;
    329     }
     294    Rect Rsrc, Rdst;
     295    QRect display_rect;
    330296
    331     if ((hscale < 0.99) || (hscale > 1.01) ||
    332         (vscale < 0.99) || (vscale > 1.01))
    333     {
    334         VERBOSE(VB_PLAYBACK, QString("%0Scaling to %1 x %2 of original")
    335                                     .arg(name).arg(hscale).arg(vscale));
    336         ScaleMatrix(&matrix,
    337                     X2Fix(hscale),
    338                     X2Fix(vscale),
    339                     zero, zero);
     297    Rsrc.left   = 0;
     298    Rsrc.top    = 0;
     299    Rsrc.right  = parentData->srcWidth;
     300    Rsrc.bottom = parentData->srcHeight;
    340301
    341         // reset sw, sh for new apparent width/height
    342         sw = (int)(sw * hscale);
    343         sh = (int)(sh * vscale);
    344     }
     302    display_rect= parentData->display_rect;
     303    Rdst.left   = display_rect.left();
     304    Rdst.top    = display_rect.top();
     305    Rdst.right  = display_rect.right();
     306    Rdst.bottom = display_rect.bottom();
    345307
    346     // center image in viewport
    347     if ((h != sh) || (w != sw))
    348     {
    349         VERBOSE(VB_PLAYBACK, QString("%0Centering with %1, %2")
    350                              .arg(name).arg((w - sw)/2.0).arg((h - sh)/2.0));
    351         TranslateMatrix(&matrix, X2Fix((w - sw) / 2.0), X2Fix((h - sh) / 2.0));
    352     }
    353 
    354 // apply the basic sizing to DVDV
    355 #ifdef USING_DVDV
    356     if (parentData->dvdv)
    357     {
    358         parentData->dvdv->MoveResize(
    359             0, 0, parentData->srcWidth, parentData->srcHeight,
    360             (int)((w - sw) / 2.0), (int)((h - sh) / 2.0), sw, sh);
    361     }
    362 #endif // USING_DVDV
    363 
    364     // apply graphics port or embedding offset
    365     if (x || y)
    366     {
    367         VERBOSE(VB_PLAYBACK, QString("%0Translating to %1, %2")
    368                                     .arg(name).arg(x).arg(y));
    369         TranslateMatrix(&matrix, Long2Fix(x), Long2Fix(y));
    370     }
    371 
    372     // Apply the transformation
     308    MapMatrix(&matrix, &Rsrc, &Rdst);
     309#if 0
     310    VERBOSE(VB_PLAYBACK, QString("%0Viewport is now %1 / %2 / %3 / %4")
     311                                .arg(name)
     312                                .arg(Rdst.left)
     313                                .arg(Rdst.top)
     314                                .arg(Rdst.right)
     315                                .arg(Rdst.bottom)
     316    );
     317#endif
    373318    viewLock.lock();
    374319    SetDSequenceMatrix(theCodec, &matrix);
    375320    viewLock.unlock();
    376321    BlankScreen(true);   // clean up screen of artifacts at next Show
    void VideoOutputQuartzView::BlankScreen(bool deferred)  
    387332    viewLock.lock();
    388333    if (thePort)
    389334    {
    390335        SetPort(thePort);
    391 
     336#if 0
    392337        // set clipping rectangle
    393338        Rect clipRect;
    394339        if (m_desired.width() && m_desired.height())
    395340        {
    void VideoOutputQuartzView::BlankScreen(bool deferred)  
    401346        else
    402347        {
    403348            GetPortBounds(thePort, &clipRect);
    404349        }
     350#endif
     351        Rect clipRect;
     352        GetPortBounds(thePort, &clipRect);
     353
    405354        RgnHandle clipRgn = NewRgn();
    406355        RectRgn(clipRgn, &clipRect);
    407356
    408357        // erase our rectangle to black
    void VideoOutputQuartzView::InputChanged(int width, int height, float aspect,  
    471420    End();
    472421    Begin();
    473422}
    474423
    475 void VideoOutputQuartzView::MoveResize(QRect newRect)
     424void VideoOutputQuartzView::MoveResize()
    476425{
    477426    if (applyMoveResize)
    478         Transform(newRect);
     427        Transform();
    479428}
    480429
    481430/// Subclasses that block the main window should suspend
    482431/// playback, hide windows, etc by overriding this method.
    class VoqvEmbedded : public VideoOutputQuartzView  
    575524  public:
    576525    VoqvEmbedded(QuartzData *pData, int x, int y, int w, int h)
    577526    : VideoOutputQuartzView(pData)
    578527    {
    579         m_desired = QRect(x, y, w, h);
     528        // m_desired = QRect(x, y, w, h);
    580529        name = "Embedded window: ";
    581530    };
    582531
    583532   ~VoqvEmbedded()
    class VoqvDock : public VideoOutputQuartzView  
    740689            VERBOSE(VB_IMPORTANT, "VoqvDock::BeginPort() - "
    741690                    "BeginQDContextForApplicationDockTile failed");
    742691            return false;
    743692        }
     693
    744694        return true;
    745695    };
    746696
    747697    void EndPort(void)
    class VoqvFloater : public VideoOutputQuartzView  
    789739        {
    790740            // Resize complete, reset the window drawing transformation
    791741            Rect curBounds;
    792742            GetPortBounds(thePort, &curBounds);
    793             m_desired.setWidth(curBounds.right - curBounds.left);
    794             m_desired.setHeight(curBounds.bottom - curBounds.top);
    795             SetRectRgn(theMask, m_desired.left(),  m_desired.top(),
    796                                 m_desired.width(), m_desired.height());
    797             Transform(m_desired);
     743
     744            VERBOSE(VB_IMPORTANT, "Fixme: resizing window");
     745
     746//          m_desired.setWidth(curBounds.right - curBounds.left);
     747//          m_desired.setHeight(curBounds.bottom - curBounds.top);
     748//          SetRectRgn(theMask, m_desired.left(),  m_desired.top(),
     749//                              m_desired.width(), m_desired.height());
     750            Transform();
    798751        }
    799752        resizing = startResizing;
    800753    }
    801754
    class VoqvDesktop : public VideoOutputQuartzView  
    10551008                    "VoqvDesktop::BeginPort() - GetWindowPort failed");
    10561009            viewLock.unlock();
    10571010            return false;
    10581011        }
     1012
    10591013        viewLock.unlock();
    10601014        ShowWindow(window);
    10611015        // don't lose focus from main window
    10621016        SelectWindow(parentData->window);
    VideoOutputQuartz::~VideoOutputQuartz()  
    11311085void VideoOutputQuartz::VideoAspectRatioChanged(float aspect)
    11321086{
    11331087    VERBOSE(VB_PLAYBACK, (LOC + "VideoAspectRatioChanged(aspect=%1) [was %2]")
    11341088                         .arg(aspect).arg(data->srcAspect));
     1089    VERBOSE(VB_PLAYBACK, "QU: VideoAspectRatioChanged");
    11351090
    11361091    VideoOutput::VideoAspectRatioChanged(aspect);
    11371092
    11381093    data->srcAspect = aspect;
    void VideoOutputQuartz::ToggleAdjustFill(AdjustFillMode adjustFill)  
    11541109    VideoOutput::ToggleAdjustFill(adjustFill);
    11551110
    11561111    // We could change all the views, but the user probably only
    11571112    // wants the main one (window or fullscreen) to change.
    1158     data->views[0]->MoveResize(windows[0].GetDisplayVideoRect());
     1113    data->views[0]->MoveResize();
    11591114}
    11601115
    11611116void VideoOutputQuartz::MoveResize(void)
    11621117{
    11631118    // This recalculates the desired output rectangle, based on
    11641119    // the user's current aspect/fill/letterbox/zoom settings.
    11651120    VideoOutput::MoveResize();
    11661121
    1167     QRect newRect = windows[0].GetDisplayVideoRect();
     1122    const QSize video_dim = windows[0].GetVideoDim();
     1123    data->srcWidth  = video_dim.width();
     1124    data->srcHeight = video_dim.height();
     1125    data->srcAspect = windows[0].GetVideoAspect();
     1126    data->srcMode   = db_aspectoverride;
     1127    data->display_rect = windows[0].GetDisplayVideoRect();
    11681128
    11691129    vector<VideoOutputQuartzView*>::iterator it;
    11701130    for (it = data->views.begin(); it != data->views.end(); ++it)
    11711131    {
    1172         (*it)->MoveResize(newRect);
     1132        (*it)->MoveResize();
    11731133    }
    11741134}
    11751135
     1136void VideoOutputQuartz::ToggleAspectOverride(AspectOverrideMode aspectMode) {
     1137    VideoOutput::ToggleAspectOverride(aspectMode);
     1138    MoveResize();
     1139}
     1140
    11761141bool VideoOutputQuartz::InputChanged(const QSize &input_size,
    11771142                                     float        aspect,
    11781143                                     MythCodecID  av_codec_id,
    11791144                                     void        *codec_private,
    bool VideoOutputQuartz::InputChanged(const QSize &input_size,  
    12231188    DeleteQuartzBuffers();
    12241189
    12251190    data->srcWidth  = video_dim.width();
    12261191    data->srcHeight = video_dim.height();
    1227     data->srcAspect = aspect;
     1192    data->srcAspect = windows[0].GetVideoAspect();
    12281193    data->srcMode   = db_aspectoverride;
     1194    data->display_rect = windows[0].GetDisplayVideoRect();
    12291195
    12301196    CreateQuartzBuffers();
    12311197
    12321198    vector<VideoOutputQuartzView*>::iterator it = data->views.begin();
    bool VideoOutputQuartz::Init(int width, int height, float aspect,  
    12791245    data->srcWidth  = video_dim.width();
    12801246    data->srcHeight = video_dim.height();
    12811247    data->srcAspect = aspect;
    12821248    data->srcMode   = db_aspectoverride;
     1249    data->display_rect = windows[0].GetDisplayVideoRect();
    12831250
    12841251    // Initialize QuickTime
    12851252    if (EnterMovies())
    12861253    {
    void VideoOutputQuartz::DeleteQuartzBuffers()  
    15971564
    15981565    vbuffers.DeleteBuffers();
    15991566}
    16001567
    1601 void VideoOutputQuartz::EmbedInWidget(WId wid, int x, int y, int w, int h)
     1568void VideoOutputQuartz::EmbedInWidget(int x, int y, int w, int h)
    16021569{
    16031570    VERBOSE(VB_PLAYBACK,
    1604             (LOC + "EmbedInWidget(wid=%1, x=%2, y=%3, w=%4, h=%5)")
    1605             .arg(wid).arg(x).arg(y).arg(w).arg(h));
     1571            (LOC + "EmbedInWidget(x=%1, y=%2, w=%3, h=%4)")
     1572            .arg(x).arg(y).arg(w).arg(h));
    16061573
    16071574    if (windows[0].IsEmbedding())
    16081575        return;
    16091576
    16101577    VideoOutput::EmbedInWidget(x, y, w, h);
    16111578
    16121579    data->pixelLock.lock();
     1580    data->display_rect = windows[0].GetDisplayVideoRect();
    16131581
    16141582    // warn other views that embedding is starting
    16151583    vector<VideoOutputQuartzView*>::iterator it = data->views.begin();
    16161584    for (; it != data->views.end(); ++it)
    void VideoOutputQuartz::StopEmbedding(void)  
    16381606
    16391607    VideoOutput::StopEmbedding();
    16401608
    16411609    data->pixelLock.lock();
     1610    data->display_rect = windows[0].GetDisplayVideoRect();
    16421611
    16431612    // delete embedded widget
    16441613    if (data->embeddedView)
    16451614    {
  • mythtv/libs/libmythtv/videoout_quartz.h

    diff --git a/mythtv/libs/libmythtv/videoout_quartz.h b/mythtv/libs/libmythtv/videoout_quartz.h
    index 0a249d9..6ed8da6 100644
    a b class VideoOutputQuartz : public VideoOutput  
    3030                      void        *codec_private,
    3131                      bool        &aspect_only);
    3232    void VideoAspectRatioChanged(float aspect);
    3333    void MoveResize(void);
     34    void ToggleAspectOverride(AspectOverrideMode aspectMode);
    3435    void Zoom(ZoomDirection direction);
    3536    void ToggleAdjustFill(AdjustFillMode adjustFill);
    3637
    37     void EmbedInWidget(WId wid, int x, int y, int w, int h);
     38    void EmbedInWidget(int x, int y, int w, int h);
    3839    void StopEmbedding(void);
    3940
    4041    DisplayInfo GetDisplayInfo(void);
    4142    void MoveResizeWindow(QRect new_rect) {;}
  • mythtv/libs/libmythtv/videooutbase.h

    diff --git a/mythtv/libs/libmythtv/videooutbase.h b/mythtv/libs/libmythtv/videooutbase.h
    index 8455f27..43c8d24 100644
    a b class VideoOutput  
    109109
    110110    /// \brief Returns current aspect override mode
    111111    /// \sa ToggleAspectOverride(AspectOverrideMode)
    112112    AspectOverrideMode GetAspectOverride(void) const;
    113     void ToggleAspectOverride(
     113    virtual void ToggleAspectOverride(
    114114        AspectOverrideMode aspectOverrideMode = kAspect_Toggle);
    115115
    116116    /// \brief Returns current adjust fill mode
    117117    /// \sa ToggleAdjustFill(AdjustFillMode)
  • mythtv/programs/programs.pro

    diff --git a/mythtv/programs/programs.pro b/mythtv/programs/programs.pro
    index 7604c45..9cf268b 100644
    a b using_frontend:using_backend {  
    1717    SUBDIRS += mythtranscode
    1818}
    1919
    2020mingw: SUBDIRS -= mythtranscode mythtranscode/replex
     21# Nigel's speedup hack:
     22SUBDIRS = mythfrontend mythavtest