Allison,

It would be very difficult to help you debug this without a sample of the data you're trying to decode.

If I had to guess, it would be that you are getting a transport stream, because presumably audio is present as well. Such a stream will need to be demultiplexed before you can send the MPEG-2 Video elementary stream to libmpeg2. See mpeg2dec.c for an example of how to do this.

Again, that is just a guess. If you really want our help, you will have to save a sample of the stream to a file and then let us examine it.

-Keith

On Wed, 25 Apr 2007, hdzhang wrote:

Keith,

I am decoding real-time mpeg2 data, not mpeg file. so I can not provide the 
mpeg2 file.

and I package libmpeg2 codec into windows dirctshow filter, and source code as 
follows:

The Transform function is recall repeatly under real time capture stream data.

It can decoder mpeg2 file correctly ,but real-time data wrong.

HRESULT CMPEG2Decomp::Transform(IMediaSample *pIn, IMediaSample *pOut)
{
   BYTE *pBufferIn, *pBufferOut;
   long inputLen = pIn->GetActualDataLength();
   HRESULT hr = pIn->GetPointer(&pBufferIn);//pBufferIn is mpeg2 data input. it 
includes header data or one frame data or multi-frame data.
   hr = pOut->GetPointer(&pBufferOut);//pBufferOut is output data
   do
  {
       state = mpeg2_parse (decoder);
       sequence = info->sequence;
       //bMem:  0--memory is uncopied
       //             1--memory is copied
       //             2--need read new  memory data
       //
       switch (state)
       {
           case STATE_BUFFER:
                    if(bMem==1)
                         bMem=2;
                    if(bMem==0)
                    {
                         memcpy(buffer,pBufferIn,inputLen);
                         bMem=1;
                         mpeg2_buffer (decoder, buffer, buffer + inputLen);
                    }
                    break;
           case STATE_SEQUENCE:
                    mpeg2_custom_fbuf (decoder, 1);
                    for (i = 0; i < 3; i++)
                    {
                         fbuf[i].mbuf[0] = (uint8_t *) malloc 
(info->sequence->width*info->sequence->height + 15);
                         fbuf[i].mbuf[1] = (uint8_t *) malloc 
(info->sequence->chroma_width*info->sequence->chroma_height + 15);
                         fbuf[i].mbuf[2] = (uint8_t *) malloc 
(info->sequence->chroma_width*info->sequence->chroma_height + 15);
                         for (j = 0; j < 3; j++)
                               fbuf[i].yuv[j] = (unsigned char *)ALIGN_16 
(fbuf[i].mbuf[j]);
                         fbuf[i].used = 0;
                    }
                    for (i = 0; i < 2; i++)
                   {
                          current_fbuf = get_fbuf ();
                          mpeg2_set_buf (decoder, current_fbuf->yuv, 
current_fbuf);
                   }
                   break;
           case STATE_PICTURE:
                   current_fbuf = get_fbuf ();
                   mpeg2_set_buf (decoder, current_fbuf->yuv, current_fbuf);
                   break;
           case STATE_SLICE:
           case STATE_END:
           case STATE_INVALID_END:
                    if (info->display_fbuf)
                   {
                          if(pBufferIn != NULL)
                          {
                            //convert YUV420 data into BMP24 format
                            Convert(  info->display_fbuf->buf[0],  
info->display_fbuf->buf[1],info->display_fbuf->buf[2],pBufferOut);
                             
pOut->SetActualDataLength(info->sequence->width*info->sequence->height*3);//sets
 the sample's data length.

                            pOut->SetSyncPoint(TRUE);//output data to display
                           }
                     }
                    if (info->discard_fbuf)
                          ((struct fbuf_s *)info->discard_fbuf->id)->used = 0;
                   break;
          default:
                   break;
         }//end switch
     } while (bMem!=2);
  return S_OK;
}



??2007-04-25??"Keith Winstein" <[EMAIL PROTECTED]> ??????

Allison,



I have no idea. Please post the file somewhere or we won't be able to help

you.



-Keith



On Wed, 25 Apr 2007, hdzhang wrote:



Keith,



I used a "MPEG push demultiplexer".



Is data from this demultiplexer TS or ES?





Allison



??2007-04-25??"Keith Winstein" <[EMAIL PROTECTED]> ??????



Hello,



Can you please post a section of this file on the Internet so we can

examine it? Maybe you've got a transport stream instead of an elementary

stream or something like that.



-Keith



On Wed, 25 Apr 2007, hdzhang wrote:



hi, now I receive mpeg2 data from satelite receiver.

But when I run mpeg2 codec ,I found it only can recognize STATE_BUFFER, can not 
recognize  STATE_SEQUENCE or STATE_PICTURE. So it can not decoder picture 
correctly.

Why ? is the format of data received by satelite receiver not the same with 
data from MPEG2 file?



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Libmpeg2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel

Reply via email to