Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29743

Phonon::VideoWidget return inconstant sizeHint() under macosx 10.8

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.7.4
    • (Inactive) Phonon
    • None
    • MacBookPro "Retina" screen with Mac OS X 10.8.2, Qt4.7.4

    Description

      I have an application with a successfully embedded a Phonon::QVideoWidget in a QGraphicsItem. This application is based on QT 4.7.x (x from 0 to 4). It works well under Linux (...), windows (XP, seven, 8) and Mac OS X (from 10.6.x -> 10.8.x)

      I recently found a strange behavior under Mac OS X 10.8 with Phonon video widget initial size: video size hint is twice as big as it should be.

      I have two physical system running Mac Os X 10.8.2 :
      -iMac 27" (no problem)
      -MacBookPro 15" "Retina" (with problem)

      Circumstances : I use virtual method QWidget::sizeHint(), called from a Phonon::VideoWidget object, to retrieve video Height and Width.
      And obviously, I wait for "Phonon::LoadingState" state to fall in "StoppedState" before doing that.
      It works well on every system we tested (linux, windows, mac os x) except on that MacBook pro Retina running mac os x 10.8.2.

      I tryed to debug deeply in phonon qt7 sub component and found something suspicious.

      This routine is use to retrieve initial video size under phonon/qt7 at least since qt 4.7:

       
      QRect QuickTimeVideoPlayer::videoRect() const
      {
          if (!m_QTMovie)
              return QRect();
      
      	PhononAutoReleasePool pool;
          NSSize size = [[m_QTMovie attributeForKey:@"QTMovieCurrentSizeAttribute"] sizeValue];
          return QRect(0, 0, size.width, size.height);
      }
      

      After investigating "QTMovieCurrentSizeAttribute" usage, I found that it might be deprecated or not applicable under some circumstances.
      I also found that Apple introduced new QTMovie attributes to retrieve "strange kind of" sizes from a movie. Especially an undocumented attribute, named
      "QTMoviePreferredTransformAttribute" that seems to have the ability to unexpectedly scale videos.
      Here is the only usage of this attribute I use to found (at http://opensource.apple.com/source/WebCore/WebCore-955.66/platform/graphics/mac/MediaPlayerPrivateQTKit.mm) :

       
      void MediaPlayerPrivate::cacheMovieScale()
      {
          NSSize initialSize = NSZeroSize;
          NSSize naturalSize = [[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
      
      #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
          // QTMovieCurrentSizeAttribute is not allowed with instances of QTMovie that have been 
          // opened with QTMovieOpenForPlaybackAttribute, so ask for the display transform attribute instead.
          NSAffineTransform *displayTransform = [m_qtMovie.get() attributeForKey:@"QTMoviePreferredTransformAttribute"];
          if (displayTransform)
              initialSize = [displayTransform transformSize:naturalSize];
          else {
              initialSize.width = naturalSize.width;
              initialSize.height = naturalSize.height;
          }
      #else
          initialSize = [[m_qtMovie.get() attributeForKey:QTMovieCurrentSizeAttribute] sizeValue];
      #endif
      
          if (naturalSize.width)
              m_scaleFactor.setWidth(initialSize.width / naturalSize.width);
          if (naturalSize.height)
              m_scaleFactor.setHeight(initialSize.height / naturalSize.height);
      }
      

      This piece of code introduce a possible scale factor between the "natural" size of a movie and its "initial" size. And this seems to be the explanation of the issue I observed.
      I'm not sure to really understand Apple motivation to scale video "real" size, nor if its a bug or an "Apple feature", but I can see its disastrous effect on phonon video widget embedded in a QGraphicScene (scale and position side effects).

      I think this bug (if any) is still there in Qt 4.8 (and more ?) because QuickTimeVideoPlayer::videoRect() still has the same implementation. (from http://qt.gitorious.org)

      And I would appreciate any advice from a qtPhonon developer.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            franck.bonin franck bonin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes