delphiopenh264

Delphi OpenH264 decode


i'm using the cisco OpenH264 codec in coding and decoding process , the coding stage works very well and i can read my encoded H.264 file correctly , the issue is with my decoding process and mainly the conversion from I420 to ARGB , please can any one helps to fix this .

Here's my Decoding function ( from the OpenH264 wrapper DLL ) :

/*
* [ IN ]   SourceData : the encoded frame(s)
* [ OUT ] pTargetbuffer : the Target buffer 
* [ OUT ] width
* [ OUT ] height
*/
 {

    int iStride[2];
    init();

         ... the decoding routine : pData contains the YUV 

        if (ret != dsErrorFree) {

            return -1;
        }
        if (!m_sBufferInfo.iBufferStatus) {
            return -2;
        }

    LWidth = m_sBufferInfo.UsrData.sSystemBuffer.iWidth;
    LHeight = m_sBufferInfo.UsrData.sSystemBuffer.iHeight;
    *width = LWidth;
    *height = LHeight;

      iStride[0] = m_sBufferInfo.UsrData.sSystemBuffer.iStride[0];
      iStride[1] = m_sBufferInfo.UsrData.sSystemBuffer.iStride[1];



        return 0;
}

and here's my Delphi implementation :

Image.Picture.Bitmap.PixelFormat := pf24bit;
Image.Picture.Bitmap.Width  := 320;
Image.Picture.Bitmap.Height := 240;
    ...
Result:=H264Decoder_decode(FEncodedBuffer,
                            Image.Picture.Bitmap.ScanLine[Image.Picture.Bitmap.Height-1],
                            EncodedBufferSize,LWidth,LHeight);

 if result=0 then Image.Repaint;

So many thanks.


Solution

  • So many thanks , i fixed the issue ; the problem was just i set :

    Image.Picture.Bitmap.PixelFormat := pf24bit;
    

    But the correct PixelFormat is the pf32bit