[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-cvs
Subject:    [Datatype-cvs] h264/codec/decoder_qtsdk h264qt.cpp,1.2,1.2.4.1
From:       stanb () helixcommunity ! org
Date:       2010-01-28 21:56:50
Message-ID: 201001282157.o0SLvp5i001944 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/datatype/h264/codec/decoder_qtsdk
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv25226

Modified Files:
      Tag: hxclient_4_0_1_brizo
	h264qt.cpp 
Log Message:
Eric’s modifications from 8 weeks ago removed correction of QT produced frames 
according to expected stride. Unfortunately this code is still needed in many cases.
I suggest conditionally use the old stride correction when it actually is needed.
(PR# 256125)


Index: h264qt.cpp
===================================================================
RCS file: /cvsroot/datatype/h264/codec/decoder_qtsdk/h264qt.cpp,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -d -r1.2 -r1.2.4.1
--- h264qt.cpp	3 Dec 2009 19:48:15 -0000	1.2
+++ h264qt.cpp	28 Jan 2010 21:56:47 -0000	1.2.4.1
@@ -1247,7 +1247,8 @@
 
             // In some cases, the QT decoder will give us more pixels than we \
                actually ask for.
             // This value represents the stride that the rest of our pipeline \
                expects, given the width of our frame.
-            UINT32 ulCorrectedStride = ulWidth * \
(GetQTPixelFormatBitsPerPixel(pixelFormat) / 8); +            UINT32 nBytesPerPixel = \
GetQTPixelFormatBitsPerPixel(pixelFormat) / 8; +            UINT32 ulCorrectedStride \
= ulWidth * nBytesPerPixel;  ASSERT(ulCorrectedStride <= ulBytesPerRow);
             
             // Have we initialized the output MOF yet?
@@ -1269,97 +1270,99 @@
             // Do we have an output buffer allocator?
             if (m_pOutputAllocator)
             {
-#if 0
+                HX_RESULT retVal        = HXR_OK;
+                BYTE*     pOutputBuffer = pBaseAddress;
                 // Sometimes the data size is different from the expected
                 // frame size, so compute the expected frame size
                 UINT32 ulFrameSize = ulCorrectedStride * ulHeight;
-                // Get a buffer from the allocator
-                HX20ALLOCPROPS allocRequest;
-                HX20ALLOCPROPS allocActual;
-                allocRequest.uBufferSize = ulFrameSize;
-                allocRequest.nNumBuffers = HX_MAX_FREE_BUFFERS;
-                HX_RESULT retVal = m_pOutputAllocator->SetProperties(&allocRequest, \
                &allocActual);
-                if (SUCCEEDED(retVal))
+
+                // Get the buffer
+                IHXUnknown* pUnkBuffer  = NULL;
+
+                if(ulBytesPerRow != ulCorrectedStride)
                 {
-                    // Set the return value
-                    retVal = HXR_OUTOFMEMORY;
-                    // Get the buffer
-                    IHXUnknown* pUnk          = NULL;
-                    BYTE*       pOutputBuffer = \
                m_pOutputAllocator->GetPacketBuffer(&pUnk);
-                    if (pOutputBuffer)
+                    // Sometimes the data size is different from the expected
+                    // frame size, so compute the expected frame size
+                    // Get a buffer from the allocator
+                    HX20ALLOCPROPS allocRequest;
+                    HX20ALLOCPROPS allocActual;
+                    allocRequest.uBufferSize = ulFrameSize;
+                    allocRequest.nNumBuffers = 1;
+                    retVal = m_pOutputAllocator->SetProperties(&allocRequest, \
&allocActual); +                    if (SUCCEEDED(retVal))
                     {
-                        // Copy the frame. QT SDK returns the frame inverted
-                        // so we need to invert it as we copy.
-                        UINT32 i = 0;
-                        for (i = 0; i < ulHeight; i++)
-                        {
-                            BYTE* pSrc = pBaseAddress + i * ulBytesPerRow;
-                            BYTE* pDst = pOutputBuffer + (ulHeight - 1 - i) * \
                ulCorrectedStride;
-                            memcpy(pDst, pSrc, ulCorrectedStride);
-                        }
-#else
-                        HX_RESULT retVal        = HXR_OK;
-                        BYTE*     pOutputBuffer = pBaseAddress;
-                        // Sometimes the data size is different from the expected
-                        // frame size, so compute the expected frame size
-                        UINT32 ulFrameSize = ulCorrectedStride * ulHeight;
-#endif
-                        // Compute the size of the HXCODEC_DATA struct and
-                        // extra segment info we need to allocate
-                        UINT32 ulCodecDataSize    = HXCODEC_DATA_SIZE + 2 * \
                HXCODEC_SEGMENTINFO_SIZE;
-                        UINT32 ulCodecDataSizeU32 = ulCodecDataSize / 4 + 1;
-                        // Now we need to set up an HXCODEC_DATA structure which 
-                        // we will use to call back to the renderer.
-                        UINT32* pulCodecDataBuf = new UINT32 [ulCodecDataSizeU32];
-                        if (pulCodecDataBuf)
+                        // Set the return value
+                        retVal = HXR_OUTOFMEMORY;
+                        pOutputBuffer = \
m_pOutputAllocator->GetPacketBuffer(&pUnkBuffer); +                        if \
(pOutputBuffer)  {
-                            // Clear the return value
-                            retVal = HXR_OK;
-                            // NULL out the buffer
-                            memset(pulCodecDataBuf, 0, ulCodecDataSizeU32 * \
                sizeof(UINT32));
-                            // Assign to a HXCODEC_DATA pointer
-                            HXCODEC_DATA* pCodecData = (HXCODEC_DATA*) \
                pulCodecDataBuf;
-                            // Get the timestamp
-                            UINT32 ulTimestamp = 0;
-                            if (validTimeFlags && \
                kICMValidTime_DisplayTimeStampIsValid)
-                            {
-                                ulTimestamp = (UINT32) displayTime;
-                            }
-                            else
+                            // Copy the frame. QT SDK returns the frame inverted
+                            // so we need to invert it as we copy.
+                            UINT32 i = 0;
+                            for (i = 0; i < ulHeight; i++)
                             {
-                                // No output display time was given, so 
-                                // just use the input timestamp
-                                HXCODEC_DATA* pCodecDataIn = (HXCODEC_DATA*) \
                sourceFrameRefCon;
-                                if (pCodecDataIn)
-                                {
-                                    ulTimestamp = pCodecDataIn->timestamp;
-                                }
+                                BYTE* pSrc = pBaseAddress + i * ulBytesPerRow;
+                                BYTE* pDst = pOutputBuffer + i * ulCorrectedStride;
+                                memcpy(pDst, pSrc, ulCorrectedStride);
                             }
-                            // Set the members of the HXCODEC_DATA struct
-                            pCodecData->data        = pOutputBuffer;
-                            pCodecData->dataLength  = ulFrameSize;
-                            pCodecData->timestamp   = ulTimestamp;
-                            pCodecData->sequenceNum = 0;
-                            pCodecData->flags       = (HX_RELIABLE_FLAG | \
                HX_SEGMENT_CONTAINS_OUTPUT_SIZE_FLAG);
-                            pCodecData->numSegments = 2;
-                            pCodecData->lastPacket  = FALSE; // XXXMEH - don't know \
                yet where to get this info
-                            // In the first segment we simply say the data buffer is \
                valid
-                            pCodecData->Segments[0].ulSegmentOffset = 0;
-                            pCodecData->Segments[0].bIsValid        = TRUE;
-                            // In the second "segment" we store width and height of \
                buffer
-                            pCodecData->Segments[1].ulSegmentOffset = ulWidth;
-                            pCodecData->Segments[1].bIsValid        = ulHeight;
-                            // Add this to the output queue
-                            retVal = InsertIntoOutputQueue(pCodecData);
                         }
-                        if (FAILED(retVal))
+                    }
+                }
+
+                // Compute the size of the HXCODEC_DATA struct and
+                // extra segment info we need to allocate
+                UINT32 ulCodecDataSize    = HXCODEC_DATA_SIZE + 2 * \
HXCODEC_SEGMENTINFO_SIZE; +                UINT32 ulCodecDataSizeU32 = \
ulCodecDataSize / 4 + 1; +                // Now we need to set up an HXCODEC_DATA \
structure which  +                // we will use to call back to the renderer.
+                UINT32* pulCodecDataBuf = new UINT32 [ulCodecDataSizeU32];
+                if (pulCodecDataBuf)
+                {
+                    // Clear the return value
+                    retVal = HXR_OK;
+                    // NULL out the buffer
+                    memset(pulCodecDataBuf, 0, ulCodecDataSizeU32 * sizeof(UINT32));
+                    // Assign to a HXCODEC_DATA pointer
+                    HXCODEC_DATA* pCodecData = (HXCODEC_DATA*) pulCodecDataBuf;
+                    // Get the timestamp
+                    UINT32 ulTimestamp = 0;
+                    if (validTimeFlags && kICMValidTime_DisplayTimeStampIsValid)
+                    {
+                        ulTimestamp = (UINT32) displayTime;
+                    }
+                    else
+                    {
+                        // No output display time was given, so 
+                        // just use the input timestamp
+                        HXCODEC_DATA* pCodecDataIn = (HXCODEC_DATA*) \
sourceFrameRefCon; +                        if (pCodecDataIn)
                         {
-                            HX_VECTOR_DELETE(pulCodecDataBuf);
+                            ulTimestamp = pCodecDataIn->timestamp;
                         }
-#if 0
                     }
+                    // Set the members of the HXCODEC_DATA struct
+                    pCodecData->data        = pOutputBuffer;
+                    pCodecData->dataLength  = ulFrameSize;
+                    pCodecData->timestamp   = ulTimestamp;
+                    pCodecData->sequenceNum = 0;
+                    pCodecData->flags       = (HX_RELIABLE_FLAG | \
HX_SEGMENT_CONTAINS_OUTPUT_SIZE_FLAG); +                    pCodecData->numSegments = \
2; +                    pCodecData->lastPacket  = FALSE; // XXXMEH - don't know yet \
where to get this info +                    // In the first segment we simply say the \
data buffer is valid +                    pCodecData->Segments[0].ulSegmentOffset = \
0; +                    pCodecData->Segments[0].bIsValid        = TRUE;
+                    // In the second "segment" we store width and height of buffer
+                    pCodecData->Segments[1].ulSegmentOffset = ulWidth;
+                    pCodecData->Segments[1].bIsValid        = ulHeight;
+                    // Add this to the output queue
+                    retVal = InsertIntoOutputQueue(pCodecData);
                 }
-#endif
+                if (FAILED(retVal))
+                {
+                    HX_VECTOR_DELETE(pulCodecDataBuf);
+                }
+
+                HX_RELEASE(pUnkBuffer);
             }
             // Unlock the pixel buffer base address
             cvRet = CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);


_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic