hello All,
I am trying to decode H.264 incoming stream from LIVE555 but not able to
get the value of m_nGotPicture as non-zero.
my code is as below , the same code is working just fine in case of MJPEG
codec.
please let me know If I need to perform anything else to successfuly decode
the incoming H.264 stream.
Initialization of codec :
if (true == bResult)
{
m_nCodecID = codecID;
/*avcodec api. Finds a decoder with a matching codec ID*/
m_pCodec = avcodec_find_decoder(CODEC_ID_H264);
if(NULL == m_pCodec)
{
bResult = false;
}
}
if (true == bResult)//allocates struct
{
/*avcodec api. * Allocates an AVCodecContext
* and sets its fields to default values*/
m_pContext = avcodec_alloc_context();
if(NULL == m_pContext)
{
bResult = false;
}
}
if (true == bResult)//allocates frame
{
/*Allocates an AVFrame and sets its fields to default values*/
m_pPicture = avcodec_alloc_frame();
m_pPictureRGB = avcodec_alloc_frame();
if(NULL == m_pPicture || NULL == m_pPictureRGB)
{
bResult = false;
}
}
if (true == bResult)//Open codec finally
{
m_pContext->width = m_nWidth;
m_pContext->height = m_nHeight;
m_pContext->flags |= CODEC_FLAG_4MV;
m_pContext->flags |= CODEC_FLAG_PART;
m_pContext->pix_fmt = PIX_FMT_RGB24;
m_pContext->workaround_bugs = 0;
if(avcodec_open(m_pContext, m_pCodec) < 0)
{
bResult = false;
}
}
Decoding Part:
bool NVCCORE_Decoder::DecodeFrame(char *pbuf, int bufsize)
{
bool bResult = false;
int len = 0;
if(pbuf != NULL && 0 != bufsize)
{
bResult = true;
}
if (true == bResult)//verify the frame and m_nGot_picture
{
/* decodes a video frame from the input buffer*/
if((len = avcodec_decode_video(m_pContext, m_pPicture,
&m_nGot_picture, (uint8_t*)pbuf, bufsize)) < 0)
{
bResult = FALSE;
}
}
if (true == bResult)
{
if(m_nGot_picture)
{
/*The fields of the given AVPicture are filled in
depending on the specified picture format */
avpicture_fill((AVPicture*)m_pPictureRGB,
RGBbuf,
PIX_FMT_RGB24,
m_pContext->width,
m_pContext->height);
/*Conversion of pixel format*/
img_convert((AVPicture *)m_pPictureRGB, PIX_FMT_BGR24,
(AVPicture*)m_pPicture, m_pContext->pix_fmt,
m_pContext->width, m_pContext->height);
/*send decoded data to UI*/
((fxn_callbackmedia.pfnMediaTransmission))
(m_nWidth,m_nHeight,m_pPictureRGB->data[0]);
}
}
m_nGot_picture = 0;
return bResult;
}
Regards
Deepti
Help save paper - do you need to print this email ?
This e-mail and any files transmitted with it are confidential and intended
solely for the use of the individual(s) or entity addressed above. If you are
not the intended recipient of this e-mail, then (i) please notify us at
[email protected] (ii) do not use the information contained &
(iii) delete it from your system . E-mail communications are not secure. Though
efforts have been taken to ensure that this communication has not been tampered
with; however, Canon India Pvt Ltd. is not responsible for any changes made to
the contents of or any attachments to this message without its consent. All
information contained in this message which are not of an official nature shall
not be deemed as given or endorsed by Canon India Pvt. Ltd.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user