Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAbstractVideoSurface present silent crash on image copy

QAbstractVideoSurface present silent crash on image copy

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jnbrunet
    wrote on last edited by
    #1

    Hi,

    I try to copy the frame passed to the function present of my QAbstractVideoSurface class. When I place a breakpoint at the start of the function, and hit play manually to pause the application flow at each present calls, there is no crash. If I remove the breakpoint and let the application run normally, the application will crash at the second call to the function.

    Here is my function

    @
    bool VideoSurface::present(const QVideoFrame &frame)
    {
    if (frame.isValid())
    {
    QVideoFrame videoFrame(frame);
    if( videoFrame.map(QAbstractVideoBuffer::ReadOnly) )
    {
    m_lastFrame = QImage(videoFrame.width(), videoFrame.height(), QImage::Format_ARGB32);
    memcpy(m_lastFrame.bits(), videoFrame.bits(), videoFrame.mappedBytes());

            videoFrame.unmap();
    
            return true;
        }
    }
    return true;
    

    }
    @

    Does any one have an idea why?

    Thank you!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure that frame is mapped ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jnbrunet
        wrote on last edited by
        #3

        Well that was a good observation, but I beleive it is not mapped. I changed

        @if( videoFrame.map(QAbstractVideoBuffer::ReadOnly) )@

        for

        @if( videoFrame.isMapped() && videoFrame.map(QAbstractVideoBuffer::ReadOnly) )@

        And the application still crash.

        I added a qDebug() call before the memcpy and just after it, and it seems the application crashes on the first call of memcpy, not at the second as I thought.

        If I add a breakpoint at the start of the function, start debugging and hit play as soon as the breakpoint is reached, I got the second qDebug() call and the memcpy succeed.

        I also add a videoFrame.isMapped() condition just before the memcpy, to be safe. And the application still crashed at the first call of memcpy.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jnbrunet
          wrote on last edited by
          #4

          Well my QImage bytes space is lower than the frame...Here is my debug :

          @qDebug() << "frame buffer bits address is " << videoFrame.bits() << " and is composed of " << videoFrame.mappedBytes() << "bytes with format " << videoFrame.pixelFormat();@
          frame buffer bits address is 0x112000000 and is composed of 3686432 bytes with format Format_RGB32

          @qDebug() << "image buffer bits address is " << m_lastFrame.bits() << " and is composed of " << m_lastFrame.byteCount() << "bytes with color model " << m_lastFrame.pixelFormat().colorModel() << " and TypeInterpretation " << m_lastFrame.pixelFormat().typeInterpretation();@
          image buffer bits address is 0x112385000 and is composed of 3686400 bytes with color model 0 and TypeInterpretation 0

          So this is why the memcpy failed. But I do not understand why they do not have the same size in bytes...

          The color model 0 is QPixelFormat::RGB and the typeInterpretation 0 is QPixelFormat::UnsignedInteger

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Is it me or does it looks like there's one pixel messing around ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jnbrunet
              wrote on last edited by
              #6

              Isn't 32 bytes missing? With 32 bits per pixels, there are likely 4 pixels messing around.

              Still, this is strange !

              For now, I used m_lastFrame.byteCount() for the memcpy and it is working fine. Do you think this could be a bug from the Qt side?

              Thanks !

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Yes, you're right, that makes it 4, late night math :D

                Pretty good question, I'd recommend asking on the interest mailing list and you should also check the "bug report system":http://bugreports.qt.io

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved