VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Hello , 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 ) :

    Code:
    /*
    * [ IN ]   SourceData : the encoded frame(s)
    * [ OUT ] pTargetbuffer : the Target buffer 
    * [ OUT ] width
    * [ OUT ] height
    */
    int H264Decoder_decode(BufferedData &SourceData, void *pTargetbuffer, int *width, int *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];
    			   
                   /*
    		BOOL I420ToARGB(const unsigned char *src_y, int src_stride_y,
                    const unsigned char *src_u, int src_stride_u,
                    const unsigned char *src_v, int src_stride_v,
                    unsigned char *dst_frame, int dst_stride_frame,
                    int width, int height);
    		*/
    
    		I420ToARGB(
    		(unsigned char *)pData[0],iStride[0],
    		(unsigned char *)pData[1],iStride[1],
    		(unsigned char *)pData[2],iStride[1],
    		(unsigned char *)pTargetbuffer,
                    /*
                    * if i put LWidth*4 which is the correct way to get the real pixel i get an AV in delphi
                    * and i think the AV is not related to delphi but the OpenH264 itself
                    */
    		LWidth*2,
    		LWidth,LHeight);
    			
    		return 0;
    }
    and here's my Delphi implementation :

    Code:
      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 .
    yours,Randy
    Last edited by randydom; 1st Dec 2017 at 00:42.
    Quote Quote  
  2. If i understand correctly your problem then I420 use 12 bits per pixel (U and V are 1/4 size each of the Y plane size), ARGB use 32 bits per pixel. before converting YUV (or correctly YCbCr) you should upscale plane U and V to size of plane Y (this sampling scheme is called 4:4:4). A is Alpha plane and it doesn't exist in your YUV source so you need to create it as empty table filled with constant.
    If i misunderstood your problem then sorry.
    Quote Quote  
  3. Originally Posted by pandy View Post
    If i understand correctly your problem then I420 use 12 bits per pixel (U and V are 1/4 size each of the Y plane size), ARGB use 32 bits per pixel. before converting YUV (or correctly YCbCr) you should upscale plane U and V to size of plane Y (this sampling scheme is called 4:4:4). A is Alpha plane and it doesn't exist in your YUV source so you need to create it as empty table filled with constant.
    If i misunderstood your problem then sorry.
    so many thanks pandy , can you just give me this step ( in code if possible ) .
    Quote Quote  
  4. so many thanks i've fixed it , the issue was that i used :
    Code:
    Image.Picture.Bitmap.PixelFormat := pf24bit;
    but the correct PixelFormat is :
    Code:
    PixelFormat is the pf32bit
    Thank you again
    Quote Quote  



Similar Threads