#include "DVDClock.h"
#include "DVDStreamInfo.h"
#include "AMLCodec.h"
-#include "video/VideoThumbLoader.h"
#include "utils/BitstreamConverter.h"
#include "utils/log.h"
m_queue_depth(0),
m_framerate(0.0),
m_video_rate(0),
- m_mpeg2_sequence(NULL)
+ m_mpeg2_sequence(NULL),
+ m_parser(NULL),
+ m_bitstream(NULL)
{
pthread_mutex_init(&m_queue_mutex, NULL);
}
bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
{
- switch(hints.codec)
+ m_hints = hints;
+
+ switch(m_hints.codec)
{
case AV_CODEC_ID_MJPEG:
m_pFormatName = "am-mjpeg";
case AV_CODEC_ID_MPEG2VIDEO_XVMC:
m_mpeg2_sequence_pts = 0;
m_mpeg2_sequence = new mpeg2_sequence;
- m_mpeg2_sequence->width = hints.width;
- m_mpeg2_sequence->height = hints.height;
- m_mpeg2_sequence->ratio = hints.aspect;
- if (hints.rfpsrate > 0 && hints.rfpsscale != 0)
- m_mpeg2_sequence->rate = (float)hints.rfpsrate / hints.rfpsscale;
- else if (hints.fpsrate > 0 && hints.fpsscale != 0)
- m_mpeg2_sequence->rate = (float)hints.fpsrate / hints.fpsscale;
+ m_mpeg2_sequence->width = m_hints.width;
+ m_mpeg2_sequence->height = m_hints.height;
+ m_mpeg2_sequence->ratio = m_hints.aspect;
+ if (m_hints.rfpsrate > 0 && m_hints.rfpsscale != 0)
+ m_mpeg2_sequence->rate = (float)m_hints.rfpsrate / m_hints.rfpsscale;
+ else if (m_hints.fpsrate > 0 && m_hints.fpsscale != 0)
+ m_mpeg2_sequence->rate = (float)m_hints.fpsrate / m_hints.fpsscale;
else
m_mpeg2_sequence->rate = 1.0;
m_pFormatName = "am-mpeg2";
break;
case AV_CODEC_ID_H264:
m_pFormatName = "am-h264";
+ // convert h264-avcC to h264-annex-b as h264-avcC
+ // under streamers can have issues when seeking.
+ if (*(uint8_t*)m_hints.extradata == 1)
+ {
+ m_bitstream = new CBitstreamConverter;
+ m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true);
+ // make sure we do not leak the existing m_hints.extradata
+ free(m_hints.extradata);
+ m_hints.extrasize = m_bitstream->GetExtraSize();
+ m_hints.extradata = malloc(m_hints.extrasize);
+ memcpy(m_hints.extradata, m_bitstream->GetExtraData(), m_hints.extrasize);
+ }
+ //m_parser = new CBitstreamParser();
+ //m_parser->Open();
break;
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
m_pFormatName = "am-avs";
break;
default:
- CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, hints.codec);
+ CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, m_hints.codec);
return false;
break;
}
- m_hints = hints;
- m_aspect_ratio = hints.aspect;
+ m_aspect_ratio = m_hints.aspect;
m_Codec = new CAMLCodec();
if (!m_Codec)
{
m_videobuffer.color_range = 0;
m_videobuffer.color_matrix = 4;
m_videobuffer.iFlags = DVP_FLAG_ALLOCATED;
- m_videobuffer.iWidth = hints.width;
- m_videobuffer.iHeight = hints.height;
+ m_videobuffer.iWidth = m_hints.width;
+ m_videobuffer.iHeight = m_hints.height;
m_videobuffer.iDisplayWidth = m_videobuffer.iWidth;
m_videobuffer.iDisplayHeight = m_videobuffer.iHeight;
- if (hints.aspect > 0.0 && !hints.forced_aspect)
+ if (m_hints.aspect > 0.0 && !m_hints.forced_aspect)
{
- m_videobuffer.iDisplayWidth = ((int)lrint(m_videobuffer.iHeight * hints.aspect)) & -3;
+ m_videobuffer.iDisplayWidth = ((int)lrint(m_videobuffer.iHeight * m_hints.aspect)) & -3;
if (m_videobuffer.iDisplayWidth > m_videobuffer.iWidth)
{
m_videobuffer.iDisplayWidth = m_videobuffer.iWidth;
- m_videobuffer.iDisplayHeight = ((int)lrint(m_videobuffer.iWidth / hints.aspect)) & -3;
+ m_videobuffer.iDisplayHeight = ((int)lrint(m_videobuffer.iWidth / m_hints.aspect)) & -3;
}
}
if (m_mpeg2_sequence)
delete m_mpeg2_sequence, m_mpeg2_sequence = NULL;
+ if (m_bitstream)
+ delete m_bitstream, m_bitstream = NULL;
+
+ if (m_parser)
+ delete m_parser, m_parser = NULL;
+
while (m_queue_depth)
FrameQueuePop();
}
{
// Handle Input, add demuxer packet to input queue, we must accept it or
// it will be discarded as DVDPlayerVideo has no concept of "try again".
-
if (pData)
+ {
+ if (m_bitstream)
+ {
+ if (!m_bitstream->Convert(pData, iSize))
+ return VC_ERROR;
+
+ pData = m_bitstream->GetConvertBuffer();
+ iSize = m_bitstream->GetConvertSize();
+ }
+
+ if (m_parser)
+ m_parser->FindIdrSlice(pData, iSize);
+
FrameRateTracking( pData, iSize, dts, pts);
+ }
if (!m_opened)
{
CLog::Log(LOGDEBUG, "%s: detected mpeg2 aspect ratio(%f), framerate(%f), video_rate(%d)",
__MODULE_NAME__, m_mpeg2_sequence->ratio, m_framerate, m_video_rate);
- // update hints for 1st frame fixup.
+ // update m_hints for 1st frame fixup.
switch(m_mpeg2_sequence->rate_info)
{
default: